mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
Compare commits
No commits in common. "45fd180dcb902ec9dcd69270cfd9bf705101a5af" and "ab439144ea0aea2c37ffdf3e34c245ae30a4906a" have entirely different histories.
45fd180dcb
...
ab439144ea
@ -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, bool))
|
||||
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str))
|
||||
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str) -> None:
|
||||
pass
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
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
|
||||
|
||||
@ -17,4 +20,5 @@ def is_dayz_installed(config: Path) -> None:
|
||||
PeFile.get_app_path(Path(path) / LIBRARYFOLDERS_PATH, APPID_DAYZ)
|
||||
except Exception as e:
|
||||
logger.critical(e)
|
||||
raise e
|
||||
EarlyAlertDialog(dayz_not_found)
|
||||
sys.exit(1)
|
||||
|
||||
@ -11,6 +11,7 @@ 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,
|
||||
@ -123,9 +124,18 @@ 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,
|
||||
|
||||
@ -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 ModelFactory
|
||||
from dzgui.model.model_factory import FastInsertListStore, 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) -> None:
|
||||
def parse_custom_mods(self, local_mods: list[str], folder: str) -> "FastInsertListStore":
|
||||
mods = get_custom_mods(Path(folder))
|
||||
store = ModelFactory().make_mod_store()
|
||||
store.extend(mods)
|
||||
@ -42,8 +42,9 @@ class OfflineManager:
|
||||
row[-1]=True
|
||||
has_duplicates = True
|
||||
|
||||
func = StoredFunc(lambda: self.emitter.emit("custom_mods_loaded", store, folder, has_duplicates))
|
||||
func = StoredFunc(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,
|
||||
|
||||
@ -3,4 +3,4 @@ api_validation_error = (
|
||||
)
|
||||
|
||||
api_popover = "API key validation failed."
|
||||
dayz_not_found = "Could not find a valid DayZ installation."
|
||||
dayz_not_found = "Could not find DayZ and/or Steam: are they installed?"
|
||||
|
||||
@ -3,4 +3,3 @@ signatures = "Updating mod signatures"
|
||||
geo = "Checking geolocation records"
|
||||
coords = "Checking local coordinates"
|
||||
updates = "Checking for updates"
|
||||
dayz = "Looking for DayZ"
|
||||
|
||||
@ -10,7 +10,6 @@ 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
|
||||
@ -120,7 +119,6 @@ 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),
|
||||
@ -128,7 +126,6 @@ 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),
|
||||
]
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
from __future__ import annotations
|
||||
from pathlib import Path
|
||||
from typing import Self, Sequence, TYPE_CHECKING
|
||||
|
||||
@ -20,6 +19,7 @@ from dzgui.views.components.scrollable import NoOverlayScrolledWindow
|
||||
from dzgui.views.trees.tree_mods import OfflineModTreeView
|
||||
|
||||
|
||||
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
@ -27,7 +27,6 @@ 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
|
||||
|
||||
|
||||
@ -106,12 +105,6 @@ 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()
|
||||
|
||||
@ -141,9 +134,7 @@ class ModFrame(HeadingFrame):
|
||||
|
||||
|
||||
class CustomModFrame(ModFrame):
|
||||
def __init__(
|
||||
self, parent: OfflineLoader, controller: "Controller", heading: str
|
||||
) -> None:
|
||||
def __init__(self, parent: Gtk.Widget, controller: "Controller", heading: str) -> None:
|
||||
super().__init__(controller, heading)
|
||||
|
||||
self.parent = parent
|
||||
@ -159,13 +150,8 @@ class CustomModFrame(ModFrame):
|
||||
|
||||
self.emitter.connect("custom_mods_loaded", self._on_custom_mods_loaded)
|
||||
|
||||
def _on_custom_mods_loaded(
|
||||
self,
|
||||
emitter: "Emitter",
|
||||
store: "FastInsertListStore",
|
||||
folder: str,
|
||||
has_duplicates: bool,
|
||||
) -> None:
|
||||
|
||||
def _on_custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
|
||||
if len(store) == 0:
|
||||
# TODO: pop error dialog area
|
||||
# block button access
|
||||
@ -180,6 +166,7 @@ class CustomModFrame(ModFrame):
|
||||
# duplicates should block button access
|
||||
pass
|
||||
|
||||
|
||||
def _on_custom_button_clicked(self, button: Gtk.Button) -> None:
|
||||
self.parent.parse_mods()
|
||||
|
||||
@ -244,7 +231,7 @@ class OfflineLoader(Gtk.Box):
|
||||
self.add(PageHeading(offline.heading))
|
||||
|
||||
self.local_frame = ModFrame(controller, offline.local_frame)
|
||||
self.custom_frame = CustomModFrame(self, controller, offline.custom_frame)
|
||||
self.custom_frame = CustomModFrame(controller, offline.custom_frame)
|
||||
|
||||
# TODO: suppress symlink column
|
||||
self.custom_tree = OfflineModTreeView(controller)
|
||||
@ -287,7 +274,7 @@ class OfflineLoader(Gtk.Box):
|
||||
self.add(self.button_box)
|
||||
|
||||
def parse_mods(self) -> None:
|
||||
# TODO: check method on custom frame
|
||||
# TODO:
|
||||
local_mods = self.local_frame.get_mods()
|
||||
folder = self.controller.set_custom_folder()
|
||||
if folder is not None:
|
||||
|
||||
@ -115,13 +115,10 @@ 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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user