[gnome-games/wip/exalm/rebrand: 67/124] Introduce GameParser
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 67/124] Introduce GameParser
- Date: Sat, 19 Jun 2021 14:37:45 +0000 (UTC)
commit 78339aa243769cba86724a649b4704db03b85597
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 30 01:51:04 2021 +0500
Introduce GameParser
src/core/game-parser.vala | 25 +++++++++++++++++++++++++
src/core/platform.vala | 1 +
src/meson.build | 1 +
src/retro/retro-simple-game-uri-adapter.vala | 13 ++++++++++---
4 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/src/core/game-parser.vala b/src/core/game-parser.vala
new file mode 100644
index 00000000..ccf903d0
--- /dev/null
+++ b/src/core/game-parser.vala
@@ -0,0 +1,25 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.GameParser : Object {
+ public Platform platform { get; construct; }
+ public Uri uri { get; construct; }
+
+ public GameParser (Platform platform, Uri uri) {
+ Object (platform: platform, uri: uri);
+ }
+
+ public virtual void parse () throws Error {
+ }
+
+ public virtual string get_uid () throws Error {
+ return Fingerprint.get_uid (uri, platform.get_uid_prefix ());
+ }
+
+ public virtual Title get_title () {
+ return new FilenameTitle (uri);
+ }
+
+ public virtual Icon? get_icon () {
+ return null;
+ }
+}
diff --git a/src/core/platform.vala b/src/core/platform.vala
index fe3ffe0a..e05ff158 100644
--- a/src/core/platform.vala
+++ b/src/core/platform.vala
@@ -10,6 +10,7 @@ public class Games.Platform : Object {
public bool autodiscovery { get; set; }
public Type snapshot_type { get; set; default = typeof (Snapshot); }
public Type runner_type { get; set; default = typeof (Runner); }
+ public Type parser_type { get; set; default = typeof (GameParser); }
public Platform (string id, string name, string mime_type, string prefix) {
this.id = id;
diff --git a/src/meson.build b/src/meson.build
index 657128aa..0ba31d38 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -29,6 +29,7 @@ vala_sources = [
'core/game-callback.vala',
'core/game-collection.vala',
'core/game-model.vala',
+ 'core/game-parser.vala',
'core/game-uri-adapter.vala',
'core/icon.vala',
'core/input-capabilities.vala',
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index 05acad84..4bb45662 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -1,6 +1,6 @@
// This file is part of GNOME Games. License: GPL-3.0+.
-private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
+public class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
private Platform platform;
public RetroSimpleGameUriAdapter (Platform platform) {
@@ -8,15 +8,22 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
}
public Game game_for_uri (Uri uri) throws Error {
- var uid = new Uid (Fingerprint.get_uid (uri, platform.get_uid_prefix ()));
- var title = new FilenameTitle (uri);
+ var parser = Object.new (platform.parser_type, platform: platform, uri: uri) as GameParser;
+
+ parser.parse ();
+
+ var uid = new Uid (parser.get_uid ());
+ var title = parser.get_title ();
var media = new GriloMedia (title, platform.get_presentation_mime_type ());
var cover = new CompositeCover ({
new LocalCover (uri),
new GriloCover (media, uid)});
+ var icon = parser.get_icon ();
var game = new Game (uid, uri, title, platform);
game.set_cover (cover);
+ if (icon != null)
+ game.set_icon (icon);
return game;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]