Initial ScummVM Service support

This commit is contained in:
Alexander Weber 2023-10-06 12:09:56 +02:00
parent d180c7ee4c
commit 6a15d39498
2 changed files with 74 additions and 21 deletions

View file

@ -14,6 +14,7 @@ from lutris.services.itchio import ItchIoService
from lutris.services.lutris import LutrisService
from lutris.services.mame import MAMEService
from lutris.services.origin import OriginService
from lutris.services.scummvm import ScummvmService, SCUMMVM_CONFIG_FILE
from lutris.services.steam import SteamService
from lutris.services.steamwindows import SteamWindowsService
from lutris.services.ubisoft import UbisoftConnectService
@ -48,6 +49,8 @@ def get_services():
_services["steamwindows"] = SteamWindowsService
if system.path_exists(DOLPHIN_GAME_CACHE_FILE):
_services["dolphin"] = DolphinService
if system.path_exists(SCUMMVM_CONFIG_FILE):
_services["scummvm"] = ScummvmService
return _services

View file

@ -1,30 +1,80 @@
"""Legacy ScummVM 'service', has to be ported to the current architecture"""
import os
import re
from configparser import ConfigParser
from gettext import gettext as _
from lutris.util import system
from lutris.util.log import logger
from lutris import settings
from lutris.services.base import BaseService
from lutris.services.service_game import ServiceGame
from lutris.services.service_media import ServiceMedia
from lutris.util.strings import slugify
NAME = _("ScummVM")
ICON = "scummvm"
ONLINE = False
SCUMMVM_CONFIG_FILE = os.path.join(os.path.expanduser("~/.config/scummvm"), "scummvm.ini")
def get_scummvm_games():
"""Return the available ScummVM games"""
if not system.path_exists(SCUMMVM_CONFIG_FILE):
logger.info("No ScummVM config found")
return []
config = ConfigParser()
config.read(SCUMMVM_CONFIG_FILE)
config_sections = config.sections()
for section in config_sections:
if section == "scummvm":
continue
scummvm_id = section
name = re.split(r" \(.*\)$", config[section]["description"])[0]
path = config[section]["path"]
yield (scummvm_id, name, path)
# Dummy banner. Maybe the download from lutris should be implemented at this place
class ScummvmBanner(ServiceMedia):
service = "scummvm"
source = "local"
size = (96, 32)
file_pattern = "%s.png"
file_format = "jpeg"
dest_path = settings.CACHE_DIR
class ScummvmService(BaseService):
id = "scummvm"
icon = "scummvm"
name = _("ScummVM")
local = True
medias = {
"icon": ScummvmBanner
}
game_paths = None
def load(self):
if not os.path.isfile(SCUMMVM_CONFIG_FILE):
return
config = ConfigParser()
config.read(SCUMMVM_CONFIG_FILE)
config_sections = config.sections()
self.game_paths = {}
for section in config_sections:
if section == "scummvm":
continue
game = ScummvmGame()
game.name = re.split(r" \(.*\)$", config[section]["description"])[0]
game.slug = slugify(game.name)
game.appid = section
game.game_id = section
game.runner = "scummvm"
game.lutris_slug = game.slug
game.details = config[section]["description"]
game.path = config[section]["path"]
self.game_paths[game.slug] = game.path
game.save()
def generate_installer(self, game):
return {
"name": game["name"],
"version": "ScummVM",
"slug": game["slug"],
"game_slug": slugify(game["lutris_slug"]),
"runner": "scummvm",
"script": {
"game": {
"game_id": game["appid"],
"path": self.game_paths[game["slug"]],
"platform": "scummvm"
}
}
}
class ScummvmGame(ServiceGame):
service = "scummvm"
runner = "scummvm"