Skip to content

Commit 9c7acf2

Browse files
committed
Fix config popup losing focus after modal popups
1 parent c1a76c6 commit 9c7acf2

File tree

5 files changed

+60
-63
lines changed

5 files changed

+60
-63
lines changed

scenes/config/ConfigPopup.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ extends Window
22

33
signal popup_hide
44

5+
@onready var n_filesystem_popup := %FileSystemPopup
6+
@onready var n_warning_popup := %WarningPopup
7+
58
@onready var n_main := %SettingsTab
69
@onready var n_game_tab := %GameTab
710
@onready var n_panel_container := %PanelContainer
@@ -23,6 +26,9 @@ func _ready():
2326
n_panel_container.get_parent().custom_minimum_size.y = n_panel_container.size.y
2427
n_panel_container.get_parent().update_minimum_size()
2528

29+
RetroHubUI._n_filesystem_popup = n_filesystem_popup
30+
RetroHubUI._n_warning_popup = n_warning_popup
31+
2632
func _input(event: InputEvent):
2733
if not RetroHub._running_game:
2834
if event.is_action_pressed("rh_menu") and not RetroHubConfig.config.is_first_time:

scenes/config/ConfigPopup.tscn

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=27 format=3 uid="uid://cjx4cfx0f2k2"]
1+
[gd_scene load_steps=28 format=3 uid="uid://cjx4cfx0f2k2"]
22

33
[ext_resource type="Theme" uid="uid://jtuqhw3am1h3" path="res://resources/default_theme.tres" id="1"]
44
[ext_resource type="Texture2D" uid="uid://du66o2pueo6qh" path="res://assets/icons/config/emulators.png" id="2"]
@@ -25,6 +25,7 @@
2525
[ext_resource type="Texture2D" uid="uid://7qv28u4mq7xl" path="res://assets/icons/config/about.png" id="23"]
2626
[ext_resource type="Script" path="res://source/utils/ScrollHandler.gd" id="24"]
2727
[ext_resource type="Script" path="res://scenes/ui_nodes/AccessibilityFocus.gd" id="25"]
28+
[ext_resource type="Script" path="res://scenes/root/FileSystemPopup.gd" id="26_sbwuo"]
2829

2930
[sub_resource type="ButtonGroup" id="ButtonGroup_l35le"]
3031

@@ -33,9 +34,12 @@ disable_3d = true
3334
transparent_bg = true
3435
initial_position = 1
3536
size = Vector2i(1000, 480)
37+
transient = true
3638
exclusive = true
3739
borderless = true
3840
transparent = true
41+
popup_window = true
42+
content_scale_size = Vector2i(1000, 480)
3943
content_scale_mode = 1
4044
content_scale_aspect = 3
4145
theme = ExtResource("1")
@@ -464,6 +468,46 @@ layout_mode = 2
464468
visible = false
465469
layout_mode = 2
466470

471+
[node name="FileSystemPopup" type="FileDialog" parent="."]
472+
unique_name_in_owner = true
473+
title = "Open a File"
474+
position = Vector2i(0, 24)
475+
size = Vector2i(949, 477)
476+
popup_window = true
477+
theme = ExtResource("1")
478+
ok_button_text = "Open"
479+
file_mode = 0
480+
access = 2
481+
script = ExtResource("26_sbwuo")
482+
483+
[node name="WarningPopup" type="AcceptDialog" parent="."]
484+
unique_name_in_owner = true
485+
handle_input_locally = false
486+
size = Vector2i(608, 346)
487+
popup_window = true
488+
content_scale_size = Vector2i(608, 346)
489+
content_scale_mode = 1
490+
content_scale_aspect = 4
491+
theme = ExtResource("1")
492+
493+
[node name="WarningLabel" type="Label" parent="WarningPopup"]
494+
unique_name_in_owner = true
495+
anchors_preset = 15
496+
anchor_right = 1.0
497+
anchor_bottom = 1.0
498+
offset_left = 8.0
499+
offset_top = 8.0
500+
offset_right = -8.0
501+
offset_bottom = -49.0
502+
text = "
503+
"
504+
horizontal_alignment = 1
505+
vertical_alignment = 1
506+
autowrap_mode = 3
507+
clip_text = true
508+
text_overrun_behavior = 3
509+
510+
[connection signal="close_requested" from="." to="." method="_on_close_requested"]
467511
[connection signal="focus_entered" from="Panel/HBoxContainer/ScrollContainer" to="." method="_on_ScrollContainer_focus_entered"]
468512
[connection signal="button_up" from="Panel/HBoxContainer/ScrollContainer/Panel/PanelContainer/QuitTab" to="." method="_on_Tab_pressed" binds= [0]]
469513
[connection signal="focus_entered" from="Panel/HBoxContainer/ScrollContainer/Panel/PanelContainer/QuitTab" to="." method="_on_Tab_focus_entered" binds= [0]]
@@ -488,3 +532,6 @@ layout_mode = 2
488532
[connection signal="focus_entered" from="Panel/HBoxContainer/MarginContainer/SettingsTab" to="." method="_on_SettingsTab_focus_entered"]
489533
[connection signal="theme_reload" from="Panel/HBoxContainer/MarginContainer/SettingsTab/RegionSettings" to="." method="_on_theme_reload"]
490534
[connection signal="theme_reload" from="Panel/HBoxContainer/MarginContainer/SettingsTab/SystemSettings" to="." method="_on_theme_reload"]
535+
[connection signal="about_to_popup" from="FileSystemPopup" to="FileSystemPopup" method="_on_about_to_popup"]
536+
[connection signal="close_requested" from="FileSystemPopup" to="FileSystemPopup" method="restore_window_focus"]
537+
[connection signal="focus_exited" from="FileSystemPopup" to="FileSystemPopup" method="restore_window_focus"]

scenes/popups/scraper/ScraperPopup.tscn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ transient = true
2525
exclusive = true
2626
borderless = true
2727
transparent = true
28-
popup_window = true
2928
content_scale_size = Vector2i(953, 542)
3029
content_scale_mode = 1
3130
content_scale_aspect = 4

scenes/root/Root.gd

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,18 @@ extends Control
44
@onready var n_viewport := $SubViewportContainer/SubViewport
55

66
@onready var n_config_popup := $ConfigPopup
7-
@onready var n_filesystem_popup := $FileSystemPopup
87
@onready var n_keyboard_popup := %Keyboard
9-
@onready var n_warning_popup := %WarningPopup
108

11-
@onready var popup_nodes := [
12-
n_config_popup,
13-
n_filesystem_popup
14-
]
15-
16-
@onready var viewport_orig_size := Vector2(1162, 648)
9+
@onready var viewport_orig_size := Vector2(
10+
ProjectSettings.get_setting("display/window/size/viewport_width"),
11+
ProjectSettings.get_setting("display/window/size/viewport_height")
12+
)
1713

1814
var n_last_focused : Control
1915
var is_popup_open : bool = false
2016

21-
var resources_remap := []
22-
2317
func _enter_tree():
2418
load("res://scenes/ui_nodes/AccessibilityFocus.gd").take_over_path("res://addons/retrohub_theme_helper/ui/AccessibilityFocus.gd")
25-
#resources_remap.append_array([
26-
#])
2719

2820
func _raw_input(event: InputEvent):
2921
if not RetroHub._running_game:
@@ -43,10 +35,8 @@ func _ready():
4335
RetroHubConfig.config_updated.connect(_on_config_updated)
4436

4537
# Add popups to UI singleton
46-
RetroHubUI._n_filesystem_popup = n_filesystem_popup
47-
RetroHubUI._n_virtual_keyboard = n_keyboard_popup
4838
RetroHubUI._n_config_popup = n_config_popup
49-
RetroHubUI._n_warning_popup = n_warning_popup
39+
RetroHubUI._n_virtual_keyboard = n_keyboard_popup
5040

5141
# Handle viewport changes
5242
#warning-ignore:return_value_discarded
@@ -84,7 +74,6 @@ func setup_controller_remap(remap_str: String):
8474
func show_first_time_popup():
8575
var first_time_popup : Window = load("res://scenes/popups/first_time/FirstTimePopups.tscn").instantiate()
8676
add_child(first_time_popup)
87-
popup_nodes.push_back(first_time_popup)
8877
#warning-ignore:return_value_discarded
8978
first_time_popup.about_to_popup.connect(opened_popup)
9079
#warning-ignore:return_value_discarded

scenes/root/Root.tscn

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
[gd_scene load_steps=12 format=3 uid="uid://c60kwat0su1y"]
1+
[gd_scene load_steps=11 format=3 uid="uid://c60kwat0su1y"]
22

33
[ext_resource type="Script" path="res://scenes/root/Root.gd" id="1"]
44
[ext_resource type="Script" path="res://addons/onscreenkeyboard/onscreen_keyboard.gd" id="2"]
55
[ext_resource type="PackedScene" uid="uid://cjx4cfx0f2k2" path="res://scenes/config/ConfigPopup.tscn" id="3"]
66
[ext_resource type="Script" path="res://scenes/root/Viewport.gd" id="4"]
77
[ext_resource type="Theme" uid="uid://jtuqhw3am1h3" path="res://resources/default_theme.tres" id="5"]
88
[ext_resource type="Shader" path="res://resources/shaders/MenuBlur.gdshader" id="5_co422"]
9-
[ext_resource type="Script" path="res://scenes/root/FileSystemPopup.gd" id="6"]
109
[ext_resource type="Script" path="res://addons/godot-accessibility/ScreenReader.gd" id="7"]
1110
[ext_resource type="Script" path="res://source/utils/InputHandler.gd" id="9_5ltce"]
1211
[ext_resource type="PackedScene" uid="uid://dmcmcyq0jach5" path="res://scenes/no_theme/NoTheme.tscn" id="10"]
@@ -57,47 +56,8 @@ focus_mode = 2
5756
[node name="ConfigPopup" parent="." instance=ExtResource("3")]
5857
handle_input_locally = false
5958
visible = false
60-
content_scale_size = Vector2i(1000, 480)
6159
content_scale_aspect = 4
6260

63-
[node name="FileSystemPopup" type="FileDialog" parent="."]
64-
title = "Open a File"
65-
position = Vector2i(0, 24)
66-
size = Vector2i(949, 477)
67-
popup_window = true
68-
theme = ExtResource("5")
69-
ok_button_text = "Open"
70-
file_mode = 0
71-
access = 2
72-
script = ExtResource("6")
73-
74-
[node name="WarningPopup" type="AcceptDialog" parent="."]
75-
unique_name_in_owner = true
76-
handle_input_locally = false
77-
size = Vector2i(608, 346)
78-
popup_window = true
79-
content_scale_size = Vector2i(608, 346)
80-
content_scale_mode = 1
81-
content_scale_aspect = 4
82-
theme = ExtResource("5")
83-
84-
[node name="WarningLabel" type="Label" parent="WarningPopup"]
85-
unique_name_in_owner = true
86-
anchors_preset = 15
87-
anchor_right = 1.0
88-
anchor_bottom = 1.0
89-
offset_left = 8.0
90-
offset_top = 8.0
91-
offset_right = -8.0
92-
offset_bottom = -48.0
93-
text = "
94-
"
95-
horizontal_alignment = 1
96-
vertical_alignment = 1
97-
autowrap_mode = 3
98-
clip_text = true
99-
text_overrun_behavior = 3
100-
10161
[node name="Keyboard" type="PopupPanel" parent="."]
10262
unique_name_in_owner = true
10363
position = Vector2i(0, 348)
@@ -112,7 +72,3 @@ script = ExtResource("9_5ltce")
11272

11373
[connection signal="about_to_popup" from="ConfigPopup" to="." method="opened_popup"]
11474
[connection signal="popup_hide" from="ConfigPopup" to="." method="closed_popup"]
115-
[connection signal="about_to_popup" from="FileSystemPopup" to="." method="opened_popup"]
116-
[connection signal="about_to_popup" from="FileSystemPopup" to="FileSystemPopup" method="_on_about_to_popup"]
117-
[connection signal="close_requested" from="FileSystemPopup" to="FileSystemPopup" method="restore_window_focus"]
118-
[connection signal="focus_exited" from="FileSystemPopup" to="FileSystemPopup" method="restore_window_focus"]

0 commit comments

Comments
 (0)