fix: reduce debug spam, refactor unhandled input

This commit is contained in:
tiger tiger tiger 2026-01-22 16:43:25 +01:00
parent 982c426439
commit 6c9bbe871d
6 changed files with 44 additions and 33 deletions

View File

@ -220,4 +220,8 @@ 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()
func notification(what: int, _reversed: bool = false) -> void:
if what == NOTIFICATION_VISIBILITY_CHANGED:
self.set_process_input(visible)

View File

@ -12,7 +12,7 @@ func _find_selectable_in(parent:Control) -> Control:
for child in parent.get_children(): for child in parent.get_children():
var ret := _find_selectable_in(child) var ret := _find_selectable_in(child)
if not ret == self: if not ret == self:
return ret return ret
return self return self
func _unhandled_input(event : InputEvent) -> void: func _unhandled_input(event : InputEvent) -> void:
@ -40,3 +40,7 @@ func previous() -> void:
focus_list[current_tab].grab_focus() focus_list[current_tab].grab_focus()
else: else:
current_tab -= 1 current_tab -= 1
func notification(what: int, _reversed: bool = false) -> void:
if what == NOTIFICATION_VISIBILITY_CHANGED:
self.set_process_input(visible)

View File

@ -229,21 +229,6 @@ func save_settings():
_settings_initialized = true _settings_initialized = true
settings_changed.emit() settings_changed.emit()
var last_mode := DisplayServer.WINDOW_MODE_WINDOWED
func _unhandled_input(event: InputEvent) -> void:
#FIXME this can be removed when state no longer needs to be a tool
if not Engine.is_editor_hint():
if event.is_action_pressed("toggle_fullscreen"):
# I have no idea why I wrote thit as conviluted,
# but it works(TM) so I am not gonna change it :D
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(last_mode)
else:
last_mode = DisplayServer.window_get_mode()
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
#endregion
func _ready(): func _ready():
await get_tree().process_frame await get_tree().process_frame
music_volume = music_volume music_volume = music_volume

View File

@ -42,7 +42,7 @@ var state: AppState = AppState.BOOT:
AppState.PAUSE: AppState.PAUSE:
credits_roll.hide() credits_roll.hide()
main_menu.hide() main_menu.hide()
pause_menu.show() pause_menu.appear()
AppState.CREDITS: AppState.CREDITS:
main_menu.hide() main_menu.hide()
pause_menu.hide() pause_menu.hide()
@ -106,7 +106,21 @@ func _load_room(scene_path: String) -> void:
assert(false, "Couldn't load room %s" % scene_path) assert(false, "Couldn't load room %s" % scene_path)
var last_mode := DisplayServer.WINDOW_MODE_WINDOWED
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
if event.is_action_type(): print_debug("Unhandled Input", event) if not event.is_action_type(): return
if event.is_action_pressed("ui_pause"): if event.is_action_pressed("ui_pause"):
state = AppState.PAUSE state = AppState.PAUSE
if not Engine.is_editor_hint():
if event.is_action_pressed("toggle_fullscreen"):
# I have no idea why I wrote thit as convoluted,
# but it works(TM) so I am not gonna change it :D
if DisplayServer.window_get_mode() == DisplayServer.WINDOW_MODE_FULLSCREEN:
DisplayServer.window_set_mode(last_mode)
else:
last_mode = DisplayServer.window_get_mode()
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
#endregion

View File

@ -130,7 +130,7 @@ layout_mode = 1
visible = false visible = false
layout_mode = 1 layout_mode = 1
[node name="PauseMenu" type="Control" parent="."] [node name="PauseMenu" type="Panel" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 1 layout_mode = 1
@ -139,6 +139,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
focus_mode = 2
script = ExtResource("9_ihfph") script = ExtResource("9_ihfph")
[node name="TextureRect" type="TextureRect" parent="PauseMenu"] [node name="TextureRect" type="TextureRect" parent="PauseMenu"]
@ -160,59 +161,58 @@ anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
[node name="PauseMenu" type="PanelContainer" parent="PauseMenu/PauseContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="PauseMenu/PauseContainer"]
unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="PauseMenu/PauseContainer/PauseMenu"] [node name="Label" type="Label" parent="PauseMenu/PauseContainer/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"]
layout_mode = 2 layout_mode = 2
theme_type_variation = &"HeaderLarge" theme_type_variation = &"HeaderLarge"
text = "Game Paused" text = "Game Paused"
[node name="ResumeButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="ResumeButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Resume" text = "Resume"
[node name="BugButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="BugButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "Bug Report"
script = ExtResource("12_cegan") script = ExtResource("12_cegan")
metadata/_custom_type_script = "uid://sa15wakvpj2e" metadata/_custom_type_script = "uid://sa15wakvpj2e"
[node name="ToMenuButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="ToMenuButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Return to Menu" text = "Return to Menu"
[node name="ToSettingsButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="ToSettingsButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2
text = "Open Settings" text = "Open Settings"
[node name="ToDesktopButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="ToDesktopButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Quit to Desktop" text = "Quit to Desktop"
[node name="HSeparator" type="HSeparator" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="HSeparator" type="HSeparator" parent="PauseMenu/PauseContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 20) custom_minimum_size = Vector2(0, 20)
layout_mode = 2 layout_mode = 2
[node name="FindHelplineButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="FindHelplineButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
text = "Find Help-Lines" text = "Find Help-Lines"
[node name="Label2" type="Label" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="Label2" type="Label" parent="PauseMenu/PauseContainer/VBoxContainer"]
layout_mode = 2 layout_mode = 2
text = "opens findahelpline.com" text = "opens findahelpline.com"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="SkipStoryButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] [node name="SkipStoryButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
visible = false visible = false
layout_mode = 2 layout_mode = 2

View File

@ -18,3 +18,7 @@ func _ready() -> void:
func _on_help_pressed(): func _on_help_pressed():
OS.shell_open("https://findahelpline.com/") OS.shell_open("https://findahelpline.com/")
func appear():
show()
%ResumeButton.grab_focus.call_deferred()