[gnome-games/wip/exalm/uid: 4/16] retro-runner: Simplify construction
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/uid: 4/16] retro-runner: Simplify construction
- Date: Thu, 5 Mar 2020 17:58:36 +0000 (UTC)
commit c1c98bc288b6ffd5e8881ca0a0fdd2c6e05e7316
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Feb 21 20:24:36 2020 +0500
retro-runner: Simplify construction
Remove RetroRunnerBuilder, restore separate constructors. Since everything
other than RetroCoreSource or Retro.CoreDescriptor is now contained within
Game, they can be simplified down to 2 arguments each. Pass
InputCapabilities via a property.
plugins/libretro/src/libretro-plugin.vala | 14 +++----
plugins/ms-dos/src/ms-dos-plugin.vala | 10 +----
plugins/nintendo-ds/src/nintendo-ds-plugin.vala | 7 +---
plugins/nintendo-ds/src/nintendo-ds-runner.vala | 4 ++
plugins/playstation/src/playstation-plugin.vala | 15 +------
src/meson.build | 1 -
src/retro/retro-runner-builder.vala | 56 -------------------------
src/retro/retro-runner-factory.vala | 9 +---
src/retro/retro-runner.vala | 35 +++++++++++-----
9 files changed, 39 insertions(+), 112 deletions(-)
---
diff --git a/plugins/libretro/src/libretro-plugin.vala b/plugins/libretro/src/libretro-plugin.vala
index a4e773c8..a060716c 100644
--- a/plugins/libretro/src/libretro-plugin.vala
+++ b/plugins/libretro/src/libretro-plugin.vala
@@ -73,15 +73,11 @@ private class Games.LibretroPlugin : Object, Plugin {
private static Runner? create_runner (Game game) throws Error {
var uri = game.get_uri ();
var core_descriptor = get_core_descriptor (uri);
- var input_capabilities = new GenericInputCapabilities (true);
-
- var builder = new RetroRunnerBuilder ();
- builder.core_descriptor = core_descriptor;
- builder.platform = platform;
- builder.uid = game.get_uid ();
- builder.title = game.name;
- builder.input_capabilities = input_capabilities;
- return builder.to_runner ();
+ var runner = new RetroRunner.from_descriptor (game, core_descriptor);
+
+ runner.input_capabilities = new GenericInputCapabilities (true);
+
+ return runner;
}
}
diff --git a/plugins/ms-dos/src/ms-dos-plugin.vala b/plugins/ms-dos/src/ms-dos-plugin.vala
index 5c3ac606..a0249a5f 100644
--- a/plugins/ms-dos/src/ms-dos-plugin.vala
+++ b/plugins/ms-dos/src/ms-dos-plugin.vala
@@ -47,15 +47,9 @@ private class Games.MsDosPlugin : Object, Plugin {
private static Runner? create_runner (Game game) throws Error {
var core_source = new RetroCoreSource (platform);
- var input_capabilities = new GenericInputCapabilities (true, false);
+ var runner = new RetroRunner.from_source (game, core_source);
- var builder = new RetroRunnerBuilder ();
- builder.core_source = core_source;
- builder.uri = game.get_uri ();
- builder.uid = game.get_uid ();
- builder.title = game.name;
- builder.input_capabilities = input_capabilities;
- var runner = builder.to_runner ();
+ runner.input_capabilities = new GenericInputCapabilities (true, false);
return runner;
}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index b599fb29..61143a62 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
@@ -54,12 +54,7 @@ private class Games.NintendoDsPlugin : Object, Plugin {
private static Runner? create_runner (Game game) throws Error {
var core_source = new RetroCoreSource (platform);
- var builder = new RetroRunnerBuilder ();
- builder.core_source = core_source;
- builder.uri = game.get_uri ();
- builder.uid = game.get_uid ();
- builder.title = game.name;
- return builder.to_runner (typeof (NintendoDsRunner));
+ return new NintendoDsRunner (game, core_source);
}
}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index 5aea4cb9..88ecf8f0 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -65,6 +65,10 @@ private class Games.NintendoDsRunner : RetroRunner {
}
}
+ public NintendoDsRunner (Game game, RetroCoreSource source) {
+ base.from_source (game, source);
+ }
+
private bool core_supports_layouts () {
var core = get_core ();
diff --git a/plugins/playstation/src/playstation-plugin.vala b/plugins/playstation/src/playstation-plugin.vala
index c6b9e84f..dfc90612 100644
--- a/plugins/playstation/src/playstation-plugin.vala
+++ b/plugins/playstation/src/playstation-plugin.vala
@@ -29,23 +29,10 @@ private class Games.PlayStation : Object, Plugin {
}
public RunnerFactory[] get_runner_factories () {
- var factory = new GenericRunnerFactory (create_runner);
- factory.add_platform (platform);
+ var factory = new RetroRunnerFactory (platform);
return { factory };
}
-
- public static Runner? create_runner (Game game) throws Error {
- var core_source = new RetroCoreSource (platform);
-
- var builder = new RetroRunnerBuilder ();
- builder.core_source = core_source;
- builder.media_set = game.get_media_set ();
- builder.uid = game.get_uid ();
- builder.title = game.name;
-
- return builder.to_runner ();
- }
}
[ModuleInit]
diff --git a/src/meson.build b/src/meson.build
index d1500e79..ba8dd3b0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -83,7 +83,6 @@ vala_sources = [
'retro/retro-options.vala',
'retro/retro-platform.vala',
'retro/retro-runner.vala',
- 'retro/retro-runner-builder.vala',
'retro/retro-runner-factory.vala',
'retro/retro-simple-game-uri-adapter.vala',
'retro/retro-simple-type.vala',
diff --git a/src/retro/retro-runner-factory.vala b/src/retro/retro-runner-factory.vala
index ef8300f3..48ba89b8 100644
--- a/src/retro/retro-runner-factory.vala
+++ b/src/retro/retro-runner-factory.vala
@@ -14,13 +14,6 @@ public class Games.RetroRunnerFactory : Object, RunnerFactory {
public Runner? create_runner (Game game) throws Error {
var core_source = new RetroCoreSource (platform);
- var builder = new RetroRunnerBuilder ();
- builder.core_source = core_source;
- builder.uri = game.get_uri ();
- builder.uid = game.get_uid ();
- builder.title = game.name;
- var runner = builder.to_runner ();
-
- return runner;
+ return new RetroRunner.from_source (game, core_source);
}
}
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 3bef2844..000739d0 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -24,6 +24,8 @@ public class Games.RetroRunner : Object, Runner {
get { return _media_set; }
}
+ public InputCapabilities input_capabilities { get; set; }
+
private Retro.Core core;
private Retro.CoreView view;
private RetroInputManager input_manager;
@@ -40,7 +42,6 @@ public class Games.RetroRunner : Object, Runner {
private RetroCoreSource core_source;
private Platform platform;
private Uid uid;
- private InputCapabilities input_capabilities;
private Settings settings;
private string game_title;
@@ -64,21 +65,35 @@ public class Games.RetroRunner : Object, Runner {
private bool is_ready;
private bool is_error;
- public RetroRunnerBuilder builder {
- construct {
- core_descriptor = value.core_descriptor;
- _media_set = value.media_set;
+ private RetroRunner (Game game) {
+ uid = game.get_uid ();
+ platform = game.get_platform ();
+ game_title = game.name;
+
+ _media_set = game.get_media_set ();
+ if (media_set == null && game.get_uri () != null) {
+ var media = new Media ();
+ media.add_uri (game.get_uri ());
- uid = value.uid;
- core_source = value.core_source;
- platform = value.platform;
- input_capabilities = value.input_capabilities;
- game_title = value.title;
+ _media_set = new MediaSet ();
+ _media_set.add_media (media);
_media_set.notify["selected-media-number"].connect (on_media_number_changed);
}
}
+ public RetroRunner.from_source (Game game, RetroCoreSource source) {
+ this (game);
+
+ core_source = source;
+ }
+
+ public RetroRunner.from_descriptor (Game game, Retro.CoreDescriptor descriptor) {
+ this (game);
+
+ core_descriptor = descriptor;
+ }
+
construct {
is_initialized = false;
is_ready = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]