[gnome-games/wip/exalm/loading: 19/29] playstation: Cache game info
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/loading: 19/29] playstation: Cache game info
- Date: Mon, 11 Nov 2019 21:46:15 +0000 (UTC)
commit 07110a5a21fe35a6965f275418b39d085bedc6fe
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Nov 12 02:31:54 2019 +0500
playstation: Cache game info
This is required to separate runner creation, since it cannot reference
PlaystationGameFactory.
plugins/playstation/src/meson.build | 1 +
.../playstation/src/playstation-game-factory.vala | 7 +++++-
.../src/playstation-gameinfo-cache.vala | 26 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
---
diff --git a/plugins/playstation/src/meson.build b/plugins/playstation/src/meson.build
index 1871682c..8f60a5f5 100644
--- a/plugins/playstation/src/meson.build
+++ b/plugins/playstation/src/meson.build
@@ -2,6 +2,7 @@ vala_sources = [
'playstation-error.vala',
'playstation-game-factory.vala',
'playstation-header.vala',
+ 'playstation-gameinfo-cache.vala',
'playstation-plugin.vala',
'playstation-uid.vala',
]
diff --git a/plugins/playstation/src/playstation-game-factory.vala
b/plugins/playstation/src/playstation-game-factory.vala
index b8a7c33b..dc1d8a3b 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -7,6 +7,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
private const string GAMEINFO =
"resource:///org/gnome/Games/plugin/playstation/playstation.gameinfo.xml";
private static GameinfoDoc gameinfo;
+ private PlaystationGameinfoCache gameinfo_cache;
private HashTable<string, Media> media_for_disc_id;
private HashTable<Uri, Game> game_for_uri;
@@ -14,12 +15,13 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
private GenericSet<Game> games;
private RetroPlatform platform;
- public PlayStationGameFactory (RetroPlatform platform) {
+ public PlayStationGameFactory (RetroPlatform platform, PlaystationGameinfoCache gameinfo_cache) {
media_for_disc_id = new HashTable<string, Media> (str_hash, str_equal);
game_for_uri = new HashTable<Uri, Game> (Uri.hash, Uri.equal);
game_for_disc_set_id = new HashTable<string, Game> (GLib.str_hash, GLib.str_equal);
games = new GenericSet<Game> (direct_hash, direct_equal);
this.platform = platform;
+ this.gameinfo_cache = gameinfo_cache;
}
public string[] get_mime_types () {
@@ -125,6 +127,9 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
game_for_disc_set_id[disc_set_id] = game;
games.add (game);
game_added (game);
+
+ var input_capabilities = new GameinfoDiscIdInputCapabilities (gameinfo, disc_set_id);
+ gameinfo_cache.store_info (uri, media_set, input_capabilities);
}
public async void foreach_game (GameCallback game_callback) {
diff --git a/plugins/playstation/src/playstation-gameinfo-cache.vala
b/plugins/playstation/src/playstation-gameinfo-cache.vala
new file mode 100644
index 00000000..8446de09
--- /dev/null
+++ b/plugins/playstation/src/playstation-gameinfo-cache.vala
@@ -0,0 +1,26 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.PlaystationGameinfoCache : Object {
+ private struct InfoCache {
+ MediaSet media_set;
+ InputCapabilities input_capabilities;
+ }
+
+ private HashTable<Uri, InfoCache?> info_for_uri;
+
+ construct {
+ info_for_uri = new HashTable<Uri, InfoCache?> (Uri.hash, Uri.equal);
+ }
+
+ public void store_info (Uri uri, MediaSet media_set, InputCapabilities input_capabilities) {
+ info_for_uri[uri] = { media_set, input_capabilities };
+ }
+
+ public MediaSet get_media_set (Uri uri) {
+ return info_for_uri[uri].media_set;
+ }
+
+ public InputCapabilities get_input_capabilities (Uri uri) {
+ return info_for_uri[uri].input_capabilities;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]