fix: no double escape press / settings menu doesnt steal focus

This commit is contained in:
tiger tiger tiger 2026-01-22 20:29:22 +01:00
parent 0de7f96064
commit 14453c12b9
9 changed files with 23 additions and 26 deletions

View File

@ -40,9 +40,6 @@ func _delayed_ready() ->void:
board_room.card_board = self board_room.card_board = self
func play(): func play():
check_board_completion() check_board_completion()
await closed await closed

View File

@ -18,8 +18,8 @@ func _ready() -> void:
# Clunky rebuild... # Clunky rebuild...
story_array = story_array story_array = story_array
progress = progress progress = progress
func _debug_mode(): func _debug_mode():
Main.curtain.open() Main.curtain.open()
super._debug_mode() super._debug_mode()
@ -83,7 +83,7 @@ var substring_sizes: Array[int]
func _rebuild(): func _rebuild():
print("StoryPlayable.gd: %s._rebuild()" % self.name) print("StoryPlayable.gd: %s._rebuild()" % self.name)
if is_node_ready(): if is_node_ready(): # FIXME: node is always ready?
substring_sizes = [] substring_sizes = []
var p: int = 0 var p: int = 0
label.text = "[p]" label.text = "[p]"
@ -103,22 +103,15 @@ func _rebuild():
func try_scroll(): func try_scroll():
var forward_target: float var forward_target: float
#print( "max lines: " + str(max_lines))
#print( "current lines: " + str(label.get_character_line(label.visible_characters)))
var visible_ratio: float = float(label.get_character_line(label.visible_characters)) / max_lines var visible_ratio: float = float(label.get_character_line(label.visible_characters)) / max_lines
#print("Tried scrolling with ratio of %f. Comparing %f against %f" % [visible_ratio, label.size.y * visible_ratio - scroll_container.scroll_vertical, scroll_container.size.y * 0.9])
if label.size.y * visible_ratio + scroll_container.scroll_vertical > scroll_container.size.y * 0.9: if label.size.y * visible_ratio + scroll_container.scroll_vertical > scroll_container.size.y * 0.9:
if scroll_container.scroll_vertical + scroll_container.size.y * 0.9 < label.size.y: if scroll_container.scroll_vertical + scroll_container.size.y * 0.9 < label.size.y:
forward_target = scroll_container.scroll_vertical + scroll_container.size.y * 0.8 forward_target = scroll_container.scroll_vertical + scroll_container.size.y * 0.8
else: else:
forward_target = label.size.y - scroll_container.size.y forward_target = label.size.y - scroll_container.size.y
if scroll_target != null:
#var tween: Tween = get_tree().create_tween() scroll_target = forward_target
##tween.set_trans()
scroll_target = forward_target
## frame rate independent FIR smoothing filter used for small or dynamic card adjustments ## frame rate independent FIR smoothing filter used for small or dynamic card adjustments
@ -131,13 +124,13 @@ func _process(delta: float) -> void:
scroll_current = _smooth(scroll_current, scroll_target, delta) scroll_current = _smooth(scroll_current, scroll_target, delta)
scroll_container.scroll_vertical = ceili(scroll_current) scroll_container.scroll_vertical = ceili(scroll_current)
func appear(): func appear():
hide() hide()
if animation_player.has_animation("ini"): if animation_player.has_animation("ini"):
animation_player.play("ini") animation_player.play("ini")
await animation_player.animation_finished await animation_player.animation_finished
scroll_target = 0 scroll_target = 0
# FIXME: find out why this needs to be set to prevent scenes from being fully revealed # FIXME: find out why this needs to be set to prevent scenes from being fully revealed
@ -153,7 +146,7 @@ func appear():
# Wait and get ready. # Wait and get ready.
await get_tree().process_frame await get_tree().process_frame
await super.appear() await super.appear()
func play(): func play():
print("StoryPlayable.gd: %s.play()" % self.name) print("StoryPlayable.gd: %s.play()" % self.name)
@ -232,4 +225,3 @@ func _on_text_finished():
func _emit_thunder() -> void: func _emit_thunder() -> void:
if State.room is YouthRoom: (State.room as YouthRoom).play_thunder() if State.room is YouthRoom: (State.room as YouthRoom).play_thunder()

View File

@ -86,5 +86,5 @@ func _on_exit_button_pressed() -> void:
State.save_settings() State.save_settings()
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and focused: if event.is_action_pressed("ui_cancel") and focused and is_visible_in_tree():
leave_stage.emit() leave_stage.emit()

View File

@ -47,5 +47,5 @@ func _on_exit_button_pressed() -> void:
leave_stage.emit() leave_stage.emit()
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and focused: if event.is_action_pressed("ui_cancel") and focused and is_visible_in_tree():
leave_stage.emit() leave_stage.emit()

View File

@ -39,5 +39,5 @@ func _on_exit_button_pressed() -> void:
State.save_settings() State.save_settings()
func _gui_input(event: InputEvent) -> void: func _gui_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and focused: if event.is_action_pressed("ui_cancel") and focused and is_visible_in_tree():
leave_stage.emit() leave_stage.emit()

View File

@ -41,7 +41,7 @@ func _on_exit_button_pressed() -> void:
State.save_settings() State.save_settings()
func _gui_input(event: InputEvent) -> void: func _gui_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and focused: if event.is_action_pressed("ui_cancel") and focused and is_visible_in_tree():
leave_stage.emit() leave_stage.emit()
func reset_all_stats(): func reset_all_stats():

View File

@ -286,5 +286,5 @@ func select_id_to_window_mode(item_id) -> DisplayServer.WindowMode:
return item_id + 2 if item_id != 0 else 0 return item_id + 2 if item_id != 0 else 0
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event.is_action_pressed("ui_cancel") and focused: if event.is_action_pressed("ui_cancel") and focused and is_visible_in_tree():
_on_exit_button_pressed() _on_exit_button_pressed()

View File

@ -1,7 +1,13 @@
[gd_scene load_steps=2 format=3 uid="uid://bsjc1ry0qpe61"] [gd_scene load_steps=4 format=3 uid="uid://bsjc1ry0qpe61"]
[ext_resource type="Script" uid="uid://dugfwcvp7i01k" path="res://ui/menu_main/save_game_list.gd" id="1_w1a7u"] [ext_resource type="Script" uid="uid://dugfwcvp7i01k" path="res://ui/menu_main/save_game_list.gd" id="1_w1a7u"]
[sub_resource type="InputEventAction" id="InputEventAction_4wrxo"]
action = &"ui_cancel"
[sub_resource type="Shortcut" id="Shortcut_lficf"]
events = [SubResource("InputEventAction_4wrxo")]
[node name="SaveGameList" type="Control"] [node name="SaveGameList" type="Control"]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@ -63,4 +69,5 @@ alignment = 2
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
size_flags_vertical = 4 size_flags_vertical = 4
shortcut = SubResource("Shortcut_lficf")
text = "Zurück" text = "Zurück"

View File

@ -245,6 +245,7 @@ _data = {
[node name="SettingsPopup" type="PanelContainer"] [node name="SettingsPopup" type="PanelContainer"]
visible = false visible = false
self_modulate = Color(1, 1, 1, 0) self_modulate = Color(1, 1, 1, 0)
scale = Vector2(1, 0.57)
script = ExtResource("1_87f5w") script = ExtResource("1_87f5w")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]