Added Wine support

This commit is contained in:
tcsenpai 2024-02-28 14:44:31 +01:00
parent ac006b900f
commit 198eea2ef9
2 changed files with 31 additions and 2 deletions

13
libs/wine_runner.py Normal file
View File

@ -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)

18
uwine
View File

@ -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
# 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"])