frame-of-mind/src/logic-scenes/collectable/collectable_ui.gd

151 lines
4.1 KiB
GDScript3
Raw Normal View History

@tool
extends CenterContainer
class_name Collectable_Ui
2025-02-06 17:55:05 +00:00
@export var scene:Scenes.id = 0
@export var collapsed = true:
2024-09-15 09:30:31 +00:00
set(collapse):
if is_inside_tree() and not Engine.is_editor_hint():
if State.reduce_motion:
collapsed = false
return
if collapse and not collapsed:
if is_inside_tree():
_hide_buttons()
collapsed = collapse
elif not collapse and collapsed:
if is_inside_tree():
_show_buttons()
collapsed = collapse
if collapse and has_stage: State.leave_stage(self)
2025-02-06 17:55:05 +00:00
@export var is_board: bool = false:
set(board):
is_board = board
if board:
2024-09-15 09:30:31 +00:00
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Order Thoughts"
else:
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "Collect Memento"
@export var has_stage: bool = false:
2024-09-15 09:30:31 +00:00
set(focused):
print("set focus of card to ", focused)
if has_stage == focused: return
if focused:
has_stage = true
collapsed = false
if not visible: show()
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
elif has_stage:
has_stage = false
get_viewport().gui_release_focus()
# FIXME needs to be outsourced to scene reference state
@export var collected: bool = false:
2024-09-15 09:30:31 +00:00
set(set_collected):
collected = set_collected
if set_collected:
$Panel/Content/Buttons/VBoxContainer/put_back.show()
2025-02-06 17:55:05 +00:00
if not is_board:
2024-09-15 09:30:31 +00:00
$Panel/Content/Buttons/VBoxContainer/put_back.disabled = true
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "listen again"
if State.allow_skipping:
$Panel/Content/Buttons/VBoxContainer/skip.text = "discard cards (skip)"
else:
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = true
$Panel/Content/Buttons/VBoxContainer/put_back.show()
else:
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = false
@export var skipped: bool = false
@export var item_name: String = "":
2024-09-15 09:30:31 +00:00
set(new_name):
item_name = new_name
if is_inside_tree():
$Panel/Content/Name.text = new_name
@export var content_notes: String = "":
2024-09-15 09:30:31 +00:00
set(new_notes):
content_notes = new_notes
if is_inside_tree():
$Panel/Content/ContentNotes.text = new_notes
signal card_collected
2023-07-19 11:51:26 +00:00
signal open_board
signal scene_skipped(i: int)
# Called when the node enters the scene tree for the first time.
func _ready():
2024-09-15 09:30:31 +00:00
#$Panel/Content/ContentNotes.visible = State.show_content_notes
#$Panel/Content/Buttons/VBoxContainer/Summary.visible = State.provide_summaries
#$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping
if visible and not collapsed: _show_buttons()
content_notes = content_notes
2025-02-06 17:55:05 +00:00
is_board = is_board
2024-09-15 09:30:31 +00:00
item_name = item_name
func _hide_buttons():
2024-09-15 09:30:31 +00:00
if is_inside_tree():
if not State.reduce_motion:
$AnimationPlayer.play_backwards("show_buttons")
func _show_buttons():
2024-09-15 09:30:31 +00:00
if is_inside_tree():
if not State.reduce_motion:
$AnimationPlayer.play("show_buttons")
else:
$AnimationPlayer.play("RESET")
else:
$AnimationPlayer.play("RESET")
2025-03-23 13:22:40 +00:00
func vanish():
2024-09-15 09:30:31 +00:00
if visible:
var tween = create_tween()
tween.tween_property(self, "modulate", Color(0, 0, 0), 0.4)
if not collapsed: _hide_buttons()
await tween.finished
visible = false
if has_stage: State.leave_stage(self)
2025-03-23 13:22:40 +00:00
func reveal():
2024-09-15 09:30:31 +00:00
if !visible:
$Panel/Content/ContentNotes.visible = State.show_content_notes
2025-02-06 17:55:05 +00:00
$Panel/Content/Buttons/VBoxContainer/skip.visible = State.allow_skipping and not is_board and not skipped
2024-09-15 09:30:31 +00:00
if not collapsed:
_show_buttons()
modulate = Color()
visible = true
var tween = create_tween()
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.4)
func _yoink_focus():
2024-09-15 09:30:31 +00:00
if not has_stage:
State.transition_stage_to(self)
func _on_pick_button_pressed():
2024-09-15 09:30:31 +00:00
print("card collected!")
2025-02-06 17:55:05 +00:00
if not is_board:
Scenes.start_sequence(scene)
2024-09-15 09:30:31 +00:00
State.leave_stage(self)
2025-02-06 17:55:05 +00:00
#get_tree().call_group("scene_actors", "play_scene", scene, collected)
2024-09-15 09:30:31 +00:00
if skipped: emit_signal("scene_skipped", -1)
collected = true
else:
emit_signal("open_board")
hide()
2023-07-19 11:51:26 +00:00
func _on_skip_pressed():
2024-09-15 09:30:31 +00:00
print("Scene skipped!")
if scene != null:
emit_signal("scene_skipped", 1)
skipped = true
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "collect (un-skip)"
State.leave_stage(self)