106 lines
3.3 KiB
GDScript3
106 lines
3.3 KiB
GDScript3
|
|
@tool
|
||
|
|
extends CenterContainer
|
||
|
|
class_name Collectable_Ui
|
||
|
|
|
||
|
|
@export var collapsed = true:
|
||
|
|
set(collapse):
|
||
|
|
if is_inside_tree():
|
||
|
|
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
|
||
|
|
|
||
|
|
@export var is_story: bool = false
|
||
|
|
@export var has_focus: bool = false:
|
||
|
|
set(focused):
|
||
|
|
if has_focus == focused: return
|
||
|
|
|
||
|
|
if focused:
|
||
|
|
has_focus = State.request_focus(self)
|
||
|
|
if has_focus:
|
||
|
|
collapsed = false
|
||
|
|
if collected:
|
||
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.grab_focus()
|
||
|
|
else:
|
||
|
|
$Panel/Content/Buttons/VBoxContainer/collect_or_listen.grab_focus()
|
||
|
|
elif has_focus:
|
||
|
|
has_focus = false
|
||
|
|
State.drop_own_focus(self)
|
||
|
|
get_viewport().gui_release_focus()
|
||
|
|
hide()
|
||
|
|
|
||
|
|
if not visible:
|
||
|
|
show()
|
||
|
|
|
||
|
|
|
||
|
|
@export var collected: bool = false:
|
||
|
|
set(set_collected):
|
||
|
|
collected = set_collected
|
||
|
|
if set_collected:
|
||
|
|
$Panel/Content/Buttons/VBoxContainer/put_back.show()
|
||
|
|
if is_story:
|
||
|
|
$Content/Buttons/VBoxContainer/put_back.disabled = true
|
||
|
|
$Content/Buttons/VBoxContainer/collect_or_listen.text = "listen again"
|
||
|
|
if State.allow_skipping:
|
||
|
|
$Content/Buttons/VBoxContainer/skip.text = "discard cards (skip)"
|
||
|
|
else:
|
||
|
|
$Content/Buttons/VBoxContainer/collect_or_listen.disabled = true
|
||
|
|
$Content/Buttons/VBoxContainer/put_back.show()
|
||
|
|
else:
|
||
|
|
$Content/Buttons/VBoxContainer/collect_or_listen.disabled = false
|
||
|
|
|
||
|
|
@export var skipped: bool = false
|
||
|
|
|
||
|
|
@export var item_name: String = "":
|
||
|
|
set(new_name):
|
||
|
|
item_name = new_name
|
||
|
|
$Content/Name.text = new_name
|
||
|
|
|
||
|
|
@export var content_notes: String = "":
|
||
|
|
set(new_notes):
|
||
|
|
content_notes = new_notes
|
||
|
|
$Content/Name.text = new_notes
|
||
|
|
|
||
|
|
# 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()
|
||
|
|
|
||
|
|
func _hide_buttons():
|
||
|
|
if not State.reduce_motion: $AnimationPlayer.play_backwards("show_buttons")
|
||
|
|
|
||
|
|
func _show_buttons():
|
||
|
|
if State.reduce_motion:
|
||
|
|
$AnimationPlayer.play("show_buttons")
|
||
|
|
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
|
||
|
|
|
||
|
|
func show():
|
||
|
|
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():
|
||
|
|
State.request_focus(self, true)
|