mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 17:57:06 +02:00
Merge branch 'feat/server-threading' of github.com:aclist/dzgui-devel into feat/server-threading
This commit is contained in:
commit
a754203d10
@ -4,7 +4,7 @@ import struct
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import BinaryIO, Union
|
||||
from typing import BinaryIO, Self, Union
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
@ -69,7 +69,7 @@ class i64:
|
||||
|
||||
class PackedData:
|
||||
@classmethod
|
||||
def unpack(cls, data: BinaryIO):
|
||||
def unpack(cls, data: BinaryIO) -> Self:
|
||||
r = []
|
||||
for key, value in cls.__annotations__.items():
|
||||
if value is str:
|
||||
@ -449,18 +449,18 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
|
||||
|
||||
|
||||
# TODO: tests
|
||||
def compare_versions(local: DayZVersion, remote: DayZVersion) -> VersionMatch:
|
||||
local_str = Version(dayz_version_to_str(local))
|
||||
remote_str = Version(dayz_version_to_str(remote))
|
||||
|
||||
if local_str == remote_str:
|
||||
return VersionMatch.SAME_VERSION
|
||||
|
||||
if local_str < remote_str:
|
||||
return VersionMatch.LOCAL_OLDER
|
||||
|
||||
if local_str > remote_str:
|
||||
return VersionMatch.LOCAL_NEWER
|
||||
#def compare_versions(local: DayZVersion, remote: DayZVersion) -> VersionMatch:
|
||||
# local_str = Version(dayz_version_to_str(local))
|
||||
# remote_str = Version(dayz_version_to_str(remote))
|
||||
#
|
||||
# if local_str == remote_str:
|
||||
# return VersionMatch.SAME_VERSION
|
||||
#
|
||||
# if local_str < remote_str:
|
||||
# return VersionMatch.LOCAL_OLDER
|
||||
#
|
||||
# if local_str > remote_str:
|
||||
# return VersionMatch.LOCAL_NEWER
|
||||
|
||||
|
||||
def get_pretty_version(steam_path: Path, appid: int) -> str | None:
|
||||
|
||||
@ -464,7 +464,7 @@ def query_by_ip(addr: str) -> A2SInfo:
|
||||
record = short_ip_to_record(addr)
|
||||
return query_by_record(record, update_gameport=True)
|
||||
|
||||
def query_by_id(server_id: int, key: str) -> dict[Any] | None:
|
||||
def query_by_id(server_id: int, key: str) -> A2SInfo:
|
||||
"""
|
||||
Used with numeric Battlemetrics IDs
|
||||
"""
|
||||
|
||||
@ -89,7 +89,7 @@ def get_remote_signatures(mods: list[str]) -> list[tuple[str, str, int, int]]:
|
||||
|
||||
# TODO: set config to name=user, use official server and no mods,
|
||||
# ensure that formatted string is identical to fixture with same hash
|
||||
def connect(addr: str, appid: int, name: str, mods: list[str]) -> None:
|
||||
def connect(addr: str, appid: int, name: str, mods: list[str]) -> int:
|
||||
concat = concat_mods(mods)
|
||||
params = [
|
||||
"steam",
|
||||
@ -121,7 +121,7 @@ def find_user_id(path: Path) -> str | None:
|
||||
|
||||
|
||||
def vdf2json(path: Path) -> str:
|
||||
def _istr(indent: int, string: str):
|
||||
def _istr(indent: int, string: str) -> str:
|
||||
return (indent * " ") + string
|
||||
|
||||
jbuf = "{\n"
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import shlex
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
"""
|
||||
@ -34,7 +35,7 @@ def rc2json(file: Path) -> str:
|
||||
lex = shlex.shlex(f.read())
|
||||
lex.whitespace += "="
|
||||
|
||||
keys = {}
|
||||
keys: dict[str, Any] = {}
|
||||
ips: list[str] = []
|
||||
|
||||
toggles = ["auto_install", "fullscreen"]
|
||||
|
||||
@ -95,8 +95,8 @@ class ConfigManager:
|
||||
)
|
||||
return
|
||||
|
||||
def get_start_tab(self) -> int:
|
||||
return self.lookup(Preferences.START_TAB)
|
||||
def get_start_tab(self) -> Any:
|
||||
return int(self.lookup(Preferences.START_TAB))
|
||||
|
||||
def get_favorites(self) -> list[str]:
|
||||
return list(self.lookup(Preferences.IP_LIST))
|
||||
|
||||
@ -73,7 +73,7 @@ class Prerequisites:
|
||||
passworded: bool
|
||||
dayz_running: bool
|
||||
steam_proc: SteamProcess
|
||||
mods: list[str]
|
||||
mods: list[list[str]]
|
||||
foreground_cmd: str | None
|
||||
game_mode: bool
|
||||
|
||||
@ -89,7 +89,7 @@ class ConnectionManager:
|
||||
self.workshop: Path
|
||||
|
||||
self.remote_mod_ids: list[str] = []
|
||||
self.missing_mods: list[str, str, int, int] = []
|
||||
self.missing_mods: list[tuple[str, str, int, int]] = []
|
||||
|
||||
@call_on_thread(dialog.querying)
|
||||
def connect_by_id(self, _id: int, key: str) -> None:
|
||||
@ -206,7 +206,7 @@ class ConnectionManager:
|
||||
mods = Servers.get_rules(record)
|
||||
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||
local = get_local_mod_ids(steam_path)
|
||||
alpha_mods = [
|
||||
alpha_mods: list[list[str]] = [
|
||||
[
|
||||
mod.name,
|
||||
str(mod.workshop_id),
|
||||
@ -231,7 +231,7 @@ class ConnectionManager:
|
||||
destroy_first=True,
|
||||
)
|
||||
|
||||
def _present_modlist_dialog(self, mods: list[str]) -> None:
|
||||
def _present_modlist_dialog(self, mods: list[list[str]]) -> None:
|
||||
dialog = ServerModDialog(self.controller, mods)
|
||||
dialog.run()
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa E402
|
||||
if TYPE_CHECKING:
|
||||
from dzgui.controllers.mc import Controller
|
||||
from dzgui.views.base import Notebook
|
||||
from dzgui.views.pages.servers import ServerNotebook
|
||||
|
||||
|
||||
class Breadcrumbs(Gtk.Label):
|
||||
@ -30,10 +31,12 @@ class Breadcrumbs(Gtk.Label):
|
||||
self, notebook: "Notebook", page: Gtk.Widget, index: int
|
||||
) -> None:
|
||||
label = notebook.get_tab_label_text(page)
|
||||
if label is None:
|
||||
return
|
||||
self.set_server_crumbs(label)
|
||||
|
||||
def _on_notebook_page_changed(
|
||||
self, notebook: "Notebook", page: Gtk.Widget, index: int
|
||||
self, notebook: "Notebook", page: "ServerNotebook", index: int
|
||||
) -> None:
|
||||
enum = notebook.get_page_by_enum()
|
||||
if enum == NotebookPage.SERVERS:
|
||||
|
||||
@ -30,8 +30,7 @@ class NoteDialog(GenericDialog):
|
||||
delete_button = Gtk.Button(label="Delete note")
|
||||
delete_button.set_sensitive(False)
|
||||
self.add_action_widget(delete_button, Gtk.ResponseType.CANCEL)
|
||||
self.add_button("Update note", Gtk.ResponseType.OK)
|
||||
self.ok = self.get_widget_for_response(Gtk.ResponseType.OK)
|
||||
self.ok = self.add_button("Update note", Gtk.ResponseType.OK)
|
||||
self.ok.grab_default()
|
||||
|
||||
self.entry = ValidatedEntry(controller, self.validate)
|
||||
|
||||
@ -61,4 +61,5 @@ class CursorMixin:
|
||||
dest = end
|
||||
|
||||
path = Gtk.TreePath.new_from_indices([dest])
|
||||
self.set_cursor(path) # type: ignore return True
|
||||
self.set_cursor(path) # type: ignore
|
||||
return True
|
||||
|
||||
@ -315,6 +315,8 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
||||
def mark_finished(self) -> None:
|
||||
self.mod_count.set_label(preconnect.all_updated)
|
||||
model = self.tree.get_model()
|
||||
if model is None:
|
||||
return
|
||||
for row in model:
|
||||
row[2] = checkmark
|
||||
|
||||
|
||||
@ -75,4 +75,4 @@ class MenuTreeView(TreeView):
|
||||
model = self.get_model()
|
||||
_iter = self.get_focused_row_iter()
|
||||
rowtype = model.get_value(_iter, 1)
|
||||
return rowtype.dict["tooltip"]
|
||||
return str(rowtype.dict["tooltip"])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user