示例#1
0
 def save(self):
     """Write the game configuration in the DB and config file"""
     if self.extends:
         logger.info(
             "This is an extension to %s, not creating a new game entry",
             self.extends,
         )
         return
     configpath = write_game_config(self.slug, self.get_game_config())
     runner_inst = import_runner(self.runner)()
     if self.service:
         service_id = self.service.id
     else:
         service_id = None
     self.game_id = add_or_update(
         name=self.game_name,
         runner=self.runner,
         slug=self.game_slug,
         platform=runner_inst.get_platform(),
         directory=self.interpreter.target_path,
         installed=1,
         hidden=0,
         installer_slug=self.slug,
         parent_slug=self.requires,
         year=self.year,
         configpath=configpath,
         service=service_id,
         service_id=self.service_appid,
         id=self.game_id,
     )
     # This is a bit redundant but used to trigger the game-updated signal
     game = Game(self.game_id)
     game.save()
示例#2
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
示例#3
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
示例#4
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
示例#5
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
示例#6
0
def scan_directory(dirname):
    files = os.listdir(dirname)
    folder_extentions = {os.path.splitext(filename)[1] for filename in files}
    core_matches = {}
    for core in RECOMMENDED_CORES:
        for ext in RECOMMENDED_CORES[core].get("extensions", []):
            if ext in folder_extentions:
                core_matches[ext] = core
    added_games = []
    for filename in files:
        name, ext = os.path.splitext(filename)
        if ext not in core_matches:
            continue
        for flag in ROM_FLAGS:
            name = name.replace(" (%s)" % flag, "")
        for flag in EXTRA_FLAGS:
            name = name.replace("[%s]" % flag, "")
        if ", The" in name:
            name = "The %s" % name.replace(", The", "")
        name = name.strip()
        print("Importing '%s'" % name)
        slug = slugify(name)
        core = core_matches[ext]
        config = {
            "game": {
                "core": core_matches[ext],
                "main_file": os.path.join(dirname, filename)
            }
        }
        installer_slug = "%s-libretro-%s" % (slug, core)
        existing_game = get_games(filters={
            "installer_slug": installer_slug,
            "installed": "1"
        })
        if existing_game:
            game = Game(existing_game[0]["id"])
            game.remove()
        configpath = write_game_config(slug, config)
        game_id = add_game(name=name,
                           runner="libretro",
                           slug=slug,
                           directory=dirname,
                           installed=1,
                           installer_slug=installer_slug,
                           configpath=configpath)
        print("Imported %s" % name)
        added_games.append(game_id)
    return added_games
示例#7
0
 def simple_install(self, db_game):
     """A simplified version of the install method, used when a game doesn't need any setup"""
     installer = self.generate_installer(db_game)
     configpath = write_game_config(db_game["slug"], installer["script"])
     game_id = add_game(
         name=installer["name"],
         runner=installer["runner"],
         slug=installer["game_slug"],
         directory=self.get_game_directory(installer),
         installed=1,
         installer_slug=installer["slug"],
         configpath=configpath,
         service=self.id,
         service_id=db_game["appid"],
     )
     return game_id
示例#8
0
    def save(self):
        """Write the game configuration in the DB and config file"""
        if self.extends:
            logger.info(
                "This is an extension to %s, not creating a new game entry",
                self.extends,
            )
            return self.game_id

        if self.is_gog:
            gog_config = get_gog_config_from_path(self.interpreter.target_path)
            if gog_config:
                gog_game_path = get_gog_game_path(self.interpreter.target_path)
                lutris_config = convert_gog_config_to_lutris(
                    gog_config, gog_game_path)
                self.script["game"].update(lutris_config)

        configpath = write_game_config(self.slug, self.get_game_config())
        runner_inst = import_runner(self.runner)()
        if self.service:
            service_id = self.service.id
        else:
            service_id = None
        self.game_id = add_or_update(
            name=self.game_name,
            runner=self.runner,
            slug=self.game_slug,
            platform=runner_inst.get_platform(),
            directory=self.interpreter.target_path,
            installed=1,
            hidden=0,
            installer_slug=self.slug,
            parent_slug=self.requires,
            year=self.year,
            configpath=configpath,
            service=service_id,
            service_id=self.service_appid,
            id=self.game_id,
        )
        return self.game_id
示例#9
0
def scan_directory(dirname):
    """Add a directory of ROMs as Lutris games"""
    files = os.listdir(dirname)
    folder_extentions = {os.path.splitext(filename)[1] for filename in files}
    core_matches = {}
    for core in RECOMMENDED_CORES:
        for ext in RECOMMENDED_CORES[core].get("extensions", []):
            if ext in folder_extentions:
                core_matches[ext] = core
    added_games = []
    for filename in files:
        name, ext = os.path.splitext(filename)
        if ext not in core_matches:
            continue
        logger.info("Importing '%s'", name)
        slug = slugify(name)
        core = core_matches[ext]
        config = {
            "game": {
                "core": core_matches[ext],
                "main_file": os.path.join(dirname, filename)
            }
        }
        installer_slug = "%s-libretro-%s" % (slug, core)
        existing_game = get_games(filters={"installer_slug": installer_slug})
        if existing_game:
            game = Game(existing_game[0]["id"])
            game.remove()
        configpath = write_game_config(slug, config)
        game_id = add_game(name=name,
                           runner="libretro",
                           slug=slug,
                           directory=dirname,
                           installed=1,
                           installer_slug=installer_slug,
                           configpath=configpath)
        added_games.append(game_id)
    return added_games
示例#10
0
 def install_from_egs(self, egs_game, manifest):
     """Create a new Lutris game based on an existing EGS install"""
     app_name = manifest["AppName"]
     service_game = ServiceGameCollection.get_game("egs", app_name)
     lutris_game_id = "egs-" + app_name
     existing_game = get_game_by_field(lutris_game_id, "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="egs-" + app_name,
         directory=egs_game["directory"],
         installed=1,
         installer_slug="egs-" + app_name,
         configpath=configpath,
         service=self.id,
         service_id=app_name,
     )
     return game_id
示例#11
0
        name = name.replace("[%s]" % flag, "")
    if ", The" in name:
        name = "The %s" % name.replace(", The", "")
    name = name.strip()
    print("Importing '%s'" % name)
    slug = slugify(name)
    core = core_matches[ext]
    config = {
        "game": {
            "core": core_matches[ext],
            "main_file": os.path.join(dirname, filename)
        }
    }
    installer_slug = "%s-libretro-%s" % (slug, core)
    existing_game = get_games(filters={
        "installer_slug": installer_slug,
        "installed": "1"
    })
    if existing_game:
        game = Game(existing_game[0]["id"])
        game.remove()
    configpath = write_game_config(slug, config)
    game_id = add_game(name=name,
                       runner="libretro",
                       slug=slug,
                       directory=dirname,
                       installed=1,
                       installer_slug=installer_slug,
                       configpath=configpath)
    print("Imported %s" % name)