[gnome-games/wip/exalm/rebrand: 52/124] mame: Stop using MameGameUriAdapter
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/rebrand: 52/124] mame: Stop using MameGameUriAdapter
- Date: Sat, 19 Jun 2021 14:37:44 +0000 (UTC)
commit 00b15d17bdf8f4f58a3537aeb173c8db54200980
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Mar 29 22:05:08 2021 +0500
mame: Stop using MameGameUriAdapter
GenericGameUriAdapter works juts fine here.
plugins/mame/src/mame-game-uri-adapter.vala | 34 -----------------------------
plugins/mame/src/mame-plugin.vala | 27 ++++++++++++++++++++++-
plugins/mame/src/meson.build | 1 -
3 files changed, 26 insertions(+), 36 deletions(-)
---
diff --git a/plugins/mame/src/mame-plugin.vala b/plugins/mame/src/mame-plugin.vala
index 122ae4b0..130e5c61 100644
--- a/plugins/mame/src/mame-plugin.vala
+++ b/plugins/mame/src/mame-plugin.vala
@@ -23,7 +23,7 @@ private class Games.MamePlugin : Object, Plugin {
}
public UriGameFactory[] get_uri_game_factories () {
- var game_uri_adapter = new MameGameUriAdapter (platform);
+ var game_uri_adapter = new GenericGameUriAdapter (game_for_uri);
var factory = new GenericUriGameFactory (game_uri_adapter);
factory.add_mime_type (SEARCHED_MIME_TYPE);
@@ -35,6 +35,31 @@ private class Games.MamePlugin : Object, Plugin {
return { factory };
}
+
+ private static Game game_for_uri (Uri uri) throws Error {
+ var supported_games = MameGameInfo.get_supported_games ();
+
+ var file = uri.to_file ();
+ var game_id = file.get_basename ();
+ game_id = /\.zip$/.replace (game_id, game_id.length, 0, "");
+
+ if (!supported_games.contains (game_id))
+ throw new MameError.INVALID_GAME_ID ("Invalid MAME game id ā%sā for ā%sā.", game_id,
uri.to_string ());
+
+ var uid_string = @"mame-$game_id".down ();
+ var uid = new Uid (uid_string);
+
+ var title_string = supported_games[game_id];
+ title_string = title_string.split ("(")[0];
+ title_string = title_string.strip ();
+ var title = new GenericTitle (title_string);
+ var cover = new LocalCover (uri);
+
+ var game = new Game (uid, uri, title, platform);
+ game.set_cover (cover);
+
+ return game;
+ }
}
[ModuleInit]
diff --git a/plugins/mame/src/meson.build b/plugins/mame/src/meson.build
index 68adffba..40706c2c 100644
--- a/plugins/mame/src/meson.build
+++ b/plugins/mame/src/meson.build
@@ -1,7 +1,6 @@
vala_sources = [
'mame-error.vala',
'mame-game-info.vala',
- 'mame-game-uri-adapter.vala',
'mame-plugin.vala',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]