示例#1
0
 def on_icon_loaded(self, _store, game_slug, media_type):
     if not self.has_icon(game_slug):
         return
     if media_type != self.icon_type:
         return
     for pga_game in pga.get_games_where(slug=game_slug):
         GLib.idle_add(self.update, pga_game)
示例#2
0
 def on_image_downloaded(self, game_slugs):
     for game_slug in game_slugs:
         games = pga.get_games_where(slug=game_slug)
         for game in games:
             game = Game(game['id'])
             is_installed = game.is_installed
             self.view.update_image(game.id, is_installed)
示例#3
0
 def on_steam_game_changed(self, operation, path):
     appmanifest = steam.AppManifest(path)
     runner_name = appmanifest.get_runner_name()
     games = pga.get_games_where(steamid=appmanifest.steamid)
     if operation == Gio.FileMonitorEvent.DELETED:
         for game in games:
             if game['runner'] == runner_name:
                 steam.mark_as_uninstalled(game)
                 self.view.set_uninstalled(Game(game['id']))
                 break
     elif operation in (Gio.FileMonitorEvent.CHANGED, Gio.FileMonitorEvent.CREATED):
         if not appmanifest.is_installed():
             return
         if runner_name == 'winesteam':
             return
         game_info = None
         for game in games:
             if game['installed'] == 0:
                 game_info = game
             else:
                 # Game is already installed, don't do anything
                 return
         if not game_info:
             game_info = {
                 'name': appmanifest.name,
                 'slug': appmanifest.slug,
             }
         game_id = steam.mark_as_installed(appmanifest.steamid,
                                           runner_name,
                                           game_info)
         game_ids = [game['id'] for game in self.game_list]
         if game_id not in game_ids:
             self.add_game_to_view(game_id)
         else:
             self.view.set_installed(Game(game_id))
示例#4
0
    def on_steam_game_changed(self, operation, path):
        """Action taken when a Steam AppManifest file is updated"""
        appmanifest = steam.AppManifest(path)
        # if self.running_game and "steam" in self.running_game.runner_name:
        #     self.running_game.notify_steam_game_changed(appmanifest)

        runner_name = appmanifest.get_runner_name()
        games = pga.get_games_where(steamid=appmanifest.steamid)
        if operation == Gio.FileMonitorEvent.DELETED:
            for game in games:
                if game["runner"] == runner_name:
                    steam.mark_as_uninstalled(game)
                    self.game_store.set_uninstalled(Game(game["id"]))
                    break
        elif operation in (Gio.FileMonitorEvent.CHANGED, Gio.FileMonitorEvent.CREATED):
            if not appmanifest.is_installed():
                return
            if runner_name == "winesteam":
                return
            game_info = None
            for game in games:
                if game["installed"] == 0:
                    game_info = game
                else:
                    # Game is already installed, don't do anything
                    return
            if not game_info:
                game_info = {"name": appmanifest.name, "slug": appmanifest.slug}
            if steam in get_services_synced_at_startup():
                game_id = steam.mark_as_installed(
                    appmanifest.steamid, runner_name, game_info
                )
                self.game_store.update_game_by_id(game_id)
示例#5
0
        def update_gui(result, error):
            if error:
                logger.error("Failed to synchrone library: %s", error)
                return
            if result:
                added_ids, updated_ids = result

                # sqlite limits the number of query parameters to 999, to
                # bypass that limitation, divide the query in chunks
                size = 999
                added_games = chain.from_iterable([
                    pga.get_games_where(
                        id__in=list(added_ids)[page * size:page * size + size])
                    for page in range(math.ceil(len(added_ids) / size))
                ])
                self.game_list += added_games
                self.switch_splash_screen()
                self.view.populate_games(added_games)
                GLib.idle_add(self.update_existing_games, added_ids,
                              updated_ids, True)
            else:
                logger.error("No results returned when syncing the library")
            self.sync_label.set_label("Synchronize library")
            self.sync_spinner.props.active = False
            self.sync_button.set_sensitive(True)
示例#6
0
 def lutris_games(self):
     if not self._lutris_games:
         self._lutris_games = pga.get_games_where(
             steamid__isnull=False,
             steamid__not=""
         )
     return self._lutris_games
示例#7
0
文件: steam.py 项目: Ryochan7/lutris
def sync_with_lutris(platform='linux'):
    steamapps_paths = get_steamapps_paths()
    steam_games_in_lutris = pga.get_games_where(steamid__isnull=False, steamid__not='')
    steamids_in_lutris = set([str(game['steamid']) for game in steam_games_in_lutris])
    seen_ids = set()  # Set of Steam appids seen while browsing AppManifests

    for steamapps_path in steamapps_paths[platform]:
        appmanifests = get_appmanifests(steamapps_path)
        for appmanifest_file in appmanifests:
            steamid = re.findall(r'(\d+)', appmanifest_file)[0]
            seen_ids.add(steamid)
            appmanifest_path = os.path.join(steamapps_path, appmanifest_file)
            if steamid not in steamids_in_lutris and platform == 'linux':
                # New Steam game, not seen before in Lutris,
                # only supports Linux games
                sync_appmanifest_state(appmanifest_path)
            else:
                # Lookup previously installed Steam games
                pga_entry = None
                for game in steam_games_in_lutris:
                    if str(game['steamid']) == steamid and not game['installed']:
                        pga_entry = game
                        break
                if pga_entry:
                    sync_appmanifest_state(appmanifest_path, name=pga_entry['name'], slug=pga_entry['slug'])
    unavailable_ids = steamids_in_lutris.difference(seen_ids)
    for steamid in unavailable_ids:
        for game in steam_games_in_lutris:
            runner = 'steam' if platform == 'linux' else 'winesteam'
            if str(game['steamid']) == steamid \
               and game['installed'] \
               and game['runner'] == runner:
                mark_as_uninstalled(game)
示例#8
0
 def lutris_games(self):
     """Return all Steam games present in the Lutris library"""
     if not self._lutris_games:
         self._lutris_games = pga.get_games_where(
             steamid__isnull=False, steamid__not=""
         )
     return self._lutris_games
示例#9
0
    def remove(self, from_library=False, from_disk=False):
        """Uninstall a game

        Params:
            from_library (bool): Completely remove the game from library, do
                                 not set it as uninstalled
            from_disk (bool): Delete the game files

        Return:
            bool: Updated value for from_library
        """
        if from_disk and self.runner:
            logger.debug("Removing game %s from disk", self.id)
            self.runner.remove_game_data(game_path=self.directory)

        # Do not keep multiple copies of the same game
        existing_games = pga.get_games_where(slug=self.slug)
        if len(existing_games) > 1:
            from_library = True

        if from_library:
            logger.debug("Removing game %s from library", self.id)
            pga.delete_game(self.id)
        else:
            pga.set_uninstalled(self.id)
        if self.config:
            self.config.remove()
        xdgshortcuts.remove_launcher(self.slug,
                                     self.id,
                                     desktop=True,
                                     menu=True)
        self.is_installed = False
        self.emit("game-removed")
        return from_library
示例#10
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])
示例#11
0
    def on_steam_game_changed(self, operation, path):
        """Action taken when a Steam AppManifest file is updated"""
        appmanifest = steam.AppManifest(path)
        # if self.running_game and "steam" in self.running_game.runner_name:
        #     self.running_game.notify_steam_game_changed(appmanifest)

        runner_name = appmanifest.get_runner_name()
        games = pga.get_games_where(steamid=appmanifest.steamid)
        if operation == Gio.FileMonitorEvent.DELETED:
            for game in games:
                if game["runner"] == runner_name:
                    steam.mark_as_uninstalled(game)
                    self.game_store.set_uninstalled(Game(game["id"]))
                    break
        elif operation in (Gio.FileMonitorEvent.CHANGED, Gio.FileMonitorEvent.CREATED):
            if not appmanifest.is_installed():
                return
            if runner_name == "winesteam":
                return
            game_info = None
            for game in games:
                if game["installed"] == 0:
                    game_info = game
                else:
                    # Game is already installed, don't do anything
                    return
            if not game_info:
                game_info = {"name": appmanifest.name, "slug": appmanifest.slug}
            if steam in get_services_synced_at_startup():
                game_id = steam.mark_as_installed(
                    appmanifest.steamid, runner_name, game_info
                )
                self.game_store.update_game_by_id(game_id)
示例#12
0
文件: xdg.py 项目: Ryochan7/lutris
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])
示例#13
0
    def on_image_downloaded(self, game_slugs):
        logger.debug("Updated images for %d games" % len(game_slugs))

        for game_slug in game_slugs:
            games = pga.get_games_where(slug=game_slug)
            for game in games:
                game = Game(game['id'])
                is_installed = game.is_installed
                self.view.update_image(game.id, is_installed)
示例#14
0
    def on_image_downloaded(self, game_slugs):
        logger.debug("Updated images for %d games" % len(game_slugs))

        for game_slug in game_slugs:
            games = pga.get_games_where(slug=game_slug)
            for game in games:
                game = Game(game['id'])
                is_installed = game.is_installed
                self.view.update_image(game.id, is_installed)
示例#15
0
    def on_image_downloaded(self, game_slugs):
        """Callback for handling successful image downloads"""
        logger.debug("Updated images for %d games", len(game_slugs))

        for game_slug in game_slugs:
            games = pga.get_games_where(slug=game_slug)
            for game in games:
                game = Game(game['id'])
                is_installed = game.is_installed
                self.view.update_image(game.id, is_installed)
示例#16
0
def sync_with_lutris():
    """Sync the ScummVM games to 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):
        return pga.add_or_update(id=scummvm_games[slug]["id"], installed=0)
示例#17
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])
示例#18
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])
示例#19
0
文件: steam.py 项目: Tom-Todd/lutris
def sync_with_lutris(platform='linux'):
    steamapps_paths = get_steamapps_paths()
    steam_games_in_lutris = pga.get_games_where(steamid__isnull=False,
                                                steamid__not='')
    proton_ids = ["858280", "930400", "961940", "228980"]
    steamids_in_lutris = {
        str(game['steamid'])
        for game in steam_games_in_lutris
    }
    seen_ids = set()  # Set of Steam appids seen while browsing AppManifests

    for steamapps_path in steamapps_paths[platform]:
        appmanifests = get_appmanifests(steamapps_path)
        for appmanifest_file in appmanifests:
            steamid = re.findall(r'(\d+)', appmanifest_file)[0]
            seen_ids.add(steamid)
            appmanifest_path = os.path.join(steamapps_path, appmanifest_file)
            if steamid not in steamids_in_lutris and steamid not in proton_ids:
                # New Steam game, not seen before in Lutris,
                if platform != 'linux':
                    # Windows games might require additional steps.
                    # TODO: Find a way to mark games as "Not fully configured"
                    # as the status.
                    logger.warning(
                        "Importing Steam game %s but game might require additional configuration"
                    )
                sync_appmanifest_state(appmanifest_path)
            else:
                # Lookup previously installed Steam games
                pga_entry = None
                for game in steam_games_in_lutris:
                    if str(game['steamid']
                           ) == steamid and not game['installed']:
                        pga_entry = game
                        break
                if pga_entry:
                    sync_appmanifest_state(appmanifest_path,
                                           name=pga_entry['name'],
                                           slug=pga_entry['slug'])
    unavailable_ids = steamids_in_lutris.difference(seen_ids)
    for steamid in unavailable_ids:
        for game in steam_games_in_lutris:
            runner = 'steam' if platform == 'linux' else 'winesteam'
            if str(game['steamid']) == steamid \
               and game['installed'] \
               and game['runner'] == runner:
                mark_as_uninstalled(game)
示例#20
0
        def update_gui(result, error):
            if result:
                added_ids, updated_ids = result

                # sqlite limits the number of query parameters to 999, to
                # bypass that limitation, divide the query in chunks
                page_size = 999
                added_games = chain.from_iterable([
                    pga.get_games_where(id__in=list(added_ids)[p * page_size:p * page_size + page_size])
                    for p in range(math.ceil(len(added_ids) / page_size))
                ])
                self.game_list += added_games
                self.view.populate_games(added_games)
                self.switch_splash_screen()
                GLib.idle_add(self.update_existing_games, added_ids, updated_ids, True)
            else:
                logger.error("No results returned when syncing the library")
示例#21
0
        def update_gui(result, error):
            if result:
                added_ids, updated_ids = result

                # sqlite limits the number of query parameters to 999, to
                # bypass that limitation, divide the query in chunks
                page_size = 999
                added_games = chain.from_iterable([
                    pga.get_games_where(id__in=list(added_ids)[p * page_size:p * page_size + page_size])
                    for p in range(math.ceil(len(added_ids) / page_size))
                ])
                self.game_list += added_games
                self.view.populate_games(added_games)
                self.switch_splash_screen()
                GLib.idle_add(self.update_existing_games, added_ids, updated_ids, True)
            else:
                logger.error("No results returned when syncing the library")
示例#22
0
文件: game.py 项目: Ryochan7/lutris
    def remove(self, from_library=False, from_disk=False):
        if from_disk and self.runner:
            logger.debug("Removing game %s from disk" % self.id)
            self.runner.remove_game_data(game_path=self.directory)

        # Do not keep multiple copies of the same game
        existing_games = pga.get_games_where(slug=self.slug)
        if len(existing_games) > 1:
            from_library = True

        if from_library:
            logger.debug("Removing game %s from library" % self.id)
            pga.delete_game(self.id)
        else:
            pga.set_uninstalled(self.id)
        self.config.remove()
        xdg.remove_launcher(self.slug, self.id, desktop=True, menu=True)
        return from_library
示例#23
0
    def remove(self, from_library=False, from_disk=False):
        if from_disk and self.runner:
            logger.debug("Removing game %s from disk" % self.id)
            self.runner.remove_game_data(game_path=self.directory)

        # Do not keep multiple copies of the same game
        existing_games = pga.get_games_where(slug=self.slug)
        if len(existing_games) > 1:
            from_library = True

        if from_library:
            logger.debug("Removing game %s from library" % self.id)
            pga.delete_game(self.id)
        else:
            pga.set_uninstalled(self.id)
        self.config.remove()
        xdg.remove_launcher(self.slug, self.id, desktop=True, menu=True)
        return from_library
示例#24
0
def sync_with_lutris(platform='linux'):
    steamapps_paths = get_steamapps_paths()
    steam_games_in_lutris = pga.get_games_where(steamid__isnull=False,
                                                steamid__not='')
    steamids_in_lutris = set(
        [str(game['steamid']) for game in steam_games_in_lutris])
    seen_ids = set()  # Set of Steam appids seen while browsing AppManifests

    for steamapps_path in steamapps_paths[platform]:
        appmanifests = get_appmanifests(steamapps_path)
        for appmanifest_file in appmanifests:
            steamid = re.findall(r'(\d+)', appmanifest_file)[0]
            seen_ids.add(steamid)
            appmanifest_path = os.path.join(steamapps_path, appmanifest_file)
            if steamid not in steamids_in_lutris and platform == 'linux':
                # New Steam game, not seen before in Lutris,
                # only supports Linux games
                sync_appmanifest_state(appmanifest_path)
            else:
                # Lookup previously installed Steam games
                pga_entry = None
                for game in steam_games_in_lutris:
                    if str(game['steamid']
                           ) == steamid and not game['installed']:
                        pga_entry = game
                        break
                if pga_entry:
                    sync_appmanifest_state(appmanifest_path,
                                           name=pga_entry['name'],
                                           slug=pga_entry['slug'])
    unavailable_ids = steamids_in_lutris.difference(seen_ids)
    for steamid in unavailable_ids:
        for game in steam_games_in_lutris:
            runner = 'steam' if platform == 'linux' else 'winesteam'
            if str(game['steamid']) == steamid \
               and game['installed'] \
               and game['runner'] == runner:
                mark_as_uninstalled(game)
示例#25
0
    def on_steam_game_changed(self, operation, path):
        appmanifest = steam.AppManifest(path)
        if self.running_game and 'steam' in self.running_game.runner_name:
            self.running_game.notify_steam_game_changed(appmanifest)

        runner_name = appmanifest.get_runner_name()
        games = pga.get_games_where(steamid=appmanifest.steamid)
        if operation == Gio.FileMonitorEvent.DELETED:
            for game in games:
                if game['runner'] == runner_name:
                    steam.mark_as_uninstalled(game)
                    self.view.set_uninstalled(Game(game['id']))
                    break
        elif operation in (Gio.FileMonitorEvent.CHANGED, Gio.FileMonitorEvent.CREATED):
            if not appmanifest.is_installed():
                return
            if runner_name == 'winesteam':
                return
            game_info = None
            for game in games:
                if game['installed'] == 0:
                    game_info = game
                else:
                    # Game is already installed, don't do anything
                    return
            if not game_info:
                game_info = {
                    'name': appmanifest.name,
                    'slug': appmanifest.slug,
                }
            game_id = steam.mark_as_installed(appmanifest.steamid,
                                              runner_name,
                                              game_info)
            game_ids = [game['id'] for game in self.game_list]
            if game_id not in game_ids:
                self.add_game_to_view(game_id)
            else:
                self.view.set_installed(Game(game_id))
示例#26
0
 def lutris_games(self):
     if not self._lutris_games:
         self._lutris_games = pga.get_games_where(steamid__isnull=False,
                                                  steamid__not="")
     return self._lutris_games
示例#27
0
 def update_game(self, slug):
     for pga_game in pga.get_games_where(slug=slug):
         self.game_store.update(pga_game)
示例#28
0
 def update_game(self, slug):
     for pga_game in pga.get_games_where(slug=slug):
         self.game_store.update(pga_game)
示例#29
0
 def update_image_for_slug(self, slug):
     for pga_game in pga.get_games_where(slug=slug):
         game = Game(pga_game["id"])
         self.view.update_image(game.id, game.is_installed)
示例#30
0
 def lutris_games(self):
     """Iterates through Lutris games imported from XDG"""
     for game in pga.get_games_where(runner=XDGGame.runner,
                                     installer_slug=XDGGame.installer_slug,
                                     installed=1):
         yield game
示例#31
0
文件: xdg.py 项目: yurikoles/lutris
 def iter_lutris_games(cls):
     """Iterates through Lutris games imported from XDG"""
     for game in pga.get_games_where(runner=XDGGame.runner,
                                     installer_slug=XDGGame.installer_slug,
                                     installed=1):
         yield game