Beispiel #1
0
 def test_game_with_same_slug_is_updated(self):
     games_db.add_game(name="some game", runner="linux")
     game = games_db.get_game_by_field("some-game", "slug")
     self.assertFalse(game['directory'])
     games_db.add_or_update(name="some game", runner='linux', directory="/foo")
     game = games_db.get_game_by_field("some-game", "slug")
     self.assertEqual(game['directory'], '/foo')
Beispiel #2
0
 def save(self, save_config=False):
     """
     Save the game's config and metadata, if `save_config` is set to False,
     do not save the config. This is useful when exiting the game since the
     config might have changed and we don't want to override the changes.
     """
     if self.config:
         logger.debug("Saving %s with config ID %s", self, self.config.game_config_id)
         configpath = self.config.game_config_id
         if save_config:
             self.config.save()
     else:
         logger.warning("Saving %s without a configuration", self)
         configpath = ""
     self.set_platform_from_runner()
     self.id = games_db.add_or_update(
         name=self.name,
         runner=self.runner_name,
         slug=self.slug,
         platform=self.platform,
         directory=self.directory,
         installed=self.is_installed,
         year=self.year,
         lastplayed=self.lastplayed,
         configpath=configpath,
         id=self.id,
         playtime=self.playtime,
         hidden=self.is_hidden,
         service=self.service,
         service_id=self.appid,
     )
     self.emit("game-updated")
Beispiel #3
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 = self.write_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,
         installer_slug=self.slug,
         parent_slug=self.requires,
         year=self.year,
         steamid=self.steamid,
         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()
Beispiel #4
0
 def launch_service_game(self, runner, installer_slug):
     """For services that allow it, add the game to Lutris and launch it"""
     config_id = self.game_slug + "-" + self.service.id
     game_id = add_or_update(
         name=self.game_name,
         runner=runner,
         slug=self.game_slug,
         installed=1,
         configpath=config_id,
         installer_slug=installer_slug,
         service=self.service.id,
         service_id=self.db_game["appid"],
     )
     self.service.create_config(self.db_game, config_id)
     game = Game(game_id)
     game.emit("game-launch")
Beispiel #5
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