2023-04-22 13:11:10 +00:00
|
|
|
@tool
|
|
|
|
|
extends CenterContainer
|
|
|
|
|
class_name Collectable_Ui
|
|
|
|
|
|
2023-07-13 14:16:42 +00:00
|
|
|
@export var scene = Scenes.id
|
|
|
|
|
|
2023-04-22 13:11:10 +00:00
|
|
|
@export var collapsed = true:
|
|
|
|
|
set(collapse):
|
2023-06-25 21:45:52 +00:00
|
|
|
if is_inside_tree() and not Engine.is_editor_hint():
|
2023-04-22 13:11:10 +00:00
|
|
|
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
|
|
|
|
|
|
2023-07-13 14:16:42 +00:00
|
|
|
if collapse and has_stage: State.leave_stage(self)
|
|
|
|
|
|
2023-04-22 13:11:10 +00:00
|
|
|
@export var is_story: bool = false
|
2023-07-11 13:27:44 +00:00
|
|
|
@export var has_stage: bool = false:
|
2023-04-22 13:11:10 +00:00
|
|
|
set(focused):
|
2023-05-18 07:40:52 +00:00
|
|
|
print("set focus of card to ", focused)
|
|
|
|
|
|
2023-07-11 13:27:44 +00:00
|
|
|
if has_stage == focused: return
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
if focused:
|
2023-07-11 13:27:44 +00:00
|
|
|
has_stage = true
|
2023-06-25 21:45:52 +00:00
|
|
|
print(visible)
|
|
|
|
|
if not visible: show()
|
|
|
|
|
collapsed = false
|
|
|
|
|
if collected:
|
|
|
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.grab_focus()
|
|
|
|
|
else:
|
|
|
|
|
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
|
2023-07-11 13:27:44 +00:00
|
|
|
elif has_stage:
|
|
|
|
|
has_stage = false
|
2023-04-22 13:11:10 +00:00
|
|
|
get_viewport().gui_release_focus()
|
|
|
|
|
|
|
|
|
|
@export var collected: bool = false:
|
|
|
|
|
set(set_collected):
|
|
|
|
|
collected = set_collected
|
|
|
|
|
if set_collected:
|
|
|
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
|
|
|
|
if is_story:
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.disabled = true
|
|
|
|
|
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.text = "listen again"
|
2023-04-22 13:11:10 +00:00
|
|
|
if State.allow_skipping:
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/Buttons/VBoxContainer/skip.text = "discard cards (skip)"
|
2023-04-22 13:11:10 +00:00
|
|
|
else:
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = true
|
|
|
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
2023-04-22 13:11:10 +00:00
|
|
|
else:
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.disabled = false
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
@export var skipped: bool = false
|
|
|
|
|
|
|
|
|
|
@export var item_name: String = "":
|
|
|
|
|
set(new_name):
|
|
|
|
|
item_name = new_name
|
2023-05-18 07:40:52 +00:00
|
|
|
if is_inside_tree():
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/Name.text = new_name
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
@export var content_notes: String = "":
|
|
|
|
|
set(new_notes):
|
|
|
|
|
content_notes = new_notes
|
2023-05-18 07:40:52 +00:00
|
|
|
if is_inside_tree():
|
2023-07-14 23:07:29 +00:00
|
|
|
$Panel/Content/ContentNotes.text = new_notes
|
2023-04-22 13:11:10 +00:00
|
|
|
|
2023-06-25 21:45:52 +00:00
|
|
|
signal card_collected
|
|
|
|
|
|
2023-04-22 13:11:10 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready():
|
|
|
|
|
#$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()
|
2023-07-14 23:07:29 +00:00
|
|
|
|
|
|
|
|
item_name = item_name
|
|
|
|
|
content_notes = content_notes
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
func _hide_buttons():
|
2023-06-25 21:45:52 +00:00
|
|
|
if is_inside_tree():
|
|
|
|
|
if not State.reduce_motion: $AnimationPlayer.play_backwards("show_buttons")
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
func _show_buttons():
|
2023-06-25 21:45:52 +00:00
|
|
|
if is_inside_tree():
|
|
|
|
|
if not State.reduce_motion:
|
|
|
|
|
$AnimationPlayer.play("show_buttons")
|
|
|
|
|
else:
|
|
|
|
|
$AnimationPlayer.play("RESET")
|
2023-04-22 13:11:10 +00:00
|
|
|
else:
|
|
|
|
|
$AnimationPlayer.play("RESET")
|
|
|
|
|
|
|
|
|
|
func hide():
|
|
|
|
|
if visible:
|
|
|
|
|
_hide_buttons()
|
|
|
|
|
var tween = create_tween()
|
|
|
|
|
tween.tween_property(self, "modulate", 0, 0.4)
|
|
|
|
|
_hide_buttons()
|
|
|
|
|
await tween.finished
|
|
|
|
|
visible = false
|
2023-07-13 14:16:42 +00:00
|
|
|
if has_stage: State.leave_stage(self)
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
func show():
|
2023-07-13 14:16:42 +00:00
|
|
|
if !visible:
|
|
|
|
|
if not collapsed:
|
|
|
|
|
_show_buttons()
|
|
|
|
|
modulate = Color()
|
|
|
|
|
visible = true
|
|
|
|
|
var tween = create_tween()
|
|
|
|
|
tween.tween_property(self, "modulate", Color(1, 1, 1), 0.4)
|
2023-04-22 13:11:10 +00:00
|
|
|
|
|
|
|
|
func _yoink_focus():
|
2023-07-11 13:27:44 +00:00
|
|
|
if not has_stage:
|
2023-07-13 14:16:42 +00:00
|
|
|
State.transition_stage_to(self)
|
2023-06-25 21:45:52 +00:00
|
|
|
|
|
|
|
|
func _on_pick_button_pressed():
|
|
|
|
|
print("card collected!")
|
2023-07-13 14:16:42 +00:00
|
|
|
if scene != null:
|
|
|
|
|
get_tree().call_group("animation_player", "play_scene", scene)
|
2023-07-11 13:27:44 +00:00
|
|
|
State.leave_stage(self)
|
2023-07-13 14:16:42 +00:00
|
|
|
|
|
|
|
|
func _on_pick_button_released():
|
|
|
|
|
hide()
|