2 extends DialogicLayoutLayer
3 ## This layer's scene file contains following nodes:
4 ## - a dialog_text node
6 ## - a next_indicator node
11 ## - auto-advance progress indicator
13 ## If you want to customize this layer, here is a little rundown of this layer:
14 ## The Layer Settings are divided into the `@export_group`s below.
15 ## They get applied in [method _apply_export_overrides].
16 ## Each `@export_group` has its own method to apply the settings to the scene.
17 ## If you want to change a specific part inside the scene, you can simply
18 ## remove or add # (commenting) to the method line.
22 enum Alignments {LEFT, CENTER, RIGHT}
24 enum AnimationsIn {NONE, POP_IN, FADE_UP}
25 enum AnimationsOut {NONE, POP_OUT, FADE_DOWN}
26 enum AnimationsNewText {NONE, WIGGLE}
30 @export_subgroup("Alignment & Size")
31 @export var text_alignment: Alignments= Alignments.LEFT
32 @export var text_use_global_size: bool = true
33 @export var text_size: int = 15
35 @export_subgroup("Color")
36 @export var text_use_global_color: bool = true
37 @export var text_custom_color: Color = Color.WHITE
39 @export_subgroup('Font')
40 @export var text_use_global_font: bool = true
41 @export_file('*.ttf', '*.tres') var normal_font: String = ""
42 @export_file('*.ttf', '*.tres') var bold_font: String = ""
43 @export_file('*.ttf', '*.tres') var italics_font: String = ""
44 @export_file('*.ttf', '*.tres') var bold_italics_font: String = ""
49 @export_subgroup("Panel")
50 @export_file("*.tres") var box_panel: String = this_folder.path_join("vn_textbox_default_panel.tres")
52 @export_subgroup("Color")
53 @export var box_color_use_global: bool = true
54 @export var box_color_custom: Color = Color.BLACK
56 @export_subgroup("Size & Position")
57 @export var box_size: Vector2 = Vector2(550, 110)
58 @export var box_margin_bottom: int = 15
60 @export_subgroup("Animation")
61 @export var box_animation_in: AnimationsIn = AnimationsIn.FADE_UP
62 @export var box_animation_out: AnimationsOut = AnimationsOut.FADE_DOWN
63 @export var box_animation_new_text: AnimationsNewText = AnimationsNewText.NONE
66 @export_group("Name Label")
68 @export_subgroup('Color')
69 @export var name_label_use_global_color: bool= true
70 @export var name_label_use_character_color: bool = true
71 @export var name_label_custom_color: Color = Color.WHITE
73 @export_subgroup('Font')
74 @export var name_label_use_global_font: bool = true
75 @export_file('*.ttf', '*.tres') var name_label_font: String = ""
76 @export var name_label_use_global_font_size: bool = true
77 @export var name_label_custom_font_size: int = 15
79 @export_subgroup('Box')
80 @export_file("*.tres") var name_label_box_panel: String = this_folder.path_join("vn_textbox_name_label_panel.tres")
81 @export var name_label_box_use_global_color: bool = true
82 @export var name_label_box_modulate: Color = box_color_custom
84 @export_subgroup('Alignment')
85 @export var name_label_alignment: Alignments = Alignments.LEFT
86 @export var name_label_box_offset: Vector2 = Vector2.ZERO
89 @export_group("Indicators")
91 @export_subgroup("Next Indicator")
92 @export var next_indicator_enabled: bool = true
93 @export var next_indicator_show_on_questions: bool = true
94 @export var next_indicator_show_on_autoadvance: bool = false
95 @export_enum('bounce', 'blink', 'none') var next_indicator_animation: int = 0
96 @export_file("*.png","*.svg","*.tres") var next_indicator_texture: String = ''
97 @export var next_indicator_size: Vector2 = Vector2(25,25)
99 @export_subgroup("Autoadvance")
100 @export var autoadvance_progressbar: bool = true
103 @export_group('Sounds')
105 @export_subgroup('Typing Sounds')
106 @export var typing_sounds_enabled: bool = true
107 @export var typing_sounds_mode: DialogicNode_TypeSounds.Modes = DialogicNode_TypeSounds.Modes.INTERRUPT
108 @export_dir var typing_sounds_sounds_folder: String = "res://addons/dialogic/Example Assets/sound-effects/"
109 @export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound: String = ""
110 @export_range(1, 999, 1) var typing_sounds_every_nths_character: int = 1
111 @export_range(0.01, 4, 0.01) var typing_sounds_pitch: float = 1.0
112 @export_range(0.0, 3.0) var typing_sounds_pitch_variance: float = 0.0
113 @export_range(-80, 24, 0.01) var typing_sounds_volume: float = -10
114 @export_range(0.0, 10) var typing_sounds_volume_variance: float = 0.0
115 @export var typing_sounds_ignore_characters: String = " .,!?"
118 func _apply_export_overrides() -> void:
119 if !is_inside_tree():
123 _apply_text_settings()
127 _apply_box_settings()
130 _apply_box_animations_settings()
132 ## NAME LABEL SETTINGS
133 _apply_name_label_settings()
135 ## NEXT INDICATOR SETTINGS
136 _apply_indicator_settings()
139 var progress_bar: ProgressBar = %AutoAdvanceProgressbar
140 progress_bar.set(&'enabled', autoadvance_progressbar)
145 _apply_sounds_settings()
148 ## Applies all text box settings to the scene.
149 ## Except the box animations.
150 func _apply_box_settings() -> void:
151 var dialog_text_panel: PanelContainer = %DialogTextPanel
152 if ResourceLoader.exists(box_panel):
153 dialog_text_panel.add_theme_stylebox_override(&'panel', load(box_panel) as StyleBox)
155 if box_color_use_global:
156 dialog_text_panel.self_modulate = get_global_setting(&'bg_color', box_color_custom)
158 dialog_text_panel.self_modulate = box_color_custom
160 var sizer: Control = %Sizer
161 sizer.size = box_size
162 sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom)
165 ## Applies box animations settings to the scene.
166 func _apply_box_animations_settings() -> void:
167 var animations: AnimationPlayer = %Animations
168 animations.set(&'animation_in', box_animation_in)
169 animations.set(&'animation_out', box_animation_out)
170 animations.set(&'animation_new_text', box_animation_new_text)
173 ## Applies all name label settings to the scene.
174 func _apply_name_label_settings() -> void:
175 var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel
177 if name_label_use_global_font_size:
178 name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_font_size) as int)
180 name_label.add_theme_font_size_override(&"font_size", name_label_custom_font_size)
182 if name_label_use_global_font and get_global_setting(&'font', false):
183 name_label.add_theme_font_override(&'font', load(get_global_setting(&'font', '') as String) as Font)
184 elif not name_label_font.is_empty():
185 name_label.add_theme_font_override(&'font', load(name_label_font) as Font)
187 if name_label_use_global_color:
188 name_label.add_theme_color_override(&"font_color", get_global_setting(&'font_color', name_label_custom_color) as Color)
190 name_label.add_theme_color_override(&"font_color", name_label_custom_color)
192 name_label.use_character_color = name_label_use_character_color
194 var name_label_panel: PanelContainer = %NameLabelPanel
195 if ResourceLoader.exists(name_label_box_panel):
196 name_label_panel.add_theme_stylebox_override(&'panel', load(name_label_box_panel) as StyleBox)
198 name_label_panel.add_theme_stylebox_override(&'panel', load(this_folder.path_join("vn_textbox_name_label_panel.tres")) as StyleBox)
200 if name_label_box_use_global_color:
201 name_label_panel.self_modulate = get_global_setting(&'bg_color', name_label_box_modulate)
203 name_label_panel.self_modulate = name_label_box_modulate
204 var dialog_text_panel: PanelContainer = %DialogTextPanel
205 name_label_panel.position = name_label_box_offset+Vector2(0, -40)
206 name_label_panel.position -= Vector2(
207 dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_left,
208 dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_top)
209 name_label_panel.anchor_left = name_label_alignment/2.0
210 name_label_panel.anchor_right = name_label_alignment/2.0
211 name_label_panel.grow_horizontal = [1, 2, 0][name_label_alignment]
214 ## Applies all text settings to the scene.
215 func _apply_text_settings() -> void:
216 var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText
217 dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment
219 if text_use_global_size:
220 text_size = get_global_setting(&'font_size', text_size)
221 dialog_text.add_theme_font_size_override(&"normal_font_size", text_size)
222 dialog_text.add_theme_font_size_override(&"bold_font_size", text_size)
223 dialog_text.add_theme_font_size_override(&"italics_font_size", text_size)
224 dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size)
226 if text_use_global_color:
227 dialog_text.add_theme_color_override(&"default_color", get_global_setting(&'font_color', text_custom_color) as Color)
229 dialog_text.add_theme_color_override(&"default_color", text_custom_color)
231 if text_use_global_font and get_global_setting(&'font', false):
232 dialog_text.add_theme_font_override(&"normal_font", load(get_global_setting(&'font', '') as String) as Font)
233 elif !normal_font.is_empty():
234 dialog_text.add_theme_font_override(&"normal_font", load(normal_font) as Font)
235 if !bold_font.is_empty():
236 dialog_text.add_theme_font_override(&"bold_font", load(bold_font) as Font)
237 if !italics_font.is_empty():
238 dialog_text.add_theme_font_override(&"italics_font", load(italics_font) as Font)
239 if !bold_italics_font.is_empty():
240 dialog_text.add_theme_font_override(&"bold_italics_font", load(bold_italics_font) as Font)
243 ## Applies all indicator settings to the scene.
244 func _apply_indicator_settings() -> void:
245 var next_indicator: DialogicNode_NextIndicator = %NextIndicator
246 next_indicator.enabled = next_indicator_enabled
248 if next_indicator_enabled:
249 next_indicator.animation = next_indicator_animation as DialogicNode_NextIndicator.Animations
250 if ResourceLoader.exists(next_indicator_texture):
251 next_indicator.texture = load(next_indicator_texture)
252 next_indicator.show_on_questions = next_indicator_show_on_questions
253 next_indicator.show_on_autoadvance = next_indicator_show_on_autoadvance
254 next_indicator.texture_size = next_indicator_size
257 ## Applies all sound settings to the scene.
258 func _apply_sounds_settings() -> void:
259 var type_sounds: DialogicNode_TypeSounds = %DialogicNode_TypeSounds
260 type_sounds.enabled = typing_sounds_enabled
261 type_sounds.mode = typing_sounds_mode
263 if not typing_sounds_sounds_folder.is_empty():
264 type_sounds.sounds = DialogicNode_TypeSounds.load_sounds_from_path(typing_sounds_sounds_folder)
266 type_sounds.sounds.clear()
268 if not typing_sounds_end_sound.is_empty():
269 type_sounds.end_sound = load(typing_sounds_end_sound)
271 type_sounds.end_sound = null
273 type_sounds.play_every_character = typing_sounds_every_nths_character
274 type_sounds.base_pitch = typing_sounds_pitch
275 type_sounds.base_volume = typing_sounds_volume
276 type_sounds.pitch_variance = typing_sounds_pitch_variance
277 type_sounds.volume_variance = typing_sounds_volume_variance
278 type_sounds.ignore_characters = typing_sounds_ignore_characters