feat: board can now be left with the mouse :D

This commit is contained in:
tiger tiger tiger 2026-01-23 16:25:28 +01:00
parent a1766d5c3c
commit f8f50a0755
3 changed files with 25 additions and 37 deletions

View File

@ -17,7 +17,7 @@ var board_was_completed: bool = false
var current_context : int = NAVIGATE var current_context : int = NAVIGATE
var selection_state : SelectionState var selection_state : SelectionState
@onready var instructions := $instructions_panel/HBoxContainer/cards_remaining #@onready var instructions := $instructions_panel/HBoxContainer/cards_remaining
@onready var dropzone : Control = %CardZone @onready var dropzone : Control = %CardZone
@onready var notezone : Control = %NoteZone @onready var notezone : Control = %NoteZone
@ -32,6 +32,7 @@ func _ready() -> void:
_delayed_ready.call_deferred() _delayed_ready.call_deferred()
# We need to wait for our room further up our parent hierarchy to actually make itself known # We need to wait for our room further up our parent hierarchy to actually make itself known
# for interactables to do things with it, e.g. CardBoard needs to register itself # for interactables to do things with it, e.g. CardBoard needs to register itself
func _delayed_ready() ->void: func _delayed_ready() ->void:
@ -40,17 +41,31 @@ func _delayed_ready() ->void:
board_room.card_board = self board_room.card_board = self
## Updates prompt label based on the interaction type and collected state
func _show_prompt() -> void:
var overrides : Array[StringName] = [&"menu_back"]
P.left_bottom(P.pick(&"ui_cancel"), overrides)
P.instruction(I18n.get_memento_prompt(mementos_collected))
P.performed.connect(_perform)
func _hide_prompt():
P.performed.disconnect(_perform)
P.clear()
func play(): func play():
_show_prompt()
check_board_completion() check_board_completion()
await closed await closed
print("CardBoard.gd: closing") print("CardBoard.gd: closing")
_finalize_board_state() _finalize_board_state()
_hide_prompt()
var mementos_collected: int = 0: var mementos_collected: int = 0:
set(mementos): set(mementos):
mementos_collected = mementos mementos_collected = mementos
instructions.text = I18n.get_memento_prompt(mementos_collected)
var selection: Draggable = null: var selection: Draggable = null:
@ -302,7 +317,7 @@ func give_lore_feedback():
fitting_card_count += int(child.card_id == child.get_attached_note().parent_id) fitting_card_count += int(child.card_id == child.get_attached_note().parent_id)
if float(fitting_card_count) / float(total_card_count) < 0.2: if float(fitting_card_count) / float(total_card_count) < 0.2:
instructions.text = "You can move on, but you may not have understood Lisa." P.instruction("You can move on, but you may not have understood Lisa.")
if not unfitting: if not unfitting:
if State.speech_language == 2: if State.speech_language == 2:
$AnimationPlayer.play("unfitting_de") $AnimationPlayer.play("unfitting_de")
@ -310,7 +325,7 @@ func give_lore_feedback():
$AnimationPlayer.play("unfitting") $AnimationPlayer.play("unfitting")
unfitting = true unfitting = true
elif fitting_card_count < total_card_count: elif fitting_card_count < total_card_count:
instructions.text = TranslationServer.translate("You may leave the room, but Lisa only agrees with %d of the %d connections.") % [fitting_card_count, total_card_count] P.instruction(TranslationServer.translate("You may leave the room, but Lisa only agrees with %d of the %d connections.") % [fitting_card_count, total_card_count])
if not incomplete: if not incomplete:
if State.speech_language == 2: if State.speech_language == 2:
$AnimationPlayer.play("incomplete_de") $AnimationPlayer.play("incomplete_de")
@ -318,7 +333,7 @@ func give_lore_feedback():
$AnimationPlayer.play("incomplete") $AnimationPlayer.play("incomplete")
incomplete = true incomplete = true
else: else:
instructions.text = "Lisa would like you to leave her room and move on." P.instruction("Lisa would like you to leave her room and move on.")
if not complete: if not complete:
if State.speech_language == 2: if State.speech_language == 2:
$AnimationPlayer.play("complete_de") $AnimationPlayer.play("complete_de")
@ -387,13 +402,13 @@ func handle_drop(draggable: Draggable) -> int:
return Draggable.DropResult.ACCEPTED return Draggable.DropResult.ACCEPTED
func _perform(action : StringName) -> void:
match action:
&"ui_cancel": closed.emit()
# Takes the inputs for control inputs # Takes the inputs for control inputs
func _input(event : InputEvent) -> void: func _input(event : InputEvent) -> void:
if event.is_action_pressed("ui_cancel"):
print("CardBoard.gd: ui_cancel")
closed.emit()
get_viewport().set_input_as_handled()
if selection and not selection.is_dragged and event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"): if selection and not selection.is_dragged and event is InputEventMouseMotion and not event.is_action_pressed("mouse_left"):
var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes)) var candidate := _nearest_hovered(_sort_by_proximity_and_depth(notes))
if not candidate: if not candidate:

View File

@ -176,32 +176,6 @@ custom_minimum_size = Vector2(400, 0)
layout_mode = 2 layout_mode = 2
mouse_filter = 1 mouse_filter = 1
[node name="instructions_panel" type="PanelContainer" parent="."]
z_index = 100
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 0
mouse_filter = 2
[node name="HBoxContainer" type="HBoxContainer" parent="instructions_panel"]
layout_mode = 2
mouse_filter = 2
[node name="VSeparator2" type="VSeparator" parent="instructions_panel/HBoxContainer"]
custom_minimum_size = Vector2(15, 0)
layout_mode = 2
[node name="cards_remaining" type="Label" parent="instructions_panel/HBoxContainer"]
layout_mode = 2
size_flags_vertical = 0
text = "Collect all four Mementos to fill the mind-board. "
horizontal_alignment = 1
vertical_alignment = 1
[node name="VSeparator" type="VSeparator" parent="instructions_panel/HBoxContainer"]
custom_minimum_size = Vector2(15, 0)
layout_mode = 2
[node name="Timer" type="Timer" parent="."] [node name="Timer" type="Timer" parent="."]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]

View File

@ -180,7 +180,6 @@ func interact() -> void:
## Updates prompt label based on the interaction type and collected state ## Updates prompt label based on the interaction type and collected state
func _show_prompt() -> void: func _show_prompt() -> void:
var overrides : Array[StringName] = [] var overrides : Array[StringName] = []
if playable is StoryPlayable: if playable is StoryPlayable:
P.interaction(I18n.get_scene_caption(playable.scene_id)) P.interaction(I18n.get_scene_caption(playable.scene_id))