mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
feat: connection dialog (WIP)
This commit is contained in:
parent
29082ea1c1
commit
e319c01d58
@ -156,7 +156,6 @@ def find_stale_mods(config: Path) -> list[int]:
|
|||||||
record = fqip_to_record(rec)
|
record = fqip_to_record(rec)
|
||||||
try:
|
try:
|
||||||
mods = get_rules(record)
|
mods = get_rules(record)
|
||||||
print(mods)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
return []
|
return []
|
||||||
return [mod.workshop_id for mod in mods]
|
return [mod.workshop_id for mod in mods]
|
||||||
|
|||||||
@ -433,13 +433,14 @@ def validate_ip(addr: str) -> Record:
|
|||||||
def get_rules(record: Record) -> list["DayzMod"]:
|
def get_rules(record: Record) -> list["DayzMod"]:
|
||||||
ip = record.ip
|
ip = record.ip
|
||||||
qport = record.qport
|
qport = record.qport
|
||||||
try:
|
#try:
|
||||||
mods = dayzquery.dayz_rules((ip, qport)).mods
|
mods = dayzquery.dayz_rules((ip, qport)).mods
|
||||||
return [mod for mod in mods]
|
return [mod for mod in mods]
|
||||||
except Exception as e:
|
#except Exception as e:
|
||||||
logger.critical(e)
|
# logger.critical(e)
|
||||||
|
# raise e
|
||||||
# TODO: supposed to skip failing servers for highlight action
|
# TODO: supposed to skip failing servers for highlight action
|
||||||
return []
|
#return []
|
||||||
|
|
||||||
|
|
||||||
def query_by_id(addr: str, key: str) -> dict[Any] | None:
|
def query_by_id(addr: str, key: str) -> dict[Any] | None:
|
||||||
|
|||||||
@ -27,19 +27,19 @@ class ConnectionManager:
|
|||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def connect_by_id(self, addr: str, key: str) -> None:
|
def connect_by_id(self, addr: str, key: str) -> None:
|
||||||
res = Servers.query_by_id(addr, key)
|
res = Servers.query_by_id(addr, key)
|
||||||
self.prepare_connection(res)
|
self._prepare_connection(res)
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def connect_by_ip(self, addr: str) -> None:
|
def connect_by_ip(self, addr: str) -> None:
|
||||||
res = Servers.query_by_ip(addr)
|
res = Servers.query_by_ip(addr)
|
||||||
self.prepare_connection(res)
|
self._prepare_connection(res)
|
||||||
|
|
||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def connect_by_record(self, record: Servers.Record) -> None:
|
def connect_by_record(self, record: Servers.Record) -> None:
|
||||||
res = Servers.query_by_record(record)
|
res = Servers.query_by_record(record)
|
||||||
self.prepare_connection(res)
|
self._prepare_connection(res)
|
||||||
|
|
||||||
def prepare_connection(self, res: dict[Any] | None) -> None:
|
def _prepare_connection(self, res: dict[Any] | None) -> None:
|
||||||
if res is None:
|
if res is None:
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
@ -49,11 +49,12 @@ class ConnectionManager:
|
|||||||
record = Servers.response_to_record(res)
|
record = Servers.response_to_record(res)
|
||||||
try:
|
try:
|
||||||
# TODO: proper error handling (currently returns empty list)
|
# TODO: proper error handling (currently returns empty list)
|
||||||
mods = self.query_modlist(record)
|
mods = self._query_modlist(record)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
)
|
)
|
||||||
|
return
|
||||||
func = StoredFunc(self.controller.open_connection_assistant, res, mods)
|
func = StoredFunc(self.controller.open_connection_assistant, res, mods)
|
||||||
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
self.thread_man.set_cleanup_func(func, destroy_first=True)
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ class ConnectionManager:
|
|||||||
StoredFunc(self._present_details_dialog, details), destroy_first=True
|
StoredFunc(self._present_details_dialog, details), destroy_first=True
|
||||||
)
|
)
|
||||||
|
|
||||||
def query_modlist(self, record: Servers.Record) -> None:
|
def _query_modlist(self, record: Servers.Record) -> None:
|
||||||
mods = Servers.get_rules(record)
|
mods = Servers.get_rules(record)
|
||||||
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
steam_path = self.controller.query_config(Preferences.DEFAULT)
|
||||||
local = get_local_mod_ids(steam_path)
|
local = get_local_mod_ids(steam_path)
|
||||||
@ -94,7 +95,7 @@ class ConnectionManager:
|
|||||||
@call_on_thread(dialog.querying)
|
@call_on_thread(dialog.querying)
|
||||||
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
def query_modlist_and_present(self, record: Servers.Record) -> None:
|
||||||
try:
|
try:
|
||||||
mods = self.query_modlist(record)
|
mods = self._query_modlist(record)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.thread_man.set_cleanup_func(
|
self.thread_man.set_cleanup_func(
|
||||||
StoredFunc(self._server_timeout), destroy_first=True
|
StoredFunc(self._server_timeout), destroy_first=True
|
||||||
|
|||||||
@ -43,36 +43,61 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
self.controller.register_widget("preconnect", self)
|
self.controller.register_widget("preconnect", self)
|
||||||
|
|
||||||
# TODO: strings
|
# TODO: strings
|
||||||
self.back = Gtk.Button(label="Back")
|
|
||||||
# TODO: dynamic button text if no mods needed
|
# TODO: dynamic button text if no mods needed
|
||||||
self.ok = Gtk.Button(label="Download mods and connect")
|
self.back = Gtk.Button(label="Back", halign=Gtk.Align.START)
|
||||||
self.button_box.add(self.back)
|
self.cancel = Gtk.Button(
|
||||||
self.button_box.add(self.ok)
|
label="Cancel", halign=Gtk.Align.END, sensitive=False, hexpand=True
|
||||||
|
)
|
||||||
|
self.ok = Gtk.Button(label="Update mods and connect", halign=Gtk.Align.END)
|
||||||
|
|
||||||
|
self.button_box = Gtk.Box(
|
||||||
|
orientation=Gtk.Orientation.HORIZONTAL,
|
||||||
|
valign=Gtk.Align.END,
|
||||||
|
vexpand=True,
|
||||||
|
spacing=5,
|
||||||
|
)
|
||||||
|
for button in self.back, self.cancel, self.ok:
|
||||||
|
self.button_box.add(button)
|
||||||
|
|
||||||
self.back.connect("clicked", self._on_back_clicked)
|
self.back.connect("clicked", self._on_back_clicked)
|
||||||
self.ok.connect("clicked", self._on_ok_clicked)
|
self.ok.connect("clicked", self._on_ok_clicked)
|
||||||
|
|
||||||
self.warnings = []
|
self.title = Gtk.Label(label="")
|
||||||
# TODO: populate with strings and icons
|
|
||||||
# set visibility if warnings > 1
|
|
||||||
frame = HeadingFrame(Gtk.Label(label="ITEM ONE"), "Warnings")
|
|
||||||
|
|
||||||
self.tree = ServerModTreeView(self.controller)
|
self.tree = ServerModTreeView(self.controller)
|
||||||
|
self.mod_count = Gtk.Label(label="", halign=Gtk.Align.START, margin_start=5)
|
||||||
|
# TODO: live count of remaining downloads
|
||||||
|
# "Steam is downloading: {mod_name}"
|
||||||
|
# mention whether manual or auto mod is active
|
||||||
|
|
||||||
self.scrolled = Gtk.ScrolledWindow()
|
self.scrolled = Gtk.ScrolledWindow()
|
||||||
self.scrolled.add(self.tree)
|
self.scrolled.add(self.tree)
|
||||||
self.scrolled.set_size_request(600, 400)
|
self.scrolled.set_size_request(600, 400)
|
||||||
|
|
||||||
self.tree_frame = HeadingFrame(self.scrolled, "Mods")
|
self.tree_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||||
|
self.tree_box.add(self.scrolled)
|
||||||
|
self.tree_box.add(self.mod_count)
|
||||||
|
|
||||||
# TODO: should form a part of tree_frame above
|
self.tree_frame = HeadingFrame(self.tree_box, "Mods")
|
||||||
self.mod_count = Gtk.Label(label="")
|
|
||||||
|
|
||||||
self.title = Gtk.Label(label="")
|
self.warnings = []
|
||||||
|
# TODO: populate with strings and icons
|
||||||
|
# set visibility if warnings > 1
|
||||||
|
# warning category enums with matching strings
|
||||||
|
"""
|
||||||
|
blocking warning types:
|
||||||
|
- build mismatch
|
||||||
|
- version mismatch
|
||||||
|
- not enough drive space
|
||||||
|
passing warning types:
|
||||||
|
- dayz is running
|
||||||
|
- steam is not running
|
||||||
|
- server has password
|
||||||
|
"""
|
||||||
|
frame = HeadingFrame(Gtk.Label(label="ITEM ONE"), "Warnings")
|
||||||
|
|
||||||
self.add(self.title)
|
self.add(self.title)
|
||||||
self.add(self.tree_frame)
|
self.add(self.tree_frame)
|
||||||
self.add(self.mod_count)
|
|
||||||
self.add(frame)
|
self.add(frame)
|
||||||
self.add(self.button_box)
|
self.add(self.button_box)
|
||||||
|
|
||||||
@ -90,13 +115,16 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
total = len(mods)
|
total = len(mods)
|
||||||
self.title.set_text(f"Connecting to {res["name"]}")
|
self.title.set_text(f"Connecting to {res["name"]}")
|
||||||
if total < 1:
|
if total < 1:
|
||||||
self.tree.set_visible(False)
|
self.tree_frame.set_visible(False)
|
||||||
self.mod_count.set_visible(False)
|
self.mod_count.set_visible(False)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.tree.set_visible(True)
|
self.tree.set_visible(True)
|
||||||
self.mod_count.set_visible(True)
|
self.mod_count.set_visible(True)
|
||||||
self.mod_count.set_text(f"Total mods: {str(total)}")
|
self.mod_count.set_text(f"Total mods: {str(total)}")
|
||||||
|
|
||||||
|
# TODO: check which mods need updating
|
||||||
|
# TODO: fourth column: needs update
|
||||||
# steam_path = self.controller.get_config_man().lookup(Preferences.DEFAULT)
|
# steam_path = self.controller.get_config_man().lookup(Preferences.DEFAULT)
|
||||||
# dayz_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ)
|
# dayz_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ)
|
||||||
# dayz_exp_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ_EXP)
|
# dayz_exp_version = PeFile.get_pretty_version(steam_path, APPID_DAYZ_EXP)
|
||||||
@ -107,6 +135,12 @@ class PreConnectionAssistant(Gtk.Box):
|
|||||||
|
|
||||||
def connect(self) -> None:
|
def connect(self) -> None:
|
||||||
# TODO: add to history file and list store
|
# TODO: add to history file and list store
|
||||||
|
"""
|
||||||
|
spawn dialog in thread
|
||||||
|
watch for subprocess
|
||||||
|
return to prior page when finished
|
||||||
|
"""
|
||||||
|
self.back.emit("clicked")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# TODO: icon for mod signature issue
|
# TODO: icon for mod signature issue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user