mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 09:47:36 +02:00
feat: wait for DayZ process
This commit is contained in:
parent
ff0ced1c33
commit
fb5397ae91
@ -102,7 +102,7 @@ def connect(addr: str, appid: int, name: str, mods: list[str]) -> None:
|
||||
f"-name={name}",
|
||||
f"-mod={concat}",
|
||||
]
|
||||
proc = subprocess.Popen([*params])
|
||||
proc = subprocess.run([*params])
|
||||
return proc.returncode
|
||||
|
||||
|
||||
|
||||
@ -479,3 +479,4 @@ class Controller(GObject.GObject):
|
||||
|
||||
def get_steam_client_name(self) -> str:
|
||||
return self.mediator.options.get_client_name()
|
||||
|
||||
|
||||
@ -16,7 +16,14 @@ from dzgui.util.strings import init
|
||||
|
||||
# TODO: move to util.proc
|
||||
def is_dayz_running() -> bool:
|
||||
return is_running(DAYZ_BINARY)
|
||||
procs = []
|
||||
substring = DAYZ_BINARY
|
||||
for proc in psutil.process_iter():
|
||||
try:
|
||||
procs.append(proc.cmdline())
|
||||
except Exception as e:
|
||||
continue
|
||||
return any(substring in item for sublist in procs for item in sublist)
|
||||
|
||||
|
||||
def is_steam_running(cmd: str) -> bool:
|
||||
|
||||
@ -32,9 +32,10 @@ from dzgui.const.constants import (
|
||||
APPNAME_DAYZ_EXP,
|
||||
DAYZ_BINARY,
|
||||
)
|
||||
from dzgui.const.enum import Preferences
|
||||
from dzgui.const.enum import NotebookPage, Preferences
|
||||
from dzgui.init.proc import foreground, is_dayz_running, is_steam_running, is_running
|
||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||
from dzgui.strings.dialogs import waiting_for_launch
|
||||
from dzgui.strings.server_mods import checkmark, resync
|
||||
from dzgui.util.format import format_mib
|
||||
from dzgui.util.strings import dialog, server_timeout
|
||||
@ -246,16 +247,22 @@ class ConnectionManager:
|
||||
def _connect_steam(self) -> None:
|
||||
addr = f"{self.record.ip}:{self.record.gameport}"
|
||||
playername = self.controller.query_config(Preferences.NAME)
|
||||
proc = connect(addr, self.appid, playername, self.remote_mod_ids)
|
||||
# TODO: test returncode
|
||||
rc = connect(addr, self.appid, playername, self.remote_mod_ids)
|
||||
if rc != 0:
|
||||
# TODO: log/pop the error
|
||||
func = StoredFunc(self.controller.update_status)
|
||||
self.thread_man.set_cleanup_func(func)
|
||||
return
|
||||
|
||||
# self.thread_man.update_dialog("Waiting for DayZ to launch")
|
||||
# while not is_running(DAYZ_BINARY):
|
||||
# time.sleep(1)
|
||||
# TODO: wait for DAYZ_BINARY to load
|
||||
# on cleanup:
|
||||
self.thread_man.update_dialog(waiting_for_launch)
|
||||
while True:
|
||||
if is_dayz_running():
|
||||
break
|
||||
time.sleep(1)
|
||||
# TODO: add to history file and list store
|
||||
# proxy_model.append_to_history()
|
||||
func = StoredFunc(self.controller.open_page, NotebookPage.SERVERS)
|
||||
self.thread_man.set_cleanup_func(func)
|
||||
|
||||
def _update_mods(self, raise_window: bool) -> None:
|
||||
# NOTE: fast enqueue all mods in auto mode
|
||||
@ -294,7 +301,7 @@ class ConnectionManager:
|
||||
def update_and_connect(self, raise_window: bool) -> None:
|
||||
if len(self.missing_mods) > 0:
|
||||
self._update_mods(raise_window)
|
||||
self._connect_steam()
|
||||
else:
|
||||
self._connect_steam()
|
||||
func = StoredFunc(self.controller.update_status)
|
||||
self.thread_man.set_cleanup_func(func)
|
||||
# TODO: use this only if going back before launching
|
||||
|
||||
Loading…
Reference in New Issue
Block a user