[gnome-games/wip/exalm/rebrand: 61/102] virtual-boy: Migrate to a game parser
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 61/102] virtual-boy: Migrate to a game parser
- Date: Thu, 8 Apr 2021 21:29:44 +0000 (UTC)
commit 0c4145cc42e36e1c86d04f00fb2f0b17f95a4dc5
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 30 04:00:15 2021 +0500
virtual-boy: Migrate to a game parser
plugins/virtual-boy/src/meson.build | 1 +
plugins/virtual-boy/src/virtual-boy-parser.vala | 14 ++++++++++++++
plugins/virtual-boy/src/virtual-boy-plugin.vala | 22 ++--------------------
3 files changed, 17 insertions(+), 20 deletions(-)
---
diff --git a/plugins/virtual-boy/src/meson.build b/plugins/virtual-boy/src/meson.build
index d72f2754..08b23844 100644
--- a/plugins/virtual-boy/src/meson.build
+++ b/plugins/virtual-boy/src/meson.build
@@ -1,5 +1,6 @@
vala_sources = [
'virtual-boy-header.vala',
+ 'virtual-boy-parser.vala',
'virtual-boy-plugin.vala',
]
diff --git a/plugins/virtual-boy/src/virtual-boy-parser.vala b/plugins/virtual-boy/src/virtual-boy-parser.vala
new file mode 100644
index 00000000..48518aeb
--- /dev/null
+++ b/plugins/virtual-boy/src/virtual-boy-parser.vala
@@ -0,0 +1,14 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.VirtualBoyParser : GameParser {
+ public VirtualBoyParser (Platform platform, Uri uri) {
+ base (platform, uri);
+ }
+
+ public override void parse () throws Error {
+ var file = uri.to_file ();
+
+ var header = new VirtualBoyHeader (file);
+ header.check_validity ();
+ }
+}
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index df8e5fcf..f57ac3b2 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -10,6 +10,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
static construct {
platform = new Platform (PLATFORM_ID, PLATFORM_NAME, MIME_TYPE, PLATFORM_UID_PREFIX);
+ platform.parser_type = typeof (VirtualBoyParser);
}
public Platform[] get_platforms () {
@@ -17,31 +18,12 @@ private class Games.VirtualBoyPlugin : 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 file = uri.to_file ();
-
- var header = new VirtualBoyHeader (file);
- header.check_validity ();
-
- var uid = new Uid (Fingerprint.get_uid (uri, PLATFORM_UID_PREFIX));
- var title = new FilenameTitle (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_cover (cover);
-
- return game;
- }
}
[ModuleInit]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]