forked from NanahiraCommunity/Birthday23
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquest_line.gd
56 lines (48 loc) · 1.43 KB
/
quest_line.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@tool
extends MarginContainer
var _text: String
@export var text: String:
get:
return _text
set(value):
_text = value
if $HBoxContainer/MarginContainer/Label:
if Engine.is_editor_hint():
$HBoxContainer/MarginContainer/Label.text = value
else:
$HBoxContainer/MarginContainer/Label.text = Global.preprocess_bbcode(value)
var _finished: bool
@export var finished: bool:
get:
return _finished
set(value):
_finished = value
if $HBoxContainer/Finished:
$HBoxContainer/Finished.visible = value
$HBoxContainer/Unfinished.visible = not value
var freeing: bool = false
func _ready():
text = _text
finished = _finished
func mark_finished():
finished = true
func show_animated():
if $AnimationPlayer and $AnimationPlayer.has_animation("show"):
$AnimationPlayer.play("show")
await $AnimationPlayer.animation_finished
func hide_animated():
if $AnimationPlayer and $AnimationPlayer.has_animation("hide"):
$AnimationPlayer.play("hide")
await $AnimationPlayer.animation_finished
func hide_animated_and_free(timeout: float = 0.0):
assert(not freeing, "attempted to animated free twice")
freeing = true
if timeout > 0.0:
await get_tree().create_timer(timeout).timeout
await hide_animated()
var tween = get_tree().create_tween()
$Panel.custom_minimum_size.y = size.y
$HBoxContainer.queue_free()
tween.set_ease(Tween.EASE_OUT).tween_property($Panel, "custom_minimum_size:y", 0, 0.15)
await tween.finished
queue_free()