From 94582f15472296762a556d10af0037384a395a1d Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 23 Dec 2023 14:04:18 +0100 Subject: [PATCH] Allow looking for multiple executable names --- lmm/games/bg3.py | 8 ++++++-- lmm/games/game.py | 15 ++++++++------- lmm/games/lc.py | 6 ++++-- lmm/games/pdmm.py | 6 ++++-- lmm/games/ron.py | 6 ++++-- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/lmm/games/bg3.py b/lmm/games/bg3.py index 3eeae4b..254de17 100644 --- a/lmm/games/bg3.py +++ b/lmm/games/bg3.py @@ -134,8 +134,12 @@ class BaldursGate3Game(ProtonGame): return overlays @property - def game_executable(self) -> Path: - return self.installation_path / "bin" / "bg3_dx11.exe" + def game_executables(self) -> list[Path]: + # Handle both the Dx11 version and the Vulkan version. + return [ + self.installation_path / "bin" / "bg3_dx11.exe", + self.installation_path / "bin" / "bg3.exe", + ] def to_dict(self) -> dict[str, Any]: return { diff --git a/lmm/games/game.py b/lmm/games/game.py index 99cadbd..ee5a3ec 100644 --- a/lmm/games/game.py +++ b/lmm/games/game.py @@ -91,7 +91,7 @@ class ProtonGame(Game, abc.ABC): raise NotImplementedError() @property - def game_executable(self) -> Path: + def game_executables(self) -> list[Path]: raise NotImplementedError() @property @@ -101,9 +101,10 @@ class ProtonGame(Game, abc.ABC): def wait(self): # Wait until we started the game. proc = Path("/proc") - windows_path = str(self.game_executable).replace("/", "\\") - wine_exe_path = f"Z:{windows_path}" - print(wine_exe_path) + windows_paths = [str(executable).replace("/", "\\") for executable in self.game_executables] + wine_exe_paths = [f"Z:{windows_path}" for windows_path in windows_paths] + executables = [str(exe) for exe in self.game_executables] + print(wine_exe_paths) print("Polling for game process...") while True: for dir in os.listdir(proc): @@ -127,9 +128,9 @@ class ProtonGame(Game, abc.ABC): abs_cmdline = os.path.abspath(cmdline).replace("\x00", "") if ( - cmdline.startswith(wine_exe_path) - or abs_cmdline == str(self.game_executable) - or abs_cmdline.startswith(str(self.game_executable)) + any(cmdline.startswith(wine_exe_path) for wine_exe_path in wine_exe_paths) + or abs_cmdline in executables + or any(abs_cmdline.startswith(exe) for exe in executables) ): self._pid = dir break diff --git a/lmm/games/lc.py b/lmm/games/lc.py index 9f81c93..d859683 100644 --- a/lmm/games/lc.py +++ b/lmm/games/lc.py @@ -35,8 +35,10 @@ class LethalCompanyGame(ProtonGame): ) @property - def game_executable(self) -> Path: - return self.installation_path / "Lethal Company.exe" + def game_executables(self) -> list[Path]: + return [ + self.installation_path / "Lethal Company.exe", + ] def prepare_overlays( self, profile: LethalCompanyProfile diff --git a/lmm/games/pdmm.py b/lmm/games/pdmm.py index 64c8434..541528a 100644 --- a/lmm/games/pdmm.py +++ b/lmm/games/pdmm.py @@ -35,8 +35,10 @@ class ProjectDivaMegaMixGame(ProtonGame): ) @property - def game_executable(self) -> Path: - return self.installation_path / "DivaMegaMix.exe" + def game_executables(self) -> list[Path]: + return [ + self.installation_path / "DivaMegaMix.exe", + ] def prepare_overlays( self, profile: ProjectDivaMegaMixProfile diff --git a/lmm/games/ron.py b/lmm/games/ron.py index 9fb2573..8a81d6a 100644 --- a/lmm/games/ron.py +++ b/lmm/games/ron.py @@ -46,8 +46,10 @@ class ReadyOrNotGame(ProtonGame): ] @property - def game_executable(self) -> Path: - return self.installation_path / "ReadyOrNot.exe" + def game_executables(self) -> list[Path]: + return [ + self.installation_path / "ReadyOrNot.exe", + ] def to_dict(self) -> dict[str, Any]: return {