Skip to content

Commit fba974d

Browse files
committed
Review FirstTimePopup wizard
1 parent a521be8 commit fba974d

File tree

15 files changed

+68
-58
lines changed

15 files changed

+68
-58
lines changed

scenes/config/settings/system/SelectExtensionsPopup.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func start(system_name: String, _extensions: Array):
2121
create_curr_extension_button(ext)
2222

2323
# Add new extensions
24-
var game_path : String = RetroHubConfig.config.games_dir + "/" + system_name
24+
var game_path : String = RetroHubConfig.config.games_dir.path_join(system_name)
2525
var dir := DirAccess.open(game_path)
2626
if dir:
2727
#warning-ignore:return_value_discarded

scenes/popups/first_time/DoneSection.tscn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ layout_mode = 3
1111
anchors_preset = 15
1212
anchor_right = 1.0
1313
anchor_bottom = 1.0
14+
grow_horizontal = 2
15+
grow_vertical = 2
1416
size_flags_horizontal = 3
1517
size_flags_vertical = 3
1618
script = ExtResource("3")

scenes/popups/first_time/EmulatorsSection.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func handle_emulator_info(system_raw: Dictionary) -> bool:
9696
continue
9797
var corepaths := []
9898
for core in avail_cores:
99-
corepaths.push_back(corespath + "/" + core["file"])
99+
corepaths.push_back(corespath.path_join(core["file"]))
100100
var corepath := FileUtils.test_for_valid_path(corepaths)
101101
if not corepath.is_empty():
102102
for core in avail_cores:

scenes/popups/first_time/FirstTimePopups.gd

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func _on_MainContent_tab_changed(tab):
4747
counter += 1
4848

4949

50-
func _on_FirstTimePopup_popup_hide():
51-
RetroHubConfig.emit_signal("config_ready", RetroHubConfig.config)
52-
queue_free()
50+
func _on_visibility_changed():
51+
if not visible:
52+
RetroHubConfig.emit_signal("config_ready", RetroHubConfig.config)
53+
queue_free()

scenes/popups/first_time/FirstTimePopups.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ size_flags_horizontal = 2
220220
text = "for scrolling information"
221221

222222
[connection signal="about_to_popup" from="." to="." method="_on_FirstTimePopup_about_to_show"]
223+
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
223224
[connection signal="tab_changed" from="Panel/HBoxContainer/MainContent" to="." method="_on_MainContent_tab_changed"]
224225
[connection signal="advance_section" from="Panel/HBoxContainer/MainContent/IntroductionSection" to="." method="advance_section"]
225226
[connection signal="advance_section" from="Panel/HBoxContainer/MainContent/RegionSection" to="." method="advance_section"]

scenes/popups/scraper/ScraperPopup.gd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,10 @@ func prepare_media_scrape_from_search(game_entry: RetroHubScraperGameEntry, sear
303303
func t_on_media_scrape_finished(game_data: RetroHubGameData, type: int, data: PackedByteArray, extension: String):
304304
if pending_medias.has(game_data):
305305
# Save media
306-
var path := RetroHubConfig.get_gamemedia_dir() + "/" + \
307-
game_data.system.name + "/" + \
308-
RetroHubMedia.convert_type_to_media_path(type) + "/" + \
309-
game_data.path.get_file().get_basename() + \
310-
"." + extension
306+
var path := RetroHubConfig.get_gamemedia_dir() \
307+
.path_join(game_data.system.name) \
308+
.path_join(RetroHubMedia.convert_type_to_media_path(type)) \
309+
.path_join(game_data.path.get_file().get_basename() + "." + extension)
311310
FileUtils.ensure_path(path)
312311
var file := FileAccess.open(path, FileAccess.WRITE)
313312
if file:

scenes/root/Root.gd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func _enter_tree():
2525
#resources_remap.append_array([
2626
#])
2727

28-
func _input(event: InputEvent):
28+
func _raw_input(event: InputEvent):
2929
if not RetroHub._running_game:
3030
if event.is_action_pressed("rh_menu") and not RetroHubConfig.config.is_first_time:
31-
get_viewport().set_input_as_handled()
3231
if not $ConfigPopup.visible:
32+
get_viewport().set_input_as_handled()
3333
$ConfigPopup.popup()
3434

3535
func _ready():

source/Config.gd

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func load_game_data_files():
294294
if dir.current_is_dir() and \
295295
((_systems_raw.has(file_name) and not _systems_raw[file_name].has("#delete")) or \
296296
_system_renames.has(file_name)):
297-
load_system_gamelists_files(config.games_dir + "/" + file_name, file_name)
297+
load_system_gamelists_files(config.games_dir.path_join(file_name), file_name)
298298
# We are not interested in files, only folders
299299
file_name = dir.get_next()
300300
dir.list_dir_end()
@@ -310,7 +310,7 @@ func load_system_gamelists_files(folder_path: String, system_name: String):
310310
return
311311
var file_name := dir.get_next()
312312
while file_name != "":
313-
var full_path := folder_path + "/" + file_name
313+
var full_path := folder_path.path_join(file_name)
314314
if dir.current_is_dir():
315315
# Recurse
316316
# TODO: prevent infinite recursion with shortcuts/symlinks
@@ -350,10 +350,9 @@ func load_system_gamelists_files(folder_path: String, system_name: String):
350350
dir.list_dir_end()
351351

352352
func make_system_folder(system_raw: Dictionary):
353-
var path : String = config.games_dir + "/" + system_raw["name"]
354-
var dir := DirAccess.open(path)
355-
if dir and not dir.dir_exists(path):
356-
if dir.make_dir_recursive(path):
353+
var path : String = config.games_dir.path_join(system_raw["name"])
354+
if not DirAccess.dir_exists_absolute(path):
355+
if DirAccess.make_dir_recursive_absolute(path):
357356
push_error("Failed to create system folder " + path)
358357

359358
func fetch_game_data(path: String, game: RetroHubGameData) -> bool:
@@ -378,7 +377,7 @@ func fetch_game_data(path: String, game: RetroHubGameData) -> bool:
378377
return true
379378

380379
func get_game_data_path_from_file(system_name: String, file_name: String) -> String:
381-
return get_gamelists_dir() + "/" + system_name + "/" + file_name.get_file().trim_suffix(file_name.get_extension()) + "json"
380+
return get_gamelists_dir().path_join(system_name).path_join(file_name.get_file().trim_suffix(file_name.get_extension()) + "json")
382381

383382
func save_game_data(game_data: RetroHubGameData) -> bool:
384383
var metadata_path := get_game_data_path_from_file(game_data.system.name, game_data.path)
@@ -424,9 +423,9 @@ func is_file_from_system(file_name: String, system_name: String) -> bool:
424423
func load_theme() -> bool:
425424
var current_theme := config.current_theme
426425
if current_theme.ends_with(".pck"):
427-
theme_path = get_themes_dir() + "/" + current_theme
426+
theme_path = get_themes_dir().path_join(current_theme)
428427
else:
429-
theme_path = get_default_themes_dir() + "/" + current_theme + ".pck"
428+
theme_path = get_default_themes_dir().path_join(current_theme + ".pck")
430429
# FIXME: Theme hot-reloading is disabled until nasty GDScript bug is solved
431430
if not ProjectSettings.is_pack_loaded(theme_path):
432431
if not ProjectSettings.load_resource_pack(theme_path, false):

source/Media.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func retrieve_media_data(game_data: RetroHubGameData, types: int = Type.ALL) ->
126126
_media_cache[game_data] = RetroHubGameMediaData.new()
127127
var game_media_data : RetroHubGameMediaData = _media_cache[game_data]
128128

129-
var media_path := RetroHubConfig.get_gamemedia_dir() + "/" + game_data.system_path
129+
var media_path := RetroHubConfig.get_gamemedia_dir().path_join(game_data.system_path)
130130
var game_path := game_data.path.get_file().get_basename()
131131

132132
var path : String

source/emulators/RetroarchEmulator.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func _init(emulator_raw : Dictionary, game_data : RetroHubGameData, system_cores
5151
for core_name in system_cores:
5252
for core_info in emulator_raw["cores"]:
5353
if core_info["name"] == core_name:
54-
var core_file_path : String = corepath + "/" + core_info["file"]
54+
var core_file_path : String = corepath.path_join(core_info["file"])
5555
if FileAccess.file_exists(core_file_path):
5656
corefile = core_info["file"]
5757
_substitutes["corefile"] = corefile

0 commit comments

Comments
 (0)