[gnome-games/wip/exalm/loading: 20/29] playstation: Add runner factory



commit 0be2c6161f7a87a960a6aa353844aee571f7b25e
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Nov 11 23:15:48 2019 +0500

    playstation: Add runner factory

 plugins/playstation/src/playstation-plugin.vala | 29 ++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
---
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index 7695de96..d021baf7 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -8,10 +8,13 @@ private class Games.PlayStation : Object, Plugin {
        private const string PLATFORM_UID_PREFIX = "playstation";
 
        private static RetroPlatform platform;
+       private static PlaystationGameinfoCache gameinfo_cache;
 
        static construct {
                string[] mime_types = { CUE_MIME_TYPE, PHONY_MIME_TYPE };
                platform = new RetroPlatform (PLATFORM_ID, PLATFORM_NAME, mime_types, PLATFORM_UID_PREFIX);
+
+               gameinfo_cache = new PlaystationGameinfoCache ();
        }
 
        public Platform[] get_platforms () {
@@ -23,10 +26,34 @@ private class Games.PlayStation : Object, Plugin {
        }
 
        public UriGameFactory[] get_uri_game_factories () {
-               var factory = new PlayStationGameFactory (platform);
+               var factory = new PlayStationGameFactory (platform, gameinfo_cache);
+
+               return { factory };
+       }
+
+       public RunnerFactory[] get_runner_factories () {
+               var factory = new GenericRunnerFactory (create_runner);
+               factory.add_platform (platform);
 
                return { factory };
        }
+
+       public static Runner? create_runner (Game game) throws Error {
+               var uri = game.get_uri ();
+               var media_set = gameinfo_cache.get_media_set (uri);
+               var input_capabilities = gameinfo_cache.get_input_capabilities (uri);
+
+               var core_source = new RetroCoreSource (platform);
+
+               var builder = new RetroRunnerBuilder ();
+               builder.core_source = core_source;
+               builder.media_set = media_set;
+               builder.uid = game.get_uid ();
+               builder.title = game.name;
+               builder.input_capabilities = input_capabilities;
+
+               return builder.to_runner ();
+       }
 }
 
 [ModuleInit]


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