fix: settings no longer stuck open until a tab was focused, and load game menu starts at the top item properly aligned
This commit is contained in:
parent
cf057ec84f
commit
c76f599e4b
|
|
@ -7,7 +7,12 @@ func _ready() -> void:
|
|||
if "leave_stage" in child:
|
||||
child.leave_stage.connect(_on_stage_left)
|
||||
tab_changed.connect(_on_tab_changed)
|
||||
pass_to_actor = get_child(current_tab)
|
||||
|
||||
# Initialize the first tab's focus state
|
||||
var initial_child = get_child(current_tab)
|
||||
if "focused" in initial_child:
|
||||
initial_child.focused = true
|
||||
pass_to_actor = initial_child
|
||||
|
||||
func _on_tab_changed(tab_id: int):
|
||||
# Transfer focused to the new tab's child
|
||||
|
|
@ -23,5 +28,4 @@ func _on_tab_changed(tab_id: int):
|
|||
|
||||
func _on_stage_left():
|
||||
await get_tree().process_frame
|
||||
if not pass_to_actor.focused:
|
||||
get_parent().vanish()
|
||||
get_parent().vanish()
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ var save_buttons: Array[SaveGameDisplay]
|
|||
set(value):
|
||||
_load_games()
|
||||
|
||||
@onready var scroll_container: ScrollContainer = %ScrollContainer
|
||||
@onready var list_container: VBoxContainer = %ListContainer
|
||||
@onready var back_button: Button = $MarginContainer/VBoxContainer/HBoxContainer/Button
|
||||
|
||||
|
|
@ -85,6 +86,9 @@ func _rebuild_buttons() -> void:
|
|||
new_button.pressed.connect(_on_game_picked.bind(i))
|
||||
new_button.delete_requested.connect(_on_delete_requested.bind(i))
|
||||
|
||||
# Reset scroll position to top after rebuilding
|
||||
scroll_container.scroll_vertical = 0
|
||||
|
||||
|
||||
func _on_game_picked(id: int) -> void:
|
||||
_picked.emit(saves[id])
|
||||
|
|
@ -139,7 +143,12 @@ func pick_save_slot() -> SaveGame:
|
|||
# TODO: ugh, godot tweens are the wurst
|
||||
func open() -> void:
|
||||
show()
|
||||
save_buttons[0].grab_focus()
|
||||
await get_tree().process_frame
|
||||
if save_buttons.size() > 0:
|
||||
save_buttons[0].grab_focus()
|
||||
# Reset scroll to top AFTER focus (which triggers auto-scroll)
|
||||
await get_tree().process_frame
|
||||
scroll_container.scroll_vertical = 0
|
||||
modulate = Color.TRANSPARENT
|
||||
if _tween != null:
|
||||
_tween.kill()
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ anchor_right = 1.0
|
|||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 320
|
||||
theme_override_constants/margin_top = 100
|
||||
theme_override_constants/margin_right = 320
|
||||
theme_override_constants/margin_bottom = 100
|
||||
theme_override_constants/margin_left = 400
|
||||
theme_override_constants/margin_top = 120
|
||||
theme_override_constants/margin_right = 400
|
||||
theme_override_constants/margin_bottom = 120
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
|
@ -41,9 +41,12 @@ color = Color(0, 0, 0, 0.2509804)
|
|||
layout_mode = 2
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
follow_focus = true
|
||||
horizontal_scroll_mode = 0
|
||||
vertical_scroll_mode = 2
|
||||
|
||||
[node name="ListContainer" type="VBoxContainer" parent="MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
|
|
|
|||
Loading…
Reference in New Issue