Compare commits

..

No commits in common. "5532e4e267e4dbb2bee05e95180d981572255f30" and "65e11ddd0384b3800ffd5c50039bb3e12fb54753" have entirely different histories.

9 changed files with 54 additions and 73 deletions

View File

@ -21,7 +21,6 @@ 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
@ -119,7 +118,6 @@ 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

View File

@ -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 from dzgui.util.map_count import set_map_count, test_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,6 +39,7 @@ 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}")

View File

@ -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_official: True,
strings.filter_nonascii: False,
strings.filter_lowpop: True, strings.filter_lowpop: True,
strings.filter_unofficial: True, strings.filter_nonascii: False,
strings.filter_duplicate: False, strings.filter_duplicate: False,
strings.filter_official: True,
strings.filter_unofficial: True,
strings.filter_modded: True, strings.filter_modded: True,
} }

View File

@ -1,16 +0,0 @@
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"

View File

@ -54,6 +54,8 @@ 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)
@ -77,6 +79,8 @@ 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}

View File

@ -1,19 +1,15 @@
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 APP_NAME, VM_FILE, MIN_COUNT from dzgui.const.constants import 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:
def is_map_count_valid(count: int | None) -> bool: count = get_map_count()
if count is None: if count is None:
# NOTE: permit if count was unreadable # NOTE: permit if count was unreadable
return True return True
@ -22,50 +18,47 @@ def is_map_count_valid(count: int | None) -> bool:
def get_map_count() -> int | None: def get_map_count() -> int | None:
path = Path(VM_FILE) path = Path(VM_FILE)
try: if path.is_file() is False:
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:
count = get_map_count() if is_map_count_valid():
if is_map_count_valid(count):
return return
msg = map_count.exit_msg 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:
count = get_map_count() valid = is_map_count_valid()
if count is None: if valid is None:
print(map_count.failed_to_parse)
return return
if is_map_count_valid(count): elif valid:
msg = map_count.meets_minimum.format(count) print("System map count already meets the minimum.")
print(msg)
return return
conf = "/etc/sysctl.d/dayz.conf" conf = "/etc/sysctl.d/dayz.conf"
value = f"vm.max_map_count={MIN_COUNT}" count = f"vm.max_map_count={MIN_COUNT}"
try: try:
msg = map_count.prompt.format(conf) msg = (
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(value) Path(tmp).write_text(count)
args = concat_bash_args(f"sudo mv {tmp} {conf}")
mv_cmd = f"sudo mv {tmp} {conf}" subprocess.run([*args])
reload_cmd = f"sudo sysctl -p {conf}" args = concat_bash_args(f"sudo sysctl -p {conf}")
for cmd in mv_cmd, reload_cmd:
args = concat_bash_args(cmd)
subprocess.run([*args]) subprocess.run([*args])
except Exception as e: except Exception as e:
logger.debug(e) print(e)
trace = traceback.format_exc()
print(map_count.failed_to_update.format(trace))
except KeyboardInterrupt: except KeyboardInterrupt:
print(map_count.user_exit) print("User exit")
sys.exit(0) sys.exit(0)

View File

@ -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,7 +543,9 @@ 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=("- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"), entry_tooltip=(
"- 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",
) )

View File

@ -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] = []
flowbox = Gtk.FlowBox( # TODO: use enumerated checks
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,12 +51,14 @@ 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(

View File

@ -22,10 +22,6 @@ 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
@ -53,6 +49,7 @@ 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