[gnome-games/wip/exalm/rebrand: 32/102] retro-runner-factory: Merge into RunnerFactory




commit 5947bf53dcc889810654d3249ccc113d9a6bb3dc
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Mon Mar 29 21:51:46 2021 +0500

    retro-runner-factory: Merge into RunnerFactory

 plugins/dreamcast/src/dreamcast-plugin.vala         |  2 +-
 plugins/game-cube/src/game-cube-plugin.vala         |  2 +-
 plugins/mame/src/mame-plugin.vala                   |  2 +-
 plugins/ms-dos/src/ms-dos-plugin.vala               |  2 +-
 plugins/nintendo-3ds/src/nintendo-3ds-plugin.vala   |  2 +-
 plugins/nintendo-64/src/nintendo-64-plugin.vala     |  2 +-
 plugins/nintendo-ds/src/nintendo-ds-plugin.vala     |  2 +-
 plugins/playstation/src/playstation-plugin.vala     |  2 +-
 plugins/sega-cd/src/sega-cd-plugin.vala             |  4 ++--
 plugins/sega-saturn/src/sega-saturn-plugin.vala     |  2 +-
 plugins/turbografx-cd/src/turbografx-cd-plugin.vala |  2 +-
 plugins/virtual-boy/src/virtual-boy-plugin.vala     |  2 +-
 plugins/wii/src/wii-plugin.vala                     |  2 +-
 src/core/runner-factory.vala                        | 20 ++++++++++++++++----
 src/meson.build                                     |  1 -
 src/retro/retro-runner-factory.vala                 | 21 ---------------------
 src/ui/application.vala                             |  2 +-
 17 files changed, 31 insertions(+), 41 deletions(-)
---
diff --git a/plugins/dreamcast/src/dreamcast-plugin.vala b/plugins/dreamcast/src/dreamcast-plugin.vala
index 1923bbcf..0de1b60c 100644
--- a/plugins/dreamcast/src/dreamcast-plugin.vala
+++ b/plugins/dreamcast/src/dreamcast-plugin.vala
@@ -33,7 +33,7 @@ private class Games.DreamcastPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/game-cube/src/game-cube-plugin.vala b/plugins/game-cube/src/game-cube-plugin.vala
index 49f6e1a1..808c6fef 100644
--- a/plugins/game-cube/src/game-cube-plugin.vala
+++ b/plugins/game-cube/src/game-cube-plugin.vala
@@ -29,7 +29,7 @@ private class Games.GameCubePlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/mame/src/mame-plugin.vala b/plugins/mame/src/mame-plugin.vala
index def219c9..122ae4b0 100644
--- a/plugins/mame/src/mame-plugin.vala
+++ b/plugins/mame/src/mame-plugin.vala
@@ -31,7 +31,7 @@ private class Games.MamePlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index aa1f771e..3eef229e 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -25,7 +25,7 @@ private class Games.MsDosPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform, typeof (MsDosRunner));
+               var factory = new RunnerFactory (platform, typeof (MsDosRunner));
 
                return { factory };
        }
diff --git a/plugins/nintendo-3ds/src/nintendo-3ds-plugin.vala 
b/plugins/nintendo-3ds/src/nintendo-3ds-plugin.vala
index b7c96e8a..59a58b32 100644
--- a/plugins/nintendo-3ds/src/nintendo-3ds-plugin.vala
+++ b/plugins/nintendo-3ds/src/nintendo-3ds-plugin.vala
@@ -32,7 +32,7 @@ private class Games.Nintendo3DsPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform, typeof (Nintendo3DsRunner));
+               var factory = new RunnerFactory (platform, typeof (Nintendo3DsRunner));
 
                return { factory };
        }
diff --git a/plugins/nintendo-64/src/nintendo-64-plugin.vala b/plugins/nintendo-64/src/nintendo-64-plugin.vala
index ca0dcf5a..fda562d9 100644
--- a/plugins/nintendo-64/src/nintendo-64-plugin.vala
+++ b/plugins/nintendo-64/src/nintendo-64-plugin.vala
@@ -29,7 +29,7 @@ private class Games.Nintendo64Plugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform, typeof (Nintendo64Runner));
+               var factory = new RunnerFactory (platform, typeof (Nintendo64Runner));
 
                return { factory };
        }
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index d7ff950a..df7d7fa2 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -29,7 +29,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform, typeof (NintendoDsRunner));
+               var factory = new RunnerFactory (platform, typeof (NintendoDsRunner));
 
                return { factory };
        }
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index b994f85d..636ffdbc 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -29,7 +29,7 @@ private class Games.PlayStation : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/sega-cd/src/sega-cd-plugin.vala b/plugins/sega-cd/src/sega-cd-plugin.vala
index 5c69d164..9d2a0bd1 100644
--- a/plugins/sega-cd/src/sega-cd-plugin.vala
+++ b/plugins/sega-cd/src/sega-cd-plugin.vala
@@ -42,8 +42,8 @@ private class Games.SegaCDPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory_sega_cd = new RetroRunnerFactory (platform_sega_cd);
-               var factory_sega_cd_32x = new RetroRunnerFactory (platform_sega_cd_32x);
+               var factory_sega_cd = new RunnerFactory (platform_sega_cd);
+               var factory_sega_cd_32x = new RunnerFactory (platform_sega_cd_32x);
 
                return { factory_sega_cd, factory_sega_cd_32x };
        }
diff --git a/plugins/sega-saturn/src/sega-saturn-plugin.vala b/plugins/sega-saturn/src/sega-saturn-plugin.vala
index 9aa2a543..566f2816 100644
--- a/plugins/sega-saturn/src/sega-saturn-plugin.vala
+++ b/plugins/sega-saturn/src/sega-saturn-plugin.vala
@@ -35,7 +35,7 @@ private class Games.SegaSaturnPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala 
b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
index 731cbbee..73bead54 100644
--- a/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
+++ b/plugins/turbografx-cd/src/turbografx-cd-plugin.vala
@@ -33,7 +33,7 @@ private class Games.TurboGrafxCDPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/virtual-boy/src/virtual-boy-plugin.vala b/plugins/virtual-boy/src/virtual-boy-plugin.vala
index c102dcbe..191c8d9f 100644
--- a/plugins/virtual-boy/src/virtual-boy-plugin.vala
+++ b/plugins/virtual-boy/src/virtual-boy-plugin.vala
@@ -29,7 +29,7 @@ private class Games.VirtualBoyPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/plugins/wii/src/wii-plugin.vala b/plugins/wii/src/wii-plugin.vala
index 93441bd5..6344a6a0 100644
--- a/plugins/wii/src/wii-plugin.vala
+++ b/plugins/wii/src/wii-plugin.vala
@@ -29,7 +29,7 @@ private class Games.WiiPlugin : Object, Plugin {
        }
 
        public RunnerFactory[] get_runner_factories () {
-               var factory = new RetroRunnerFactory (platform);
+               var factory = new RunnerFactory (platform);
 
                return { factory };
        }
diff --git a/src/core/runner-factory.vala b/src/core/runner-factory.vala
index 3b22350b..641c1a52 100644
--- a/src/core/runner-factory.vala
+++ b/src/core/runner-factory.vala
@@ -1,9 +1,21 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
-public interface Games.RunnerFactory : Object {
-       public virtual Platform[] get_platforms () {
-               return {};
+public class Games.RunnerFactory : Object {
+       private Platform platform;
+       private Type<Runner> type;
+
+       public RunnerFactory (Platform platform, Type<Runner> type = typeof (Runner)) {
+               this.platform = platform;
+               this.type = type;
+       }
+
+       public Platform[] get_platforms () {
+               return { platform };
        }
 
-       public abstract Runner? create_runner (Game game) throws Error;
+       public Runner? create_runner (Game game) throws Error {
+               var core_source = new RetroCoreSource (platform);
+
+               return Object.new (type, game: game, core_source: core_source) as Runner;
+       }
 }
diff --git a/src/meson.build b/src/meson.build
index 74150c29..213f78da 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -103,7 +103,6 @@ vala_sources = [
   'retro/retro-gamepad.vala',
   'retro/retro-input-manager.vala',
   'retro/retro-options.vala',
-  'retro/retro-runner-factory.vala',
   'retro/retro-simple-game-uri-adapter.vala',
   'retro/retro-simple-type.vala',
   'retro/retro-simple-types.vala',
diff --git a/src/ui/application.vala b/src/ui/application.vala
index b9eba0b0..7ad2b8de 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -460,7 +460,7 @@ public class Games.Application : Gtk.Application {
 
                        game_collection.add_factory (factory);
 
-                       var runner_factory = new RetroRunnerFactory (platform);
+                       var runner_factory = new RunnerFactory (platform);
 
                        game_collection.add_runner_factory (runner_factory);
                }


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