[gnome-games] mame: Replace MameGame by GenericGame



commit 7716edc0396e5d22b5451967dd93b038e4068ebb
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu May 12 08:59:22 2016 +0200

    mame: Replace MameGame by GenericGame
    
    This is needed to remove custom game types and to simplify the code
    base.

 plugins/mame/src/Makefile.am      |    1 -
 plugins/mame/src/mame-game.vala   |   51 -------------------------------------
 plugins/mame/src/mame-plugin.vala |   26 ++++++++++++++++++-
 3 files changed, 25 insertions(+), 53 deletions(-)
---
diff --git a/plugins/mame/src/Makefile.am b/plugins/mame/src/Makefile.am
index 93d3fc0..c1d2264 100644
--- a/plugins/mame/src/Makefile.am
+++ b/plugins/mame/src/Makefile.am
@@ -30,7 +30,6 @@ libgames_mame_plugin_la_DEPENDENCIES = \
 
 libgames_mame_plugin_la_SOURCES = \
        mame-error.vala \
-       mame-game.vala \
        mame-game-info.vala \
        mame-plugin.vala \
        $(BUILT_SOURCES) \
diff --git a/plugins/mame/src/mame-plugin.vala b/plugins/mame/src/mame-plugin.vala
index d5996fc..2a4a9ba 100644
--- a/plugins/mame/src/mame-plugin.vala
+++ b/plugins/mame/src/mame-plugin.vala
@@ -1,7 +1,9 @@
 // This file is part of GNOME Games. License: GPLv3
 
 private class Games.MamePlugin : Object, Plugin {
+       private const string MODULE_BASENAME = "libretro-mame.so";
        private const string MIME_TYPE = "application/zip";
+       private const bool SUPPORTS_SNAPSHOTTING = false;
 
        public GameSource get_game_source () throws Error {
                var query = new MimeTypeTrackerQuery (MIME_TYPE, game_for_uri);
@@ -13,7 +15,29 @@ private class Games.MamePlugin : Object, Plugin {
        }
 
        private static Game game_for_uri (string uri) throws Error {
-               return new MameGame (uri);
+               var supported_games = MameGameInfo.get_supported_games ();
+
+               var file = File.new_for_uri (uri);
+               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);
+
+               var uid_string = @"mame-$game_id".down ();
+               var uid = new GenericUid (uid_string);
+
+               var info = supported_games[game_id];
+               var title_string = info.name;
+               title_string = title_string.split ("(")[0];
+               title_string = title_string.strip ();
+               var title = new GenericTitle (title_string);
+
+               var icon = new DummyIcon ();
+               var cover = new DummyCover ();
+               var runner =  new RetroRunner (MODULE_BASENAME, uri, uid, SUPPORTS_SNAPSHOTTING);
+
+               return new GenericGame (title, icon, cover, runner);
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]