[gnome-games/wip/exalm/runner-refactor: 41/58] retro-core: Move instantiate_core() and prepare_core() to where they are used
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/runner-refactor: 41/58] retro-core: Move instantiate_core() and prepare_core() to where they are used
- Date: Sun, 8 Mar 2020 13:44:13 +0000 (UTC)
commit f3a8e197bc3ed821dcc92f3230419303ac94d8aa
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sat Mar 7 03:02:39 2020 +0500
retro-core: Move instantiate_core() and prepare_core() to where they are used
src/retro/retro-runner.vala | 124 ++++++++++++++++++++++----------------------
1 file changed, 62 insertions(+), 62 deletions(-)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index 3efaf7db..9b78dba1 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -129,6 +129,68 @@ public class Games.RetroRunner : Object, Runner {
return DirUtils.make_tmp ("games_save_dir_XXXXXX");
}
+ private void prepare_core () throws Error {
+ string module_path;
+ if (core_descriptor != null) {
+ var module_file = core_descriptor.get_module_file ();
+ if (module_file == null)
+ throw new RetroError.MODULE_NOT_FOUND (_("No module found for ā%sā."),
core_descriptor.get_name ());
+
+ module_path = module_file.get_path ();
+ }
+ else
+ module_path = core_source.get_module_path ();
+ core = new Retro.Core (module_path);
+
+ var options_path = get_options_path ();
+ if (FileUtils.test (options_path, FileTest.EXISTS))
+ try {
+ var options = new RetroOptions (options_path);
+ options.apply (core);
+ } catch (Error e) {
+ critical (e.message);
+ }
+
+ var platforms_dir = Application.get_platforms_dir ();
+ var platform_id = game.platform.get_id ();
+ core.system_directory = @"$platforms_dir/$platform_id/system";
+
+ core.save_directory = tmp_save_dir;
+
+ core.log.connect (Retro.g_log);
+ view.set_core (core);
+
+ string[] medias_uris = {};
+ media_set.foreach_media ((media) => {
+ var uris = media.get_uris ();
+ medias_uris += (uris.length == 0) ? "" : uris[0].to_string ();
+ });
+
+ core.set_medias (medias_uris);
+ core.boot ();
+
+ if (medias_uris.length > 0)
+ core.set_current_media (media_set.selected_media_number);
+ }
+
+ private void instantiate_core () throws Error {
+ prepare_core ();
+
+ input_manager = new RetroInputManager (core, view);
+ // Keep the internal values of input_mode in sync between RetroRunner and RetroInputManager
+ input_mode = get_available_input_modes ()[0];
+
+ core.shutdown.connect (stop);
+ core.crashed.connect ((core, error) => {
+ is_error = true;
+ crash (error);
+ });
+
+ running = false;
+
+ is_initialized = true;
+ }
+
public void prepare () throws RunnerError {
try {
snapshot_manager = new SnapshotManager (game, get_core_id ());
@@ -262,24 +324,6 @@ public class Games.RetroRunner : Object, Runner {
running = true;
}
- private void instantiate_core () throws Error {
- prepare_core ();
-
- input_manager = new RetroInputManager (core, view);
- // Keep the internal values of input_mode in sync between RetroRunner and RetroInputManager
- input_mode = get_available_input_modes ()[0];
-
- core.shutdown.connect (stop);
- core.crashed.connect ((core, error) => {
- is_error = true;
- crash (error);
- });
-
- running = false;
-
- is_initialized = true;
- }
-
private void deinit () {
if (!is_initialized)
return;
@@ -306,50 +350,6 @@ public class Games.RetroRunner : Object, Runner {
view.set_filter (filter);
}
- private void prepare_core () throws Error {
- string module_path;
- if (core_descriptor != null) {
- var module_file = core_descriptor.get_module_file ();
- if (module_file == null)
- throw new RetroError.MODULE_NOT_FOUND (_("No module found for ā%sā."),
core_descriptor.get_name ());
-
- module_path = module_file.get_path ();
- }
- else
- module_path = core_source.get_module_path ();
- core = new Retro.Core (module_path);
-
- var options_path = get_options_path ();
- if (FileUtils.test (options_path, FileTest.EXISTS))
- try {
- var options = new RetroOptions (options_path);
- options.apply (core);
- } catch (Error e) {
- critical (e.message);
- }
-
- var platforms_dir = Application.get_platforms_dir ();
- var platform_id = game.platform.get_id ();
- core.system_directory = @"$platforms_dir/$platform_id/system";
-
- core.save_directory = tmp_save_dir;
-
- core.log.connect (Retro.g_log);
- view.set_core (core);
-
- string[] medias_uris = {};
- media_set.foreach_media ((media) => {
- var uris = media.get_uris ();
- medias_uris += (uris.length == 0) ? "" : uris[0].to_string ();
- });
-
- core.set_medias (medias_uris);
- core.boot ();
-
- if (medias_uris.length > 0)
- core.set_current_media (media_set.selected_media_number);
- }
-
public void pause () {
if (!is_initialized)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]