Fix game sorting, add extra 🍝

This commit is contained in:
kramo
2023-08-13 15:09:44 +02:00
parent 9670a98246
commit 21952e635a
9 changed files with 22 additions and 11 deletions

View File

@@ -69,6 +69,7 @@ class Game(Gtk.Box):
self.version = shared.SPEC_VERSION
self.update_values(data)
self.base_source = self.source.split("_")[0]
self.set_play_icon()

View File

@@ -20,7 +20,7 @@
import sys
from abc import abstractmethod
from collections.abc import Iterable
from typing import Any, Generator, Collection
from typing import Any, Collection, Generator
from src.game import Game
from src.importer.sources.location import Location

View File

@@ -153,7 +153,13 @@ class CartridgesApplication(Adw.Application):
shared.store.add_game(game, {"skip_save": True})
def get_source_name(self, source_id):
return globals()[f'{source_id.split("_")[0].title()}Source'].name
if source_id == "all":
name = _("All Games")
elif source_id == "imported":
name = _("Added")
else:
name = globals()[f'{source_id.split("_")[0].title()}Source'].name
return name
def on_about_action(self, *_args):
# Get the debug info from the log files

View File

@@ -18,7 +18,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import logging
from typing import MutableMapping, Generator, Any
from typing import Any, Generator, MutableMapping
from src import shared
from src.game import Game
@@ -44,7 +44,7 @@ class Store:
"""Check if the game is present in the store with the `in` keyword"""
if not isinstance(obj, Game):
return False
if not (source_mapping := self.source_games.get(obj.source)):
if not (source_mapping := self.source_games.get(obj.base_source)):
return False
return obj.game_id in source_mapping
@@ -133,9 +133,9 @@ class Store:
game.connect(signal, manager.run)
# Add the game to the store
if not game.source in self.source_games:
self.source_games[game.source] = {}
self.source_games[game.source][game.game_id] = game
if not game.base_source in self.source_games:
self.source_games[game.base_source] = {}
self.source_games[game.base_source][game.game_id] = game
# Run the pipeline for the game
if not run_pipeline:

View File

@@ -196,6 +196,8 @@ class CartridgesWindow(Adw.ApplicationWindow):
case _default:
value = self.source_rows[row][0]
self.library_page.set_title(self.get_application().get_source_name(value))
self.filter_state = value
self.library.invalidate_filter()
@@ -304,7 +306,7 @@ class CartridgesWindow(Adw.ApplicationWindow):
if not filtered:
if self.filter_state == "all":
pass
elif game.source != self.filter_state:
elif game.base_source != self.filter_state:
filtered = True
game.filtered = filtered