From 6c9bbe871dac5fa0735f285de21d67cd33d506b9 Mon Sep 17 00:00:00 2001 From: Tiger Jove Date: Thu, 22 Jan 2026 16:43:25 +0100 Subject: [PATCH] fix: reduce debug spam, refactor unhandled input --- .../luna/playables/story_playable.gd | 4 +++ .../startup/accessibility_container.gd | 6 +++- src/singletons/global_state.gd | 15 ---------- src/singletons/main/main.gd | 18 +++++++++-- src/singletons/main/main.tscn | 30 +++++++++---------- src/ui/menu_main/pause_menu.gd | 4 +++ 6 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/logic-scenes/luna/playables/story_playable.gd b/src/logic-scenes/luna/playables/story_playable.gd index 6bf94b0..3fcae45 100644 --- a/src/logic-scenes/luna/playables/story_playable.gd +++ b/src/logic-scenes/luna/playables/story_playable.gd @@ -220,4 +220,8 @@ func _on_text_finished(): func _emit_thunder() -> void: 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) diff --git a/src/logic-scenes/startup/accessibility_container.gd b/src/logic-scenes/startup/accessibility_container.gd index 12c7e85..910a1fa 100644 --- a/src/logic-scenes/startup/accessibility_container.gd +++ b/src/logic-scenes/startup/accessibility_container.gd @@ -12,7 +12,7 @@ func _find_selectable_in(parent:Control) -> Control: for child in parent.get_children(): var ret := _find_selectable_in(child) if not ret == self: - return ret + return ret return self func _unhandled_input(event : InputEvent) -> void: @@ -40,3 +40,7 @@ func previous() -> void: focus_list[current_tab].grab_focus() else: current_tab -= 1 + +func notification(what: int, _reversed: bool = false) -> void: + if what == NOTIFICATION_VISIBILITY_CHANGED: + self.set_process_input(visible) diff --git a/src/singletons/global_state.gd b/src/singletons/global_state.gd index 8c15e5a..c315714 100644 --- a/src/singletons/global_state.gd +++ b/src/singletons/global_state.gd @@ -229,21 +229,6 @@ func save_settings(): _settings_initialized = true 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(): await get_tree().process_frame music_volume = music_volume diff --git a/src/singletons/main/main.gd b/src/singletons/main/main.gd index cde375b..3e6cee0 100644 --- a/src/singletons/main/main.gd +++ b/src/singletons/main/main.gd @@ -42,7 +42,7 @@ var state: AppState = AppState.BOOT: AppState.PAUSE: credits_roll.hide() main_menu.hide() - pause_menu.show() + pause_menu.appear() AppState.CREDITS: main_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) +var last_mode := DisplayServer.WINDOW_MODE_WINDOWED + 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"): 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 diff --git a/src/singletons/main/main.tscn b/src/singletons/main/main.tscn index 42e0a46..85d9274 100644 --- a/src/singletons/main/main.tscn +++ b/src/singletons/main/main.tscn @@ -130,7 +130,7 @@ layout_mode = 1 visible = false layout_mode = 1 -[node name="PauseMenu" type="Control" parent="."] +[node name="PauseMenu" type="Panel" parent="."] unique_name_in_owner = true visible = false layout_mode = 1 @@ -139,6 +139,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +focus_mode = 2 script = ExtResource("9_ihfph") [node name="TextureRect" type="TextureRect" parent="PauseMenu"] @@ -160,59 +161,58 @@ anchor_bottom = 1.0 grow_horizontal = 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 -[node name="VBoxContainer" type="VBoxContainer" parent="PauseMenu/PauseContainer/PauseMenu"] -layout_mode = 2 - -[node name="Label" type="Label" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] +[node name="Label" type="Label" parent="PauseMenu/PauseContainer/VBoxContainer"] layout_mode = 2 theme_type_variation = &"HeaderLarge" 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 layout_mode = 2 text = "Resume" -[node name="BugButton" type="Button" parent="PauseMenu/PauseContainer/PauseMenu/VBoxContainer"] +[node name="BugButton" type="Button" parent="PauseMenu/PauseContainer/VBoxContainer"] layout_mode = 2 +text = "Bug Report" script = ExtResource("12_cegan") 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 visible = false layout_mode = 2 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 visible = false layout_mode = 2 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 layout_mode = 2 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) 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 layout_mode = 2 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 text = "opens findahelpline.com" 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 visible = false layout_mode = 2 diff --git a/src/ui/menu_main/pause_menu.gd b/src/ui/menu_main/pause_menu.gd index f372de7..46c5157 100644 --- a/src/ui/menu_main/pause_menu.gd +++ b/src/ui/menu_main/pause_menu.gd @@ -18,3 +18,7 @@ func _ready() -> void: func _on_help_pressed(): OS.shell_open("https://findahelpline.com/") + +func appear(): + show() + %ResumeButton.grab_focus.call_deferred()