Skip to content

Commit 1a8b61d

Browse files
committed
Support portable configuration in self-contained mode
1 parent 813e41e commit 1a8b61d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

source/Config.gd

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ var _systems_raw : Dictionary
2222
var _system_renames : Dictionary
2323
var emulators_map : Dictionary
2424

25+
var _is_sc := false
26+
2527
const CONTROLLER_AXIS_FLAG : int = (1 << 8)
2628

2729
var _implicit_mappings := {
@@ -33,6 +35,9 @@ var _implicit_mappings := {
3335
"rh_down": "ui_down"
3436
}
3537

38+
func _enter_tree():
39+
_determine_sc_mode()
40+
3641
func _ready():
3742
get_window().min_size = Vector2(1024, 576)
3843
if FileUtils.get_os_id() == FileUtils.OS_ID.UNSUPPORTED:
@@ -702,8 +707,22 @@ func remove_custom_emulator(emulator_raw: Dictionary):
702707
JSONUtils.save_json_file(emulator_config, get_custom_emulators_file())
703708
return
704709

710+
func _determine_sc_mode():
711+
# This functionality is not exposed on exported projects, so
712+
# we replicate it from engine code
713+
var exe_path := OS.get_executable_path().get_base_dir()
714+
if FileUtils.get_os_id() == FileUtils.OS_ID.MACOS:
715+
if exe_path.ends_with("MacOS") and exe_path.path_join("..").simplify_path().ends_with("Contents"):
716+
exe_path = exe_path.path_join("../../..").simplify_path()
717+
718+
if FileAccess.file_exists(exe_path + "/._sc_") or FileAccess.file_exists(exe_path + "/_sc_"):
719+
_is_sc = true
720+
705721
func get_config_dir() -> String:
706722
var path : String
723+
if _is_sc:
724+
return OS.get_executable_path().get_base_dir() + "/config"
725+
707726
match FileUtils.get_os_id():
708727
FileUtils.OS_ID.WINDOWS:
709728
path = FileUtils.get_home_dir() + "/RetroHub"

0 commit comments

Comments
 (0)