mirror of
https://github.com/aclist/dztui.git
synced 2026-08-30 03:37:00 +02:00
Compare commits
3 Commits
ab439144ea
...
45fd180dcb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45fd180dcb | ||
|
|
486da7749a | ||
|
|
606df3423c |
@ -155,6 +155,6 @@ class Emitter(GObject.GObject):
|
|||||||
def lan_page_initialized(self) -> None:
|
def lan_page_initialized(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str))
|
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object, str, bool))
|
||||||
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str) -> None:
|
def custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@ -1,13 +1,10 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
from dzgui.const.constants import APPID_DAYZ, APP_NAME, LIBRARYFOLDERS_PATH
|
from dzgui.const.constants import APPID_DAYZ, APP_NAME, LIBRARYFOLDERS_PATH
|
||||||
from dzgui.const.enum import Preferences
|
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
|
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)
|
PeFile.get_app_path(Path(path) / LIBRARYFOLDERS_PATH, APPID_DAYZ)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.critical(e)
|
logger.critical(e)
|
||||||
EarlyAlertDialog(dayz_not_found)
|
raise e
|
||||||
sys.exit(1)
|
|
||||||
|
|||||||
@ -11,7 +11,6 @@ from dzgui.const.enum import Preferences
|
|||||||
from dzgui.config.query import lookup
|
from dzgui.config.query import lookup
|
||||||
from dzgui.config.userprefs import UserPrefs
|
from dzgui.config.userprefs import UserPrefs
|
||||||
from dzgui.config.xdg import get_xdg_paths, parse_filepaths
|
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.flock import lock_acquire
|
||||||
from dzgui.init.migrate import (
|
from dzgui.init.migrate import (
|
||||||
has_new_config,
|
has_new_config,
|
||||||
@ -124,18 +123,9 @@ def main() -> None:
|
|||||||
if has_steam_client() is False:
|
if has_steam_client() is False:
|
||||||
EarlyAlertDialog(init.requires_steam)
|
EarlyAlertDialog(init.requires_steam)
|
||||||
|
|
||||||
is_dayz_installed(XDG.config)
|
|
||||||
|
|
||||||
bootwin = BootWindow(XDG, version)
|
bootwin = BootWindow(XDG, version)
|
||||||
local_coords, latest_release = bootwin.get_results()
|
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)
|
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||||
prefs = UserPrefs(
|
prefs = UserPrefs(
|
||||||
is_steam_deck=_is_steam_deck,
|
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.api.steam import launch_offline
|
||||||
from dzgui.const.enum import Preferences
|
from dzgui.const.enum import Preferences
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
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.strings import dialogs
|
||||||
from dzgui.util.symlink import clone_symlinks
|
from dzgui.util.symlink import clone_symlinks
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ class OfflineManager:
|
|||||||
|
|
||||||
# TODO: strings
|
# TODO: strings
|
||||||
@call_on_thread("parsing")
|
@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))
|
mods = get_custom_mods(Path(folder))
|
||||||
store = ModelFactory().make_mod_store()
|
store = ModelFactory().make_mod_store()
|
||||||
store.extend(mods)
|
store.extend(mods)
|
||||||
@ -42,9 +42,8 @@ class OfflineManager:
|
|||||||
row[-1]=True
|
row[-1]=True
|
||||||
has_duplicates = 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)
|
self.thread_man.set_cleanup_func(func)
|
||||||
# TODO: return store from cleanup function
|
|
||||||
|
|
||||||
def setup(
|
def setup(
|
||||||
self,
|
self,
|
||||||
|
|||||||
@ -3,4 +3,4 @@ api_validation_error = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
api_popover = "API key validation failed."
|
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."
|
||||||
|
|||||||
@ -3,3 +3,4 @@ signatures = "Updating mod signatures"
|
|||||||
geo = "Checking geolocation records"
|
geo = "Checking geolocation records"
|
||||||
coords = "Checking local coordinates"
|
coords = "Checking local coordinates"
|
||||||
updates = "Checking for updates"
|
updates = "Checking for updates"
|
||||||
|
dayz = "Looking for DayZ"
|
||||||
|
|||||||
@ -10,6 +10,7 @@ from dzgui.api.mods import remove_stale_signatures as remove_stale
|
|||||||
from dzgui.config.ipdb import get_ipdb
|
from dzgui.config.ipdb import get_ipdb
|
||||||
from dzgui.const.constants import HEX_GREEN, HEX_RED
|
from dzgui.const.constants import HEX_GREEN, HEX_RED
|
||||||
from dzgui.init.coords import get_local_coords
|
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.init.update import check_updates
|
||||||
from dzgui.const.constants import EXPAND, FILL
|
from dzgui.const.constants import EXPAND, FILL
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
@ -119,6 +120,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.error_box.hide()
|
self.error_box.hide()
|
||||||
|
|
||||||
steps = [
|
steps = [
|
||||||
|
(StoredFunc(is_dayz_installed, self.xdg.config), preboot.dayz, False),
|
||||||
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
|
(StoredFunc(rebuild_symlinks, self.xdg.config), preboot.symlinks, False),
|
||||||
(
|
(
|
||||||
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
|
StoredFunc(remove_stale, self.xdg.config, self.xdg.version),
|
||||||
@ -126,6 +128,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
False,
|
False,
|
||||||
),
|
),
|
||||||
(StoredFunc(get_ipdb, self.xdg.ips), preboot.geo, 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(get_local_coords, self.xdg.ips), preboot.coords, True),
|
||||||
(StoredFunc(check_updates, self.version), preboot.updates, True),
|
(StoredFunc(check_updates, self.version), preboot.updates, True),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import annotations
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Self, Sequence, TYPE_CHECKING
|
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
|
from dzgui.views.trees.tree_mods import OfflineModTreeView
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version("Gtk", "3.0")
|
gi.require_version("Gtk", "3.0")
|
||||||
@ -27,6 +27,7 @@ from gi.repository import Gtk, Gdk # noqa
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from dzgui.controllers.mc import Controller
|
from dzgui.controllers.mc import Controller
|
||||||
|
from dzgui.controllers.emitter import Emitter
|
||||||
from dzgui.model.model_factory import FastInsertListStore
|
from dzgui.model.model_factory import FastInsertListStore
|
||||||
|
|
||||||
|
|
||||||
@ -105,6 +106,12 @@ class ModFrame(HeadingFrame):
|
|||||||
sel = self.tree.get_selection()
|
sel = self.tree.get_selection()
|
||||||
sel.connect("changed", self._on_selection_changed)
|
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:
|
def collapse_tree(self) -> None:
|
||||||
self.tree_vbox.hide()
|
self.tree_vbox.hide()
|
||||||
|
|
||||||
@ -134,7 +141,9 @@ class ModFrame(HeadingFrame):
|
|||||||
|
|
||||||
|
|
||||||
class CustomModFrame(ModFrame):
|
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)
|
super().__init__(controller, heading)
|
||||||
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
@ -150,8 +159,13 @@ class CustomModFrame(ModFrame):
|
|||||||
|
|
||||||
self.emitter.connect("custom_mods_loaded", self._on_custom_mods_loaded)
|
self.emitter.connect("custom_mods_loaded", self._on_custom_mods_loaded)
|
||||||
|
|
||||||
|
def _on_custom_mods_loaded(
|
||||||
def _on_custom_mods_loaded(self, store: "FastInsertListStore", folder: str, has_duplicates: bool) -> None:
|
self,
|
||||||
|
emitter: "Emitter",
|
||||||
|
store: "FastInsertListStore",
|
||||||
|
folder: str,
|
||||||
|
has_duplicates: bool,
|
||||||
|
) -> None:
|
||||||
if len(store) == 0:
|
if len(store) == 0:
|
||||||
# TODO: pop error dialog area
|
# TODO: pop error dialog area
|
||||||
# block button access
|
# block button access
|
||||||
@ -166,7 +180,6 @@ class CustomModFrame(ModFrame):
|
|||||||
# duplicates should block button access
|
# duplicates should block button access
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def _on_custom_button_clicked(self, button: Gtk.Button) -> None:
|
def _on_custom_button_clicked(self, button: Gtk.Button) -> None:
|
||||||
self.parent.parse_mods()
|
self.parent.parse_mods()
|
||||||
|
|
||||||
@ -231,7 +244,7 @@ class OfflineLoader(Gtk.Box):
|
|||||||
self.add(PageHeading(offline.heading))
|
self.add(PageHeading(offline.heading))
|
||||||
|
|
||||||
self.local_frame = ModFrame(controller, offline.local_frame)
|
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
|
# TODO: suppress symlink column
|
||||||
self.custom_tree = OfflineModTreeView(controller)
|
self.custom_tree = OfflineModTreeView(controller)
|
||||||
@ -274,7 +287,7 @@ class OfflineLoader(Gtk.Box):
|
|||||||
self.add(self.button_box)
|
self.add(self.button_box)
|
||||||
|
|
||||||
def parse_mods(self) -> None:
|
def parse_mods(self) -> None:
|
||||||
# TODO:
|
# TODO: check method on custom frame
|
||||||
local_mods = self.local_frame.get_mods()
|
local_mods = self.local_frame.get_mods()
|
||||||
folder = self.controller.set_custom_folder()
|
folder = self.controller.set_custom_folder()
|
||||||
if folder is not None:
|
if folder is not None:
|
||||||
|
|||||||
@ -115,10 +115,13 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView): # type: ignore
|
|||||||
val = model[it][3]
|
val = model[it][3]
|
||||||
formatted = localize.number(val)
|
formatted = localize.number(val)
|
||||||
cell.set_property("text", formatted)
|
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:
|
def set_menu(self, context: ContextMenuGroup) -> None:
|
||||||
self.menu = context
|
self.menu = context
|
||||||
|
|
||||||
|
|
||||||
class OfflineModTreeView(ModTreeView):
|
class OfflineModTreeView(ModTreeView):
|
||||||
def __init__(self, controller: "Controller") -> None:
|
def __init__(self, controller: "Controller") -> None:
|
||||||
super().__init__(controller)
|
super().__init__(controller)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user