from . import Library, Game
from .support import Support, SupportDos, SupportWin31, SupportGog, SupportExt
+from .support import SupportWin
class Builder:
"""Manage all the resources needed to run games."""
supports = [] # be careful about the order
supports.append(SupportGog())
+ supports.append(SupportWin())
supports.append(SupportWin31())
supports.append(SupportDos())
supports.append(SupportExt())
--- /dev/null
+from random import random
+from math import floor
+from os import environ
+from pathlib import Path
+from subprocess import run
+from shutil import which
+
+from . import Support
+from ..game import Game
+
+class SupportWin(Support):
+ """Supports Windows games via wine."""
+ def __init__(self):
+ pass
+
+ def supports(self, game: Game):
+ return game.dir.joinpath("wine.bat").exists()
+
+ def start(self, game: Game, params: list[str] = []):
+ dir = game.dir.resolve()
+
+ if (not dir.joinpath("wine.prefix").exists()):
+ raise RuntimeError("Windows game without a wine.prefix")
+
+ wine_bat = dir.joinpath("wine.bat")
+ wine_prefix = dir.joinpath("wine.prefix").as_posix()
+
+ env = environ.copy()
+
+ tfile = None
+ if (Support.program("launch.sh") != None):
+ env["OPTS"] = "-e WINEPREFIX='" +wine_prefix.replace("'","\\'")+ "'"
+ cmd = [
+ Support.program("launch.sh"),
+ "wine", "--dlink", wine_bat
+ ]
+ else:
+ env["WINEPREFIX"] = wine_prefix
+ cmd = [ "wine", wine_bat ]
+
+ print("Running", game.name)
+ rep = run(cmd, env=env)
+ if (rep.returncode != 0):
+ print("\nError when running", game.name, ": RC", rep.returncode)
+
+