1 extends AnimationPlayer
3 ## A custom script/node that adds some animations to the textbox.
5 # Careful: Sync these with the ones in the root script!
6 enum AnimationsIn {NONE, POP_IN, FADE_UP}
7 enum AnimationsOut {NONE, POP_OUT, FADE_DOWN}
8 enum AnimationsNewText {NONE, WIGGLE}
10 var animation_in: AnimationsIn
11 var animation_out: AnimationsOut
12 var animation_new_text: AnimationsNewText
14 var full_clear := true
17 func get_text_panel() -> PanelContainer:
18 return %DialogTextPanel
21 func get_dialog() -> DialogicNode_DialogText:
22 return %DialogicNode_DialogText
25 func _ready() -> void:
26 var text_system: Node = DialogicUtil.autoload().get(&'Text')
27 text_system.connect(&'animation_textbox_hide', _on_textbox_hide)
28 text_system.connect(&'animation_textbox_show', _on_textbox_show)
29 text_system.connect(&'animation_textbox_new_text', _on_textbox_new_text)
30 text_system.connect(&'about_to_show_text', _on_about_to_show_text)
31 var animation_system: Node = DialogicUtil.autoload().get(&'Animations')
32 animation_system.connect(&'animation_interrupted', _on_animation_interrupted)
35 func _on_textbox_show() -> void:
36 if animation_in == AnimationsIn.NONE:
39 var animation_system: Node = DialogicUtil.autoload().get(&'Animations')
40 animation_system.call(&'start_animating')
41 get_text_panel().get_parent().get_parent().set(&'modulate', Color.TRANSPARENT)
42 get_dialog().text = ""
47 play("textbox_fade_up")
48 if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')):
49 animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT)
52 func _on_textbox_hide() -> void:
53 if animation_out == AnimationsOut.NONE:
56 var animation_system: Node = DialogicUtil.autoload().get(&'Animations')
57 animation_system.call(&'start_animating')
59 AnimationsOut.POP_OUT:
60 play_backwards("textbox_pop")
61 AnimationsOut.FADE_DOWN:
62 play_backwards("textbox_fade_up")
64 if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')):
65 animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT)
68 func _on_about_to_show_text(info:Dictionary) -> void:
69 full_clear = !info.append
72 func _on_textbox_new_text() -> void:
73 if DialogicUtil.autoload().Inputs.auto_skip.enabled:
76 if animation_new_text == AnimationsNewText.NONE:
79 var animation_system: Node = DialogicUtil.autoload().get(&'Animations')
80 animation_system.call(&'start_animating')
82 get_dialog().text = ""
83 match animation_new_text:
84 AnimationsNewText.WIGGLE:
87 if not animation_finished.is_connected(Callable(animation_system, &'animation_finished')):
88 animation_finished.connect(Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT)
91 func _on_animation_interrupted() -> void: