Compare commits

..

3 Commits

Author SHA1 Message Date
aclist
45fd180dcb fix: accept emitter as arg
Some checks are pending
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-06-10 19:23:14 +09:00
aclist
486da7749a fix: emitter arguments 2026-06-10 18:37:31 +09:00
aclist
606df3423c change: delegate early checks to BootWindow 2026-06-10 15:59:44 +09:00
9 changed files with 34 additions and 29 deletions

View File

@ -155,6 +155,6 @@ class Emitter(GObject.GObject):
def lan_page_initialized(self) -> None:
pass
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str))
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str) -> None:
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str, bool))
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
pass

View File

@ -1,13 +1,10 @@
import logging
import sys
from pathlib import Path
from dzgui.config.query import lookup
from dzgui.const.constants import APPID_DAYZ, APP_NAME, LIBRARYFOLDERS_PATH
from dzgui.const.enum import Preferences
from dzgui.strings.errors import dayz_not_found
from dzgui.views.dialogs.early_alert import EarlyAlertDialog
import dzgui.api.pefile as PeFile
@ -20,5 +17,4 @@ def is_dayz_installed(config: Path) -> None:
PeFile.get_app_path(Path(path) / LIBRARYFOLDERS_PATH, APPID_DAYZ)
except Exception as e:
logger.critical(e)
EarlyAlertDialog(dayz_not_found)
sys.exit(1)
raise e

View File

@ -11,7 +11,6 @@ from dzgui.const.enum import Preferences
from dzgui.config.query import lookup
from dzgui.config.userprefs import UserPrefs
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
from dzgui.init.dayz import is_dayz_installed
from dzgui.init.flock import lock_acquire
from dzgui.init.migrate import (
has_new_config,
@ -124,18 +123,9 @@ def main() -> None:
if has_steam_client() is False:
EarlyAlertDialog(init.requires_steam)
is_dayz_installed(XDG.config)
bootwin = BootWindow(XDG, version)
local_coords, latest_release = bootwin.get_results()
# rebuild_symlinks(XDG.config)
# remove_stale_signatures(XDG.config, XDG.version)
## TODO: handle IP DB failure and use coords fallback
# local_coords = get_local_coords(XDG.ips)
# latest_release = check_updates(version)
use_miles = lookup(XDG.config, Preferences.DIST)
prefs = UserPrefs(
is_steam_deck=_is_steam_deck,

View File

@ -5,7 +5,7 @@ from dzgui.api.mods import get_custom_mods
from dzgui.api.steam import launch_offline
from dzgui.const.enum import Preferences
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.model.model_factory import FastInsertListStore, ModelFactory
from dzgui.model.model_factory import ModelFactory
from dzgui.strings import dialogs
from dzgui.util.symlink import clone_symlinks
@ -31,7 +31,7 @@ class OfflineManager:
# TODO: strings
@call_on_thread("parsing")
def parse_custom_mods(self, local_mods: list[str], folder: str) -> "FastInsertListStore":
def parse_custom_mods(self, local_mods: list[str], folder: str) -> None:
mods = get_custom_mods(Path(folder))
store = ModelFactory().make_mod_store()
store.extend(mods)
@ -42,9 +42,8 @@ class OfflineManager:
row[-1]=True
has_duplicates = True
func = StoredFunc(self.emitter.emit, "custom_mods_loaded", store, folder, has_duplicates)
func = StoredFunc(lambda: self.emitter.emit("custom_mods_loaded", store, folder, has_duplicates))
self.thread_man.set_cleanup_func(func)
# TODO: return store from cleanup function
def setup(
self,

View File

@ -3,4 +3,4 @@ api_validation_error = (
)
api_popover = "API key validation failed."
dayz_not_found = "Could not find DayZ and/or Steam: are they installed?"
dayz_not_found = "Could not find a valid DayZ installation."

View File

@ -3,3 +3,4 @@ signatures = "Updating mod signatures"
geo = "Checking geolocation records"
coords = "Checking local coordinates"
updates = "Checking for updates"
dayz = "Looking for DayZ"

View File

@ -10,6 +10,7 @@ from dzgui.api.mods import remove_stale_signatures as remove_stale
from dzgui.config.ipdb import get_ipdb
from dzgui.const.constants import HEX_GREEN, HEX_RED
from dzgui.init.coords import get_local_coords
from dzgui.init.dayz import is_dayz_installed
from dzgui.init.update import check_updates
from dzgui.const.constants import EXPAND, FILL
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
@ -119,6 +120,7 @@ class BootDialog(Gtk.Dialog):
self.error_box.hide()
steps = [
(StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False),
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
(
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
@ -126,6 +128,7 @@ class BootDialog(Gtk.Dialog):
False,
),
(StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, False),
# TODO: handle IP DB failure and use coords fallback
(StoredFunc(get_local_coords, self.xdg.ips), preboot.coords, True),
(StoredFunc(check_updates, self.version), preboot.updates, True),
]

View File

@ -1,3 +1,4 @@
from __future__ import annotations
from pathlib import Path
from typing import Self, Sequence, TYPE_CHECKING
@ -19,7 +20,6 @@ from dzgui.views.components.scrollable import NoOverlayScrolledWindow
from dzgui.views.trees.tree_mods import OfflineModTreeView
import gi
gi.require_version("Gtk", "3.0")
@ -27,6 +27,7 @@ from gi.repository import Gtk, Gdk # noqa
if TYPE_CHECKING:
from dzgui.controllers.mc import Controller
from dzgui.controllers.emitter import Emitter
from dzgui.model.model_factory import FastInsertListStore
@ -105,6 +106,12 @@ class ModFrame(HeadingFrame):
sel = self.tree.get_selection()
sel.connect("changed", self._on_selection_changed)
def get_mods(self) -> list[str]:
model = self.tree.get_model()
if model is None:
return []
return [row[1] for row in model]
def collapse_tree(self) -> None:
self.tree_vbox.hide()
@ -134,7 +141,9 @@ class ModFrame(HeadingFrame):
class CustomModFrame(ModFrame):
def __init__(self, parent: Gtk.Widget, controller: "Controller", heading: str) -> None:
def __init__(
self, parent: OfflineLoader, controller: "Controller", heading: str
) -> None:
super().__init__(controller, heading)
self.parent = parent
@ -150,8 +159,13 @@ class CustomModFrame(ModFrame):
self.emitter.connect("custom_mods_loaded", self._on_custom_mods_loaded)
def _on_custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
def _on_custom_mods_loaded(
self,
emitter: "Emitter",
store: "FastInsertListStore",
folder: str,
has_duplicates: bool,
) -> None:
if len(store) == 0:
# TODO: pop error dialog area
# block button access
@ -166,7 +180,6 @@ class CustomModFrame(ModFrame):
# duplicates should block button access
pass
def _on_custom_button_clicked(self, button: Gtk.Button) -> None:
self.parent.parse_mods()
@ -231,7 +244,7 @@ class OfflineLoader(Gtk.Box):
self.add(PageHeading(offline.heading))
self.local_frame = ModFrame(controller, offline.local_frame)
self.custom_frame = CustomModFrame(controller, offline.custom_frame)
self.custom_frame = CustomModFrame(self, controller, offline.custom_frame)
# TODO: suppress symlink column
self.custom_tree = OfflineModTreeView(controller)
@ -274,7 +287,7 @@ class OfflineLoader(Gtk.Box):
self.add(self.button_box)
def parse_mods(self) -> None:
# TODO:
# TODO: check method on custom frame
local_mods = self.local_frame.get_mods()
folder = self.controller.set_custom_folder()
if folder is not None:

View File

@ -115,10 +115,13 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
val = model[it][3]
formatted = localize.number(val)
cell.set_property("text", formatted)
# NOTE: reapply color property after float conversion
self._format_color(column, cell, model, it, data)
def set_menu(self, context: ContextMenuGroup) -> None:
self.menu = context
class OfflineModTreeView(ModTreeView):
def __init__(self, controller: "Controller") -> None:
super().__init__(controller)