Exemplo n.º 1
0
    def get_games_from_filters(self):
        if self.filters.get("service"):
            service_name = self.filters["service"]
            if service_name in services.get_services():
                self.service = services.get_services()[service_name]()
                if self.service.online:
                    self.service.connect("service-login",
                                         self.on_service_games_updated)
                    self.service.connect("service-logout",
                                         self.on_service_logout)
                self.service.connect("service-games-loaded",
                                     self.on_service_games_updated)

                service_games = ServiceGameCollection.get_for_service(
                    service_name)
                if service_games:
                    return [
                        game for game in sorted(
                            service_games,
                            key=lambda game: game.get(self.view_sorting) or
                            game["name"],
                            reverse=not self.view_sorting_ascending,
                        ) if self.game_matches(game)
                    ]

                if not self.service.online or self.service.is_connected():
                    AsyncCall(self.service.load, None)
                    spinner = Gtk.Spinner(visible=True)
                    spinner.start()
                    self.blank_overlay.add(spinner)
                else:
                    self.blank_overlay.add(
                        Gtk.Label(
                            _("Connect your %s account to access your games") %
                            self.service.name,
                            visible=True,
                        ))
                self.blank_overlay.props.visible = True
                return
            self.unset_service()
        dynamic_categories = {
            "running": self.get_running_games,
            "installed": self.get_installed_games,
        }
        if self.filters.get("dynamic_category") in dynamic_categories:
            return dynamic_categories[self.filters["dynamic_category"]]()
        self.unset_service()
        if self.filters.get("category"):
            game_ids = categories_db.get_game_ids_for_category(
                self.filters["category"])
            return games_db.get_games_by_ids(game_ids)

        searches, filters, excludes = self.get_sql_filters()
        return games_db.get_games(
            searches=searches,
            filters=filters,
            excludes=excludes,
            sorts=self.sort_params,
        )
Exemplo n.º 2
0
 def get_service(self, initial=None):
     if initial:
         return initial
     if "steam" in self.runner:
         return get_services()["steam"]()
     version = self.version.lower()
     if "humble" in version:
         return get_services()["humblebundle"]()
     if "gog" in version:
         return get_services()["gog"]()
Exemplo n.º 3
0
 def get_games_from_filters(self):
     service_name = self.filters.get("service")
     if service_name in services.get_services():
         self.set_service(service_name)
         service_games = ServiceGameCollection.get_for_service(service_name)
         if service_games:
             return [
                 game
                 for game in sorted(service_games,
                                    key=lambda game: game.get(
                                        self.view_sorting) or game["name"],
                                    reverse=not self.view_sorting_ascending)
                 if self.game_matches(game)
             ]
         if self.service.online and not self.service.is_connected():
             self.show_label(
                 _("Connect your %s account to access your games") %
                 self.service.name)
         return
     self.unset_service()
     dynamic_categories = {
         "running": self.get_running_games,
         "installed": self.get_installed_games
     }
     if self.filters.get("dynamic_category") in dynamic_categories:
         return dynamic_categories[self.filters["dynamic_category"]]()
     if self.filters.get("category"):
         game_ids = categories_db.get_game_ids_for_category(
             self.filters["category"])
         return games_db.get_games_by_ids(game_ids)
     searches, filters, excludes = self.get_sql_filters()
     return games_db.get_games(searches=searches,
                               filters=filters,
                               excludes=excludes,
                               sorts=self.sort_params)
Exemplo n.º 4
0
 def get_games_from_filters(self):
     service_name = self.filters.get("service")
     self.tabs_box.hide()
     if service_name in services.get_services():
         if service_name == "lutris":
             self.tabs_box.show(
             )  # Only the lutris service has the ability to search through all games.
             if self.website_button.props.active:
                 return self.get_api_games()
         if self.service.online and not self.service.is_authenticated():
             self.show_label(
                 _("Connect your %s account to access your games") %
                 self.service.name)
             return []
         return self.get_service_games(service_name)
     dynamic_categories = {
         "recent": self.get_recent_games,
         "running": self.get_running_games,
     }
     if self.filters.get("dynamic_category") in dynamic_categories:
         return dynamic_categories[self.filters["dynamic_category"]]()
     if self.filters.get("category") and self.filters["category"] != "all":
         game_ids = categories_db.get_game_ids_for_category(
             self.filters["category"])
         return games_db.get_games_by_ids(game_ids)
     searches, filters, excludes = self.get_sql_filters()
     return games_db.get_games(searches=searches,
                               filters=filters,
                               excludes=excludes,
                               sorts=self.sort_params)
Exemplo n.º 5
0
 def set_service(self, service_name):
     if self.service and self.service.id == service_name:
         return self.service
     if not service_name:
         self.service = None
         return
     self.service = services.get_services()[service_name]()
     return self.service
Exemplo n.º 6
0
 def set_service(self, service_name):
     if self.service and self.service.id == service_name:
         return self.service
     if not service_name:
         self.unset_service()
         return
     self.service = services.get_services()[service_name]()
     if self.game_store:
         self.game_store.service = self.service
     self._bind_zoom_adjustment()
     return self.service
Exemplo n.º 7
0
 def set_service(self, service_name):
     if self.service and self.service.id == service_name:
         return self.service
     if not service_name:
         self.service = None
         return
     try:
         self.service = services.get_services()[service_name]()
     except KeyError:
         logger.error("Non existent service '%s'", service_name)
         self.service = None
     return self.service
Exemplo n.º 8
0
    def on_game_install(self, game):
        """Request installation of a game"""
        if game.service:
            service = get_services()[game.service]()
            db_game = ServiceGameCollection.get_game(service.id, game.appid)
            service.install(db_game)
            return True

        installers = get_installers(game_slug=game.slug)
        if installers:
            self.show_installer_window(installers)
        else:
            logger.debug("Should generate automagical installer here but....")
            logger.debug("Wait? how did you get here?")
        return True
Exemplo n.º 9
0
    def __init__(self, db_game, game_actions, application):
        """Create the game bar with a database row"""
        super().__init__(visible=True)
        GObject.add_emission_hook(Game, "game-start",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-started",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-stopped",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-updated",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-removed",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-installed",
                                  self.on_game_state_changed)

        self.set_margin_bottom(12)
        self.game_actions = game_actions
        self.db_game = db_game
        self.service = None
        if db_game.get("service"):
            try:
                self.service = services.get_services()[db_game["service"]]()
            except KeyError:
                logger.warning("Non existent service '%s'", db_game["service"])

        game_id = None
        if "service_id" in db_game:
            self.appid = db_game["service_id"]
            game_id = db_game["id"]
        elif self.service:
            self.appid = db_game["appid"]
            if self.service.id == "lutris":
                game = get_game_by_field(self.appid, field="slug")
            else:
                game = get_game_for_service(self.service.id, self.appid)
            if game:
                game_id = game["id"]
        if game_id:
            self.game = application.get_game_by_id(game_id) or Game(game_id)
            game_actions.set_game(self.game)
        else:
            self.game = Game()
        self.game_name = db_game["name"]
        self.game_slug = db_game["slug"]
        self.update_view()
Exemplo n.º 10
0
    def __init__(self, application):
        super().__init__(title=_("Import games"), application=application)
        self.set_default_icon_name("lutris")
        self.application = application
        self.set_show_menubar(False)
        self.connect("delete-event", lambda *x: self.destroy())

        self.set_border_width(10)
        self.set_size_request(640, 480)

        notebook = Gtk.Notebook()
        notebook.set_tab_pos(Gtk.PositionType.LEFT)
        self.add(notebook)

        for service in get_services():
            sync_row = ServiceSyncBox(service, self)
            notebook.append_page(sync_row, sync_row.get_icon())
        notebook.connect("switch-page", self.on_page_change)
        self.show_all()
Exemplo n.º 11
0
    def __init__(self, application):
        super().__init__(title="Import games", application=application)
        self.set_default_icon_name("lutris")
        self.application = application
        self.set_show_menubar(False)
        self.connect("delete-event", lambda *x: self.destroy())

        self.set_border_width(10)
        self.set_size_request(640, 480)

        notebook = Gtk.Notebook()
        notebook.set_tab_pos(Gtk.PositionType.LEFT)
        self.add(notebook)

        for service in get_services():
            sync_row = ServiceSyncBox(service, self)
            notebook.append_page(sync_row, sync_row.get_icon())
        notebook.connect("switch-page", self.on_page_change)
        self.show_all()
Exemplo n.º 12
0
    def __init__(self, db_game, game_actions):
        """Create the game bar with a database row"""
        super().__init__(visible=True)
        GObject.add_emission_hook(Game, "game-start",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-started",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-stopped",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-updated",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-removed",
                                  self.on_game_state_changed)
        GObject.add_emission_hook(Game, "game-installed",
                                  self.on_game_state_changed)

        self.set_margin_bottom(12)
        self.game_actions = game_actions
        self.db_game = db_game
        if db_game.get("service"):
            self.service = services.get_services()[db_game["service"]]()
        else:
            self.service = None
        game_id = None
        if "service_id" in db_game:
            self.appid = db_game["service_id"]
            game_id = db_game["id"]
        elif self.service:
            self.appid = db_game["appid"]
            game = get_game_for_service(self.service.id, self.appid)
            if game:
                game_id = game["id"]
        if game_id:
            self.game = Game(game_id)
        else:
            self.game = Game()
        self.game_name = db_game["name"]
        self.game_slug = db_game["slug"]

        if self.game:
            game_actions.set_game(self.game)
        self.update_view()
Exemplo n.º 13
0
 def get_games_from_filters(self):
     service_name = self.filters.get("service")
     if service_name in services.get_services():
         return self.switch_to_service(service_name)
     self.unset_service()
     dynamic_categories = {
         "recent": self.get_recent_games,
         "running": self.get_running_games,
     }
     if self.filters.get("dynamic_category") in dynamic_categories:
         return dynamic_categories[self.filters["dynamic_category"]]()
     if self.filters.get("category") and self.filters["category"] != "all":
         game_ids = categories_db.get_game_ids_for_category(
             self.filters["category"])
         return games_db.get_games_by_ids(game_ids)
     searches, filters, excludes = self.get_sql_filters()
     return games_db.get_games(searches=searches,
                               filters=filters,
                               excludes=excludes,
                               sorts=self.sort_params)
Exemplo n.º 14
0
    def __init__(self, parent=None):
        Gtk.Dialog.__init__(self, title="Import local games", parent=parent)
        self.connect("delete-event", lambda *x: self.destroy())
        self.set_border_width(10)
        self.set_size_request(512, 0)

        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.get_content_area().add(box_outer)

        description_label = Gtk.Label()
        description_label.set_markup("You can import games from local game sources, \n"
                                     "you can also choose to sync everytime Lutris starts")
        box_outer.pack_start(description_label, False, False, 5)

        separator = Gtk.Separator()
        box_outer.pack_start(separator, False, False, 0)

        for service in get_services():
            sync_row = ServiceSyncRow(service)
            box_outer.pack_start(sync_row, False, True, 0)
        box_outer.show_all()
Exemplo n.º 15
0
 def on_game_install(self, game):
     """Request installation of a game"""
     if game.service:
         service = get_services()[game.service]()
         db_game = ServiceGameCollection.get_game(service.id, game.appid)
         game_id = service.install(db_game)
         if game_id:
             game = Game(game_id)
             game.launch()
         return True
     if not game.slug:
         logger.error("%s doesn't have a slug set, can't query installers",
                      game)
         return True
     installers = get_installers(game_slug=game.slug)
     if installers:
         self.show_installer_window(installers)
     else:
         logger.debug("Should generate automagical installer here but....")
         logger.debug("Wait? how did you get here?")
     return True
Exemplo n.º 16
0
    def __init__(self, parent=None):
        Gtk.Dialog.__init__(self, title="Import local games", parent=parent)
        self.connect("delete-event", lambda *x: self.destroy())
        self.set_border_width(10)
        self.set_size_request(512, 0)

        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.get_content_area().add(box_outer)

        description_label = Gtk.Label()
        description_label.set_markup("You can import games from local game sources, \n"
                                     "you can also choose to sync everytime Lutris starts")
        box_outer.pack_start(description_label, False, False, 5)

        separator = Gtk.Separator()
        box_outer.pack_start(separator, False, False, 0)

        for service in get_services():
            sync_row = ServiceSyncRow(service)
            box_outer.pack_start(sync_row, False, True, 0)
        box_outer.show_all()
Exemplo n.º 17
0
    def __init__(self, parent=None):
        Gtk.Dialog.__init__(self,
                            title="Configure local game import",
                            parent=parent)
        self.connect("delete-event", lambda *x: self.destroy())
        self.set_border_width(10)
        self.set_size_request(512, 0)

        box_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
        self.get_content_area().add(box_outer)

        description_label = Gtk.Label()
        description_label.set_markup(
            "You can choose which local game sources will get synced each\n"
            "time Lutris starts, or launch an immediate import of games.")
        box_outer.pack_start(description_label, False, False, 5)

        separator = Gtk.Separator()
        box_outer.pack_start(separator, False, False, 0)

        for service in get_services():
            sync_row = ServiceSyncRow(service)
            box_outer.pack_start(sync_row, False, True, 0)
        box_outer.show_all()
Exemplo n.º 18
0
 def set_service(self, service_name):
     self.service = services.get_services()[service_name]()
Exemplo n.º 19
0
    def on_realize(self, widget):
        self.active_platforms = games_db.get_used_platforms()
        self.runners = sorted(runners.__all__)
        self.platforms = sorted(platforms.__all__)
        self.categories = categories_db.get_categories()

        self.add(
            SidebarRow(
                "all", "category", _("Games"),
                Gtk.Image.new_from_icon_name("applications-games-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "recent", "dynamic_category", _("Recent"),
                Gtk.Image.new_from_icon_name("document-open-recent-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "favorite", "category", _("Favorites"),
                Gtk.Image.new_from_icon_name("favorite-symbolic",
                                             Gtk.IconSize.MENU)))

        self.running_row = SidebarRow(
            "running", "dynamic_category", _("Running"),
            Gtk.Image.new_from_icon_name("media-playback-start-symbolic",
                                         Gtk.IconSize.MENU))
        # I wanted this to be on top but it really messes with the headers when showing/hiding the row.
        self.add(self.running_row)

        service_classes = services.get_services()
        for service_name in service_classes:
            service = service_classes[service_name]()
            row_class = OnlineServiceSidebarRow if service.online else ServiceSidebarRow
            service_row = row_class(service)
            self.service_rows[service_name] = service_row
            self.add(service_row)

        for runner_name in self.runners:
            icon_name = runner_name.lower().replace(" ", "") + "-symbolic"
            runner = runners.import_runner(runner_name)()
            self.add(
                RunnerSidebarRow(runner_name,
                                 "runner",
                                 runner.human_name,
                                 self.get_sidebar_icon(icon_name),
                                 application=self.application))

        for platform in self.platforms:
            icon_name = (platform.lower().replace(" ", "").replace("/", "_") +
                         "-symbolic")
            self.add(
                SidebarRow(platform, "platform", platform,
                           self.get_sidebar_icon(icon_name)))

        self.update()
        for row in self.get_children():
            if row.type == self.selected_row_type and row.id == self.selected_row_id:
                self.select_row(row)
                break
        self.show_all()
        self.running_row.hide()
Exemplo n.º 20
0
    def __init__(self, application, selected=None):
        super().__init__()
        self.application = application
        self.get_style_context().add_class("sidebar")
        self.installed_runners = []
        self.active_platforms = games_db.get_used_platforms()
        self.runners = sorted(runners.__all__)
        self.platforms = sorted(platforms.__all__)
        self.categories = categories_db.get_categories()
        if selected:
            row_type, row_id = selected.split(":")
        else:
            row_type, row_id = ("runner", "all")

        GObject.add_emission_hook(RunnersDialog, "runner-installed",
                                  self.update)
        GObject.add_emission_hook(RunnersDialog, "runner-removed", self.update)
        GObject.add_emission_hook(Game, "game-updated", self.update)
        GObject.add_emission_hook(Game, "game-removed", self.update)

        load_icon_theme()

        self.add(
            SidebarRow(
                "running", "dynamic_category", _("Running"),
                Gtk.Image.new_from_icon_name("media-playback-start-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "installed", "dynamic_category", _("Installed"),
                Gtk.Image.new_from_icon_name("drive-harddisk-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "favorite", "category", _("Favorites"),
                Gtk.Image.new_from_icon_name("favorite-symbolic",
                                             Gtk.IconSize.MENU)))

        service_classes = services.get_services()
        for service_name in service_classes:
            service = service_classes[service_name]()
            self.add(
                SidebarRow(
                    service.id, "service", service.name,
                    Gtk.Image.new_from_icon_name(service.icon,
                                                 Gtk.IconSize.MENU)))

        all_row = RunnerSidebarRow(None, "runner", _("All"), None)
        self.add(all_row)
        for runner_name in self.runners:
            icon_name = runner_name.lower().replace(" ", "") + "-symbolic"
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            runner = runners.import_runner(runner_name)()
            self.add(
                RunnerSidebarRow(runner_name,
                                 "runner",
                                 runner.human_name,
                                 icon,
                                 application=self.application))

        self.add(SidebarRow(None, "platform", _("All"), None))
        for platform in self.platforms:
            icon_name = (platform.lower().replace(" ", "").replace("/", "_") +
                         "-symbolic")
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            self.add(SidebarRow(platform, "platform", platform, icon))

        self.set_filter_func(self._filter_func)
        self.set_header_func(self._header_func)
        self.update()
        for row in self.get_children():
            if row.type == row_type and row.id == row_id:
                self.select_row(row)
                break
        self.show_all()