From 198eea2ef9d9807124fd41a8fd963df2ce77bd06 Mon Sep 17 00:00:00 2001 From: tcsenpai Date: Wed, 28 Feb 2024 14:44:31 +0100 Subject: [PATCH] Added Wine support --- libs/wine_runner.py | 13 +++++++++++++ uwine | 20 ++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 libs/wine_runner.py diff --git a/libs/wine_runner.py b/libs/wine_runner.py new file mode 100644 index 0000000..95e0874 --- /dev/null +++ b/libs/wine_runner.py @@ -0,0 +1,13 @@ +import os + +def wine_run(executable_path, wine_dir): + # NOTE The wineprefix is set in the environment variable WINEPREFIX and is not needed as an argument + print("[WINE_RUNNER] Running " + executable_path + " with Wine version: ") + os.system(wine_dir + "/bin/wine --version") + executable_dir = os.path.dirname(executable_path) + if executable_dir == "": + executable_dir = "." + # Composing the command + composed_command = ( "cd " + executable_dir + " && " + wine_dir + "/bin/wine " + executable_path + "$@") + print("[WINE_RUNNER] Composed command: " + composed_command) + os.system(composed_command) diff --git a/uwine b/uwine index 4620fed..1366fe9 100755 --- a/uwine +++ b/uwine @@ -16,6 +16,7 @@ import libs.customvars_loader as customvars_loader import libs.predirectives_loader as predirectives_loader import libs.postdirectives_loader as postdirectives_loader import libs.ulwlg_runner as ulwlg_runner +import libs.wine_runner as wine_runner # SECTION Constants LAUNCHDIR = os.getcwd() @@ -26,6 +27,7 @@ print("[*] UWINE is installed in " + UWINEDIR) # SECTION Default values ulwgl_dir = UWINEDIR + "/launcher" proton_path = UWINEDIR + "/protons/current" +use_wine = False wine_prefix = UWINEDIR + "/PREFIX" ids_json_path = UWINEDIR + "/ids.json" ids = {} @@ -85,6 +87,14 @@ if os.environ["CUSTOMVARS"]: else: env_defined_customvars = {} +if os.environ["USE_WINE"]: + if os.environ["USE_WINE"] == "True": + use_wine = True + else: + use_wine = False +print("[INFO] [USE_WINE] " + str(use_wine)) + + if __name__ == "__main__": # SECTION Loading methods @@ -114,6 +124,7 @@ if __name__ == "__main__": ["ULWGLDIR", ulwgl_dir], ["WINEPREFIX", os.environ["WINEPREFIX"]], ["PROTONPATH", os.environ["PROTONPATH"]], + ["USE_WINE", use_wine], ["IDS_JSON", ids_json_path], ["GAMEID", os.environ["GAMEID"]], ["PREDIRECTIVES", predirectives], @@ -126,5 +137,10 @@ if __name__ == "__main__": ) ) - # Launching with ulwlg_runner - ulwlg_runner.ulwlg_run(filepath, ulwgl_dir, os.environ["PROTONPATH"], os.environ["WINEPREFIX"], os.environ["GAMEID"]) \ No newline at end of file + # Launching with ulwlg_runner or wine depending on the use_wine variable + if use_wine: + print("[*] Using Wine to launch the game") + wine_runner.wine_run(filepath, os.environ["PROTONPATH"]) + else: + print("[*] Using ULWGL to launch the game") + ulwlg_runner.ulwlg_run(filepath, ulwgl_dir, os.environ["PROTONPATH"], os.environ["WINEPREFIX"], os.environ["GAMEID"]) \ No newline at end of file