Compare commits

..
Author SHA1 Message Date
aclist 5423d9ad56 chore: add strings file 2026-11-21 20:47:28 +09:00
aclist 1aed045149 feat: export debug log to a named file 2026-11-21 20:45:28 +09:00
aclist a3068324fa chore: add test
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-11-21 18:00:20 +09:00
aclist 97c90b435b chore: log additional exceptions 2026-11-21 17:59:34 +09:00
aclist f300786546 feat: descend into path when making parents 2026-11-21 17:59:14 +09:00
aclist 2a6a8f0cb0 chore: clear typehinting errors
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-19 08:52:18 +09:00
aclist da718c684d change: block shortcut creation on snap client 2026-11-19 08:51:30 +09:00
aclist b42be20dc3 change: parse real home in sandbox
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-19 07:50:29 +09:00
aclist 16578eaeb3 chore: update changelog 2026-11-19 07:01:07 +09:00
aclist 1ea9428503 chore: drop unused imports 2026-11-19 06:46:38 +09:00
aclist 8aca23cf76 chore: cherry pick changes from test-typehints branch 2026-11-19 06:45:14 +09:00
aclist 663e57b8cd chore: cherry pick changes from test-typehints branch 2026-11-19 06:41:05 +09:00
aclist 5853e15b8e fix: return empty list if mod dir is missing 2026-11-19 06:22:05 +09:00
aclist 29223a8a1f change: disambiguate custom XDG_DATA_HOME
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-18 16:27:11 +09:00
aclist 45c412e1ad change: make reference to snap more generic 2026-11-17 03:12:05 +09:00
aclist a32c99b3eb feat: support Ubuntu Snap path 2026-11-17 02:22:59 +09:00
aclist da474e274f chore: update tests 2026-11-17 01:45:26 +09:00
aclist d694aa56e8 chore: clear typehinting errors 2026-11-17 01:44:23 +09:00
aclist 6adecbedaa fix: parse custom xdg path correctly 2026-11-17 01:44:12 +09:00
27 changed files with 520 additions and 276 deletions

No files matched your search

+3
View File
@@ -58,6 +58,7 @@
- Validate mods via Mod page to pull in updates - Validate mods via Mod page to pull in updates
- Support for Nasdara (Badlands) DLC - Support for Nasdara (Badlands) DLC
- Load offline mods - Load offline mods
- Support Snap package version of Steam
### Changed ### Changed
- Conform to PEP 440 versioning for beta versions - Conform to PEP 440 versioning for beta versions
@@ -101,6 +102,8 @@
- Steam Flatpak cannot run DZGUI as a non-Steam game - Steam Flatpak cannot run DZGUI as a non-Steam game
- Collisions between native Steam and Steam Flatpak clients - Collisions between native Steam and Steam Flatpak clients
- Sticky toggle signal on radio buttons when reloading Options - Sticky toggle signal on radio buttons when reloading Options
- Handle missing mods directory if not installed previously
- Filters not blocked by keyboard keys when filters are disabled
### Developer-facing ### Developer-facing
- Options -> Dev page - Options -> Dev page
+1 -1
View File
@@ -15,7 +15,7 @@ author = 'aclist'
extensions = [] extensions = []
templates_path = ['_templates'] templates_path = ['_templates']
exclude_patterns = [] exclude_patterns = [] # type: ignore[var-annotated]
+5
View File
@@ -35,6 +35,10 @@ def get_local_mod_path(steam_path: Path) -> Path:
def get_local_mods(workshop_path: Path) -> list[Path]: def get_local_mods(workshop_path: Path) -> list[Path]:
# NOTE: user may not have staged mods before
if workshop_path.is_dir() is False:
logger.debug("Mod directory not yet present, returning empty list")
return []
mods = [file for file in workshop_path.iterdir() if file.is_dir()] mods = [file for file in workshop_path.iterdir() if file.is_dir()]
return mods return mods
@@ -123,6 +127,7 @@ def remove_stale_signatures(
path = lookup(config, Preferences.DEFAULT) path = lookup(config, Preferences.DEFAULT)
steam_path = Path(path) steam_path = Path(path)
if ids is None: if ids is None:
local_ids = get_local_mod_ids(steam_path) local_ids = get_local_mod_ids(steam_path)
+23 -11
View File
@@ -12,9 +12,7 @@ from typing import Any, Generator, Union
from warnings import deprecated from warnings import deprecated
from dzgui.api.acf import ACF from dzgui.api.acf import ACF
from dzgui.const.endpoints import VALIDATE from dzgui.config.xdg import get_real_home
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.const.constants import ( from dzgui.const.constants import (
APPID_DAYZ, APPID_DAYZ,
APPID_DAYZ_EXP, APPID_DAYZ_EXP,
@@ -27,6 +25,7 @@ from dzgui.const.constants import (
FLATPAK_STEAM_PATH, FLATPAK_STEAM_PATH,
LIBRARYFOLDERS_PATH, LIBRARYFOLDERS_PATH,
REQUEST_TIMEOUT, REQUEST_TIMEOUT,
SNAP_STEAM_PATH,
UBUNTU_STEAM_PATH, UBUNTU_STEAM_PATH,
VDF_PATH, VDF_PATH,
) )
@@ -35,7 +34,10 @@ from dzgui.const.endpoints import (
STEAM_PUBLISHED_FILES, STEAM_PUBLISHED_FILES,
STEAM_SUB, STEAM_SUB,
STEAM_UNSUB, STEAM_UNSUB,
VALIDATE,
) )
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.strings import wizard from dzgui.strings import wizard
from dzgui.strings.errors import api_validation_error, workshop_endpoint_error from dzgui.strings.errors import api_validation_error, workshop_endpoint_error
from dzgui.util.bash import concat_bash_args from dzgui.util.bash import concat_bash_args
@@ -64,26 +66,36 @@ class VDFLoadError(Exception):
def get_steam_paths() -> list[tuple[Path, str]]: def get_steam_paths() -> list[tuple[Path, str]]:
paths = [] paths = []
if has_any_client(): if has_any_client():
HOME = Path.home() HOME = get_real_home()
env = os.environ.get("XDG_DATA_HOME") env = os.environ.get("XDG_DATA_HOME")
if env is not None: if env is not None:
XDG_DATA_HOME = env XDG_DATA_HOME = Path(env)
DEFAULT_PATH = XDG_DATA_HOME.joinpath("Steam")
default_label = wizard.desc_custom_path
else: else:
XDG_DATA_HOME = DEFAULT_STEAM_PATH DEFAULT_PATH = HOME.joinpath(DEFAULT_STEAM_PATH)
default_label = wizard.desc_default_path
DEFAULT_PATH = HOME.joinpath(XDG_DATA_HOME)
FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH) FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH)
UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH) UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH)
DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH) DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH)
SNAP_PATH = HOME.joinpath(SNAP_STEAM_PATH)
human = { human = {
DEFAULT_PATH: wizard.desc_default_path, DEFAULT_PATH: default_label,
FLATPAK_PATH: wizard.desc_flatpak_path, FLATPAK_PATH: wizard.desc_flatpak_path,
UBUNTU_PATH: wizard.desc_ubuntu_path, UBUNTU_PATH: wizard.desc_ubuntu_path,
SNAP_PATH: wizard.desc_snap_path,
DEBIAN_PATH: wizard.desc_debian_path, DEBIAN_PATH: wizard.desc_debian_path,
} }
for path in DEFAULT_PATH, FLATPAK_PATH, UBUNTU_PATH, DEBIAN_PATH: for path in (
DEFAULT_PATH,
FLATPAK_PATH,
UBUNTU_PATH,
SNAP_PATH,
DEBIAN_PATH,
):
if path is FLATPAK_PATH and has_flatpak_client() is False: if path is FLATPAK_PATH and has_flatpak_client() is False:
continue continue
if path is not FLATPAK_PATH and has_steam_client() is False: if path is not FLATPAK_PATH and has_steam_client() is False:
@@ -485,11 +497,11 @@ def is_dayz_downloading(steam_path: Path, appid: int) -> bool:
def get_app_path(folders_path: Path, appid: int) -> Path: def get_app_path(folders_path: Path, appid: int) -> Path:
app_path = None app_path = None
try: try:
with open(folders_path / LIBRARYFOLDERS_PATH) as f: with open(folders_path / LIBRARYFOLDERS_PATH) as f:
folders = vdf.load(f) folders = vdf.load(f)
except Exception: except Exception as e:
logger.debug(e)
raise VDFLoadError("Failed to parse libraryfolders") raise VDFLoadError("Failed to parse libraryfolders")
for obj in folders["libraryfolders"]: for obj in folders["libraryfolders"]:
+3 -1
View File
@@ -3,6 +3,7 @@ import textwrap
from pathlib import Path from pathlib import Path
from dzgui.config.xdg import get_real_home
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
@@ -36,7 +37,8 @@ def write_desktop_file(exe_path: Path) -> Path:
def write_desktop_shortcut(desktop_file: Path) -> None: def write_desktop_shortcut(desktop_file: Path) -> None:
# NOTE: necessarily depends on the above (UI blocks creation without XDG entry first) # NOTE: necessarily depends on the above (UI blocks creation without XDG entry first)
link = Path.home().joinpath("Desktop/dzgui.desktop") home = get_real_home()
link = home.joinpath("Desktop/dzgui.desktop")
make_parents(link) make_parents(link)
if link.exists(): if link.exists():
link.unlink() link.unlink()
+9 -6
View File
@@ -6,10 +6,8 @@ from dataclasses import dataclass
from dzgui.const.constants import ( from dzgui.const.constants import (
APP_NAME_LOWER, APP_NAME_LOWER,
DEBUG_LOG, DEBUG_LOG,
FLATPAK_ROOT_PATH,
SYSTEM_LOG, SYSTEM_LOG,
) )
from dzgui.init.proc import is_sandboxed
@dataclass(slots=True, frozen=True) @dataclass(slots=True, frozen=True)
@@ -50,9 +48,17 @@ def is_writeable(path_str: str) -> bool:
file.unlink() file.unlink()
return True return True
def get_real_home() -> Path:
home = Path.home()
if resolved := os.environ.get("SNAP_REAL_HOME"): # Snap
home = Path(resolved)
elif resolved := os.environ.get("HOME"): # Flatpak
home = Path(resolved)
return home
def get_xdg_paths() -> dict[str, Path]: def get_xdg_paths() -> dict[str, Path]:
home = Path.home() home = get_real_home()
xdg_paths = { xdg_paths = {
"XDG_CONFIG_HOME": home / ".config", "XDG_CONFIG_HOME": home / ".config",
"XDG_STATE_HOME": home / ".local" / "state", "XDG_STATE_HOME": home / ".local" / "state",
@@ -62,9 +68,6 @@ def get_xdg_paths() -> dict[str, Path]:
resolved_paths = {} resolved_paths = {}
for path in xdg_paths: for path in xdg_paths:
real_path = os.environ.get(path) real_path = os.environ.get(path)
if real_path is not None and is_sandboxed():
search_string = FLATPAK_ROOT_PATH + "/"
real_path = real_path.replace(search_string, "")
if real_path is not None and is_writeable(real_path): if real_path is not None and is_writeable(real_path):
new_path = Path(real_path) new_path = Path(real_path)
else: else:
+1
View File
@@ -60,6 +60,7 @@ DEFAULT_STEAM_PATH = ".local/share/Steam"
FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam" FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam"
FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam" FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam"
UBUNTU_STEAM_PATH = ".steam/steam" UBUNTU_STEAM_PATH = ".steam/steam"
SNAP_STEAM_PATH = "snap/steam/common/" + DEFAULT_STEAM_PATH
DEBIAN_STEAM_PATH = ".steam/debian-installation" DEBIAN_STEAM_PATH = ".steam/debian-installation"
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG") LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
+4 -2
View File
@@ -207,7 +207,8 @@ class RowType(Enum):
CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status) CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status)
SHOW_LOG = RowMeta(rows.log_label, rows.log_status) SHOW_LOG = RowMeta(rows.log_label, rows.log_status)
SEPARATOR = RowMeta(rows.separator_label, rows.separator_status) SEPARATOR = RowMeta(rows.separator_label, rows.separator_status)
DUMP_LOG = RowMeta(rows.system_log_label, rows.system_log_status) DUMP_DIAGNOSTIC = RowMeta(rows.system_log_label, rows.system_log_status)
DUMP_DEBUG = RowMeta(rows.debug_log_label, rows.debug_log_status)
DOCS = RowMeta(rows.docs_label, rows.docs_status) DOCS = RowMeta(rows.docs_label, rows.docs_status)
DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status) DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status)
BUGS = RowMeta(rows.bugs_label, rows.bugs_status) BUGS = RowMeta(rows.bugs_label, rows.bugs_status)
@@ -302,7 +303,8 @@ class ButtonType(Enum):
HELP_MENU_ROWS = ( HELP_MENU_ROWS = (
RowType.CHANGELOG, RowType.CHANGELOG,
RowType.SHOW_LOG, RowType.SHOW_LOG,
RowType.DUMP_LOG, RowType.DUMP_DIAGNOSTIC,
RowType.DUMP_DEBUG,
RowType.SEPARATOR, RowType.SEPARATOR,
RowType.DOCS, RowType.DOCS,
RowType.DOCS_FALLBACK, RowType.DOCS_FALLBACK,
+24 -9
View File
@@ -2,6 +2,7 @@ import gi
import logging import logging
import threading import threading
from pathlib import Path
from typing import Any, TYPE_CHECKING, Union from typing import Any, TYPE_CHECKING, Union
from dzgui.config.userprefs import UserPrefs from dzgui.config.userprefs import UserPrefs
@@ -23,7 +24,7 @@ from dzgui.model.servers import ServerModelManager
from dzgui.util.diag import write_diagnostic from dzgui.util.diag import write_diagnostic
from dzgui.util.format import format_exception, format_player_count from dzgui.util.format import format_exception, format_player_count
from dzgui.util.open_links import open_user_workshop, open_workshop_page from dzgui.util.open_links import open_user_workshop, open_workshop_page
from dzgui.views.dialogs.filepicker import FilePicker from dzgui.views.dialogs.filepicker import DebugLogPicker, DiagnosticLogPicker
from dzgui.views.dialogs.generic import ExceptionDialog from dzgui.views.dialogs.generic import ExceptionDialog
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
@@ -297,15 +298,29 @@ class Controller(GObject.GObject):
return self.get_active_treeview().get_filter_man() return self.get_active_treeview().get_filter_man()
def dump_diagnostics(self) -> None: def dump_diagnostics(self) -> None:
picker = FilePicker(self.mediator.window) picker = DiagnosticLogPicker(self.mediator.window)
file = picker.pick_file() file = picker.pick_file()
if file is not None: if file is None:
try: return
write_diagnostic(self.prefs.paths.config, file) try:
except Exception as e: write_diagnostic(self.prefs.paths.config, file)
dialog = ExceptionDialog(self, str(e)) except Exception as e:
dialog.show_all() dialog = ExceptionDialog(self, str(e))
dialog.run() # type: ignore[no-untyped-call] dialog.show_all()
dialog.run() # type: ignore[no-untyped-call]
def dump_log(self) -> None:
picker = DebugLogPicker(self.mediator.window)
file = picker.pick_file()
if file is None:
return
try:
log = self.prefs.paths.debug.read_text()
Path(file).write_text(log)
except Exception as e:
dialog = ExceptionDialog(self, str(e))
dialog.show_all()
dialog.run() # type: ignore[no-untyped-call]
def update_steam_api_key(self, text: str) -> None: def update_steam_api_key(self, text: str) -> None:
self.config_man.update_steam_api_key(text) self.config_man.update_steam_api_key(text)
+7 -4
View File
@@ -12,13 +12,15 @@ from dzgui.const.constants import (
LEGACY_IPS_PATH, LEGACY_IPS_PATH,
) )
from dzgui.config.convert import rc2json from dzgui.config.convert import rc2json
from dzgui.config.xdg import get_real_home
from dzgui.util._json import read_json, write_json from dzgui.util._json import read_json, write_json
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def migrate_legacy_conf(config: Path) -> Any: def migrate_legacy_conf(config: Path) -> Any:
old_conf = Path.home() / LEGACY_CONFIG_PATH home = get_real_home()
old_conf = home / LEGACY_CONFIG_PATH
j = rc2json(old_conf) j = rc2json(old_conf)
return json.loads(j) return json.loads(j)
@@ -44,7 +46,8 @@ def convert_cols_file(res: Path) -> Any | None:
def migrate_cols_file(res: Path) -> None: def migrate_cols_file(res: Path) -> None:
# NOTE: filename "dzg.columns.json" is API 7 spec # NOTE: filename "dzg.columns.json" is API 7 spec
old_res = Path.home() / LEGACY_COLS_PATH home = get_real_home()
old_res = home / LEGACY_COLS_PATH
if old_res.is_file(): if old_res.is_file():
j = convert_cols_file(old_res) j = convert_cols_file(old_res)
if j is not None: if j is not None:
@@ -52,7 +55,7 @@ def migrate_cols_file(res: Path) -> None:
def copy_state_files(state_path: Path) -> None: def copy_state_files(state_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / ".local/state/dzgui" legacy = home / ".local/state/dzgui"
to_copy = [ to_copy = [
"dzg.res.json", "dzg.res.json",
@@ -71,7 +74,7 @@ def copy_state_files(state_path: Path) -> None:
def copy_ipdb(ips_path: Path) -> None: def copy_ipdb(ips_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / LEGACY_IPS_PATH legacy = home / LEGACY_IPS_PATH
if ips_path == legacy: if ips_path == legacy:
return return
+2 -2
View File
@@ -3,13 +3,13 @@ import shutil
import subprocess import subprocess
from dzgui.const.constants import APP_NAME, FLATPAK_APPID, FLATPAK_CMD, STEAM_CMD from dzgui.const.constants import APP_NAME, FLATPAK_APPID, FLATPAK_CMD, STEAM_CMD
from dzgui.init.proc import is_sandboxed from dzgui.init.proc import is_flatpak_sandbox
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def has_flatpak_client() -> bool: def has_flatpak_client() -> bool:
if is_sandboxed(): if is_flatpak_sandbox():
return True return True
try: try:
res = subprocess.run( res = subprocess.run(
+27 -6
View File
@@ -27,19 +27,40 @@ def is_steam_running(cmd: str) -> bool:
raise TypeError("Not a valid Steam client selection") raise TypeError("Not a valid Steam client selection")
def is_sandboxed() -> bool: def is_snap_sandbox() -> bool:
return bool(os.environ.get("SNAP"))
def is_flatpak_sandbox() -> bool:
return bool(os.environ.get("FLATPAK_ID")) return bool(os.environ.get("FLATPAK_ID"))
def is_sandboxed() -> bool:
if is_snap_sandbox() or is_flatpak_sandbox():
return True
return False
def get_flatpak_output() -> list[str] | None:
try:
proc = subprocess.check_output(
[FLATPAK_CMD, "ps", "--columns=application"], text=True
)
lines = proc.splitlines()
return lines
except Exception as e:
logger.debug(e)
return None
def is_flatpak_steam_running() -> bool: def is_flatpak_steam_running() -> bool:
if is_sandboxed(): if is_flatpak_sandbox():
return True return True
if has_cmd(FLATPAK_CMD) is False: if has_cmd(FLATPAK_CMD) is False:
return False return False
proc = subprocess.check_output( lines = get_flatpak_output()
[FLATPAK_CMD, "ps", "--columns=application"], text=True if lines is None:
) return False
lines = proc.splitlines()
if FLATPAK_APPID in lines: if FLATPAK_APPID in lines:
return True return True
return False return False
+2
View File
@@ -0,0 +1,2 @@
debug_picker_title = "Save the debug log to a file"
diagnostic_picker_title = "Save system diagnostics to a file"
-41
View File
@@ -1,41 +0,0 @@
navigation = {
"Enter/space/double click": "select row item",
"Down arrow": "move down a row/scroll down",
"Up arrow": "move up a row/scroll up",
"Right arrow": "jump to sidebar from main area",
"Left arrow": "jump to main area from sidebar",
"Tab": "cycle forward through elements",
"Shift-tab": "cycle backward through elements",
"ESC/Enter": "close dialogs",
"?": "show/hide this dialog",
"Ctrl-q": "Quit",
}
servers = {
"Enter/space/double-click": "connect to server",
"Right-click/Ctrl-l": "additional context menus",
"Ctrl-r": "refresh players",
"Ctrl-f": "jump to keyword search field",
"Ctrl-m": "jump to maps field",
"Ctrl-d": "select default LAN port",
"Ctrl-n": "select custom LAN port",
"Ctrl-u": "connect to server from preconnect dialog",
"Ctrl-i": "jump to IP insert field",
"n": "navigate to next tab",
"p": "navigate to previous tab",
"ESC": "return to table",
"1-9": "toggle filter 1-9 on/off",
"0": "toggle filter 10",
"Minus": "toggle filter 11",
"Backslash": "toggle filter 12",
"Apostrophe": "toggle filter 13",
}
vim = {
"j": "Move down a row/scroll up",
"k": "Move up a row/scroll down",
"h": "Jump to main area from sidebar",
"l": "Jump to sidebar from main area",
"g": "Jump to first row/top of page",
"G": "Jump to last row/bottom of page",
}
key_contexts = ["Servers", "Navigation", "Vim-style keys"]
key_header = "Keybindings"
+4 -1
View File
@@ -7,9 +7,12 @@ log_status = "Read the DZGUI log generated since startup"
separator_label = "SEPARATOR" separator_label = "SEPARATOR"
separator_status = "" separator_status = ""
system_log_label = "Output system info to log file" system_log_label = "Output system info to a file"
system_log_status = "Dump diagnostic data for troubleshooting" system_log_status = "Dump diagnostic data for troubleshooting"
debug_log_label = "Output debug log to a file"
debug_log_status = "Dump a summary of errors/events since DZGUI started"
docs_label = "Documentation/help files (GitHub) ⧉" docs_label = "Documentation/help files (GitHub) ⧉"
docs_status = "Open the DZGUI documentation in a browser" docs_status = "Open the DZGUI documentation in a browser"
+5 -5
View File
@@ -3,7 +3,7 @@ title_intro = "Welcome"
blurb_intro = """ blurb_intro = """
This wizard will help you set up some common config options before launching the application. This wizard will help you set up some common config options before launching the application.
""" """
error_sandbox = "Setup cannot be run from inside Flatpak sandbox.\nPlease launch the application directly." error_sandbox = "Setup cannot be run from inside a sandboxed version of Steam (Snap/Flatpak).\nPlease launch the application directly first."
welcome = "Welcome to {0}!" welcome = "Welcome to {0}!"
### SteamPathPage ### SteamPathPage
@@ -12,15 +12,15 @@ blurb_steam_path = """
DZGUI needs to find the location to your default Steam installation. DZGUI needs to find the location to your default Steam installation.
This will be used to determine whether (and where) DayZ is installed. This will be used to determine whether (and where) DayZ is installed.
""" """
desc_custom_path = "This is the expected Steam path <b>if you set a custom XDG_DATA_HOME directory.</b>"
desc_default_path = "This is the default Steam path on <b>most distributions</b>." desc_default_path = "This is the default Steam path on <b>most distributions</b>."
desc_flatpak_path = ( desc_flatpak_path = (
"This is the default Steam path if you are using <b>Flatpak Steam</b>." "This is the default Steam path if you are using <b>Flatpak Steam</b>."
) )
desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>." desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>."
desc_snap_path = "This is the default Steam path on <b>systems using Snap packages</b>."
desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>." desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>."
no_valid_paths = ( no_valid_paths = "No valid Steam path or Steam command found on system. Please install Steam to continue."
"No valid Steam path or Steam command found on system. Please install Steam to continue."
)
button_scan = "Scan for Steam" button_scan = "Scan for Steam"
### ConfigMigrationPage ### ConfigMigrationPage
@@ -73,7 +73,7 @@ checkbox_steam_shortcut = (
"This creates a standalone copy of DZGUI and adds it to Steam. " "This creates a standalone copy of DZGUI and adds it to Steam. "
"You <b>must restart Steam</b> for the shortcut to appear. This will not replace or update existing shortcuts. " "You <b>must restart Steam</b> for the shortcut to appear. This will not replace or update existing shortcuts. "
"If you update DZGUI when it is launched via Steam, updates will be applied to the Steam version. " "If you update DZGUI when it is launched via Steam, updates will be applied to the Steam version. "
"Not available if you selected the Flatpak client as your Steam default." "Not available if you selected the Snap client as your Steam default."
), ),
) )
checkbox_start_menu = ( checkbox_start_menu = (
+3 -2
View File
@@ -10,8 +10,9 @@ from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def make_parents(path: "Path") -> None: def make_parents(path: "Path", descend: bool = False) -> None:
path.parent.mkdir(parents=True, exist_ok=True) p = path if descend else path.parent
p.mkdir(parents=True, exist_ok=True)
def copy_dzgui_to_xdg_data(exe_path: Path) -> None: def copy_dzgui_to_xdg_data(exe_path: Path) -> None:
+249 -162
View File
@@ -1,36 +1,186 @@
from dataclasses import dataclass from dataclasses import dataclass
from dzgui.const.constants import SYSTEM_LOG
@dataclass(slots=True, frozen=True)
class DevelopersPage:
header: str
paths_label: str
prefs_label: str
columns: list[str]
@dataclass(slots=True, frozen=True)
class ServerLabels:
browser: str
saved: str
recent: str
lan: str
@dataclass(slots=True, frozen=True) # General
class AtomicButton: dialog_header = "DZGUI - Dialog"
refresh: str dz = "DayZ"
refresh_tooltip: str dz_exp = "DayZ Experimental"
copy: str delimiter = "␞"
keys: str
keys_tooltip: str # GenericDialog
main_menu = "Return to main menu"
exit_app = "Exit"
modlist = "Modlist"
input_required = "User input required"
confirm = "Confirmation"
notice = "Notice"
wait = "Please wait"
restart_required = "App relaunch required"
# Wait dialogs
ping = "Ping"
mod = "Mod"
_id = "ID"
# ContextMenu
add_note = "Add note"
edit_note = "Edit note"
show_mods = "Show server-side mods"
show_details = "Show server details"
refresh_players = "Refresh player count"
open_workshop = "Open in Steam Workshop"
unsub_mod = "Unsubscribe mod"
validate_mod = "Validate mod"
copy_name = "Copy name to clipboard"
copy_ip = "Copy IP to clipboard"
copy_log = "Copy record(s) to clipboard"
add = "Add to Saved Servers"
add_fav = "Set as favorite"
remove = "Remove from Saved Servers"
remove_history = "Remove from history"
connect = "Connect"
# Columns
server_mod_cols = ["Mod", "ID", "Installed"]
mod_cols = ["Mod", "Symlink", "ID", "Size (MiB)", "Color"]
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
browser_cols = [
"Name",
"Map",
"View",
"Gametime",
"Players",
"Max",
"Queue",
"IP",
"Qport",
"Ping",
]
# DetailsDialog
workshop = "Enter/double click a row to open in Steam Workshop."
# LanDialog
default_port = "Use default query port (27016)"
custom_port = "Enter custom query port"
scan_servers = "Scan LAN servers"
select_port = "Select the query port"
# Errors
error_heading = "Error"
config_not_found = "DZGUI configuration file not found. Please exit and restart."
cannot_acquire_lock = "DZGUI is already open."
something_wrong = "Something went wrong. See the detailed error below."
steam_key_missing = "No Steam API key is set."
malformed_mods = "Found mods on system, but was unable to parse results."
steam_missing = "Local Steam installation is not set, possibly malformed config file."
build_corrupted = (
"Steam settings or DayZ installation may be corrupted. Try restarting Steam."
)
server_timeout = "Timed out when querying server(s). Check IP or try again later."
server_error = (
"Error while contacting server, possibly timed out. Please wait and try again."
)
server_protected = (
"This server is password-protected and you will be "
"prompted when connecting. Do you want to proceed?"
)
@dataclass(slots=True, frozen=True) # KeybindingsDialog
class Flags: navigation = {
description: str "Enter/space/double click": "select row item",
version: str "Down arrow": "move down a row/scroll down",
uninstall: str "Up arrow": "move up a row/scroll up",
debug: str "Right arrow": "jump to sidebar from main area",
map_count: str "Left arrow": "jump to main area from sidebar",
"Tab": "cycle forward through elements",
"Shift-tab": "cycle backward through elements",
"ESC/Enter": "close dialogs",
"?": "show/hide this dialog",
"Ctrl-q": "Quit",
}
servers = {
"Enter/space/double-click": "connect to server",
"Right-click/Ctrl-l": "additional context menus",
"Ctrl-r": "refresh players",
"Ctrl-f": "jump to keyword search field",
"Ctrl-m": "jump to maps field",
"Ctrl-d": "select default LAN port",
"Ctrl-n": "select custom LAN port",
"Ctrl-u": "connect to server from preconnect dialog",
"Ctrl-i": "jump to IP insert field",
"n": "navigate to next tab",
"p": "navigate to previous tab",
"ESC": "return to table",
"1-9": "toggle filter 1-9 on/off",
"0": "toggle filter 10",
"Minus": "toggle filter 11",
"Backslash": "toggle filter 12",
"Apostrophe": "toggle filter 13",
}
vim = {
"j": "Move down a row/scroll up",
"k": "Move up a row/scroll down",
"h": "Jump to main area from sidebar",
"l": "Jump to sidebar from main area",
"g": "Jump to first row/top of page",
"G": "Jump to last row/bottom of page",
}
key_contexts = ["Servers", "Navigation", "Vim-style keys"]
key_header = "Keybindings"
# ModSelectionPanel
# labels
label_main_menu = "Main menu"
# buttons
ping_servers = "Ping servers"
ping_tooltip = (
"Refresh the ping for visible servers.\n" "Available once per unique filter context"
)
# statusbar_helptext = "Select a row to see its detailed description"
# statusbar_helptext = "No server metadata to list."
# use e.g. filters.1pp
filter_1pp = "1PP"
filter_3pp = "3PP"
filter_day = "Day"
filter_night = "Night"
filter_empty = "Empty"
filter_full = "Full"
filter_lowpop = "Low pop"
filter_nonascii = "Non-ASCII"
filter_duplicate = "Duplicate"
filter_official = "Official"
filter_unofficial = "Unofficial"
filter_modded = "Modded"
filter_unmodded = "Unmodded"
# state
unknown = "Unknown"
none_provided = "None provided"
disabled = "Disabled"
enabled = "Enabled"
null = "-"
unspecified = "not specified"
# DLC
dlc_frostline = "Frostline"
dlc_badlands = "Badlands"
dlc_none = "None"
# platform
windows = "Windows"
linux = "Linux"
# misc
self_workshop = "Open Steam workshop"
settings_updated = "Settings updated!"
@dataclass(slots=True, frozen=True) @dataclass(slots=True, frozen=True)
class ModPanelStrings: class ModPanelStrings:
@@ -130,6 +280,12 @@ class Options:
manual_dl: str manual_dl: str
auto_dl: str auto_dl: str
update: str update: str
install_mode: str
force_update: str
dl_eventbox: str
force_eventbox: str
self_update: str
no_self_update: str
api_key: str api_key: str
prefs: str prefs: str
mods: str mods: str
@@ -137,140 +293,7 @@ class Options:
branch: str branch: str
stable: str stable: str
testing: str testing: str
manual_sub_msg: str
# General
dialog_header = "DZGUI - Dialog"
dz = "DayZ"
dz_exp = "DayZ Experimental"
delimiter = "␞"
# GenericDialog
main_menu = "Return to main menu"
exit_app = "Exit"
modlist = "Modlist"
input_required = "User input required"
confirm = "Confirmation"
notice = "Notice"
wait = "Please wait"
restart_required = "App relaunch required"
# Wait dialogs
ping = "Ping"
mod = "Mod"
_id = "ID"
# ContextMenu
add_note = "Add note"
edit_note = "Edit note"
show_mods = "Show server-side mods"
show_details = "Show server details"
refresh_players = "Refresh player count"
open_workshop = "Open in Steam Workshop"
unsub_mod = "Unsubscribe mod"
validate_mod = "Validate mod"
copy_name = "Copy name to clipboard"
copy_ip = "Copy IP to clipboard"
copy_log = "Copy record(s) to clipboard"
add = "Add to Saved Servers"
add_fav = "Set as favorite"
remove = "Remove from Saved Servers"
remove_history = "Remove from history"
connect = "Connect"
# Columns
server_mod_cols = ["Mod", "ID", "Installed"]
mod_cols = ["Mod", "Symlink", "ID", "Size (MiB)", "Color"]
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
browser_cols = [
"Name",
"Map",
"View",
"Gametime",
"Players",
"Max",
"Queue",
"IP",
"Qport",
"Ping",
]
# DetailsDialog
workshop = "Enter/double click a row to open in Steam Workshop."
# LanDialog
default_port = "Use default query port (27016)"
custom_port = "Enter custom query port"
scan_servers = "Scan LAN servers"
select_port = "Select the query port"
# Errors
error_heading = "Error"
config_not_found = "DZGUI configuration file not found. Please exit and restart."
cannot_acquire_lock = "DZGUI is already open."
something_wrong = "Something went wrong. See the detailed error below."
steam_key_missing = "No Steam API key is set."
malformed_mods = "Found mods on system, but was unable to parse results."
steam_missing = "Local Steam installation is not set, possibly malformed config file."
build_corrupted = (
"Steam settings or DayZ installation may be corrupted. Try restarting Steam."
)
server_timeout = "Timed out when querying server(s). Check IP or try again later."
server_error = (
"Error while contacting server, possibly timed out. Please wait and try again."
)
server_protected = (
"This server is password-protected and you will be "
"prompted when connecting. Do you want to proceed?"
)
# labels
label_main_menu = "Main menu"
# buttons
ping_servers = "Ping servers"
ping_tooltip = (
"Refresh the ping for visible servers.\n" "Available once per unique filter context"
)
# use e.g. filters.1pp
filter_1pp = "1PP"
filter_3pp = "3PP"
filter_day = "Day"
filter_night = "Night"
filter_empty = "Empty"
filter_full = "Full"
filter_lowpop = "Low pop"
filter_nonascii = "Non-ASCII"
filter_duplicate = "Duplicate"
filter_official = "Official"
filter_unofficial = "Unofficial"
filter_modded = "Modded"
filter_unmodded = "Unmodded"
# state
unknown = "Unknown"
none_provided = "None provided"
disabled = "Disabled"
enabled = "Enabled"
null = "-"
unspecified = "not specified"
# DLC
dlc_frostline = "Frostline"
dlc_badlands = "Badlands"
dlc_none = "None"
# platform
windows = "Windows"
linux = "Linux"
# misc
self_workshop = "Open Steam workshop"
settings_updated = "Settings updated!"
init = Init( init = Init(
@@ -348,6 +371,20 @@ options = Options(
manual_dl="Manual", manual_dl="Manual",
auto_dl="Auto", auto_dl="Auto",
update="Update", update="Update",
install_mode="Mod install mode",
force_update="Force update local mods",
dl_eventbox=(
"Manual: prompt to subscribe to mods in Steam. " "Auto: unmanned downloads."
),
force_eventbox="Synchronize all local mods. Automatic mode must be enabled.",
self_update=(
"Stable: only contains stable features. "
"Testing: pre-release beta, contains new features."
),
no_self_update=(
"In-app updates are disabled when DZGUI is "
"installed globally (e.g., via package manager)."
),
api_key="API Key", api_key="API Key",
prefs="Preferences", prefs="Preferences",
mods="Mods", mods="Mods",
@@ -355,6 +392,13 @@ options = Options(
branch="DZGUI branch", branch="DZGUI branch",
stable="Stable", stable="Stable",
testing="Testing", testing="Testing",
manual_sub_msg="""When switching from MANUAL to AUTO mod install mode,
DZGUI will manage mod installation and deletion for you.
To prevent conflicts with Steam Workshop subscriptions and old mods from being downloaded
when Steam updates, you should unsubscribe from any existing Workshop mods you manually subscribed to.
Open your Profile, then 'Workshop Items' and select 'Unsubscribe from all'
on the right-hand side.
""",
) )
dialog = Dialog( dialog = Dialog(
@@ -401,6 +445,14 @@ no_mods = "No local mods found."
no_servers = "No server metadata to list." no_servers = "No server metadata to list."
@dataclass(slots=True, frozen=True)
class Flags:
description: str
version: str
uninstall: str
debug: str
map_count: str
flags = Flags( flags = Flags(
description="DayZ server browser and mod manager", description="DayZ server browser and mod manager",
@@ -411,11 +463,28 @@ flags = Flags(
) )
@dataclass(slots=True, frozen=True)
class FilePicker:
title: str
placeholder: str
picker = FilePicker(
title="Save diagnostic log to file",
placeholder=SYSTEM_LOG,
)
api_error = ( api_error = (
"API key validation error or timeout. See 'Help > Show debug log' for details." "API key validation error or timeout. See 'Help > Show debug log' for details."
) )
@dataclass(slots=True, frozen=True)
class DevelopersPage:
header: str
paths_label: str
prefs_label: str
columns: list[str]
developers = DevelopersPage( developers = DevelopersPage(
@@ -426,6 +495,14 @@ developers = DevelopersPage(
) )
@dataclass(slots=True, frozen=True)
class ServerLabels:
browser: str
saved: str
recent: str
lan: str
server_labels = ServerLabels( server_labels = ServerLabels(
browser="Server Browser", browser="Server Browser",
saved="Saved Servers", saved="Saved Servers",
@@ -434,9 +511,19 @@ server_labels = ServerLabels(
) )
distance_suffix = "Distance: calculating..."
dialog_error = "ERROR" dialog_error = "ERROR"
@dataclass(slots=True, frozen=True)
class AtomicButton:
refresh: str
refresh_tooltip: str
copy: str
keys: str
keys_tooltip: str
atomic_buttons = AtomicButton( atomic_buttons = AtomicButton(
refresh="Refresh", refresh="Refresh",
refresh_tooltip="Refresh server data", refresh_tooltip="Refresh server data",
+2
View File
@@ -35,6 +35,8 @@ def rebuild_symlinks(config: Path) -> None:
expunge_link(file) expunge_link(file)
workshop = get_local_mod_path(steam_path) workshop = get_local_mod_path(steam_path)
if workshop.is_dir() is False:
return
# NOTE: create symlinks for missing mods # NOTE: create symlinks for missing mods
for mod_id in get_local_mod_ids(steam_path): for mod_id in get_local_mod_ids(steam_path):
uid = str(mod_id) uid = str(mod_id)
+15 -4
View File
@@ -1,6 +1,7 @@
from pathlib import Path from pathlib import Path
from dzgui.util.strings import picker from dzgui.const.constants import DEBUG_LOG, SYSTEM_LOG
from dzgui.strings.filepickers import diagnostic_picker_title, debug_picker_title
import gi import gi
@@ -9,9 +10,9 @@ from gi.repository import Gtk
class FilePicker(Gtk.FileChooserDialog): class FilePicker(Gtk.FileChooserDialog):
def __init__(self, parent: Gtk.Window) -> None: def __init__(self, parent: Gtk.Window, title: str, placeholder: str) -> None:
super().__init__( super().__init__(
title=picker.title, title=title,
action=Gtk.FileChooserAction.SAVE, action=Gtk.FileChooserAction.SAVE,
transient_for=parent, transient_for=parent,
resizable=True, resizable=True,
@@ -20,7 +21,7 @@ class FilePicker(Gtk.FileChooserDialog):
self.add_buttons("_Save", Gtk.ResponseType.OK) # type: ignore[no-untyped-call] self.add_buttons("_Save", Gtk.ResponseType.OK) # type: ignore[no-untyped-call]
self.set_default_response(Gtk.ResponseType.OK) self.set_default_response(Gtk.ResponseType.OK)
self.set_current_name(picker.placeholder) self.set_current_name(placeholder)
def pick_file(self) -> Path | None: def pick_file(self) -> Path | None:
res = self.run() # type: ignore[no-untyped-call] res = self.run() # type: ignore[no-untyped-call]
@@ -35,6 +36,16 @@ class FilePicker(Gtk.FileChooserDialog):
return None return None
class DiagnosticLogPicker(FilePicker):
def __init__(self, parent: Gtk.Window) -> None:
super().__init__(parent, diagnostic_picker_title, SYSTEM_LOG)
class DebugLogPicker(FilePicker):
def __init__(self, parent: Gtk.Window) -> None:
super().__init__(parent, debug_picker_title, DEBUG_LOG)
class FolderPicker(Gtk.FileChooserDialog): class FolderPicker(Gtk.FileChooserDialog):
def __init__(self, parent: Gtk.Window, title: str) -> None: def __init__(self, parent: Gtk.Window, title: str) -> None:
super().__init__( super().__init__(
+8 -1
View File
@@ -14,8 +14,10 @@ from dzgui.const.constants import (
HERO_PATH, HERO_PATH,
FLATPAK_ROOT_PATH, FLATPAK_ROOT_PATH,
LEGACY_CONFIG_PATH, LEGACY_CONFIG_PATH,
SNAP_STEAM_PATH,
TMP_PATH, TMP_PATH,
) )
from dzgui.config.xdg import get_real_home
from dzgui.const.boilerplate import config_boilerplate from dzgui.const.boilerplate import config_boilerplate
from dzgui.const.endpoints import STEAM_API_SETUP from dzgui.const.endpoints import STEAM_API_SETUP
from dzgui.config import freedesktop from dzgui.config import freedesktop
@@ -506,7 +508,8 @@ class Assistant(Gtk.Assistant):
self.pages: dict[EnumeratedWizardPage, int] = {} self.pages: dict[EnumeratedWizardPage, int] = {}
legacy_path = Path.home().joinpath(LEGACY_CONFIG_PATH) home = get_real_home()
legacy_path = home.joinpath(LEGACY_CONFIG_PATH)
self.has_legacy_config = legacy_path.is_file() self.has_legacy_config = legacy_path.is_file()
for page in ( for page in (
self.page_intro, self.page_intro,
@@ -699,6 +702,7 @@ class ShortcutCreationPage(OptionalPageMixin, EnumeratedWizardPage): # type: ig
self.add_start(self.checks_area) self.add_start(self.checks_area)
self.show_all() self.show_all()
self.connect("map", self._on_map) self.connect("map", self._on_map)
def _on_start_menu_toggled(self, button: Gtk.CheckButton) -> None: def _on_start_menu_toggled(self, button: Gtk.CheckButton) -> None:
@@ -709,6 +713,9 @@ class ShortcutCreationPage(OptionalPageMixin, EnumeratedWizardPage): # type: ig
def set_steam_path(self, path: Path) -> None: def set_steam_path(self, path: Path) -> None:
self.steam_path = path self.steam_path = path
if SNAP_STEAM_PATH in str(self.steam_path):
self.steam_checkbox.set_active(False)
self.steam_checkbox.set_sensitive(False)
def is_steam_checkbox_active(self) -> bool: def is_steam_checkbox_active(self) -> bool:
return self.steam_checkbox.get_active() return self.steam_checkbox.get_active()
+4 -6
View File
@@ -1,7 +1,7 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.views.mixins.scrollable_mixin import ScrollableMixin from dzgui.views.mixins.scrollable_mixin import ScrollableMixin
from dzgui.strings import keybindings from dzgui.util.strings import navigation, servers, vim, key_header, key_contexts
from dzgui.util.css import add_class from dzgui.util.css import add_class
import gi import gi
@@ -26,12 +26,10 @@ class Keybindings(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
self.controller = controller self.controller = controller
self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
label = Gtk.Label(label=keybindings.key_header) label = Gtk.Label(label=key_header)
add_class(label, "page-heading") add_class(label, "page-heading")
grid = self.build_grid( grid = self.build_grid([servers, navigation, vim])
[keybindings.servers, keybindings.navigation, keybindings.vim]
)
self.box.add(label) self.box.add(label)
self.box.add(grid) self.box.add(grid)
self.add(self.box) self.add(self.box)
@@ -96,7 +94,7 @@ class Keybindings(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
row, column = 1, 1 row, column = 1, 1
w, h = 1, 1 w, h = 1, 1
sidebar = self.build_sidebar(keybindings.key_contexts) sidebar = self.build_sidebar(key_contexts)
separator = Gtk.Separator() separator = Gtk.Separator()
keys_box = self.build_keys(items) keys_box = self.build_keys(items)
+11 -12
View File
@@ -56,19 +56,18 @@ class MenuTreeView(TreeView):
self.controller.populate_log() self.controller.populate_log()
case RowType.CHANGELOG: case RowType.CHANGELOG:
self.controller.open_page(NotebookPage.CHANGELOG) self.controller.open_page(NotebookPage.CHANGELOG)
case RowType.DUMP_LOG: case RowType.DUMP_DIAGNOSTIC:
self.controller.dump_diagnostics() self.controller.dump_diagnostics()
pass case RowType.DUMP_DEBUG:
self.controller.dump_log()
docs = [ case (
RowType.DOCS, RowType.DOCS
RowType.DOCS_FALLBACK, | RowType.DOCS_FALLBACK
RowType.BUGS, | RowType.BUGS
RowType.FORUM, | RowType.FORUM
RowType.SPONSOR, | RowType.SPONSOR
] ):
if row_type in docs: open_link_by_rowtype(row_type)
open_link_by_rowtype(row_type)
def get_row_enum(self) -> str: def get_row_enum(self) -> str:
# NOTE: col 1 contains a RowType enum # NOTE: col 1 contains a RowType enum
+12
View File
@@ -0,0 +1,12 @@
"libraryfolders"
{
"0"
{
"path" ""
"label" ""
"apps"
{
"221100" "11111"
}
}
}
+43
View File
@@ -0,0 +1,43 @@
import pytest
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING
from dzgui.api.steam import get_steam_paths
if TYPE_CHECKING:
from _pytest.monkeypatch import MonkeyPatch
def test_custom_xdg_path(monkeypatch: "MonkeyPatch") -> None:
tmp = tempfile.TemporaryDirectory(delete=False).name
custom_path = Path(tmp).joinpath("xdg_data_home")
monkeypatch.setenv("XDG_DATA_HOME", str(custom_path))
vdf_path = custom_path.joinpath("Steam/steamapps")
vdf_path.mkdir(parents=True, exist_ok=True)
vdf_path.joinpath("libraryfolders.vdf").touch()
resolved_paths = get_steam_paths()
expect = custom_path.joinpath("Steam")
assert any(expect in el for el in resolved_paths)
def test_default_xdg_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".local/share/Steam")
assert any(expect in el for el in resolved_paths)
def test_ubuntu_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".steam/steam")
assert any(expect in el for el in resolved_paths)
@pytest.mark.flatpak
def test_flatpak_path() -> None:
resolved_paths = get_steam_paths()
expect = Path.home().joinpath(".var/app/com.valvesoftware.Steam/data/steam")
assert any(expect in el for el in resolved_paths)
+23
View File
@@ -0,0 +1,23 @@
import pytest
import tempfile
from pathlib import Path
from typing import TYPE_CHECKING
from dzgui.config.xdg import get_xdg_paths
if TYPE_CHECKING:
from _pytest.monkeypatch import MonkeyPatch
@pytest.mark.parametrize("env", ["SNAP_REAL_HOME", "HOME"])
def test_sandbox_home_resolution(monkeypatch: "MonkeyPatch", env: str) -> None:
with tempfile.NamedTemporaryFile(delete=False) as f:
monkeypatch.setenv(env, f.name)
paths = get_xdg_paths()
assert paths["XDG_CONFIG_HOME"] == Path(f.name).joinpath(".config/dzgui")
def test_home_fallback() -> None:
paths = get_xdg_paths()
assert paths["XDG_CONFIG_HOME"] == Path.home().joinpath(".config/dzgui")
+30
View File
@@ -0,0 +1,30 @@
import pytest
import vdf
from pathlib import Path
from dzgui.api.mods import get_local_mod_ids
from dzgui.util.dirs import make_parents
from tests.fixtures import fixture_path
@pytest.fixture
def libraryfolders() -> Path:
return fixture_path("api/steamapps/libraryfolders.vdf")
def test_missing_mod_dir(tmp_path, libraryfolders: Path) -> None:
"""
Updates fixture file key with tmp path value serializes to file,
then tests for missing mod directory returning an empty list
"""
folders = tmp_path.joinpath("steamapps/libraryfolders.vdf")
workshop = tmp_path.joinpath("steamapps/workshop/content")
make_parents(folders)
make_parents(workshop, descend=True)
with open(libraryfolders, "r") as f:
data = vdf.load(f)
data["libraryfolders"]["0"]["path"] = tmp_path
with open(folders, "w") as f:
vdf.dump(data, f, pretty=True)
ids = get_local_mod_ids(tmp_path)
assert len(ids) == 0