[gnome-games] retro-runner: Load options from file
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] retro-runner: Load options from file
- Date: Thu, 28 Jun 2018 09:54:01 +0000 (UTC)
commit d291da9aacebe8d246748e0135d1a951d353f7e5
Author: Exalm <exalm7659 gmail com>
Date: Wed May 2 19:04:50 2018 +0500
retro-runner: Load options from file
Use RetroOptions to parse an option file located in OPTIONS_DIR.
Since some libretro options have to be applied at the start, it does
not apply options directly after boot() call, but instead connect to
a signal that would be emitted directly after the core registers the
options.
src/retro/retro-runner.vala | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index cbdca3b..14ab325 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -244,6 +244,16 @@ public class Games.RetroRunner : Object, Runner {
module_path = core_source.get_module_path ();
core = new Retro.Core (module_path);
+ var options_path = get_options_path ();
+ core.options_set.connect (() => {
+ try {
+ var options = new RetroOptions (options_path);
+ options.apply (core);
+ } catch (Error e) {
+ critical (e.message);
+ }
+ });
+
if (core_source != null) {
var platforms_dir = Application.get_platforms_dir ();
var platform = core_source.get_platform ();
@@ -358,6 +368,18 @@ public class Games.RetroRunner : Object, Runner {
should_save = false;
}
+ private string get_options_path () throws Error {
+ assert (core != null);
+
+ var core_filename = core.get_filename ();
+ var file = File.new_for_path (core_filename);
+ var basename = file.get_basename ();
+ var options_name = basename.split (".")[0];
+ options_name = options_name.replace ("_libretro", "");
+
+ return @"$OPTIONS_DIR/$options_name.options";
+ }
+
private string get_save_directory_path () throws Error {
if (save_directory_path != null)
return save_directory_path;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]