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

@@ -19,6 +19,7 @@
<file alias="itch-source-symbolic.svg">icons/sources/itch-source-symbolic.svg</file> <file alias="itch-source-symbolic.svg">icons/sources/itch-source-symbolic.svg</file>
<file alias="legendary-source-symbolic.svg">icons/sources/legendary-source-symbolic.svg</file> <file alias="legendary-source-symbolic.svg">icons/sources/legendary-source-symbolic.svg</file>
<file alias="lutris-source-symbolic.svg">icons/sources/lutris-source-symbolic.svg</file> <file alias="lutris-source-symbolic.svg">icons/sources/lutris-source-symbolic.svg</file>
<file alias="retroarch-source-symbolic.svg">icons/sources/retroarch-source-symbolic.svg</file>
<file alias="steam-source-symbolic.svg">icons/sources/steam-source-symbolic.svg</file> <file alias="steam-source-symbolic.svg">icons/sources/steam-source-symbolic.svg</file>
</gresource> </gresource>
</gresources> </gresources>

View File

@@ -72,7 +72,7 @@ template $CartridgesWindow : Adw.ApplicationWindow {
Adw.ToastOverlay toast_overlay { Adw.ToastOverlay toast_overlay {
Adw.NavigationView navigation_view { Adw.NavigationView navigation_view {
Adw.NavigationPage library_page { Adw.NavigationPage library_page {
title: _("Cartridges"); title: _("All Games");
Adw.OverlaySplitView overlay_split_view { Adw.OverlaySplitView overlay_split_view {
[sidebar] [sidebar]

View File

@@ -97,10 +97,10 @@
</schema> </schema>
<schema id="@APP_ID@.State" path="@PREFIX@/State/"> <schema id="@APP_ID@.State" path="@PREFIX@/State/">
<key name="width" type="i"> <key name="width" type="i">
<default>1110</default> <default>1170</default>
</key> </key>
<key name="height" type="i"> <key name="height" type="i">
<default>795</default> <default>798</default>
</key> </key>
<key name="is-maximized" type="b"> <key name="is-maximized" type="b">
<default>false</default> <default>false</default>

View File

@@ -0,0 +1 @@
<svg width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.56 4 5.6 5.28H3.52L3.04 7.2H1.76l.48-1.92H.96L0 9.12h2.56l-.32 1.28h2.24L2.8 12.32h1.88l1.56-1.92h3.52l1.56 1.92h1.88l-1.68-1.92h2.24l-.32-1.28H16l-.96-3.84h-1.28l.48 1.92h-1.28l-.48-1.92H10.4L11.44 4h-1.36L8.96 5.28H7.04L5.92 4H4.56Zm.16 2.56H6v1.28H4.72V6.56Zm5.283 0h1.28v1.28h-1.28V6.56Z" fill="#000"/></svg>

After

Width:  |  Height:  |  Size: 399 B

View File

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

View File

@@ -20,7 +20,7 @@
import sys import sys
from abc import abstractmethod from abc import abstractmethod
from collections.abc import Iterable from collections.abc import Iterable
from typing import Any, Generator, Collection from typing import Any, Collection, Generator
from src.game import Game from src.game import Game
from src.importer.sources.location import Location 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}) shared.store.add_game(game, {"skip_save": True})
def get_source_name(self, source_id): 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): def on_about_action(self, *_args):
# Get the debug info from the log files # Get the debug info from the log files

View File

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

View File

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