-from .library import Library
-from .game import Game
-from .builder import Builder
-from .support import Support
+# Order the dependencies in the right way, and make public classes accessible
+from .game import Game
+from .support import Support
+from .library import Library
+from .builder import Builder
from pathlib import Path, PurePath
-from . import Library, Game
-from .support import Support, SupportDos, SupportWin31, SupportGog, SupportExt
-from .support import SupportWin
+from gamiki import Game, Support, Library
+from gamiki.support import (
+ SupportDos, SupportWin31, SupportGog, SupportExt, SupportWin
+)
class Builder:
"""Manage all the resources needed to run games."""
self.libraries : list[Library] = []
self.games : list[Game] = []
- supports = []
- supports.append(SupportGog()) # gameinfo
- supports.append(SupportWin()) # wine.bat
- supports.append(SupportWin31()) # start.conf + C/WINDOWS
- supports.append(SupportDos()) # start.conf + no C/WINDOWS
- supports.append(SupportExt()) # start.sh
-
targets = []
config = Path("~/.games.cfg").expanduser()
if (config.exists()):
targets.append(Path("~/Games").expanduser())
for target in targets:
- self.load_libs(supports, target)
+ self.load_libs(target)
for lib in self.libraries:
for game in lib:
self.games.append(game)
- def load_libs(self, supports: list[Support], dir: PurePath):
+ def load_libs(self, dir: PurePath):
for path in dir.iterdir():
if (not path.is_dir()):
continue
try:
- self.libraries.append(Library(path, supports))
+ self.libraries.append(Library(path))
except FileNotFoundError:
pass
from pathlib import PurePath
-from .support import Support
-from .game import Game
+from gamiki import Game, Support
class Library(list[Game]):
"""Manage a library (a folder) of Games."""
- def __init__(self, dir: PurePath, supports: list[Support]):
+ def __init__(self, dir: PurePath):
self.name = dir.name
self.dir = dir
- self.supports = supports
self.preferredSupport = None
config = self.dir.joinpath("games.cfg")
if (not path.is_dir()):
continue
game = Game(self, path)
- for support in self.supports:
+ for support in Support.all:
if (support.supports(game)):
game.set_support(support)
break;
+# Order the dependencies in the right way, and make classes accessible
from .support import Support
from .support_dos import SupportDos
from .support_win31 import SupportWin31
from .support_gog import SupportGog
from .support_ext import SupportExt
from .support_win import SupportWin
+
+Support.all = [ SupportGog() , # gaminfo
+ SupportWin() , # wine.bat
+ SupportWin31(), # start.conf + C/WINDOWS
+ SupportDos() , # start.conf + no C/WINDOWS
+ SupportExt() # start.sh
+]
+
from subprocess import run
from shutil import which
-from ..game import Game
+from gamiki import Game
class Support:
"""Can detect and start games."""
-from . import Support
-from .commands import dosbox
-from ..game import Game
+from gamiki import Game
+from gamiki.support import Support
+from gamiki.support.commands import dosbox
class SupportDos(Support):
"""Supports DOS games via DosBox."""
-from . import Support
-from .commands import start_sh
-from ..game import Game
+from gamiki import Game
+from gamiki.support import Support
+from gamiki.support.commands import start_sh
class SupportExt(Support):
"""Supports external games via the 'games' docker or natively."""
-from . import Support
-from .commands import start_sh
-from ..game import Game
+from gamiki import Game
+from gamiki.support import Support
+from gamiki.support.commands import start_sh
class SupportGog(Support):
"""Supports GoG games via the 'games' docker or natively."""
-from . import Support
-from .commands import wine
-from ..game import Game
+from gamiki import Game
+from gamiki.support import Support
+from gamiki.support.commands import wine
class SupportWin(Support):
"""Supports Windows games via wine."""
-from . import Support
-from .commands import dosbox
-from ..game import Game
+from gamiki import Game
+from gamiki.support import Support
+from gamiki.support.commands import dosbox
class SupportWin31(Support):
"""Supports Windows 3.1 games via DosBox."""