Add black

This commit is contained in:
2023-12-02 17:46:48 +01:00
parent d352e70956
commit b0d801f8a1
16 changed files with 199 additions and 88 deletions

View File

@@ -7,6 +7,7 @@ from lmm.games.game import Game, ProtonGame
from lmm.runners.runner import Runner
from lmm.runners.steam import SteamFlatpakAppIdRunner
def runner_from_config(data: dict[str, Any]) -> Optional[Runner]:
match data["type"]:
case "steam.flatpak":

View File

@@ -2,6 +2,7 @@ import abc
from lmm.games.game import Game
class Runner(abc.ABC):
# Type identifier of the runner.
runner_type: str
@@ -10,4 +11,4 @@ class Runner(abc.ABC):
self.runner_type = runner_type
def run(self, game: Game):
raise NotImplementedError()
raise NotImplementedError()

View File

@@ -4,10 +4,12 @@ from pathlib import Path
from lmm.runners.runner import Runner
from lmm.games.game import Game
class SteamRuntime(abc.ABC):
def get_run_script(self) -> Path:
raise NotImplementedError()
class SteamSniperRuntime(SteamRuntime):
library: Path
@@ -15,7 +17,13 @@ class SteamSniperRuntime(SteamRuntime):
self.library = library
def get_run_script(self) -> Path:
return self.library / "steamapps" / "common" / "SteamLinuxRuntime_sniper" / "run-in-sniper"
return (
self.library
/ "steamapps"
/ "common"
/ "SteamLinuxRuntime_sniper"
/ "run-in-sniper"
)
class SteamSoldierRuntime(SteamRuntime):
@@ -25,7 +33,14 @@ class SteamSoldierRuntime(SteamRuntime):
self.library = library
def get_run_script(self) -> Path:
return self.library / "steamapps" / "common" / "SteamLinuxRuntime_soldier" / "run-in-soldier"
return (
self.library
/ "steamapps"
/ "common"
/ "SteamLinuxRuntime_soldier"
/ "run-in-soldier"
)
class SteamFlatpakAppIdRunner(Runner):
def __init__(self):
@@ -34,12 +49,15 @@ class SteamFlatpakAppIdRunner(Runner):
def run(self, game: Game):
assert isinstance(game, ProtonGame)
run_cmd_nonblocking([
"flatpak",
"run",
"com.valvesoftware.Steam",
f"steam://launch/{game.appid}/",
])
run_cmd_nonblocking(
[
"flatpak",
"run",
"com.valvesoftware.Steam",
f"steam://launch/{game.appid}/",
]
)
class SteamFlatpakProtonRunner(Runner):
# Path to the Proton prefix
@@ -55,7 +73,14 @@ class SteamFlatpakProtonRunner(Runner):
# "waitforexitandrun" | "run"
launchmode: str
def __init__(self, compat_data: Path, runtime: SteamRuntime, proton_version: str, game: str, launchmode: str = "waitforexitandrun"):
def __init__(
self,
compat_data: Path,
runtime: SteamRuntime,
proton_version: str,
game: str,
launchmode: str = "waitforexitandrun",
):
self.compat_data = compat_data
self.runtime = runtime
self.game = game
@@ -72,16 +97,22 @@ class SteamFlatpakProtonRunner(Runner):
return [
f"--env=STEAM_COMPAT_CLIENT_INSTALL_PATH={self._steam_install_path}",
f"--env=STEAM_COMPAT_DATA_PATH={self.compat_data}",
#f"--env=WINEDLLPATH={proton}/files/lib64/wine:{proton}/files/lib/wine",
#f"--env=WINEPREFIX={self.compat_data}/pfx",
#f"--env=SteamGameId=1144200",
#"--env=WINEDLLOVERRIDES=steam.exe=b"
#f"--env=WINEDEBUG=-all",
# f"--env=WINEDLLPATH={proton}/files/lib64/wine:{proton}/files/lib/wine",
# f"--env=WINEPREFIX={self.compat_data}/pfx",
# f"--env=SteamGameId=1144200",
# "--env=WINEDLLOVERRIDES=steam.exe=b"
# f"--env=WINEDEBUG=-all",
]
@property
def _proton_path(self) -> Path:
return Path.home() / "data" / "Steam" / "compatibilitytools.d" / self.proton_version
return (
Path.home()
/ "data"
/ "Steam"
/ "compatibilitytools.d"
/ self.proton_version
)
def _build_launch_command(self) -> str:
command = [
@@ -94,12 +125,16 @@ class SteamFlatpakProtonRunner(Runner):
return commandline
def run(self):
run_cmd_shell(" ".join([
"flatpak",
"run",
"--command=bash",
*self._build_environ(),
"com.valvesoftware.Steam",
"-c",
f'"{self._build_launch_command()}"',
]))
run_cmd_shell(
" ".join(
[
"flatpak",
"run",
"--command=bash",
*self._build_environ(),
"com.valvesoftware.Steam",
"-c",
f'"{self._build_launch_command()}"',
]
)
)