[gnome-games/wip/exalm/rebrand: 70/124] game-cube: Migrate to a game parser
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 70/124] game-cube: Migrate to a game parser
- Date: Sat, 19 Jun 2021 14:37:45 +0000 (UTC)
commit ff00e01c62ec9177f839212643374e6864d558f1
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Tue Mar 30 02:04:22 2021 +0500
game-cube: Migrate to a game parser
plugins/game-cube/src/game-cube-parser.vala | 24 ++++++++++++++++++++++++
plugins/game-cube/src/game-cube-plugin.vala | 27 ++-------------------------
plugins/game-cube/src/meson.build | 1 +
3 files changed, 27 insertions(+), 25 deletions(-)
---
diff --git a/plugins/game-cube/src/game-cube-parser.vala b/plugins/game-cube/src/game-cube-parser.vala
new file mode 100644
index 00000000..a311b7ed
--- /dev/null
+++ b/plugins/game-cube/src/game-cube-parser.vala
@@ -0,0 +1,24 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public class Games.GameCubeParser : GameParser {
+ private string uid;
+
+ public GameCubeParser (Platform platform, Uri uri) {
+ base (platform, uri);
+ }
+
+ public override void parse () throws Error {
+ var file = uri.to_file ();
+ var header = new GameCubeHeader (file);
+ header.check_validity ();
+
+ var prefix = platform.get_uid_prefix ();
+ var game_id = header.get_game_id ();
+
+ uid = @"$prefix-$game_id".down ();
+ }
+
+ public override string get_uid () {
+ return uid;
+ }
+}
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 99248f68..70c0a429 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -11,6 +11,7 @@ private class Games.GameCubePlugin : Object, Plugin {
static construct {
platform = new Platform (PLATFORM_ID, PLATFORM_NAME, MIME_TYPE, PLATFORM_UID_PREFIX);
platform.runner_type = typeof (GameCubeRunner);
+ platform.parser_type = typeof (GameCubeParser);
}
public Platform[] get_platforms () {
@@ -18,36 +19,12 @@ private class Games.GameCubePlugin : 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 string get_uid (GameCubeHeader header) throws Error {
- var game_id = header.get_game_id ();
-
- return @"$PLATFORM_UID_PREFIX-$game_id".down ();
- }
-
- private static Game game_for_uri (Uri uri) throws Error {
- var file = uri.to_file ();
- var header = new GameCubeHeader (file);
- header.check_validity ();
-
- var uid = new Uid (get_uid (header));
- 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]
diff --git a/plugins/game-cube/src/meson.build b/plugins/game-cube/src/meson.build
index 49ab86b0..dcd032c2 100644
--- a/plugins/game-cube/src/meson.build
+++ b/plugins/game-cube/src/meson.build
@@ -1,5 +1,6 @@
vala_sources = [
'game-cube-header.vala',
+ 'game-cube-parser.vala',
'game-cube-plugin.vala',
'game-cube-runner.vala',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]