fix: Pause Menu works.

This commit is contained in:
tiger tiger tiger 2026-01-22 18:36:36 +01:00
parent 03f427b76a
commit d58225f21b
8 changed files with 77 additions and 19 deletions

View File

@ -1,23 +1,27 @@
class_name CardBurner class_name CardBurner
extends Playable extends Playable
@onready var cursor: CandleCursor = %CandleCursor @onready var cursor: CandleCursor = %CandleCursor
@onready var ancors: Array[Control] = [%Ancor1, %Ancor2, %Ancor3, %Ancor4] @onready var ancors: Array[Control] = [%Ancor1, %Ancor2, %Ancor3, %Ancor4]
signal card_burned signal card_burned
var cards : Array[Card] = [] var cards : Array[Card] = []
var _submitted := false var _submitted := false
var _populated : bool = false
var _input_locked : bool: var _input_locked : bool:
get: return _submitted or not visible get: return _submitted or not visible or not _populated
func _ready(): func _ready():
print("CardBurner.gd: %s._ready()" % self.name) print("CardBurner.gd: %s._ready()" % self.name)
super._ready() super._ready()
%SkipButton.pressed.connect(card_burned.emit) %SkipButton.pressed.connect(card_burned.emit)
func vanish(): func vanish():
super.vanish() super.vanish()
await Main.curtain.black() # Go straight to loading screen await Main.curtain.black() # Go straight to loading screen
@ -27,7 +31,21 @@ func vanish():
## Main play coroutine - simple linear flow for burning a card ## Main play coroutine - simple linear flow for burning a card
func play() -> void: func play() -> void:
print("CardBurner: Starting card burning sequence") print("CardBurner: Starting card burning sequence")
_populate()
# 4. Wait for player to burn a card (or skip)
print("CardBurner: Waiting for player to burn a card...")
await card_burned
# 5. Play vanish animation and wait for completion
print("CardBurner: Card burned, playing vanish animation")
$AnimationPlayer.play("vanish")
await $AnimationPlayer.animation_finished
print("CardBurner: Sequence complete")
func _populate() -> void:
# 1. Get all card names from the board (excluding stickies which start with "p") # 1. Get all card names from the board (excluding stickies which start with "p")
var card_names: Array[StringName] = [] var card_names: Array[StringName] = []
for item_name in State.save_game.board_positions.keys(): for item_name in State.save_game.board_positions.keys():
@ -51,18 +69,7 @@ func play() -> void:
print("CardBurner: Added card '%s' to anchor" % card.name) print("CardBurner: Added card '%s' to anchor" % card.name)
print("CardBurner: ", len(cards)) print("CardBurner: ", len(cards))
_populated = true
# 4. Wait for player to burn a card (or skip)
print("CardBurner: Waiting for player to burn a card...")
await card_burned
# 5. Play vanish animation and wait for completion
print("CardBurner: Card burned, playing vanish animation")
$AnimationPlayer.play("vanish")
await $AnimationPlayer.animation_finished
print("CardBurner: Sequence complete")
func handle_hover(card: Draggable) -> void: func handle_hover(card: Draggable) -> void:
if _input_locked: return if _input_locked: return
@ -80,6 +87,7 @@ func handle_mouse_button(event: InputEventMouseButton, card: Card) -> void:
if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo(): if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo():
_submit(card) _submit(card)
func _submit(card : Card): func _submit(card : Card):
_submitted = true _submitted = true
%ActionPrompt.visible = false %ActionPrompt.visible = false

View File

@ -167,6 +167,7 @@ func pick(id: int) -> void:
await yield_to await yield_to
if not card_anim_skipped: transition() if not card_anim_skipped: transition()
func transition(): func transition():
if selection_state == CARDS_SELECTED: if selection_state == CARDS_SELECTED:
selection_state = TRANSITION selection_state = TRANSITION
@ -194,6 +195,7 @@ func transition():
cards_picked.emit(out_str) cards_picked.emit(out_str)
selection_state = DONE selection_state = DONE
func show_posts(): func show_posts():
for player:AnimationPlayer in anim_players: for player:AnimationPlayer in anim_players:
player.play("RESET") player.play("RESET")
@ -207,6 +209,7 @@ func handle_hover(draggable: Draggable) -> void:
if draggable.mouse_over: if draggable.mouse_over:
curr_selection_id = options.find(draggable) curr_selection_id = options.find(draggable)
func handle_mouse_button(event: InputEventMouseButton, draggable: Draggable) -> void: func handle_mouse_button(event: InputEventMouseButton, draggable: Draggable) -> void:
if _input_locked: return if _input_locked: return

View File

@ -181,7 +181,6 @@ func play_burner() -> void:
func interact() -> void: func interact() -> void:
Scenes.player_enable.emit(false) Scenes.player_enable.emit(false)
# we must wait for our own collapse, so it doesnt change its caption while the canvas shows # we must wait for our own collapse, so it doesnt change its caption while the canvas shows
await collapse() await collapse()
get_tree().call_group("interactables", "collapse") get_tree().call_group("interactables", "collapse")

View File

@ -268,8 +268,7 @@ var crouch_toggled: bool = false
var crouch_start_time: float = 0 var crouch_start_time: float = 0
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if not enabled: if not enabled: return
return
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
_handle_mouse_input(event) _handle_mouse_input(event)

View File

@ -95,7 +95,7 @@ func _load_room(scene_path: String) -> void:
ResourceLoader.THREAD_LOAD_LOADED: ResourceLoader.THREAD_LOAD_LOADED:
var next_scene := ResourceLoader.load_threaded_get(scene_path) as PackedScene var next_scene := ResourceLoader.load_threaded_get(scene_path) as PackedScene
State.room = next_scene.instantiate() as Room State.room = next_scene.instantiate() as Room
get_tree().root.add_child(State.room) %Stage.add_child(State.room)
await get_tree().process_frame await get_tree().process_frame
%Loading.stop() %Loading.stop()
return return

View File

@ -99,6 +99,9 @@ youth_room_path = "uid://b3b0gyvklqn50"
transition_room_path = "uid://fgp3tbah7msy" transition_room_path = "uid://fgp3tbah7msy"
adulthood_room_path = "uid://flisupth27th" adulthood_room_path = "uid://flisupth27th"
[node name="Stage" type="Node" parent="."]
unique_name_in_owner = true
[node name="Curtain" parent="." instance=ExtResource("2_nbcxq")] [node name="Curtain" parent="." instance=ExtResource("2_nbcxq")]
unique_name_in_owner = true unique_name_in_owner = true
z_index = -1 z_index = -1
@ -132,6 +135,7 @@ layout_mode = 1
[node name="PauseMenu" type="Panel" parent="."] [node name="PauseMenu" type="Panel" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 2
visible = false visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15

View File

@ -0,0 +1,35 @@
[gd_scene load_steps=2 format=3 uid="uid://d7sqqr8pkydk"]
[sub_resource type="GDScript" id="GDScript_m0plu"]
script/source = "extends Node3D
func _input(event : InputEvent):
prints(name, event)
"
[node name="InputOrderTests" type="Node"]
[node name="Item1" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item2" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item3" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item4" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item5" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item6" type="Node3D" parent="."]
process_priority = -10
script = SubResource("GDScript_m0plu")
[node name="Item7" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")
[node name="Item8" type="Node3D" parent="."]
script = SubResource("GDScript_m0plu")

View File

@ -9,7 +9,7 @@ class_name PauseMenu extends Control
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
resume_button.pressed.connect(func(): Main.state = Main.AppState.PLAY) resume_button.pressed.connect(func(): disappear())
#to_menu_button.pressed.connect(_process) #to_menu_button.pressed.connect(_process)
to_desktop_button.pressed.connect(func(): get_tree().quit()) to_desktop_button.pressed.connect(func(): get_tree().quit())
#to_settings_button.pressed.connect(_process) #to_settings_button.pressed.connect(_process)
@ -19,10 +19,20 @@ func _ready() -> void:
func _on_help_pressed(): func _on_help_pressed():
OS.shell_open("https://findahelpline.com/") OS.shell_open("https://findahelpline.com/")
var last_mouse_mode: Input.MouseMode
func appear(): func appear():
get_tree().paused = true
show() show()
last_mouse_mode = Input.mouse_mode
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
%ResumeButton.grab_focus.call_deferred() %ResumeButton.grab_focus.call_deferred()
func disappear():
hide()
Input.mouse_mode = last_mouse_mode
get_tree().paused = false
func _unhandled_input(_event: InputEvent) -> void: func _unhandled_input(_event: InputEvent) -> void:
if not visible: return if not visible: return
get_viewport().set_input_as_handled() get_viewport().set_input_as_handled()