Пример #1
0
    def install_from_ubisoft(self, ubisoft_connect, game):
        app_name = game["name"]

        lutris_game_id = slugify(game["name"]) + "-" + self.id
        existing_game = get_game_by_field(lutris_game_id, "installer_slug")
        if existing_game:
            logger.debug("Ubisoft Connect game %s is already installed",
                         app_name)
            return
        logger.debug("Installing Ubisoft Connect game %s", app_name)
        game_config = LutrisConfig(
            game_config_id=ubisoft_connect["configpath"]).game_level
        game_config["game"]["args"] = f"uplay://launch/{game['appid']}"
        configpath = write_game_config(lutris_game_id, game_config)
        game_id = add_game(
            name=game["name"],
            runner=self.runner,
            slug=slugify(game["name"]),
            directory=ubisoft_connect["directory"],
            installed=1,
            installer_slug=lutris_game_id,
            configpath=configpath,
            service=self.id,
            service_id=game["appid"],
        )
        return game_id
Пример #2
0
 def install_from_origin(self, origin_game, manifest):
     offer_id = manifest["id"].split("@")[0]
     logger.debug("Installing Origin game %s", offer_id)
     service_game = ServiceGameCollection.get_game("origin", offer_id)
     if not service_game:
         logger.error(
             "Aborting install, %s is not present in the game library.",
             offer_id)
         return
     lutris_game_id = slugify(service_game["name"]) + "-" + self.id
     existing_game = get_game_by_field(lutris_game_id, "installer_slug")
     if existing_game:
         return
     game_config = LutrisConfig(
         game_config_id=origin_game["configpath"]).game_level
     game_config["game"]["args"] = get_launch_arguments(manifest["id"])
     configpath = write_game_config(lutris_game_id, game_config)
     game_id = add_game(
         name=service_game["name"],
         runner=origin_game["runner"],
         slug=slugify(service_game["name"]),
         directory=origin_game["directory"],
         installed=1,
         installer_slug=lutris_game_id,
         configpath=configpath,
         service=self.id,
         service_id=offer_id,
     )
     return game_id
Пример #3
0
 def generate_installer(self, db_game, egs_db_game):
     egs_game = Game(egs_db_game["id"])
     egs_exe = egs_game.config.game_config["exe"]
     if not os.path.isabs(egs_exe):
         egs_exe = os.path.join(egs_game.config.game_config["prefix"], egs_exe)
     return {
         "name": db_game["name"],
         "version": self.name,
         "slug": slugify(db_game["name"]) + "-" + self.id,
         "game_slug": slugify(db_game["name"]),
         "runner": self.runner,
         "appid": db_game["appid"],
         "script": {
             "requires": self.client_installer,
             "game": {
                 "args": get_launch_arguments(db_game["appid"]),
             },
             "installer": [
                 {"task": {
                     "name": "wineexec",
                     "executable": egs_exe,
                     "args": get_launch_arguments(db_game["appid"], "install"),
                     "prefix": egs_game.config.game_config["prefix"],
                     "description": (
                         "The Epic Game Store will now open. Please launch "
                         "the installation of %s then close the EGS client "
                         "once the game has been downloaded." % db_game["name"]
                     )
                 }}
             ]
         }
     }
Пример #4
0
 def install_from_egs(self, egs_game, manifest):
     """Create a new Lutris game based on an existing EGS install"""
     app_name = manifest["AppName"]
     logger.debug("Installing EGS game %s", app_name)
     service_game = ServiceGameCollection.get_game("egs", app_name)
     if not service_game:
         logger.error("Aborting install, %s is not present in the game library.", app_name)
         return
     lutris_game_id = slugify(service_game["name"]) + "-" + self.id
     existing_game = get_game_by_field(lutris_game_id, "installer_slug")
     if existing_game:
         return
     game_config = LutrisConfig(game_config_id=egs_game["configpath"]).game_level
     game_config["game"]["args"] = get_launch_arguments(app_name)
     configpath = write_game_config(lutris_game_id, game_config)
     game_id = add_game(
         name=service_game["name"],
         runner=egs_game["runner"],
         slug=slugify(service_game["name"]),
         directory=egs_game["directory"],
         installed=1,
         installer_slug=lutris_game_id,
         configpath=configpath,
         service=self.id,
         service_id=app_name,
     )
     return game_id
Пример #5
0
def sync_with_lutris():
    desktop_games = {
        game['slug']: game
        for game in pga.get_games_where(runner='linux',
                                        installer_slug=INSTALLER_SLUG,
                                        installed=1)
    }
    seen = set()

    for name, appid, exe, args in get_games():
        slug = slugify(name) or slugify(appid)
        if not all([name, slug, appid]):
            logger.error("Failed to load desktop game \"%s\" (app: %s, slug: %s)", name, appid, slug)
            continue
        else:
            logger.info("Found desktop game \"%s\" (app: %s, slug: %s)", name, appid, slug)
        seen.add(slug)

        if slug not in desktop_games.keys():
            game_info = {
                'name': name,
                'slug': slug,
                'config_path': slug + '-' + INSTALLER_SLUG,
                'installer_slug': INSTALLER_SLUG,
                'exe': exe,
                'args': args
            }
            mark_as_installed(appid, 'linux', game_info)

    for slug in set(desktop_games.keys()).difference(seen):
        mark_as_uninstalled(desktop_games[slug])
Пример #6
0
 def generate_installer(self, db_game, egs_db_game):
     egs_game = Game(egs_db_game["id"])
     egs_exe = egs_game.config.game_config["exe"]
     if not os.path.isabs(egs_exe):
         egs_exe = os.path.join(egs_game.config.game_config["prefix"],
                                egs_exe)
     return {
         "name": db_game["name"],
         "version": self.name,
         "slug": slugify(db_game["name"]) + "-" + self.id,
         "game_slug": slugify(db_game["name"]),
         "runner": self.runner,
         "appid": db_game["appid"],
         "script": {
             "requires":
             self.client_installer,
             "game": {
                 "args": get_launch_arguments(db_game["appid"]),
             },
             "installer": [{
                 "task": {
                     "name": "wineexec",
                     "executable": egs_exe,
                     "args": get_launch_arguments(db_game["appid"],
                                                  "install"),
                     "prefix": egs_game.config.game_config["prefix"]
                 }
             }]
         }
     }
Пример #7
0
 def _on_install_setup_continue(self, button, entry):
     name = entry.get_text().strip()
     installer = {
         "name": name,
         "version": "Setup file",
         "slug": slugify(name) + "-setup",
         "game_slug": slugify(name),
         "runner": "wine",
         "script": {
             "game": {
                 "exe": AUTO_WIN32_EXE,
                 "prefix": "$GAMEDIR"
             },
             "files": [{
                 "setupfile": "N/A:Select the setup file"
             }],
             "installer": [{
                 "task": {
                     "name": "wineexec",
                     "executable": "setupfile"
                 }
             }]
         }
     }
     application = Gio.Application.get_default()
     application.show_installer_window([installer])
     self.destroy()
Пример #8
0
def sync_with_lutris():
    desktop_games = {
        game['slug']: game
        for game in pga.get_games_where(runner='linux',
                                        installer_slug=INSTALLER_SLUG,
                                        installed=1)
    }
    seen = set()

    for name, appid, exe, args in get_games():
        slug = slugify(name) or slugify(appid)
        if not all([name, slug, appid]):
            logger.error("Failed to load desktop game \"{}\" (app: {}, slug: {})".format(name, appid, slug))
            continue
        else:
            logger.info("Found desktop game \"{}\" (app: {}, slug: {})".format(name, appid, slug))
        seen.add(slug)

        if slug not in desktop_games.keys():
            game_info = {
                'name': name,
                'slug': slug,
                'config_path': slug + '-' + INSTALLER_SLUG,
                'installer_slug': INSTALLER_SLUG,
                'exe': exe,
                'args': args
            }
            mark_as_installed(appid, 'linux', game_info)

    for slug in set(desktop_games.keys()).difference(seen):
        mark_as_uninstalled(desktop_games[slug])
Пример #9
0
 def generate_installer(self, db_game):
     """Generate a basic Steam installer"""
     return {
         "name": db_game["name"],
         "version": "Steam",
         "slug": slugify(db_game["name"]) + "-steam",
         "game_slug": slugify(db_game["name"]),
         "runner": "steam",
         "appid": db_game["appid"],
         "script": {
             "game": {"appid": db_game["appid"]}
         }
     }
Пример #10
0
    def save(self, config_type=None):
        """Save configuration file

        The way to save config files can be set by the type argument
        or with self.config_type
        """

        self.update_global_config()
        logging.debug("Saving config (type %s)", config_type)
        logging.debug(self.config)
        if config_type is None:
            config_type = self.config_type
        yaml_config = yaml.dump(self.config, default_flow_style=False)

        if config_type == "system":
            filename = join(CONFIG_DIR, "system.yml")
            self.write_to_disk(filename, yaml_config)
        elif config_type == "runner":
            runner_config_path = join(CONFIG_DIR,
                                      "runners/%s.yml" % self.runner)
            self.write_to_disk(runner_config_path, yaml_config)

        elif config_type == "game":
            if not self.game:
                self.game = slugify(self.config['realname'])
            self.write_to_disk(self.game_config_file, yaml_config)
            return self.game
        else:
            print("Config type is %s or %s" % (self.config_type, type))
            print("i don't know how to save this yet")
Пример #11
0
    def on_save(self, _button):
        """Save game info and destroy widget. Return True if success."""
        if not self.is_valid():
            return False
        name = self.name_entry.get_text()

        # Do not modify slug
        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game(self.slug)
            self.game.config = self.lutris_config

        if not self.lutris_config.game:
            self.lutris_config.game = self.slug
        self.lutris_config.save()

        runner_class = lutris.runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)
        self.game.name = name
        self.game.slug = self.slug
        self.game.runner_name = self.runner_name
        self.game.directory = runner.game_path
        self.game.is_installed = True
        self.game.save()
        self.destroy()
        logger.debug("Saved %s", name)
        self.saved = True
Пример #12
0
def add_game(name, **game_data):
    """Add a game to the PGA database."""
    game_data['name'] = name
    if 'slug' not in game_data:
        game_data['slug'] = slugify(name)
    inserted_id = sql.db_insert(PGA_DB, "games", game_data)
    return inserted_id
Пример #13
0
def add_game(name, **game_data):
    """Add a game to the PGA database."""
    game_data["name"] = name
    game_data["installed_at"] = int(time.time())
    if "slug" not in game_data:
        game_data["slug"] = slugify(name)
    return sql.db_insert(PGA_DB, "games", game_data)
Пример #14
0
 def generate_installer(self, db_game):
     details = json.loads(db_game["details"])
     platforms = [download["platform"] for download in details["downloads"]]
     logger.debug(details)
     system_config = {}
     if "linux" in platforms and self.platform_has_downloads(details["downloads"], "linux"):
         runner = "linux"
         game_config = {"exe": AUTO_ELF_EXE}
         filename = self.get_filename_for_platform(details["downloads"], "linux")
         if filename.lower().endswith(".sh"):
             script = [
                 {"extract": {"file": "humblegame", "format": "zip", "dst": "$CACHE"}},
                 {"merge": {"src": "$CACHE/data/noarch", "dst": "$GAMEDIR", "optional": True}},
                 {"move": {"src": "$CACHE/data/noarch", "dst": "$CACHE/noarch", "optional": True}},
                 {"merge": {"src": "$CACHE/data/x86_64", "dst": "$GAMEDIR", "optional": True}},
                 {"move": {"src": "$CACHE/data/x86_64", "dst": "$CACHE/x86_64", "optional": True}},
                 {"merge": {"src": "$CACHE/data/x86", "dst": "$GAMEDIR", "optional": True}},
                 {"move": {"src": "$CACHE/data/x86", "dst": "$CACHE/x86", "optional": True}},
                 {"merge": {"src": "$CACHE/data/", "dst": "$GAMEDIR", "optional": True}},
             ]
         elif filename.endswith("-bin"):
             script = [
                 {"extract": {"file": "humblegame", "format": "zip", "dst": "$CACHE"}},
                 {"merge": {"src": "$CACHE/data/", "dst": "$GAMEDIR"}},
             ]
         else:
             script = [{"extract": {"file": "humblegame"}}]
             system_config = {"gamemode": 'false'}  # Unity games crash with gamemode
     elif "windows" in platforms:
         runner = "wine"
         game_config = {"exe": AUTO_WIN32_EXE, "prefix": "$GAMEDIR"}
         filename = self.get_filename_for_platform(details["downloads"], "windows")
         if filename.lower().endswith(".zip"):
             script = [
                 {"task": {"name": "create_prefix", "prefix": "$GAMEDIR"}},
                 {"extract": {"file": "humblegame", "dst": "$GAMEDIR/drive_c/%s" % db_game["slug"]}}
             ]
         else:
             script = [
                 {"task": {"name": "wineexec", "executable": "humblegame"}}
             ]
     else:
         logger.warning("Unsupported platforms: %s", platforms)
         return {}
     return {
         "name": db_game["name"],
         "version": "Humble Bundle",
         "slug": details["machine_name"],
         "game_slug": slugify(db_game["name"]),
         "runner": runner,
         "humbleid": db_game["appid"],
         "script": {
             "game": game_config,
             "system": system_config,
             "files": [
                 {"humblegame": "N/A:Select the installer from Humble Bundle"}
             ],
             "installer": script
         }
     }
Пример #15
0
def add_game(name, **game_data):
    """Add a game to the PGA database."""
    game_data['name'] = name
    game_data['installed_at'] = int(time.time())
    if 'slug' not in game_data:
        game_data['slug'] = slugify(name)
    return sql.db_insert(PGA_DB, "games", game_data)
Пример #16
0
    def on_save(self, _button, callback=None):
        """Save game info and destroy widget. Return True if success."""
        if not self.is_valid():
            return False
        name = self.name_entry.get_text()

        # Do not modify slug
        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game()

        if self.lutris_config.game_config_id == TEMP_CONFIG:
            self.lutris_config.game_config_id = self.get_config_id()

        runner_class = runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)
        self.game.name = name
        self.game.slug = self.slug
        self.game.runner_name = self.runner_name
        self.game.config = self.lutris_config
        self.game.directory = runner.game_path
        self.game.is_installed = True
        if self.runner_name in ('steam', 'winesteam'):
            self.game.steamid = self.lutris_config.game_config['appid']
        self.game.save()
        self.destroy()
        logger.debug("Saved %s", name)
        self.saved = True
        if callback:
            callback()
Пример #17
0
 def generate_installer(self, db_game):
     details = json.loads(db_game["details"])
     platforms = [platform.lower() for platform, is_supported in details["worksOn"].items() if is_supported]
     system_config = {}
     if "linux" in platforms:
         runner = "linux"
         game_config = {"exe": AUTO_ELF_EXE}
         script = [
             {"extract": {"file": "goginstaller", "format": "zip", "dst": "$CACHE"}},
             {"merge": {"src": "$CACHE/data/noarch", "dst": "$GAMEDIR"}},
         ]
     else:
         runner = "wine"
         game_config = {"exe": AUTO_WIN32_EXE}
         script = [
             {"autosetup_gog_game": "goginstaller"},
         ]
     return {
         "name": db_game["name"],
         "version": "GOG",
         "slug": details["slug"],
         "game_slug": slugify(db_game["name"]),
         "runner": runner,
         "gogid": db_game["appid"],
         "script": {
             "game": game_config,
             "system": system_config,
             "files": [
                 {"goginstaller": "N/A:Select the installer from GOG"}
             ],
             "installer": script
         }
     }
Пример #18
0
def add_or_update(**params):
    """Add a game to the PGA or update an existing one

    If an 'id' is provided in the parameters then it
    will try to match it, otherwise it will try matching
    by slug, creating one when possible.
    """
    slug = params.get("slug")
    if "id" in params and params["id"] is None:
        params.pop("id")
    game = None
    if params.get("id"):
        game = get_game_by_field(params["id"], "id")
    if not game:
        if not slug:
            slug = slugify(params["name"])
        game = get_game_by_field(slug, "slug")
    if game and (
            game["runner"] == params.get("runner")
            or not all([params.get("runner"), game["runner"]])
    ):
        sql.db_update(PGA_DB, "games", params, ("id", game["id"]))
        return game["id"]
    if game:
        logger.warning("Game found but not updated: %s", game)
    if params.get("id"):
        logger.warning("Removing id %s from parameters", params["id"])
        params.pop("id")
    return add_game(**params)
Пример #19
0
    def on_save(self, _button):
        """Save game info and destroy widget. Return True if success."""
        if not self.is_valid():
            return False
        name = self.name_entry.get_text()

        # Do not modify slug
        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game(self.slug)
            self.game.config = self.lutris_config

        if not self.lutris_config.game_slug:
            self.lutris_config.game_slug = self.slug
        self.lutris_config.save()

        runner_class = runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)
        self.game.name = name
        self.game.slug = self.slug
        self.game.runner_name = self.runner_name
        self.game.directory = runner.game_path
        self.game.is_installed = True
        self.game.save()
        self.destroy()
        logger.debug("Saved %s", name)
        self.saved = True
Пример #20
0
 def get_update_installers(self, db_game):
     appid = db_game["service_id"]
     patch_versions = self.get_update_versions(appid)
     patch_installers = []
     for version in patch_versions:
         patch = patch_versions[version]
         size = human_size(sum([part["total_size"] for part in patch]))
         patch_id = "gogpatch-%s" % slugify(patch[0]["version"])
         installer = {
             "name": db_game["name"],
             "description": patch[0]["name"] + " " + size,
             "slug": db_game["installer_slug"],
             "game_slug": db_game["slug"],
             "version": "GOG " + patch[0]["version"],
             "runner": "wine",
             "script": {
                 "extends":
                 db_game["installer_slug"],
                 "files": [{
                     patch_id: "N/A:Select the patch from GOG"
                 }],
                 "installer": [{
                     "task": {
                         "name": "wineexec",
                         "executable": patch_id
                     }
                 }]
             }
         }
         patch_installers.append(installer)
     return patch_installers
Пример #21
0
Файл: pga.py Проект: TRPB/lutris
def add_or_update(**params):
    """Add a game to the PGA or update an existing one

    If an 'id' is provided in the parameters then it
    will try to match it, otherwise it will try matching
    by slug, creating one when possible.
    """
    name = params.get("name")
    slug = params.get("slug")
    if "id" in params and params["id"] is None:
        params.pop("id")
    game_id = params.get("id")
    assert any([slug, name, game_id])
    game = None
    if game_id:
        game = get_game_by_field(params["id"], "id")
    if not game:
        if not slug:
            slug = slugify(name)
        game = get_game_by_field(slug, "slug")
    if game and (
            game["runner"] == params.get("runner")
            or not all([params.get("runner"), game["runner"]])
    ):
        sql.db_update(PGA_DB, "games", params, ("id", game["id"]))
        return game["id"]
    return add_game(**params)
Пример #22
0
 def get_dlc_installers(self, db_game):
     appid = db_game["service_id"]
     dlcs = self.get_game_dlcs(appid)
     installers = []
     for dlc in dlcs:
         dlc_id = "gogdlc-%s" % dlc["slug"]
         installer = {
             "name": db_game["name"],
             "version": dlc["title"],
             "slug": dlc["slug"],
             "description": "DLC for %s" % db_game["name"],
             "game_slug": slugify(db_game["name"]),
             "runner": "wine",
             "is_dlc": True,
             "dlcid": dlc["id"],
             "gogid": dlc["id"],
             "script": {
                 "extends":
                 db_game["installer_slug"],
                 "files": [{
                     dlc_id: "N/A:Select the patch from GOG"
                 }],
                 "installer": [{
                     "task": {
                         "name": "wineexec",
                         "executable": dlc_id
                     }
                 }]
             }
         }
         installers.append(installer)
     return installers
Пример #23
0
    def on_save(self, _button):
        """Save game info and destroy widget. Return True if success."""
        if not self.is_valid():
            logger.warning(_("Current configuration is not valid, ignoring save request"))
            return False
        name = self.name_entry.get_text()

        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game()

        year = None
        if self.year_entry.get_text():
            year = int(self.year_entry.get_text())

        if not self.lutris_config.game_config_id:
            self.lutris_config.game_config_id = make_game_config_id(self.slug)

        runner_class = runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)

        self.game.name = name
        self.game.slug = self.slug
        self.game.year = year
        self.game.game_config_id = self.lutris_config.game_config_id
        self.game.runner = runner
        self.game.runner_name = self.runner_name
        self.game.is_installed = True
        self.game.config = self.lutris_config
        self.game.save(save_config=True)
        self.destroy()
        self.saved = True
        return True
Пример #24
0
    def on_save(self, _button, callback=None):
        """Save game info and destroy widget. Return True if success."""
        if not self.is_valid():
            return False
        name = self.name_entry.get_text()

        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game()

        if self.lutris_config.game_config_id == TEMP_CONFIG:
            self.lutris_config.game_config_id = self.get_config_id()

        runner_class = runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)
        self.game.name = name
        self.game.slug = self.slug
        self.game.runner_name = self.runner_name
        self.game.config = self.lutris_config
        self.game.directory = runner.game_path
        self.game.is_installed = True
        if self.runner_name in ('steam', 'winesteam'):
            self.game.steamid = self.lutris_config.game_config['appid']
        self.game.save()
        self.destroy()
        logger.debug("Saved %s", name)
        self.saved = True
        if callback:
            callback()
Пример #25
0
 def install_from_steam(self, manifest):
     """Create a new Lutris game based on an existing Steam install"""
     if not manifest.is_installed():
         return
     appid = manifest.steamid
     if appid in self.excluded_appids:
         return
     service_game = ServiceGameCollection.get_game(self.id, appid)
     if not service_game:
         return
     lutris_game_id = "%s-%s" % (self.id, appid)
     existing_game = get_game_by_field(lutris_game_id, "slug")
     if existing_game:
         return
     game_config = LutrisConfig().game_level
     game_config["game"]["appid"] = appid
     configpath = write_game_config(lutris_game_id, game_config)
     game_id = add_game(
         name=service_game["name"],
         runner="steam",
         slug=slugify(service_game["name"]),
         installed=1,
         installer_slug=lutris_game_id,
         configpath=configpath,
         platform="Linux",
         service=self.id,
         service_id=appid,
     )
     return game_id
Пример #26
0
 def new_from_api(cls, payload):
     """Convert an Ubisoft game to a service game"""
     service_game = cls()
     service_game.appid = payload["spaceId"] or payload["installId"]
     service_game.slug = slugify(payload["name"])
     service_game.name = payload["name"]
     service_game.details = json.dumps(payload)
     return service_game
Пример #27
0
 def new_from_api(cls, egs_game):
     """Convert an EGS game to a service game"""
     service_game = cls()
     service_game.appid = egs_game["appName"]
     service_game.slug = slugify(egs_game["title"])
     service_game.name = egs_game["title"]
     service_game.details = json.dumps(egs_game)
     return service_game
Пример #28
0
def sync_with_lutris():
    apps = get_games()
    desktop_games_in_lutris = pga.get_desktop_games()
    slugs_in_lutris = set(
        [str(game['slug']) for game in desktop_games_in_lutris])

    seen_slugs = set()
    for app in apps:
        game_info = None
        name = app[0]
        appid = app[1]
        slug = slugify(name)

        # if it fails to get slug from the name
        if not slug:
            slug = slugify(appid)

        if not name or not slug or not appid:
            logger.error("Failed to load desktop game "
                         "\"" + str(name) + "\" "
                         "(app: " + str(appid) + ", slug: " + slug + ")")
            continue
        else:
            logger.debug("Found desktop game "
                         "\"" + str(name) + "\" "
                         "(app: " + str(appid) + ", slug: " + slug + ")")

        seen_slugs.add(slug)

        if slug not in slugs_in_lutris:
            game_info = {
                'name': name,
                'slug': slug,
                'config_path': slug + '-desktopapp',
                'installer_slug': 'desktopapp',
                'exe': app[2],
                'args': app[3]
            }
            mark_as_installed(appid, 'linux', game_info)

    unavailable_slugs = slugs_in_lutris.difference(seen_slugs)
    for slug in unavailable_slugs:
        for game in desktop_games_in_lutris:
            if game['slug'] == slug:
                mark_as_uninstalled(game)
Пример #29
0
def get_game_slugs_and_folders(dirname):
    """Scan a directory for games previously installed with lutris"""
    folders = os.listdir(dirname)
    game_folders = {}
    for folder in folders:
        if not os.path.isdir(os.path.join(dirname, folder)):
            continue
        game_folders[slugify(folder)] = folder
    return game_folders
Пример #30
0
 def generate_installer(self, db_game, steam_game):
     """Generate a basic Steam installer"""
     return {
         "name": db_game["name"],
         "version": self.name,
         "slug": slugify(db_game["name"]) + "-" + self.id,
         "game_slug": slugify(db_game["name"]),
         "runner": self.runner,
         "appid": db_game["appid"],
         "script": {
             "requires": self.client_installer,
             "game": {
                 "exe": steam_game.config.game_config["exe"],
                 "args": "-no-cef-sandbox -applaunch %s" % db_game["appid"],
                 "prefix": steam_game.config.game_config["prefix"],
             }
         }
     }
Пример #31
0
def add_game(name, runner=None, slug=None, directory=None):
    """Adds a game to the PGA database."""
    if not slug:
        slug = slugify(name)
    game_data = {'name': name, 'slug': slug, 'runner': runner}
    if directory:
        game_data['directory'] = directory
    print game_data
    sql.db_insert(PGA_DB, "games", game_data)
Пример #32
0
    def on_save(self, _button):
        """Save game info and destroy widget. Return True if success."""

        try:
            if self.slug_entry.get_sensitive() and self.slug != self.slug_entry.get_text():
                # Warn the user they made changes to the slug that need to be applied
                dlg = QuestionDialog(
                    {
                        "question":
                        _("You have modified the idenitifier, but not applied it."
                          "Would you like to apply those changes now?"),
                        "title":
                        _("Confirm pending identifier change"),
                    }
                )
                if dlg.result == Gtk.ResponseType.YES:
                    self.change_game_slug()
        except AttributeError:
            pass

        if not self.is_valid():
            logger.warning(_("Current configuration is not valid, ignoring save request"))
            return False
        name = self.name_entry.get_text()

        if not self.slug:
            self.slug = slugify(name)

        if not self.game:
            self.game = Game()

        year = None
        if self.year_entry.get_text():
            year = int(self.year_entry.get_text())

        if not self.lutris_config.game_config_id:
            self.lutris_config.game_config_id = make_game_config_id(self.slug)

        runner_class = runners.import_runner(self.runner_name)
        runner = runner_class(self.lutris_config)

        self.game.name = name
        self.game.slug = self.slug
        self.game.year = year
        self.game.game_config_id = self.lutris_config.game_config_id
        self.game.runner = runner
        self.game.runner_name = self.runner_name
        self.game.directory = runner.game_path
        self.game.is_installed = True
        if self.runner_name in ("steam", "winesteam"):
            self.game.steamid = self.lutris_config.game_config["appid"]

        self.game.config = self.lutris_config
        self.game.save()
        self.destroy()
        self.saved = True
        return True
Пример #33
0
def sync_with_lutris():
    apps = get_games()
    desktop_games_in_lutris = pga.get_desktop_games()
    slugs_in_lutris = set([str(game['slug']) for game in desktop_games_in_lutris])

    seen_slugs = set()
    for app in apps:
        game_info = None
        name = app[0]
        appid = app[1]
        slug = slugify(name)

        # if it fails to get slug from the name
        if not slug:
            slug = slugify(appid)

        if not name or not slug or not appid:
            logger.error("Failed to load desktop game "
                         "\"" + str(name) + "\" "
                         "(app: " + str(appid) + ", slug: " + slug + ")")
            continue
        else:
            logger.debug("Found desktop game "
                         "\"" + str(name) + "\" "
                         "(app: " + str(appid) + ", slug: " + slug + ")")

        seen_slugs.add(slug)

        if slug not in slugs_in_lutris:
            game_info = {
                'name': name,
                'slug': slug,
                'config_path': slug + '-desktopapp',
                'installer_slug': 'desktopapp',
                'exe': app[2],
                'args': app[3]
            }
            mark_as_installed(appid, 'linux', game_info)

    unavailable_slugs = slugs_in_lutris.difference(seen_slugs)
    for slug in unavailable_slugs:
        for game in desktop_games_in_lutris:
            if game['slug'] == slug:
                mark_as_uninstalled(game)
Пример #34
0
 def new_from_steam_game(cls, steam_game, game_id=None):
     """Return a Steam game instance from an AppManifest"""
     game = SteamGame()
     game.appid = steam_game["appid"]
     game.game_id = steam_game["appid"]
     game.name = steam_game["name"]
     game.slug = slugify(steam_game["name"])
     game.runner = "steam"
     game.details = json.dumps(steam_game)
     return game
Пример #35
0
def add_or_update(name, runner, slug=None, **kwargs):
    if not slug:
        slug = slugify(name)
    game = get_game_by_slug(slug)
    kwargs['name'] = name
    kwargs['runner'] = runner
    kwargs['slug'] = slug
    if game:
        sql.db_update(PGA_DB, "games", kwargs, ('slug', slug))
    else:
        add_game(**kwargs)
Пример #36
0
def add_or_update(name, runner, slug=None, **kwargs):
    if not slug:
        slug = slugify(name)
    game = get_game_by_slug(slug)
    kwargs['name'] = name
    kwargs['runner'] = runner
    kwargs['slug'] = slug
    if game:
        game_id = game['id']
        sql.db_update(PGA_DB, "games", kwargs, ('id', game_id))
    else:
        add_game(**kwargs)
Пример #37
0
 def generate_installer(self, db_game):
     ubi_db_game = get_game_by_field("ubisoft-connect", "slug")
     ubisoft_connect = Game(ubi_db_game["id"])
     uc_exe = ubisoft_connect.config.game_config["exe"]
     if not os.path.isabs(uc_exe):
         uc_exe = os.path.join(ubisoft_connect.config.game_config["prefix"],
                               uc_exe)
     return {
         "name": db_game["name"],
         "version": self.name,
         "slug": slugify(db_game["name"]) + "-" + self.id,
         "game_slug": slugify(db_game["name"]),
         "runner": self.runner,
         "appid": db_game["appid"],
         "script": {
             "requires":
             self.client_installer,
             "game": {
                 "args": f"uplay://launch/{db_game['appid']}",
             },
             "installer": [{
                 "task": {
                     "name":
                     "wineexec",
                     "executable":
                     uc_exe,
                     "args":
                     f"uplay://install/{db_game['appid']}",
                     "prefix":
                     ubisoft_connect.config.game_config["prefix"],
                     "description":
                     ("Ubisoft will now open and install %s. "
                      "Close Ubisoft Connect to complete the install process."
                      ) % db_game["name"]
                 }
             }]
         }
     }
Пример #38
0
def sync_with_lutris():
    scummvm_games = {
        game['slug']: game
        for game in pga.get_games_where(runner='scummvm',
                                        installer_slug=INSTALLER_SLUG,
                                        installed=1)
    }
    seen = set()

    for scummvm_id, name, path in get_scummvm_games():
        slug = slugify(name)
        seen.add(slug)
        if slug not in scummvm_games.keys():
            mark_as_installed(scummvm_id, name, path)
    for slug in set(scummvm_games.keys()).difference(seen):
        mark_as_uninstalled(scummvm_games[slug])
Пример #39
0
def add_or_update(**params):
    slug = params.get('slug')
    name = params.get('name')
    id = params.get('id')
    assert any([slug, name, id])
    if 'id' in params:
        game = get_game_by_field(params['id'], 'id')
    else:
        if not slug:
            slug = slugify(name)
        game = get_game_by_field(slug, 'slug')
    if game:
        game_id = game['id']
        sql.db_update(PGA_DB, "games", params, ('id', game_id))
        return game_id
    else:
        return add_game(**params)
Пример #40
0
 def on_save(self, _button):
     """Save game info and destroy widget. Return True if success."""
     if not self.is_valid():
         return False
     name = self.name_entry.get_text()
     if not self.lutris_config.game:
         self.lutris_config.game = slugify(name)
     self.lutris_config.save()
     self.slug = self.lutris_config.game
     runner_class = lutris.runners.import_runner(self.runner_name)
     runner = runner_class(self.lutris_config)
     pga.add_or_update(name, self.runner_name, slug=self.slug,
                       directory=runner.game_path,
                       installed=1)
     self.destroy()
     logger.debug("Saved %s", name)
     return True
Пример #41
0
def mark_as_installed(scummvm_id, name, path):
    """Add scummvm from the auto-import"""
    logger.info("Setting %s as installed", name)
    slug = slugify(name)
    config_id = make_game_config_id(slug)
    game_id = pga.add_or_update(
        name=name,
        runner="scummvm",
        installer_slug=INSTALLER_SLUG,
        slug=slug,
        installed=1,
        configpath=config_id,
        directory=path,
    )
    config = LutrisConfig(runner_slug="scummvm", game_config_id=config_id)
    config.raw_game_config.update({"game_id": scummvm_id, "path": path})
    config.save()
    return game_id
Пример #42
0
    def save(self):
        """ Save configuration file according to self.config_type """
        self.update_global_config()
        logging.debug("Saving config: %s", self.config)
        yaml_config = yaml.dump(self.config, default_flow_style=False)

        if self.config_type == "system":
            filename = join(CONFIG_DIR, "system.yml")
            self.write_to_disk(filename, yaml_config)
        elif self.config_type == "runner":
            runner_config_path = join(CONFIG_DIR,
                                      "runners/%s.yml" % self.runner)
            self.write_to_disk(runner_config_path, yaml_config)

        elif self.config_type == "game":
            self.game = slugify(self.config['realname'])
            self.write_to_disk(self.game_config_file, yaml_config)
        else:
            raise ValueError("Invalid config_type '%s'" % self.config_type)
Пример #43
0
def add_or_update(name, runner, slug=None, **kwargs):
    """
    FIXME probably not the desired behavior since it disallows multiple games
    with the same slug
    """
    if not slug:
        slug = slugify(name)
    if 'id' in kwargs:
        game = get_game_by_field(kwargs['id'], 'id')
    else:
        game = get_game_by_field(slug, 'slug')
    kwargs['name'] = name
    kwargs['runner'] = runner
    kwargs['slug'] = slug
    if game:
        game_id = game['id']
        sql.db_update(PGA_DB, "games", kwargs, ('id', game_id))
        return game_id
    else:
        return add_game(**kwargs)
Пример #44
0
 def __init__(self, game_ref, parent):
     self.error = None
     self.errors = []
     self.files = []
     self.target_path = None
     self.parent = parent
     self.game_name = None
     self.game_slug = None
     self.game_files = {}
     self.steam_data = {}
     self.script = self._fetch_script(game_ref)
     if not self.is_valid():
         raise ScriptingError("Invalid script", (self.script, self.errors))
     self.game_name = self.script.get('name')
     self.game_slug = slugify(self.game_name)
     self.requires = self.script.get('requires')
     if self.requires:
         self._check_dependecy()
     else:
         self.target_path = self.default_target
Пример #45
0
def add_game(name, **game_data):
    """Adds a game to the PGA database."""
    game_data['name'] = name
    if not 'slug' in game_data:
        game_data['slug'] = slugify(name)
    sql.db_insert(PGA_DB, "games", game_data)
Пример #46
0
 def remove_menu_shortcut(self, *args):
     game_slug = slugify(self.view.selected_game)
     shortcuts.remove_launcher(game_slug, menu=True)
Пример #47
0
 def slug(self):
     return slugify(self.name)
Пример #48
0
 def on_save(self, _button):
     name = self.name_entry.get_text()
     self.lutris_config.game = self.slug if self.slug else slugify(name)
     self.installed = super(AddGameDialog, self).on_save(_button)
Пример #49
0
 def remove_desktop_shortcut(self, *args):
     game_slug = slugify(self.view.selected_game)
     shortcuts.remove_launcher(game_slug, desktop=True)
Пример #50
0
 def create_menu_shortcut(self, *args):
     """Adds the game to the system's Games menu"""
     game_slug = slugify(self.view.selected_game)
     create_launcher(game_slug, menu=True)
     dialogs.NoticeDialog(
         "Shortcut added to the Games category of the global menu.")
Пример #51
0
 def create_desktop_shortcut(self, *args):
     """Adds the game to the system's Games menu"""
     game_slug = slugify(self.view.selected_game)
     create_launcher(game_slug, desktop=True)
     dialogs.NoticeDialog('Shortcut created on your desktop.')
Пример #52
0
 def create_desktop_shortcut(self, *args):
     """Create a desktop launcher for the selected game."""
     game_slug = slugify(self.view.selected_game)
     game_name = Game(game_slug).name
     shortcuts.create_launcher(game_slug, game_name, desktop=True)
Пример #53
0
 def get_slug(xdg_app):
     """Get the slug from the game name"""
     return slugify(xdg_app.get_display_name()) or slugify(get_appid(xdg_app))
Пример #54
0
 def create_menu_shortcut(self, *args):
     """Add the selected game to the system's Games menu."""
     game_slug = slugify(self.view.selected_game)
     game_name = Game(game_slug).name
     shortcuts.create_launcher(game_slug, game_name, menu=True)