Compare commits

...

12 Commits

Author SHA1 Message Date
aclist
5532e4e267 chore: simplify control flow
Some checks are pending
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-08-13 13:42:51 +09:00
aclist
120703e702 chore: move map count test to pre-config 2026-08-13 13:37:47 +09:00
aclist
b31896387a chore: simplify strings 2026-08-13 13:37:21 +09:00
aclist
e5bb25cd60 chore: drop forced exception test 2026-08-13 13:32:08 +09:00
aclist
e59b7e01fd chore: drop debug message 2026-08-13 13:31:05 +09:00
aclist
7994bf988c chore: clear typehinting errors 2026-08-13 13:27:40 +09:00
aclist
90b1c875df fix: center label in message area 2026-08-13 13:24:48 +09:00
aclist
b61e806009 chore: lowercase launch flags for conformity with parser 2026-08-13 13:24:26 +09:00
aclist
b46d0614c9 chore: add strings file 2026-08-13 13:24:10 +09:00
aclist
c73864d545 fix: unreachable code 2026-08-13 13:23:29 +09:00
aclist
314fed559c chore: drop unused log file metadata 2026-08-13 13:22:41 +09:00
aclist
1c346a6c3c chore: change sort order of CLI args 2026-08-13 13:22:05 +09:00
9 changed files with 73 additions and 54 deletions

View File

@ -21,6 +21,7 @@ from dzgui.strings import boot
from dzgui.util.deck import is_steam_deck, is_game_mode
from dzgui.util.dirs import make_parents
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.strings import init
@ -118,6 +119,7 @@ def load_gui(version: str, is_debug: bool) -> None:
del os.environ["GTK_IM_MODULE"]
if has_new_config(XDG.config) is False:
test_map_count()
migrate_cols_file(XDG.columns)
copy_state_files(xdg_paths["XDG_STATE_HOME"])
# TODO: add logging inside wizard

View File

@ -5,14 +5,14 @@ import warnings
from dzgui.const.constants import APP_NAME
from dzgui.init.libgi import test_libgi_missing
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
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("-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()
@ -39,7 +39,6 @@ def main() -> None:
set_map_count()
sys.exit(0)
test_map_count()
version = get_version()
print(f"{APP_NAME} {version}")

View File

@ -21,11 +21,11 @@ class FilterManager:
strings.filter_3pp: True,
strings.filter_night: True,
strings.filter_full: show_full,
strings.filter_lowpop: True,
strings.filter_nonascii: False,
strings.filter_duplicate: False,
strings.filter_official: True,
strings.filter_nonascii: False,
strings.filter_lowpop: True,
strings.filter_unofficial: True,
strings.filter_duplicate: False,
strings.filter_modded: True,
}

View 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"

View File

@ -54,8 +54,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
cpu = get_cpu_model()
version = get_version()
debug = lookup(config, Preferences.DEBUG)
install = lookup(config, Preferences.INSTALL)
default = lookup(config, Preferences.DEFAULT)
steam_path = Path(default)
@ -79,8 +77,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
Kernel: {kernel}
CPU: {cpu}
Debug: {debug}
Auto-install: {install}
Steam path: {steam_redacted}
Workshop path: {workshop_redacted}

View File

@ -1,15 +1,19 @@
import logging
import subprocess
import sys
import tempfile
import traceback
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.strings import map_count
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:
# NOTE: permit if count was unreadable
return True
@ -18,47 +22,50 @@ def is_map_count_valid() -> bool:
def get_map_count() -> int | None:
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
count = int(path.read_text())
return count
def test_map_count() -> None:
if is_map_count_valid():
count = get_map_count()
if is_map_count_valid(count):
return
msg = (
"System map count is not high enough to run DayZ.\n"
"Please exit and run 'dzgui -m' to update map count."
)
msg = map_count.exit_msg
EarlyIgnoreDialog(msg)
def set_map_count() -> None:
valid = is_map_count_valid()
if valid is None:
count = get_map_count()
if count is None:
print(map_count.failed_to_parse)
return
elif valid:
print("System map count already meets the minimum.")
if is_map_count_valid(count):
msg = map_count.meets_minimum.format(count)
print(msg)
return
conf = "/etc/sysctl.d/dayz.conf"
count = f"vm.max_map_count={MIN_COUNT}"
value = f"vm.max_map_count={MIN_COUNT}"
try:
msg = (
f"Updated map count will be written to the file '{conf}'.\n"
"Enter sudo password to proceed."
)
msg = map_count.prompt.format(conf)
print(msg)
with tempfile.NamedTemporaryFile(delete=False) as f:
tmp = f.name
Path(tmp).write_text(count)
args = concat_bash_args(f"sudo mv {tmp} {conf}")
subprocess.run([*args])
args = concat_bash_args(f"sudo sysctl -p {conf}")
subprocess.run([*args])
Path(tmp).write_text(value)
mv_cmd = f"sudo mv {tmp} {conf}"
reload_cmd = f"sudo sysctl -p {conf}"
for cmd in mv_cmd, reload_cmd:
args = concat_bash_args(cmd)
subprocess.run([*args])
except Exception as e:
print(e)
logger.debug(e)
trace = traceback.format_exc()
print(map_count.failed_to_update.format(trace))
except KeyboardInterrupt:
print("User exit")
print(map_count.user_exit)
sys.exit(0)

View File

@ -472,10 +472,10 @@ class Flags:
flags = Flags(
description="DayZ server browser and mod manager",
version="Print version information",
uninstall="Clean up state/config files",
debug="Enable developer debugging features",
map_count="Check and update system map count value"
version="print version information",
uninstall="clean up state/config files",
debug="enable developer debugging features",
map_count="check and update system map count value",
)
@ -543,9 +543,7 @@ connect_panel = ConnectPanel(
add="Add",
add_con="Add/connect",
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",
connect_tooltip="Connect to this server",
)

View File

@ -33,15 +33,15 @@ class ButtonGrid(Gtk.Grid):
super().__init__(
halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True
)
row = 1
col = 0
self.controller = controller
self.emitter = controller.get_emitter()
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():
checkbox = Gtk.CheckButton(label=check)
label = checkbox.get_child()
@ -51,14 +51,12 @@ class ButtonGrid(Gtk.Grid):
if defaults[check]:
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)
flowbox.add(checkbox)
self.checks.append(checkbox)
self.add(flowbox)
def block_toggles(self, state: bool) -> None:
for check in self.checks:
self.controller.suppress_signal(

View File

@ -22,6 +22,10 @@ class AbortDialog(Gtk.MessageDialog):
msg = textwrap.fill(string, 50)
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.set_margin_bottom(20)
aa.set_layout(Gtk.ButtonBoxStyle.CENTER) # type: ignore
@ -49,7 +53,6 @@ class AbortDialog(Gtk.MessageDialog):
case Gtk.ResponseType.OK | Gtk.ResponseType.DELETE_EVENT:
sys.exit(1)
case Gtk.ResponseType.CANCEL:
print("response was cancel")
return