mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
Compare commits
12 Commits
65e11ddd03
...
5532e4e267
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5532e4e267 | ||
|
|
120703e702 | ||
|
|
b31896387a | ||
|
|
e5bb25cd60 | ||
|
|
e59b7e01fd | ||
|
|
7994bf988c | ||
|
|
90b1c875df | ||
|
|
b61e806009 | ||
|
|
b46d0614c9 | ||
|
|
c73864d545 | ||
|
|
314fed559c | ||
|
|
1c346a6c3c |
@ -21,6 +21,7 @@ from dzgui.strings import boot
|
|||||||
from dzgui.util.deck import is_steam_deck, is_game_mode
|
from dzgui.util.deck import is_steam_deck, is_game_mode
|
||||||
from dzgui.util.dirs import make_parents
|
from dzgui.util.dirs import make_parents
|
||||||
from dzgui.util.localize import set_locale
|
from dzgui.util.localize import set_locale
|
||||||
|
from dzgui.util.map_count import test_map_count
|
||||||
from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS
|
from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS
|
||||||
from dzgui.util.strings import init
|
from dzgui.util.strings import init
|
||||||
|
|
||||||
@ -118,6 +119,7 @@ def load_gui(version: str, is_debug: bool) -> None:
|
|||||||
del os.environ["GTK_IM_MODULE"]
|
del os.environ["GTK_IM_MODULE"]
|
||||||
|
|
||||||
if has_new_config(XDG.config) is False:
|
if has_new_config(XDG.config) is False:
|
||||||
|
test_map_count()
|
||||||
migrate_cols_file(XDG.columns)
|
migrate_cols_file(XDG.columns)
|
||||||
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
copy_state_files(xdg_paths["XDG_STATE_HOME"])
|
||||||
# TODO: add logging inside wizard
|
# TODO: add logging inside wizard
|
||||||
|
|||||||
@ -5,14 +5,14 @@ import warnings
|
|||||||
from dzgui.const.constants import APP_NAME
|
from dzgui.const.constants import APP_NAME
|
||||||
from dzgui.init.libgi import test_libgi_missing
|
from dzgui.init.libgi import test_libgi_missing
|
||||||
from dzgui.init.prefix import get_version
|
from dzgui.init.prefix import get_version
|
||||||
from dzgui.util.map_count import set_map_count, test_map_count
|
from dzgui.util.map_count import set_map_count
|
||||||
from dzgui.util.strings import flags
|
from dzgui.util.strings import flags
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=flags.description)
|
parser = argparse.ArgumentParser(description=flags.description)
|
||||||
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
|
||||||
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
|
|
||||||
parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
|
parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
|
||||||
parser.add_argument("-m", "--map", action="store_true", help=flags.map_count)
|
parser.add_argument("-m", "--map", action="store_true", help=flags.map_count)
|
||||||
|
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
|
||||||
|
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ def main() -> None:
|
|||||||
set_map_count()
|
set_map_count()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
test_map_count()
|
|
||||||
version = get_version()
|
version = get_version()
|
||||||
|
|
||||||
print(f"{APP_NAME} {version}")
|
print(f"{APP_NAME} {version}")
|
||||||
|
|||||||
@ -21,11 +21,11 @@ class FilterManager:
|
|||||||
strings.filter_3pp: True,
|
strings.filter_3pp: True,
|
||||||
strings.filter_night: True,
|
strings.filter_night: True,
|
||||||
strings.filter_full: show_full,
|
strings.filter_full: show_full,
|
||||||
strings.filter_lowpop: True,
|
|
||||||
strings.filter_nonascii: False,
|
|
||||||
strings.filter_duplicate: False,
|
|
||||||
strings.filter_official: True,
|
strings.filter_official: True,
|
||||||
|
strings.filter_nonascii: False,
|
||||||
|
strings.filter_lowpop: True,
|
||||||
strings.filter_unofficial: True,
|
strings.filter_unofficial: True,
|
||||||
|
strings.filter_duplicate: False,
|
||||||
strings.filter_modded: True,
|
strings.filter_modded: True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
dzgui/strings/map_count.py
Normal file
16
dzgui/strings/map_count.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
exit_msg = (
|
||||||
|
"System map count is not high enough to run DayZ. "
|
||||||
|
"Please exit and run 'dzgui -m' to update map count."
|
||||||
|
)
|
||||||
|
failed_to_parse = (
|
||||||
|
"Failed to parse system map count.\n"
|
||||||
|
"This usually indicates that systemd is not installed."
|
||||||
|
)
|
||||||
|
failed_to_update = (
|
||||||
|
"Failed to update system map count.\n"
|
||||||
|
"Please report the issue upstream and provide the following traceback.\n\n"
|
||||||
|
"{0}"
|
||||||
|
)
|
||||||
|
meets_minimum = "System map count of {0} already meets the minimum."
|
||||||
|
prompt = "Updated map count will be written to the file {0}."
|
||||||
|
user_exit = "User exit"
|
||||||
@ -54,8 +54,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
|
|||||||
cpu = get_cpu_model()
|
cpu = get_cpu_model()
|
||||||
version = get_version()
|
version = get_version()
|
||||||
|
|
||||||
debug = lookup(config, Preferences.DEBUG)
|
|
||||||
install = lookup(config, Preferences.INSTALL)
|
|
||||||
default = lookup(config, Preferences.DEFAULT)
|
default = lookup(config, Preferences.DEFAULT)
|
||||||
|
|
||||||
steam_path = Path(default)
|
steam_path = Path(default)
|
||||||
@ -79,8 +77,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
|
|||||||
Kernel: {kernel}
|
Kernel: {kernel}
|
||||||
CPU: {cpu}
|
CPU: {cpu}
|
||||||
|
|
||||||
Debug: {debug}
|
|
||||||
Auto-install: {install}
|
|
||||||
Steam path: {steam_redacted}
|
Steam path: {steam_redacted}
|
||||||
Workshop path: {workshop_redacted}
|
Workshop path: {workshop_redacted}
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,19 @@
|
|||||||
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import traceback
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from dzgui.const.constants import VM_FILE, MIN_COUNT
|
from dzgui.const.constants import APP_NAME, VM_FILE, MIN_COUNT
|
||||||
from dzgui.util.bash import concat_bash_args
|
from dzgui.util.bash import concat_bash_args
|
||||||
|
from dzgui.strings import map_count
|
||||||
from dzgui.views.dialogs.early_alert import EarlyIgnoreDialog
|
from dzgui.views.dialogs.early_alert import EarlyIgnoreDialog
|
||||||
|
|
||||||
|
logger = logging.getLogger(APP_NAME)
|
||||||
|
|
||||||
def is_map_count_valid() -> bool:
|
|
||||||
count = get_map_count()
|
def is_map_count_valid(count: int | None) -> bool:
|
||||||
if count is None:
|
if count is None:
|
||||||
# NOTE: permit if count was unreadable
|
# NOTE: permit if count was unreadable
|
||||||
return True
|
return True
|
||||||
@ -18,47 +22,50 @@ def is_map_count_valid() -> bool:
|
|||||||
|
|
||||||
def get_map_count() -> int | None:
|
def get_map_count() -> int | None:
|
||||||
path = Path(VM_FILE)
|
path = Path(VM_FILE)
|
||||||
if path.is_file() is False:
|
try:
|
||||||
|
count = int(path.read_text())
|
||||||
|
except Exception as e:
|
||||||
|
logger.debug(e)
|
||||||
return None
|
return None
|
||||||
count = int(path.read_text())
|
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
|
||||||
def test_map_count() -> None:
|
def test_map_count() -> None:
|
||||||
if is_map_count_valid():
|
count = get_map_count()
|
||||||
|
if is_map_count_valid(count):
|
||||||
return
|
return
|
||||||
msg = (
|
msg = map_count.exit_msg
|
||||||
"System map count is not high enough to run DayZ.\n"
|
|
||||||
"Please exit and run 'dzgui -m' to update map count."
|
|
||||||
)
|
|
||||||
EarlyIgnoreDialog(msg)
|
EarlyIgnoreDialog(msg)
|
||||||
|
|
||||||
|
|
||||||
def set_map_count() -> None:
|
def set_map_count() -> None:
|
||||||
valid = is_map_count_valid()
|
count = get_map_count()
|
||||||
if valid is None:
|
if count is None:
|
||||||
|
print(map_count.failed_to_parse)
|
||||||
return
|
return
|
||||||
elif valid:
|
if is_map_count_valid(count):
|
||||||
print("System map count already meets the minimum.")
|
msg = map_count.meets_minimum.format(count)
|
||||||
|
print(msg)
|
||||||
return
|
return
|
||||||
|
|
||||||
conf = "/etc/sysctl.d/dayz.conf"
|
conf = "/etc/sysctl.d/dayz.conf"
|
||||||
count = f"vm.max_map_count={MIN_COUNT}"
|
value = f"vm.max_map_count={MIN_COUNT}"
|
||||||
try:
|
try:
|
||||||
msg = (
|
msg = map_count.prompt.format(conf)
|
||||||
f"Updated map count will be written to the file '{conf}'.\n"
|
|
||||||
"Enter sudo password to proceed."
|
|
||||||
)
|
|
||||||
print(msg)
|
print(msg)
|
||||||
with tempfile.NamedTemporaryFile(delete=False) as f:
|
with tempfile.NamedTemporaryFile(delete=False) as f:
|
||||||
tmp = f.name
|
tmp = f.name
|
||||||
Path(tmp).write_text(count)
|
Path(tmp).write_text(value)
|
||||||
args = concat_bash_args(f"sudo mv {tmp} {conf}")
|
|
||||||
subprocess.run([*args])
|
mv_cmd = f"sudo mv {tmp} {conf}"
|
||||||
args = concat_bash_args(f"sudo sysctl -p {conf}")
|
reload_cmd = f"sudo sysctl -p {conf}"
|
||||||
subprocess.run([*args])
|
for cmd in mv_cmd, reload_cmd:
|
||||||
|
args = concat_bash_args(cmd)
|
||||||
|
subprocess.run([*args])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
logger.debug(e)
|
||||||
|
trace = traceback.format_exc()
|
||||||
|
print(map_count.failed_to_update.format(trace))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("User exit")
|
print(map_count.user_exit)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
@ -472,10 +472,10 @@ class Flags:
|
|||||||
|
|
||||||
flags = Flags(
|
flags = Flags(
|
||||||
description="DayZ server browser and mod manager",
|
description="DayZ server browser and mod manager",
|
||||||
version="Print version information",
|
version="print version information",
|
||||||
uninstall="Clean up state/config files",
|
uninstall="clean up state/config files",
|
||||||
debug="Enable developer debugging features",
|
debug="enable developer debugging features",
|
||||||
map_count="Check and update system map count value"
|
map_count="check and update system map count value",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -543,9 +543,7 @@ connect_panel = ConnectPanel(
|
|||||||
add="Add",
|
add="Add",
|
||||||
add_con="Add/connect",
|
add_con="Add/connect",
|
||||||
placeholder="Enter IP (IP:Query port)",
|
placeholder="Enter IP (IP:Query port)",
|
||||||
entry_tooltip=(
|
entry_tooltip=("- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"),
|
||||||
"- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"
|
|
||||||
),
|
|
||||||
add_tooltip="Add to Saved Servers",
|
add_tooltip="Add to Saved Servers",
|
||||||
connect_tooltip="Connect to this server",
|
connect_tooltip="Connect to this server",
|
||||||
)
|
)
|
||||||
|
|||||||
@ -33,15 +33,15 @@ class ButtonGrid(Gtk.Grid):
|
|||||||
super().__init__(
|
super().__init__(
|
||||||
halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True
|
halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True
|
||||||
)
|
)
|
||||||
row = 1
|
|
||||||
col = 0
|
|
||||||
|
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.emitter = controller.get_emitter()
|
self.emitter = controller.get_emitter()
|
||||||
|
|
||||||
self.checks: list[Gtk.CheckButton] = []
|
self.checks: list[Gtk.CheckButton] = []
|
||||||
|
|
||||||
# TODO: use enumerated checks
|
flowbox = Gtk.FlowBox(
|
||||||
|
halign=Gtk.Align.CENTER, min_children_per_line=3, max_children_per_line=3
|
||||||
|
)
|
||||||
|
|
||||||
for check in defaults.keys():
|
for check in defaults.keys():
|
||||||
checkbox = Gtk.CheckButton(label=check)
|
checkbox = Gtk.CheckButton(label=check)
|
||||||
label = checkbox.get_child()
|
label = checkbox.get_child()
|
||||||
@ -51,14 +51,12 @@ class ButtonGrid(Gtk.Grid):
|
|||||||
if defaults[check]:
|
if defaults[check]:
|
||||||
checkbox.set_active(True)
|
checkbox.set_active(True)
|
||||||
|
|
||||||
col = col + 1
|
|
||||||
if col > 3:
|
|
||||||
row += 1
|
|
||||||
col = 1
|
|
||||||
self.attach(checkbox, col, row, 1, 1)
|
|
||||||
checkbox.connect("toggled", self._on_check_toggled)
|
checkbox.connect("toggled", self._on_check_toggled)
|
||||||
|
flowbox.add(checkbox)
|
||||||
self.checks.append(checkbox)
|
self.checks.append(checkbox)
|
||||||
|
|
||||||
|
self.add(flowbox)
|
||||||
|
|
||||||
def block_toggles(self, state: bool) -> None:
|
def block_toggles(self, state: bool) -> None:
|
||||||
for check in self.checks:
|
for check in self.checks:
|
||||||
self.controller.suppress_signal(
|
self.controller.suppress_signal(
|
||||||
|
|||||||
@ -22,6 +22,10 @@ class AbortDialog(Gtk.MessageDialog):
|
|||||||
msg = textwrap.fill(string, 50)
|
msg = textwrap.fill(string, 50)
|
||||||
self.format_secondary_text(msg)
|
self.format_secondary_text(msg)
|
||||||
|
|
||||||
|
ma = self.get_message_area()
|
||||||
|
label = ma.get_children()[1] # type: ignore
|
||||||
|
label.set_justify(Gtk.Justification.CENTER)
|
||||||
|
|
||||||
aa = self.get_action_area()
|
aa = self.get_action_area()
|
||||||
aa.set_margin_bottom(20)
|
aa.set_margin_bottom(20)
|
||||||
aa.set_layout(Gtk.ButtonBoxStyle.CENTER) # type: ignore
|
aa.set_layout(Gtk.ButtonBoxStyle.CENTER) # type: ignore
|
||||||
@ -49,7 +53,6 @@ class AbortDialog(Gtk.MessageDialog):
|
|||||||
case Gtk.ResponseType.OK | Gtk.ResponseType.DELETE_EVENT:
|
case Gtk.ResponseType.OK | Gtk.ResponseType.DELETE_EVENT:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
case Gtk.ResponseType.CANCEL:
|
case Gtk.ResponseType.CANCEL:
|
||||||
print("response was cancel")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user