from sys import argv, stderr, exit
try:
- from PyQt6.QtGui import QIcon
- from PyQt6.QtCore import *
+ from PyQt6.QtGui import QIcon
+ from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
print("Running on PyQt6", file=stderr)
except:
try:
# apt-get install python3-pyqt5
- from PyQt5.QtGui import QIcon
- from PyQt5.QtCore import *
+ from PyQt5.QtGui import QIcon
+ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
print("Running on PyQt5", file=stderr)
except:
- from PyQt4.QtGui import QIcon
+ from PyQt4.QtGui import *
from PyQt4.QtCore import *
- from PyQt4.QtWidgets import *
print("Running on PyQt4", file=stderr)
from gamiki import Builder, Library
from gamiki.qt.utils import start
from gamiki.qt.tiles import Grid, List
-class MainWindow(QMainWindow):
+class MainWindow(QWidget):
def __init__(self, centre: QWidget):
super().__init__()
self.initUi(centre)
self.setWindowTitle("Testy window")
self.setWindowIcon(QIcon('gamiki.png'))
- # Menu
- self.menu = self.menuBar()
-
- ## Menu: File (Exit)
- self.file_menu = self.menu.addMenu("File")
- exit_action = self.file_menu.addAction("Exit", self.close)
+ ## Menu
+ #self.menu = self.menuBar()
+ #
+ ### Menu: File (Exit)
+ #self.file_menu = self.menu.addMenu("File")
+ #exit_action = self.file_menu.addAction("Exit", self.close)
# Central widget: Centre
- self.setCentralWidget(centre)
+ #self.setCentralWidget(centre)
+ layout = QHBoxLayout()
+ layout.setContentsMargins(0, 0, 0, 0)
+ layout.addWidget(centre)
+ self.setLayout(layout)
# Size and visibility
self.resize(800, 600)
from typing import Optional, Any
from pathlib import PurePath, Path
-class Game(dict[str, str]):
+class Game(dict):
"""Game object generated from a directory."""
- dir : PurePath = None
- name : str = ""
- code : str = None
- src : str = ""
- tags : list[str] = None
- desc : str = ""
- icon : Path = None # "main" icon
- icons : dict[str, Path] = None # all found icons
- support : Any = None # should be gamiki.Support
- library : Any = None # should be gamiki.Library
+ dir : PurePath = None
+ name : str = ""
+ code : str = None
+ src : str = ""
+ tags : list = None
+ desc : str = ""
+ icon : Path = None # "main" icon
+ icons : dict = None # all found icons
+ support : Any = None # should be gamiki.Support
+ library : Any = None # should be gamiki.Library
def __init__(self, library, dir: PurePath):
self.dir = dir
def get_icon(self, key: str) -> PurePath:
return self.icons.get(key, self.icon)
- def start(self, params: Optional[list[str]] = None):
+ def start(self, params: list = None):
if (self.support == None):
raise RuntimeError("Unsupported game was called: " + game.name)
from gamiki import Game, Support
-class Library(list[Game]):
+class Library(list):
"""Manage a library (a folder) of Games."""
def __init__(self, dir: PurePath):
#############################################################################
try:
- from PyQt6.QtCore import *
+ from PyQt6.QtCore import *
from PyQt6.QtWidgets import *
except:
try:
- from PyQt5.QtCore import *
+ from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
except:
from PyQt4.QtCore import *
- from PyQt4.QtWidgets import *
+ from PyQt4.QtGui import *
class FlowLayout(QLayout):
from PyQt5.QtGui import QPixmap
except:
from PyQt4.QtCore import *
- from PyQt4.QtWidgets import *
- from PyQt4.QtGui import QPixmap
+ from PyQt4.QtGui import *
from gamiki import Game
from gamiki.qt.utils import makeMouseAware
class List(QWidget):
onClick = pyqtSignal(Game)
- def __init__(self, games: list[Game], icon_size: int = 0):
+ def __init__(self, games: list, icon_size: int = 0):
super().__init__()
self.games = games
from PyQt5.QtWidgets import *
except:
from PyQt4.QtCore import *
- from PyQt4.QtWidgets import *
+ from PyQt4.QtGui import *
pool = QThreadPool()
def start(startable):
for overlay in widget.overlay:
setBg(overlay, bg)
-def makeMouseAware(self: QWidget, targets: list[QWidget]):
+def makeMouseAware(self: QWidget, targets: list):
for target in targets:
addOverlay(self, target)
cmd, env = custom.cmd("dosbox", link, None)
if (not cmd):
- if (prog := custom.program("dosbox")):
+ prog = custom.program("dosbox")
+ if (prog):
cmd = [ prog ]
else:
raise RuntimeError("DosBox not found")
cmd, env = custom.cmd("wine", wine_bat, wine_prefix)
if (not cmd):
- if (prog := custom.program("wine")):
+ prog = custom.program("wine")
+ if (prog):
cmd = [ prog, wine_bat.as_posix() ]
env["WINEPREFIX"] = wine_prefix.as_posix()
else:
-from typing import Optional
from subprocess import run
from shutil import which
from os import environ
from pathlib import PurePath
-__programs__: dict[str, Optional[str]] = { }
+__programs__: dict = { }
-def program(program: str) -> Optional[str]:
+def program(program: str) -> str:
global __programs__
if (program not in __programs__):
return __programs__[program]
-def cmd (
- prog: str, p1: PurePath, p2: Optional[PurePath]
- ) -> (Optional[list[str]], dict[str, str]):
+def cmd(prog: str, p1: PurePath, p2: PurePath) -> (list, dict):
cmd = None
env = environ.copy()
- match prog:
- case "dosbox":
- if (program("app.sh")):
- cmd = [
- program("app.sh"),"--wait","dosbox","--link",p1.as_posix()
- ]
- case "wine":
- if (program("launch.sh")):
- cmd = [ program("launch.sh"), "wine", "--dlink", p1.as_posix() ]
- env["OPTS"] = (
- "-e WINEPREFIX='" + p2.as_posix().replace("'", "\\'") + "'"
- )
- case "start_sh":
- if (program("launch.sh")):
- cmd = [
- program("launch.sh"), "games", "--dlink", p1.as_posix()
- ]
- env["OPTS"] = "--entrypoint=bash"
+ if (prog == "dosbox"):
+ if (program("app.sh")):
+ cmd = [
+ program("app.sh"),"--wait","dosbox","--link",p1.as_posix()
+ ]
+ elif (prog == "wine"):
+ if (program("launch.sh")):
+ cmd = [ program("launch.sh"), "wine", "--dlink", p1.as_posix() ]
+ env["OPTS"] = (
+ "-e WINEPREFIX='" + p2.as_posix().replace("'", "\\'") + "'"
+ )
+ elif (prog == "start_sh"):
+ if (program("launch.sh")):
+ cmd = [
+ program("launch.sh"), "games", "--dlink", p1.as_posix()
+ ]
+ env["OPTS"] = "--entrypoint=bash"
return cmd, env
def supports(self, game: Game) -> bool:
return False
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
if (not self.supports(game)):
raise RuntimeError("Unsupported game was called: " + game.name)
-from typing import Optional
-
from gamiki import Game
from gamiki.support import Support
from gamiki.support.commands import dosbox
and not game.dir.joinpath("C", "WINDOWS").exists()
)
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
self.running(game)
rep = dosbox(game.dir.resolve(), game.dir.resolve())
if (rep != 0):
-from typing import Optional
-
from gamiki import Game
from gamiki.support import Support
from gamiki.support.commands import start_sh
def supports(self, game: Game):
return game.dir.joinpath("start.sh").exists()
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
start = game.dir.resolve().joinpath("start.sh")
self.running(game)
-from typing import Optional
-
from gamiki import Game
from gamiki.support import Support
from gamiki.support.commands import start_sh
def supports(self, game: Game):
return game.dir.joinpath("gameinfo").exists()
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
start = game.dir.resolve().joinpath("start.sh")
if (not start.exists()):
-from typing import Optional
-
from gamiki import Game
from gamiki.support import Support
from gamiki.support.commands import wine
def supports(self, game: Game):
return game.dir.joinpath("wine.bat").exists()
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
dir = game.dir.resolve()
if (not dir.joinpath("wine.prefix").exists()):
-from typing import Optional
-
from gamiki import Game
from gamiki.support import Support
from gamiki.support.commands import dosbox
and game.dir.joinpath("C", "WINDOWS").exists()
)
- def start(self, game: Game, params: Optional[list[str]] = None):
+ def start(self, game: Game, params: list = None):
self.running(game)
rep = dosbox(game.dir.resolve(), game.library.dir.resolve())
if (rep != 0):