[gnome-games/wip/exalm/uid] retro-runner: Simplify construction
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/uid] retro-runner: Simplify construction
- Date: Fri, 21 Feb 2020 15:35:38 +0000 (UTC)
commit cfb77ababbd794cdae380b76adc9b103e1e33789
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 49ce6659..0653a5f8 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.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 208b7de7..a2d8eb1a 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);
+ 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.uid;
- builder.title = game.name;
- builder.input_capabilities = input_capabilities;
- var runner = builder.to_runner ();
+ runner.input_capabilities = new GenericInputCapabilities (true);
return runner;
}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-plugin.vala b/plugins/nintendo-ds/src/nintendo-ds-plugin.vala
index a5ffc1bd..b09b3471 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.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 6e78b927..75c64fa3 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -33,6 +33,10 @@ private class Games.NintendoDsRunner : RetroRunner {
layouts[Gdk.Key.@4] = NintendoDsLayout.QUICK_SWITCH;
}
+ 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 46f9a88e..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.uid;
- builder.title = game.name;
-
- return builder.to_runner ();
- }
}
[ModuleInit]
diff --git a/src/meson.build b/src/meson.build
index 41ba1297..cf55f6e3 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -82,7 +82,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 f96fe997..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.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 f48fc88b..2f31986c 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 string 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.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]