Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix emulator paths using forward slashes on Windows #386

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions source/emulators/GenericEmulator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ var command : String
var _substitutes := {}

func _init(emulator_raw : Dictionary, game_data : RetroHubGameData):
_substitutes["rompath"] = game_data.path
_substitutes["romfolder"] = game_data.path.get_base_dir()
add_substitute("rompath", game_data.path)
add_substitute("romfolder", game_data.path.get_base_dir())
var binpath := RetroHubGenericEmulator.find_path(emulator_raw, "binpath", _substitutes)
if not binpath.is_empty():
_substitutes["binpath"] = binpath
add_substitute("binpath", binpath)
command = RetroHubGenericEmulator.substitute_str(emulator_raw["command"], _substitutes)
else:
print("Could not find binpath for emulator \"%s\"" % emulator_raw["name"])
Expand All @@ -36,6 +36,9 @@ static func load_icon(_name: String) -> Texture2D:
return load(path)
return null

func add_substitute(key: String, path: String) -> void:
_substitutes[key] = path.replace('/', '\\') if FileUtils.get_os_id() == FileUtils.OS_ID.WINDOWS else path

func is_valid() -> bool:
return not command.is_empty()

Expand All @@ -53,4 +56,5 @@ func launch_game() -> int:
else:
command_args.append(regex_results[idx].strings[0])

prints("Launching emulator process:", command_base, command_args)
return OS.create_process(command_base, command_args)
4 changes: 2 additions & 2 deletions source/emulators/RetroarchEmulator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ func _init(emulator_raw : Dictionary, game_data : RetroHubGameData, system_cores
if corepath.is_empty():
corepath = RetroHubRetroArchEmulator.find_path(emulator_raw, "corepath", _substitutes)
var corefile : String
_substitutes["corepath"] = corepath
add_substitute("corepath", corepath)
for core_name in system_cores:
corefile = RetroHubRetroArchEmulator.find_core_path(core_name, emulator_raw, corepath)
if not corefile.is_empty():
break

if not corefile.is_empty():
_substitutes["corefile"] = corefile
add_substitute("corefile", corefile)
command = RetroHubRetroArchEmulator.substitute_str(command, _substitutes)
else:
print("Could not find valid core file for emulator \"%s\"" % game_data.system.name)
Expand Down
Loading