[gnome-games/wip/exalm/rebrand: 75/124] nintendo-ds: Migrate to a game parser
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 75/124] nintendo-ds: Migrate to a game parser
- Date: Sat, 19 Jun 2021 14:37:45 +0000 (UTC)
commit f6168c00bc9cad155675fe486191d377819305fc
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 30 02:10:34 2021 +0500
nintendo-ds: Migrate to a game parser
plugins/nintendo-ds/src/meson.build | 1 +
plugins/nintendo-ds/src/nintendo-ds-parser.vala | 17 +++++++++++++++++
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 19 ++-----------------
3 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/meson.build b/plugins/nintendo-ds/src/meson.build
index 62cda3ce..dc576752 100644
--- a/plugins/nintendo-ds/src/meson.build
+++ b/plugins/nintendo-ds/src/meson.build
@@ -1,6 +1,7 @@
vala_sources = [
'nintendo-ds-icon.vala',
'nintendo-ds-layout.vala',
+ 'nintendo-ds-parser.vala',
'nintendo-ds-plugin.vala',
'nintendo-ds-runner.vala',
'nintendo-ds-snapshot.vala',
diff --git a/plugins/nintendo-ds/src/nintendo-ds-parser.vala b/plugins/nintendo-ds/src/nintendo-ds-parser.vala
new file mode 100644
index 00000000..735e0424
--- /dev/null
+++ b/plugins/nintendo-ds/src/nintendo-ds-parser.vala
@@ -0,0 +1,17 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.NintendoDsParser : GameParser {
+ private Icon icon;
+
+ public NintendoDsParser (Platform platform, Uri uri) {
+ base (platform, uri);
+ }
+
+ public override void parse () throws Error {
+ icon = new NintendoDsIcon (uri);
+ }
+
+ public override Icon? get_icon () {
+ return icon;
+ }
+}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 401c106d..dcc1c05e 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -12,6 +12,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
platform = new Platform (PLATFORM_ID, PLATFORM_NAME, MIME_TYPE, PLATFORM_UID_PREFIX);
platform.snapshot_type = typeof (NintendoDsSnapshot);
platform.runner_type = typeof (NintendoDsRunner);
+ platform.parser_type = typeof (NintendoDsParser);
}
public Platform[] get_platforms () {
@@ -19,28 +20,12 @@ private class Games.NintendoDsPlugin : Object, Plugin {
}
public UriGameFactory[] get_uri_game_factories () {
- var game_uri_adapter = new GenericGameUriAdapter (game_for_uri);
+ var game_uri_adapter = new RetroSimpleGameUriAdapter (platform);
var factory = new GenericUriGameFactory (game_uri_adapter);
factory.add_mime_type (MIME_TYPE);
return { factory };
}
-
- private static Game game_for_uri (Uri uri) throws Error {
- var uid = new Uid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
- var title = new FilenameTitle (uri);
- var icon = new NintendoDsIcon (uri);
- var media = new GriloMedia (title, MIME_TYPE);
- var cover = new CompositeCover ({
- new LocalCover (uri),
- new GriloCover (media, uid)});
-
- var game = new Game (uid, uri, title, platform);
- game.set_icon (icon);
- game.set_cover (cover);
-
- return game;
- }
}
[ModuleInit]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]