[gnome-games] mega-drive: Move cartridge types to simple types



commit e991afe30e125ab88f5bf176dd8996b50a574f4e
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu May 25 16:27:37 2017 +0200

    mega-drive: Move cartridge types to simple types
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783111

 plugins/mega-drive/src/mega-drive-plugin.vala |   64 +-----------------------
 src/retro/retro-simple-types.vala             |    3 +
 2 files changed, 6 insertions(+), 61 deletions(-)
---
diff --git a/plugins/mega-drive/src/mega-drive-plugin.vala b/plugins/mega-drive/src/mega-drive-plugin.vala
index 69d104d..b15ca4d 100644
--- a/plugins/mega-drive/src/mega-drive-plugin.vala
+++ b/plugins/mega-drive/src/mega-drive-plugin.vala
@@ -1,17 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private class Games.MegaDrivePlugin : Object, Plugin {
-       private const string MEGA_DRIVE_PREFIX = "mega-drive";
-       private const string MEGA_DRIVE_MIME_TYPE = "application/x-genesis-rom";
-       private const string MEGA_DRIVE_PLATFORM = "SegaGenesis";
-
-       private const string 32X_PREFIX = "mega-drive-32x";
        private const string 32X_MIME_TYPE = "application/x-genesis-32x-rom";
-       private const string 32X_PLATFORM = "Sega32X";
-
-       private const string PICO_PREFIX = "sega-pico";
-       private const string PICO_MIME_TYPE = "application/x-sega-pico-rom";
-       private const string PICO_PLATFORM = "SegaPico";
 
        private const string MEGA_CD_PREFIX = "mega-cd";
        private const string CUE_MIME_TYPE = "application/x-cue";
@@ -21,9 +11,6 @@ private class Games.MegaDrivePlugin : Object, Plugin {
 
        public string[] get_mime_types () {
                return {
-                       MEGA_DRIVE_MIME_TYPE,
-                       32X_MIME_TYPE,
-                       PICO_MIME_TYPE,
                        CUE_MIME_TYPE,
                        MEGA_CD_MIME_TYPE,
                };
@@ -32,59 +19,14 @@ private class Games.MegaDrivePlugin : Object, Plugin {
        public UriGameFactory[] get_uri_game_factories () {
                var game_uri_adapter = new GenericGameUriAdapter (game_for_uri);
                var factory = new GenericUriGameFactory (game_uri_adapter);
-               factory.add_mime_type (MEGA_DRIVE_MIME_TYPE);
-               factory.add_mime_type (32X_MIME_TYPE);
-               factory.add_mime_type (PICO_MIME_TYPE);
+               factory.add_mime_type (CUE_MIME_TYPE);
+               factory.add_mime_type (MEGA_CD_MIME_TYPE);
 
-               var cd_game_uri_adapter = new GenericGameUriAdapter (cd_game_for_uri);
-               var mega_cd_factory = new GenericUriGameFactory (cd_game_uri_adapter);
-               mega_cd_factory.add_mime_type (CUE_MIME_TYPE);
-               mega_cd_factory.add_mime_type (MEGA_CD_MIME_TYPE);
-
-               return { factory, mega_cd_factory };
+               return { factory };
        }
 
        private static Game game_for_uri (Uri uri) throws Error {
                var file = uri.to_file ();
-               var header = new MegaDriveHeader (file);
-               header.check_validity ();
-
-               string prefix;
-               string mime_type;
-               string platform;
-               if (header.is_mega_drive ()) {
-                       prefix = MEGA_DRIVE_PREFIX;
-                       mime_type = MEGA_DRIVE_MIME_TYPE;
-                       platform = MEGA_DRIVE_PLATFORM;
-               }
-               else if (header.is_32x ()) {
-                       prefix = 32X_PREFIX;
-                       mime_type = 32X_MIME_TYPE;
-                       platform = 32X_PLATFORM;
-               }
-               else if (header.is_pico ()) {
-                       prefix = PICO_PREFIX;
-                       mime_type = PICO_MIME_TYPE;
-                       platform = PICO_PLATFORM;
-               }
-               else
-                       assert_not_reached ();
-
-               var uid = new FingerprintUid (uri, prefix);
-               var title = new FilenameTitle (uri);
-               var icon = new DummyIcon ();
-               var media = new GriloMedia (title, mime_type);
-               var cover = new CompositeCover ({
-                       new LocalCover (uri),
-                       new GriloCover (media, uid)});
-               var core_source = new RetroCoreSource (platform, { mime_type });
-               var runner = new RetroRunner (core_source, uri, uid, title);
-
-               return new GenericGame (title, icon, cover, runner);
-       }
-
-       private static Game cd_game_for_uri (Uri uri) throws Error {
-               var file = uri.to_file ();
                var file_info = file.query_info (FileAttribute.STANDARD_CONTENT_TYPE, 
FileQueryInfoFlags.NONE);
                var mime_type = file_info.get_content_type ();
 
diff --git a/src/retro/retro-simple-types.vala b/src/retro/retro-simple-types.vala
index 7cc6f84..39026be 100644
--- a/src/retro/retro-simple-types.vala
+++ b/src/retro/retro-simple-types.vala
@@ -11,6 +11,9 @@ namespace Games {
                { "application/x-gameboy-rom", true, "GameBoy", "game-boy" },
                { "application/x-gamegear-rom", true, "GameGear", "game-gear" },
                { "application/x-gba-rom", true, "GameBoyAdvance", "game-boy-advance" },
+               { "application/x-genesis-32x-rom", true, "Sega32X", "mega-drive-32x" },
+               { "application/x-genesis-rom", true, "SegaGenesis", "mega-drive" },
+               { "application/x-sega-pico-rom", true, "SegaPico", "sega-pico" },
                { "application/x-sg1000-rom", true, "SG1000", "sg-1000" },
                { "application/x-sms-rom", true, "MasterSystem", "master-system" },
        };


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