[gnome-games] generic: Pass platform to GenericGame



commit b990be83136f485d700040965c60b14ca2c4da4d
Author: 1PunMan <saurabhsingh412 gmail com>
Date:   Tue Jun 26 16:44:17 2018 +0530

    generic: Pass platform to GenericGame
    
    Also update plugins and RetroSimpleGameUriAdapter.

 plugins/desktop/src/desktop-plugin.vala               |  4 +++-
 plugins/dreamcast/src/dreamcast-plugin.vala           |  4 +++-
 plugins/game-cube/src/game-cube-plugin.vala           |  4 +++-
 plugins/libretro/src/libretro-plugin.vala             |  4 +++-
 plugins/love/src/love-plugin.vala                     |  4 +++-
 plugins/mame/src/mame-game-uri-adapter.vala           |  4 +++-
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala       |  4 +++-
 plugins/playstation/src/playstation-game-factory.vala |  4 +++-
 plugins/sega-cd/src/sega-cd-plugin.vala               | 16 +++++++++++-----
 plugins/sega-saturn/src/sega-saturn-plugin.vala       |  4 +++-
 plugins/steam/src/steam-plugin.vala                   |  4 +++-
 plugins/turbografx-cd/src/turbografx-cd-plugin.vala   |  4 +++-
 plugins/virtual-boy/src/virtual-boy-plugin.vala       |  4 +++-
 plugins/wii/src/wii-plugin.vala                       |  6 ++++--
 src/generic/generic-game.vala                         |  3 ++-
 src/retro/retro-simple-game-uri-adapter.vala          |  4 +++-
 16 files changed, 56 insertions(+), 21 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index b630f5fa..f9992737 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -2,6 +2,7 @@
 
 private class Games.DesktopPlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-desktop";
+       private const string PLATFORM_NAME = _("Desktop");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -41,6 +42,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                var uid = new DesktopUid (app_info);
                var title = new DesktopTitle (app_info);
                var icon = new DesktopIcon (app_info);
+               var platform = new GenericPlatform (PLATFORM_NAME);
 
                string[] args;
                var command = app_info.get_commandline ();
@@ -48,7 +50,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                        throw new CommandError.INVALID_COMMAND (_("Invalid command “%s”."), command);
                var runner = new CommandRunner (args, true);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
 
                return game;
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 427434f9..c191a2c3 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -3,6 +3,7 @@
 private class Games.DreamcastPlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-dc-rom";
        private const string PLATFORM = "Dreamcast";
+       private const string PLATFORM_NAME = _("Dreamcast");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -35,10 +36,11 @@ private class Games.DreamcastPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 80a5b6a5..40f63331 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -3,6 +3,7 @@
 private class Games.GameCubePlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-gamecube-rom";
        private const string PLATFORM = "GameCube";
+       private const string PLATFORM_NAME = _("Nintendo GameCube");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -35,10 +36,11 @@ private class Games.GameCubePlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index 0aa4d039..c8b212a7 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -2,6 +2,7 @@
 
 private class Games.LibretroPlugin : Object, Plugin {
        private const string LIBRETRO_FILE_SCHEME = "libretro+file";
+       private const string PLATFORM_NAME = _("Libretro");
 
        public UriSource[] get_uri_sources () {
                var source = new LibretroUriSource ();
@@ -31,9 +32,10 @@ private class Games.LibretroPlugin : Object, Plugin {
                var uid = new LibretroUid (core_descriptor);
                var title = new LibretroTitle (core_descriptor);
                var icon = new LibretroIcon (core_descriptor);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var runner = new RetroRunner.for_core_descriptor (core_descriptor, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
 
                return game;
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index e83356d8..3cbdac16 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -3,6 +3,7 @@
 private class Games.LovePlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "love";
        private const string MIME_TYPE = "application/x-love-game";
+       private const string PLATFORM_NAME = _("LÖVE");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -22,10 +23,11 @@ private class Games.LovePlugin : Object, Plugin {
                var title = new LoveTitle (package);
                var icon = new LoveIcon (package);
                var cover = new LocalCover (uri);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                string[] args = { "love", uri.to_string () };
                var runner = new CommandRunner (args, true);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
                game.set_cover (cover);
 
diff --git a/plugins/mame/src/mame-game-uri-adapter.vala b/plugins/mame/src/mame-game-uri-adapter.vala
index b036d193..5e98250f 100644
--- a/plugins/mame/src/mame-game-uri-adapter.vala
+++ b/plugins/mame/src/mame-game-uri-adapter.vala
@@ -4,6 +4,7 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
        private const string SEARCHED_MIME_TYPE = "application/zip";
        private const string SPECIFIC_MIME_TYPE = "application/x-mame-rom";
        private const string PLATFORM = "MAME";
+       private const string PLATFORM_NAME = _("Arcade");
 
        public async Game game_for_uri (Uri uri) throws Error {
                var supported_games = yield MameGameInfo.get_supported_games ();
@@ -25,13 +26,14 @@ private class Games.MameGameUriAdapter : GameUriAdapter, Object {
                var title = new GenericTitle (title_string);
 
                var cover = new LocalCover (uri);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { SEARCHED_MIME_TYPE, SPECIFIC_MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
                Idle.add (this.game_for_uri.callback);
                yield;
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
 
                return game;
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index 20cdee06..3c99199d 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -4,6 +4,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "nintendo-ds";
        private const string MIME_TYPE = "application/x-nintendo-ds-rom";
        private const string PLATFORM = "NintendoDS";
+       private const string PLATFORM_NAME = _("Nintendo DS");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -33,10 +34,11 @@ private class Games.NintendoDsPlugin : Object, Plugin {
                var cover = new CompositeCover ({
                        new LocalCover (uri),
                        new GriloCover (media, uid)});
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
                game.set_cover (cover);
                game.set_release_date (release_date);
diff --git a/plugins/playstation/src/playstation-game-factory.vala 
b/plugins/playstation/src/playstation-game-factory.vala
index 83d7386f..8dacb0d9 100644
--- a/plugins/playstation/src/playstation-game-factory.vala
+++ b/plugins/playstation/src/playstation-game-factory.vala
@@ -4,6 +4,7 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
        private const string CUE_MIME_TYPE = "application/x-cue";
        private const string PHONY_MIME_TYPE = "application/x-playstation-rom";
        private const string PLATFORM = "PlayStation";
+       private const string PLATFORM_NAME = _("PlayStation");
        private const string ICON_NAME = "media-optical-symbolic";
        private const string GAMEINFO = 
"resource:///org/gnome/Games/plugin/playstation/playstation.gameinfo.xml";
 
@@ -150,11 +151,12 @@ public class Games.PlayStationGameFactory : Object, UriGameFactory {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var input_capabilities = new GameinfoDiscIdInputCapabilities (gameinfo, disc_set_id);
                var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
                var runner = new RetroRunner.for_media_set_and_input_capabilities (core_source, media_set, 
uid, input_capabilities, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 62ea18a0..566bcd7a 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -8,6 +8,8 @@ private class Games.SegaCDPlugin : Object, Plugin {
        private const string SEGA_CD_MIME_TYPE = "application/x-sega-cd-rom";
        private const string SEGA_CD_PLATFORM = "SegaCD";
        private const string SEGA_CD_32X_PLATFORM = "SegaCD32X";
+       private const string SEGA_CD_PLATFORM_NAME = _("Sega CD");
+       private const string SEGA_CD_32X_PLATFORM_NAME = _("Sega CD 32X");
 
        public string[] get_mime_types () {
                return { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
@@ -46,14 +48,17 @@ private class Games.SegaCDPlugin : Object, Plugin {
                header.check_validity ();
 
                string[] mime_types;
-               string platform;
+               string generic_platform;
+               string platform_name;
                if (header.is_sega_cd ()) {
                        mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE };
-                       platform = SEGA_CD_PLATFORM;
+                       generic_platform = SEGA_CD_PLATFORM;
+                       platform_name = SEGA_CD_PLATFORM_NAME;
                }
                else if (header.is_sega_cd_32x ()) {
                        mime_types = { CUE_MIME_TYPE, SEGA_CD_MIME_TYPE, 32X_MIME_TYPE };
-                       platform = SEGA_CD_32X_PLATFORM;
+                       generic_platform = SEGA_CD_32X_PLATFORM;
+                       platform_name = SEGA_CD_32X_PLATFORM_NAME;
                }
                else
                        assert_not_reached ();
@@ -74,10 +79,11 @@ private class Games.SegaCDPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
-               var core_source = new RetroCoreSource (platform, mime_types);
+               var platform = new GenericPlatform (platform_name);
+               var core_source = new RetroCoreSource (generic_platform, mime_types);
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index be25c931..7cf98c83 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -4,6 +4,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
        private const string CUE_MIME_TYPE = "application/x-cue";
        private const string SEGA_SATURN_MIME_TYPE = "application/x-saturn-rom";
        private const string PLATFORM = "SegaSaturn";
+       private const string PLATFORM_NAME = _("Sega Saturn");
 
        public string[] get_mime_types () {
                return {
@@ -58,10 +59,11 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { CUE_MIME_TYPE, SEGA_SATURN_MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 5aa19ec6..b75896b7 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -2,6 +2,7 @@
 
 private class Games.SteamPlugin : Object, Plugin {
        private const string STEAM_FILE_SCHEME = "steam+file";
+       private const string PLATFORM_NAME = _("Steam");
 
        private static HashTable<string, Game> game_for_id;
 
@@ -54,10 +55,11 @@ private class Games.SteamPlugin : Object, Plugin {
                var title = new SteamTitle (registry);
                var icon = new SteamIcon (game_id);
                var cover = new SteamCover (game_id);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                string[] args = { "steam", @"steam://rungameid/" + game_id };
                var runner = new CommandRunner (args, false);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
                game.set_cover (cover);
 
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 827605b2..a1797e37 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -6,6 +6,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
        private const string CUE_MIME_TYPE = "application/x-cue";
        private const string CD_MAGIC_VALUE = "PC Engine CD-ROM SYSTEM";
        private const string CD_PLATFORM = "TurboGrafxCD";
+       private const string PLATFORM_NAME = _("TurboGrafx-CD");
 
        public string[] get_mime_types () {
                return { CUE_MIME_TYPE };
@@ -37,10 +38,11 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (CD_PLATFORM, { CUE_MIME_TYPE, PHONY_MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index e0db9769..d74f6091 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -4,6 +4,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
        private const string FINGERPRINT_PREFIX = "virtual-boy";
        private const string MIME_TYPE = "application/x-virtual-boy-rom";
        private const string PLATFORM = "VirtualBoy";
+       private const string PLATFORM_NAME = _("Virtual Boy");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -37,10 +38,11 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index c1d5c5fb..6ae86a0f 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -2,7 +2,8 @@
 
 private class Games.WiiPlugin : Object, Plugin {
        private const string MIME_TYPE = "application/x-wii-rom";
-       private const string PLATFORM = "WiiWare";
+       private const string PLATFORM = "Wii";
+       private const string PLATFORM_NAME = _("Wii");
 
        public string[] get_mime_types () {
                return { MIME_TYPE };
@@ -35,10 +36,11 @@ private class Games.WiiPlugin : Object, Plugin {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform = new GenericPlatform (PLATFORM_NAME);
                var core_source = new RetroCoreSource (PLATFORM, { MIME_TYPE });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);
diff --git a/src/generic/generic-game.vala b/src/generic/generic-game.vala
index e5253b3d..944fd04e 100644
--- a/src/generic/generic-game.vala
+++ b/src/generic/generic-game.vala
@@ -33,10 +33,11 @@ public class Games.GenericGame : Object, Game {
        private Platform game_platform;
        private Runner game_runner;
 
-       public GenericGame (Uid uid, Title title, Runner runner) {
+       public GenericGame (Uid uid, Title title, Platform platform, Runner runner) {
                game_uid = uid;
                game_title = title;
                game_runner = runner;
+               game_platform = platform;
        }
 
        public Uid get_uid () {
diff --git a/src/retro/retro-simple-game-uri-adapter.vala b/src/retro/retro-simple-game-uri-adapter.vala
index b46ad17f..f8d80967 100644
--- a/src/retro/retro-simple-game-uri-adapter.vala
+++ b/src/retro/retro-simple-game-uri-adapter.vala
@@ -25,10 +25,12 @@ private class Games.RetroSimpleGameUriAdapter : GameUriAdapter, Object {
                var publisher = new GriloPublisher (media);
                var description = new GriloDescription (media);
                var rating = new GriloRating (media);
+               var platform_name = RetroPlatform.get_platform_name (simple_type.platform);
+               var platform = new GenericPlatform (platform_name);
                var core_source = new RetroCoreSource (simple_type.platform, { simple_type.mime_type });
                var runner = new RetroRunner (core_source, uri, uid, title);
 
-               var game = new GenericGame (uid, title, runner);
+               var game = new GenericGame (uid, title, platform, runner);
                game.set_cover (cover);
                game.set_release_date (release_date);
                game.set_cooperative (cooperative);


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