Пример #1
0
 def match_game(self, service_game, api_game):
     """Match a service game to a lutris game referenced by its slug"""
     if not service_game:
         return
     logger.debug("Matching service game %s with API game %s", service_game, api_game)
     conditions = {"appid": service_game["appid"], "service": self.id}
     sql.db_update(
         PGA_DB,
         "service_games",
         {"lutris_slug": api_game["slug"]},
         conditions=conditions
     )
     unmatched_lutris_games = get_games(
         searches={"installer_slug": self.matcher},
         filters={"slug": api_game["slug"]},
         excludes={"service": self.id}
     )
     for game in unmatched_lutris_games:
         logger.debug("Updating unmatched game %s", game)
         sql.db_update(
             PGA_DB,
             "games",
             {"service": self.id, "service_id": service_game["appid"]},
             conditions={"id": game["id"]}
         )
Пример #2
0
 def match_game(self, service_game, slug):
     """Match a service game to a lutris game referenced by its slug"""
     if not service_game:
         return
     conditions = {"appid": service_game["appid"], "service": self.id}
     sql.db_update(PGA_DB,
                   "service_games", {"lutris_slug": slug},
                   conditions=conditions)
Пример #3
0
 def match_existing_game(self, db_games, appid):
     """Checks if a game is already installed and populates the service info"""
     for _game in db_games:
         logger.debug("Matching %s with existing install: %s", appid, _game)
         game = Game(_game["id"])
         game.appid = appid
         game.service = self.id
         game.save()
         service_game = ServiceGameCollection.get_game(self.id, appid)
         sql.db_update(PGA_DB, "service_games", {"lutris_slug": game["slug"]}, {"id": service_game["id"]})
         return game
Пример #4
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.
    """
    game_id = get_matching_game(params)
    if game_id:
        params["id"] = game_id
        sql.db_update(PGA_DB, "games", params, {"id": game_id})
        return game_id
    return add_game(**params)
Пример #5
0
    def remove(self, delete_files=False):
        """Uninstall a game

        Params:
            delete_files (bool): Delete the game files
        """
        sql.db_update(settings.PGA_DB, "games", {"installed": 0, "runner": ""}, {"id": self.id})
        if self.config:
            self.config.remove()
        xdgshortcuts.remove_launcher(self.slug, self.id, desktop=True, menu=True)
        if delete_files and self.runner:
            self.runner.remove_game_data(game_path=self.directory)
        self.is_installed = False
        self.runner = None
        self.emit("game-removed")
Пример #6
0
 def save(self):
     """Save this game to database"""
     game_data = {
         "service": self.service,
         "appid": self.appid,
         "name": self.name,
         "slug": self.slug,
         "lutris_slug": self.lutris_slug,
         "icon": self.icon,
         "logo": self.logo,
         "details": str(self.details),
     }
     existing_game = ServiceGameCollection.get_game(self.service,
                                                    self.appid)
     if existing_game:
         sql.db_update(PGA_DB, "service_games", game_data,
                       {"id": existing_game["id"]})
     else:
         sql.db_insert(PGA_DB, "service_games", game_data)
Пример #7
0
 def match_games(self):
     """Matching of service games to lutris games"""
     service_games = {
         str(game["appid"]): game
         for game in ServiceGameCollection.get_for_service(self.id)
     }
     lutris_games = api.get_api_games(list(service_games.keys()),
                                      service=self.id)
     for lutris_game in lutris_games:
         for provider_game in lutris_game["provider_games"]:
             if provider_game["service"] != self.id:
                 continue
             service_game = service_games.get(provider_game["slug"])
             if not service_game:
                 continue
             conditions = {
                 "appid": service_game["appid"],
                 "service": self.id
             }
             sql.db_update(PGA_DB,
                           "service_games",
                           {"lutris_slug": lutris_game["slug"]},
                           conditions=conditions)
Пример #8
0
def set_uninstalled(game_id):
    sql.db_update(PGA_DB, "games", {
        "installed": 0,
        "runner": ""
    }, {"id": game_id})