From 4ef6647710b10f64220a84b300ab688ceeaaa56d Mon Sep 17 00:00:00 2001 From: nlupugla Date: Thu, 28 Dec 2023 16:50:06 -0500 Subject: [PATCH 01/12] Add static type hints to visual novel example --- .../Character/node_portrait_container.gd | 26 +-- .../dialogic/Modules/Core/subsystem_input.gd | 1 + .../Base_Default/default_layout_base.gd | 10 +- .../Layer_Glossary/glossary_popup_layer.gd | 151 ++++++------ .../Layer_History/example_history_item.gd | 38 +-- .../Layer_History/history_layer.gd | 73 +++--- .../Layer_History/history_layer.tscn | 7 - .../Layer_TextInput/text_input_layer.gd | 8 +- .../Layer_VN_Choices/vn_choice_layer.gd | 107 ++++----- .../Layer_VN_Portraits/vn_portrait_layer.gd | 7 +- .../Layer_VN_Portraits/vn_portrait_layer.tscn | 41 ++++ .../Layer_VN_Textbox/animations.gd | 8 +- .../Layer_VN_Textbox/autoadvance_indicator.gd | 4 +- .../Layer_VN_Textbox/vn_textbox_layer.gd | 218 +++++++++--------- .../Layer_VN_Textbox/vn_textbox_layer.tscn | 7 + .../Modules/Glossary/subsystem_glossary.gd | 1 + .../Modules/History/subsystem_history.gd | 25 +- .../dialogic/Modules/Text/node_dialog_text.gd | 25 +- .../dialogic/Modules/Text/node_name_label.gd | 13 +- .../Modules/Text/node_next_indicator.gd | 41 ++-- .../dialogic/Modules/Text/node_type_sound.gd | 60 ++--- .../dialogic/Modules/Text/subsystem_text.gd | 1 + addons/dialogic/Other/DialogicGameHandler.gd | 24 +- addons/dialogic/Other/DialogicUtil.gd | 17 ++ .../Resources/dialogic_layout_base.gd | 20 +- .../Resources/dialogic_layout_layer.gd | 14 +- 26 files changed, 526 insertions(+), 421 deletions(-) diff --git a/addons/dialogic/Modules/Character/node_portrait_container.gd b/addons/dialogic/Modules/Character/node_portrait_container.gd index 9a2307f36..89c085949 100644 --- a/addons/dialogic/Modules/Character/node_portrait_container.gd +++ b/addons/dialogic/Modules/Character/node_portrait_container.gd @@ -9,17 +9,17 @@ enum PositionModes { SPEAKER, ## This container has no index and is joined/left automatically based on the speaker. } -@export var mode := PositionModes.POSITION +@export var mode : PositionModes = PositionModes.POSITION @export_subgroup('Mode: Position') ## The position this node corresponds to. -@export var position_index := 0 +@export var position_index : int = 0 @export_subgroup('Mode: Speaker') ## Can be used to use a different portrait. ## E.g. "Faces/" would mean instead of "happy" it will use portrait "Faces/happy" -@export var portrait_prefix := '' +@export var portrait_prefix : String = '' @export_subgroup('Portrait Placement') enum SizeModes {KEEP, FIT_STRETCH, FIT_IGNORE_SCALE, FIT_SCALE_HEIGHT} @@ -30,7 +30,7 @@ enum SizeModes {KEEP, FIT_STRETCH, FIT_IGNORE_SCALE, FIT_SCALE_HEIGHT} _update_debug_portrait_size_position() ## If true, portraits will be mirrored in this position. -@export var mirrored := false : +@export var mirrored : bool = false : set(mirror): mirrored = mirror _update_debug_portrait_scene() @@ -45,7 +45,7 @@ enum OriginAnchors {TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_MIDDLE, CENTER, RIGHT_ _update_debug_origin() ## An offset to apply to the origin. Rarely useful. -@export var origin_offset := Vector2() : +@export var origin_offset : Vector2 = Vector2() : set(offset): origin_offset = offset _update_debug_origin() @@ -65,12 +65,12 @@ enum OriginAnchors {TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_MIDDLE, CENTER, RIGHT_ var debug_character_holder_node :Node2D = null var debug_character_scene_node : Node = null var debug_origin : Sprite2D = null -var default_portrait_scene :String = DialogicUtil.get_module_path('Character').path_join("default_portrait.tscn") +var default_portrait_scene : String = DialogicUtil.get_module_path('Character').path_join("default_portrait.tscn") # Used if no debug character is specified -var default_debug_character := load(DialogicUtil.get_module_path('Character').path_join("preview_character.tres")) +var default_debug_character : Resource = load(DialogicUtil.get_module_path('Character').path_join("preview_character.tres")) -func _ready(): +func _ready() -> void: match mode: PositionModes.POSITION: add_to_group('dialogic_portrait_con_position') @@ -80,7 +80,7 @@ func _ready(): if Engine.is_editor_hint(): resized.connect(_update_debug_origin) - if !ProjectSettings.get_setting('dialogic/portraits/default_portrait', '').is_empty(): + if ProjectSettings.get_setting('dialogic/portraits/default_portrait', '') != "": default_portrait_scene = ProjectSettings.get_setting('dialogic/portraits/default_portrait', '') debug_origin = Sprite2D.new() @@ -97,13 +97,13 @@ func _ready(): ## MAIN METHODS ################################################################################ -func update_portrait_transforms(): - for child in get_children(): +func update_portrait_transforms() -> void: + for child : Node in get_children(): DialogicUtil.autoload().Portraits._update_portrait_transform(child) ## Returns a Rect2 with the position as the position and the scale as the size. -func get_local_portrait_transform(portrait_rect:Rect2, character_scale:=1.0) -> Rect2: - var transform := Rect2() +func get_local_portrait_transform(portrait_rect:Rect2, character_scale: float =1.0) -> Rect2: + var transform : Rect2 = Rect2() transform.position = _get_origin_position() # Mode that ignores the containers size diff --git a/addons/dialogic/Modules/Core/subsystem_input.gd b/addons/dialogic/Modules/Core/subsystem_input.gd index 4f0102489..49ed62219 100644 --- a/addons/dialogic/Modules/Core/subsystem_input.gd +++ b/addons/dialogic/Modules/Core/subsystem_input.gd @@ -1,4 +1,5 @@ extends DialogicSubsystem +class_name DialogicSubsystemInput ## Subsystem that handles input, autoadvance & skipping. diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd index 66b55d6b8..ddda2fdb6 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd @@ -3,13 +3,13 @@ extends DialogicLayoutBase ## The default layout base scene. -@export var canvas_layer := 1 +@export var canvas_layer : int = 1 @export_subgroup("Global") -@export var global_bg_color := Color(0, 0, 0, 0.9) -@export var global_font_color := Color("white") -@export_file('*.ttf') var global_font := "" -@export var global_font_size := 18 +@export var global_bg_color : Color = Color(0, 0, 0, 0.9) +@export var global_font_color : Color = Color("white") +@export_file('*.ttf') var global_font : String = "" +@export var global_font_size : int = 18 func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 3de3f480a..9c1c3f6f8 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -7,147 +7,156 @@ extends DialogicLayoutLayer @export_group('Text') enum Alignment {LEFT, CENTER, RIGHT} -@export var title_alignment := Alignment.LEFT -@export var text_alignment := Alignment.LEFT -@export var extra_alignment := Alignment.RIGHT +@export var title_alignment : Alignment = Alignment.LEFT +@export var text_alignment : Alignment = Alignment.LEFT +@export var extra_alignment : Alignment = Alignment.RIGHT @export_subgroup("Colors") enum TextColorModes {GLOBAL, ENTRY, CUSTOM} -@export var title_color_mode := TextColorModes.ENTRY -@export var title_custom_color := Color.WHITE -@export var text_color_mode := TextColorModes.ENTRY -@export var text_custom_color := Color.WHITE -@export var extra_color_mode := TextColorModes.ENTRY -@export var extra_custom_color := Color.WHITE +@export var title_color_mode : TextColorModes = TextColorModes.ENTRY +@export var title_custom_color : Color = Color.WHITE +@export var text_color_mode : TextColorModes = TextColorModes.ENTRY +@export var text_custom_color : Color = Color.WHITE +@export var extra_color_mode : TextColorModes = TextColorModes.ENTRY +@export var extra_custom_color : Color = Color.WHITE @export_group("Font") -@export var font_use_global := true -@export_file('*.ttf') var font_custom := "" +@export var font_use_global : bool = true +@export_file('*.ttf') var font_custom : String = "" @export_subgroup('Sizes') -@export var font_title_size := 18 -@export var font_text_size := 17 -@export var font_extra_size := 15 +@export var font_title_size : int = 18 +@export var font_text_size : int = 17 +@export var font_extra_size : int = 15 @export_group("Box") @export_subgroup("Color") enum ModulateModes {BASE_COLOR_ONLY, ENTRY_COLOR_ON_BOX, GLOBAL_BG_COLOR} -@export var box_modulate_mode := ModulateModes.ENTRY_COLOR_ON_BOX -@export var box_base_modulate := Color.WHITE +@export var box_modulate_mode : ModulateModes = ModulateModes.ENTRY_COLOR_ON_BOX +@export var box_base_modulate : Color = Color.WHITE @export_subgroup("Size") -@export var box_width := 200 +@export var box_width : int = 200 + +@onready var pointer : Control = $Pointer +@onready var title : Label = %Title +@onready var text : RichTextLabel = %Text +@onready var extra : RichTextLabel = %Extra +@onready var panel : PanelContainer = %Panel +@onready var panel_point : PanelContainer = %PanelPoint func _ready() -> void: if Engine.is_editor_hint(): return - $Pointer.hide() - DialogicUtil.autoload().Text.animation_textbox_hide.connect($Pointer.hide) - DialogicUtil.autoload().Text.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) - DialogicUtil.autoload().Text.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) - DialogicUtil.autoload().Text.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) + pointer.hide() + var text_system : DialogicSubsystemText = DialogicUtil.get_text() + text_system.animation_textbox_hide.connect(pointer.hide) + text_system.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) + text_system.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) + text_system.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var info: Dictionary = DialogicUtil.autoload().Glossary.get_entry(meta) + var info: Dictionary = DialogicUtil.get_glossary().get_entry(meta) if not info: return - $Pointer.show() - %Title.text = info.get('title', '') - %Text.text = info.get('text', '') - %Text.text = ['', '[center]', '[right]'][text_alignment] + %Text.text - %Extra.text = info.get('extra', '') - %Extra.text = ['', '[center]', '[right]'][extra_alignment] + %Extra.text - $Pointer.global_position = $Pointer.get_global_mouse_position() + pointer.show() + title.text = info.get(&'title', '') + text.text = info.get(&'text', '') + text.text = ['', '[center]', '[right]'][text_alignment] + text.text + extra.text = info.get(&'extra', '') + extra.text = ['', '[center]', '[right]'][extra_alignment] + extra.text + pointer.global_position = pointer.get_global_mouse_position() if title_color_mode == TextColorModes.ENTRY: - %Title.add_theme_color_override("font_color", info.get('color', title_custom_color)) + title.add_theme_color_override(&"font_color", info.get(&'color', title_custom_color) as Color) if text_color_mode == TextColorModes.ENTRY: - %Text.add_theme_color_override("default_color", info.get('color', text_custom_color)) + text.add_theme_color_override(&"default_color", info.get(&'color', text_custom_color) as Color) if extra_color_mode == TextColorModes.ENTRY: - %Extra.add_theme_color_override("default_color", info.get('color', extra_custom_color)) + extra.add_theme_color_override(&"default_color", info.get(&'color', extra_custom_color) as Color) match box_modulate_mode: ModulateModes.ENTRY_COLOR_ON_BOX: - %Panel.self_modulate = info.get('color', Color.WHITE) - %PanelPoint.self_modulate = info.get('color', Color.WHITE) + panel.self_modulate = info.get(&'color', Color.WHITE) + panel_point.self_modulate = info.get(&'color', Color.WHITE) - DialogicUtil.autoload().Input.action_was_consumed = true + DialogicUtil.get_input().action_was_consumed = true ## Method that keeps the bubble at mouse position when visible -func _process(delta) -> void: +func _process(_delta : float) -> void: if Engine.is_editor_hint(): return - if $Pointer.visible: - $Pointer.global_position = $Pointer.get_global_mouse_position() + if pointer.visible: + pointer.global_position = pointer.get_global_mouse_position() ## Method that hides the bubble -func _on_dialogic_display_dialog_text_meta_hover_ended(meta:String) -> void: - $Pointer.hide() - DialogicUtil.autoload().Input.action_was_consumed = false +func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: + pointer.hide() + DialogicUtil.get_input().action_was_consumed = false -func _on_dialogic_display_dialog_text_meta_clicked(meta:String) -> void: - DialogicUtil.autoload().Input.action_was_consumed = true +func _on_dialogic_display_dialog_text_meta_clicked(_meta:String) -> void: + DialogicUtil.get_input().action_was_consumed = true func _apply_export_overrides() -> void: # Apply fonts var font: FontFile - if font_use_global and ResourceLoader.exists(get_global_setting('font', '')): - font = load(get_global_setting('font', '')) + if font_use_global and ResourceLoader.exists(get_global_setting(&'font', '') as String): + font = load(get_global_setting(&'font', '') as String) elif ResourceLoader.exists(font_custom): font = load(font_custom) if font: - %Title.add_theme_font_override("font", font) - %Title.horizontal_alignment = title_alignment + title.add_theme_font_override(&"font", font) + title.horizontal_alignment = title_alignment as HorizontalAlignment # Apply font & sizes - %Title.add_theme_font_size_override("font_size", font_title_size) - for i in [[%Text, font_text_size], [%Extra, font_extra_size]]: + title.add_theme_font_size_override(&"font_size", font_title_size) + var labels : Array[RichTextLabel] = [text, extra] + var sizes : PackedInt32Array = [font_text_size, font_extra_size] + for i : int in len(labels): if font: - i[0].add_theme_font_override('normal_font', font) + labels[i].add_theme_font_override(&'normal_font', font) - i[0].add_theme_font_size_override("normal_font_size", i[1]) - i[0].add_theme_font_size_override("bold_font_size", i[1]) - i[0].add_theme_font_size_override("italics_font_size", i[1]) - i[0].add_theme_font_size_override("bold_italics_font_size", i[1]) - i[0].add_theme_font_size_override("mono_font_size", i[1]) + labels[i].add_theme_font_size_override(&"normal_font_size", sizes[i]) + labels[i].add_theme_font_size_override(&"bold_font_size", sizes[i]) + labels[i].add_theme_font_size_override(&"italics_font_size", sizes[i]) + labels[i].add_theme_font_size_override(&"bold_italics_font_size", sizes[i]) + labels[i].add_theme_font_size_override(&"mono_font_size", sizes[i]) # Apply text colors - var texts := [ - [%Title, 'font_color', title_color_mode, title_custom_color], - [%Text, 'default_color', text_color_mode, text_custom_color], - [%Extra, 'default_color', extra_color_mode, extra_custom_color], - ] - for i in texts: - match i[2]: + var controls : Array[Control] = [title, text, extra] + var global_settings : Array[StringName] = [&'font_color', &'default_color', &'default_color'] + var color_modes : Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode] + var custom_colors : PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color] + for i : int in len(controls): + match color_modes[i]: TextColorModes.GLOBAL: - i[0].add_theme_color_override(i[1], get_global_setting('font_color', i[3])) + controls[i].add_theme_color_override(global_settings[i], get_global_setting(&'font_color', custom_colors[i]) as Color) TextColorModes.CUSTOM: - i[0].add_theme_color_override(i[1], i[3]) + controls[i].add_theme_color_override(global_settings[i], custom_colors[i]) # Apply box size - %Panel.size.x = box_width - %Panel.position.x = -box_width/2.0 + panel.size.x = box_width + panel.position.x = -box_width/2.0 # Apply box coloring match box_modulate_mode: ModulateModes.BASE_COLOR_ONLY: - %Panel.self_modulate = box_base_modulate - %PanelPoint.self_modulate = box_base_modulate + panel.self_modulate = box_base_modulate + panel_point.self_modulate = box_base_modulate ModulateModes.GLOBAL_BG_COLOR: - %Panel.self_modulate = get_global_setting('bg_color', box_base_modulate) - %PanelPoint.self_modulate = get_global_setting('bg_color', box_base_modulate) + panel.self_modulate = get_global_setting(&'bg_color', box_base_modulate) + panel_point.self_modulate = get_global_setting(&'bg_color', box_base_modulate) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd index b7bba192c..ec1d25bb3 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd @@ -1,27 +1,31 @@ extends Container +@onready var text_box : RichTextLabel = %TextBox +@onready var name_label : Label = %NameLabel +@onready var icon_node : TextureRect = %Icon -func load_info(text:String, character:String = "", character_color:=Color(), icon:Texture= null) -> void: - %TextBox.text = text + +func load_info(text:String, character:String = "", character_color: Color =Color(), icon:Texture= null) -> void: + text_box.text = text if character: - %NameLabel.text = character - %NameLabel.add_theme_color_override('font_color', character_color) - %NameLabel.show() + name_label.text = character + name_label.add_theme_color_override('font_color', character_color) + name_label.show() else: - %NameLabel.hide() + name_label.hide() if icon == null: - %Icon.hide() + icon_node.hide() else: - %Icon.show() - %Icon.texture = icon + icon_node.show() + icon_node.texture = icon # #func prepare_textbox(history_root:Node) -> void: - #%TextBox.add_theme_font_override("normal_font", history_root.history_font_normal) - #%NameLabel.add_theme_font_override("font", history_root.history_font_normal) - #%NameLabel.add_theme_font_size_override("font_size", history_root.history_font_size) - #%TextBox.add_theme_font_override("bold_font", history_root.history_font_bold) - #%TextBox.add_theme_font_override("italics_font", history_root.history_font_italics) - #%TextBox.add_theme_font_size_override("normal_font_size", history_root.history_font_size) - #%TextBox.add_theme_font_size_override("bold_font_size", history_root.history_font_size) - #%TextBox.add_theme_font_size_override("italics_font_size", history_root.history_font_size) + #text_box.add_theme_font_override("normal_font", history_root.history_font_normal) + #name_label.add_theme_font_override("font", history_root.history_font_normal) + #name_label.add_theme_font_size_override("font_size", history_root.history_font_size) + #text_box.add_theme_font_override("bold_font", history_root.history_font_bold) + #text_box.add_theme_font_override("italics_font", history_root.history_font_italics) + #text_box.add_theme_font_size_override("normal_font_size", history_root.history_font_size) + #text_box.add_theme_font_size_override("bold_font_size", history_root.history_font_size) + #text_box.add_theme_font_size_override("italics_font_size", history_root.history_font_size) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index e7498bd3a..f86353bfa 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -6,12 +6,12 @@ extends DialogicLayoutLayer @export_group('Look') @export_subgroup('Font') -@export var font_use_global_size := true +@export var font_use_global_size : bool = true @export var font_custom_size : int = 15 -@export var font_use_global_fonts := true -@export_file('*.ttf') var font_custom_normal := "" -@export_file('*.ttf') var font_custom_bold := "" -@export_file('*.ttf') var font_custom_italics := "" +@export var font_use_global_fonts : bool = true +@export_file('*.ttf') var font_custom_normal : String = "" +@export_file('*.ttf') var font_custom_bold : String = "" +@export_file('*.ttf') var font_custom_italics : String = "" @export_subgroup('Buttons') @export var show_open_button: bool = true @@ -34,6 +34,11 @@ var scroll_to_bottom_flag: bool = false var history_item_theme : Theme = null +@onready var show_history_button : Button = $ShowHistory +@onready var hide_history_button : Button = $HideHistory +@onready var history_box : ScrollContainer = %HistoryBox +@onready var history_log : VBoxContainer = %HistoryLog + func _ready() -> void: if Engine.is_editor_hint(): @@ -42,68 +47,68 @@ func _ready() -> void: func _apply_export_overrides() -> void: if DialogicUtil.autoload().has_subsystem('History'): - $ShowHistory.visible = show_open_button and DialogicUtil.autoload().History.simple_history_enabled + show_history_button.visible = show_open_button and DialogicUtil.get_history().simple_history_enabled else: self.visible = false history_item_theme = Theme.new() if font_use_global_size: - history_item_theme.default_font_size = get_global_setting('font_size', font_custom_size) + history_item_theme.default_font_size = get_global_setting(&'font_size', font_custom_size) else: history_item_theme.default_font_size = font_custom_size - if font_use_global_fonts and ResourceLoader.exists(get_global_setting('font', '')): - history_item_theme.default_font = load(get_global_setting('font', '')) + if font_use_global_fonts and ResourceLoader.exists(get_global_setting(&'font', '') as String): + history_item_theme.default_font = load(get_global_setting(&'font', '') as String) as Font elif ResourceLoader.exists(font_custom_normal): history_item_theme.default_font = load(font_custom_normal) if ResourceLoader.exists(font_custom_bold): - history_item_theme.set_font('RichtTextLabel', 'bold_font', load(font_custom_bold)) + history_item_theme.set_font(&'RichtTextLabel', &'bold_font', load(font_custom_bold) as Font) if ResourceLoader.exists(font_custom_italics): - history_item_theme.set_font('RichtTextLabel', 'italics_font', load(font_custom_italics)) + history_item_theme.set_font(&'RichtTextLabel', &'italics_font', load(font_custom_italics) as Font) -func _process(delta): +func _process(_delta : float) -> void: if Engine.is_editor_hint(): return - if scroll_to_bottom_flag and $HistoryBox.visible and %HistoryLog.get_child_count(): + if scroll_to_bottom_flag and history_box.visible and history_log.get_child_count(): await get_tree().process_frame - %HistoryBox.ensure_control_visible(%HistoryLog.get_children()[-1]) + history_box.ensure_control_visible(history_log.get_children()[-1] as Control) scroll_to_bottom_flag = false -func _on_show_history_pressed(): +func _on_show_history_pressed() -> void: DialogicUtil.autoload().paused = true show_history() func show_history() -> void: - for child in %HistoryLog.get_children(): + for child : Node in history_log.get_children(): child.queue_free() - for info in DialogicUtil.autoload().History.get_simple_history(): - var history_item = HistoryItem.instantiate() - history_item.theme = history_item_theme + for info : Dictionary in DialogicUtil.get_history().get_simple_history(): + var history_item : Node = HistoryItem.instantiate() + history_item.set(&'theme', history_item_theme) match info.event_type: "Text": if info.has('character') and info['character']: if show_name_colors: - history_item.load_info(info['text'], info['character']+name_delimeter, info['character_color']) + history_item.call(&'load_info', info['text'], info['character']+name_delimeter, info['character_color']) else: - history_item.load_info(info['text'], info['character']+name_delimeter) + history_item.call(&'load_info', info['text'], info['character']+name_delimeter) else: - history_item.load_info(info['text']) + history_item.call(&'load_info', info['text']) "Character": if !show_join_and_leave: history_item.queue_free() continue - history_item.load_info('[i]'+info['text']) + history_item.call(&'load_info', '[i]'+info['text']) "Choice": - var choices_text := "" + var choices_text : String = "" if show_all_choices: - for i in info['all_choices']: + for i : String in info['all_choices']: if i.ends_with('#disabled'): choices_text += "- [i]("+i.trim_suffix('#disabled')+")[/i]\n" elif i == info['text']: @@ -112,20 +117,20 @@ func show_history() -> void: choices_text += "-> "+i+"\n" else: choices_text += "- [b]"+info['text']+"[/b]\n" - history_item.load_info(choices_text) + history_item.call(&'load_info', choices_text) - %HistoryLog.add_child(history_item) + history_log.add_child(history_item) if scroll_to_bottom: scroll_to_bottom_flag = true - $ShowHistory.hide() - $HideHistory.visible = show_close_button - %HistoryBox.show() + show_history_button.hide() + hide_history_button.visible = show_close_button + history_box.show() -func _on_hide_history_pressed(): +func _on_hide_history_pressed() -> void: DialogicUtil.autoload().paused = false - %HistoryBox.hide() - $HideHistory.hide() - $ShowHistory.visible = show_open_button and DialogicUtil.autoload().History.simple_history_enabled + history_box.hide() + hide_history_button.hide() + show_history_button.visible = show_open_button and DialogicUtil.get_history().simple_history_enabled diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn index 53f7f3563..3c602e6d6 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn @@ -27,14 +27,7 @@ size_flags_horizontal = 3 size_flags_vertical = 3 mouse_filter = 2 script = ExtResource("1_4mqm3") -font_use_global_size = null -font_custom_size = null -font_use_global_fonts = null -font_custom_normal = null -font_custom_bold = null -font_custom_italics = null HistoryItem = ExtResource("2_x1xgk") -disabled = null [node name="HistoryBox" type="ScrollContainer" parent="."] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd index 7abee44bd..a9adae158 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd @@ -4,10 +4,10 @@ extends DialogicLayoutLayer ## A layer that contains a text-input node. -func _apply_export_overrides(): +func _apply_export_overrides() -> void: if self.theme == null: self.theme = Theme.new() - if get_global_setting('font', ''): - self.theme.default_font = load(get_global_setting('font', '')) - self.theme.default_font_size = get_global_setting('font_size', 0) + if get_global_setting(&'font', ''): + self.theme.default_font = load(get_global_setting(&'font', '') as String) + self.theme.default_font_size = get_global_setting(&'font_size', 0) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index 9dba926e7..6147f1a7b 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -6,93 +6,96 @@ extends DialogicLayoutLayer @export_group("Text") @export_subgroup('Font') -@export var font_use_global := true +@export var font_use_global : bool = true @export_file('*.ttf') var font_custom : String = "" @export_subgroup('Size') -@export var font_size_use_global := true -@export var font_size_custom := 16 +@export var font_size_use_global : bool = true +@export var font_size_custom : int = 16 @export_subgroup('Color') -@export var text_color_use_global := true -@export var text_color_custom := Color.WHITE -@export var text_color_pressed := Color.WHITE -@export var text_color_hovered := Color.GRAY -@export var text_color_disabled := Color.DARK_GRAY -@export var text_color_focused := Color.WHITE +@export var text_color_use_global : bool = true +@export var text_color_custom : Color = Color.WHITE +@export var text_color_pressed : Color = Color.WHITE +@export var text_color_hovered : Color = Color.GRAY +@export var text_color_disabled : Color = Color.DARK_GRAY +@export var text_color_focused : Color = Color.WHITE @export_group('Boxes') @export_subgroup('Panels') -@export_file('*.tres') var boxes_stylebox_normal := "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_normal.tres" -@export_file('*.tres') var boxes_stylebox_hovered := "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_hover.tres" -@export_file('*.tres') var boxes_stylebox_pressed := "" -@export_file('*.tres') var boxes_stylebox_disabled := "" -@export_file('*.tres') var boxes_stylebox_focused := "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_focus.tres" +@export_file('*.tres') var boxes_stylebox_normal : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_normal.tres" +@export_file('*.tres') var boxes_stylebox_hovered : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_hover.tres" +@export_file('*.tres') var boxes_stylebox_pressed : String = "" +@export_file('*.tres') var boxes_stylebox_disabled : String = "" +@export_file('*.tres') var boxes_stylebox_focused : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_focus.tres" @export_subgroup('Modulate') @export_subgroup('Size & Position') -@export var boxes_v_separation := 10 -@export var boxes_fill_width := true -@export var boxes_min_size := Vector2() +@export var boxes_v_separation : int = 10 +@export var boxes_fill_width : bool = true +@export var boxes_min_size : Vector2 = Vector2() @export_group('Sounds') -@export_range(-80, 24, 0.01) var sounds_volume := -10 -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_pressed := "res://addons/dialogic/Example Assets/sound-effects/typing1.wav" -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_hover := "res://addons/dialogic/Example Assets/sound-effects/typing2.wav" -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_focus := "res://addons/dialogic/Example Assets/sound-effects/typing4.wav" +@export_range(-80, 24, 0.01) var sounds_volume : float = -10 +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_pressed : String = "res://addons/dialogic/Example Assets/sound-effects/typing1.wav" +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_hover : String = "res://addons/dialogic/Example Assets/sound-effects/typing2.wav" +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_focus : String = "res://addons/dialogic/Example Assets/sound-effects/typing4.wav" +@onready var choices : VBoxContainer = $Choices +@onready var button_sound : DialogicNode_ButtonSound = %DialogicNode_ButtonSound ## Method that applies all exported settings -func _apply_export_overrides(): +func _apply_export_overrides() -> void: # apply text settings - var theme: Theme = Theme.new() + var layer_theme: Theme = Theme.new() # font - if font_use_global and get_global_setting('font', false): - theme.set_font('font', 'Button', load(get_global_setting('font', ''))) + if font_use_global and get_global_setting(&'font', false): + layer_theme.set_font(&'font', &'Button', load(get_global_setting(&'font', '') as String) as Font) elif ResourceLoader.exists(font_custom): - theme.set_font('font', 'Button', load(font_custom)) + layer_theme.set_font(&'font', &'Button', load(font_custom) as Font) # font size if font_size_use_global: - theme.set_font_size('font_size', 'Button', get_global_setting('font_size', font_size_custom)) + layer_theme.set_font_size(&'font_size', &'Button', get_global_setting(&'font_size', font_size_custom) as int) else: - theme.set_font_size('font_size', 'Button', font_size_custom) + layer_theme.set_font_size(&'font_size', &'Button', font_size_custom) # font color if text_color_use_global: - theme.set_color('font_color', 'Button', get_global_setting('font_color', text_color_custom)) + layer_theme.set_color(&'font_color', &'Button', get_global_setting(&'font_color', text_color_custom) as Color) else: - theme.set_color('font_color', 'Button', text_color_custom) + layer_theme.set_color(&'font_color', &'Button', text_color_custom) - theme.set_color('font_pressed_color', 'Button', text_color_pressed) - theme.set_color('font_hover_color', 'Button', text_color_hovered) - theme.set_color('font_disabled_color', 'Button', text_color_disabled) - theme.set_color('font_pressed_color', 'Button', text_color_pressed) - theme.set_color('font_focus_color', 'Button', text_color_focused) + layer_theme.set_color(&'font_pressed_color', &'Button', text_color_pressed) + layer_theme.set_color(&'font_hover_color', &'Button', text_color_hovered) + layer_theme.set_color(&'font_disabled_color', &'Button', text_color_disabled) + layer_theme.set_color(&'font_pressed_color', &'Button', text_color_pressed) + layer_theme.set_color(&'font_focus_color', &'Button', text_color_focused) # apply box settings if ResourceLoader.exists(boxes_stylebox_normal): var style_box: StyleBox = load(boxes_stylebox_normal) - theme.set_stylebox('normal', 'Button', style_box) - theme.set_stylebox('hover', 'Button', style_box) - theme.set_stylebox('pressed', 'Button', style_box) - theme.set_stylebox('disabled', 'Button', style_box) - theme.set_stylebox('focus', 'Button', style_box) + layer_theme.set_stylebox(&'normal', &'Button', style_box) + layer_theme.set_stylebox(&'hover', &'Button', style_box) + layer_theme.set_stylebox(&'pressed', &'Button', style_box) + layer_theme.set_stylebox(&'disabled', &'Button', style_box) + layer_theme.set_stylebox(&'focus', &'Button', style_box) if ResourceLoader.exists(boxes_stylebox_hovered): - theme.set_stylebox('hover', 'Button', load(boxes_stylebox_hovered)) + layer_theme.set_stylebox(&'hover', &'Button', load(boxes_stylebox_hovered) as StyleBox) if ResourceLoader.exists(boxes_stylebox_pressed): - theme.set_stylebox('pressed', 'Button', load(boxes_stylebox_pressed)) + layer_theme.set_stylebox(&'pressed', &'Button', load(boxes_stylebox_pressed) as StyleBox) if ResourceLoader.exists(boxes_stylebox_disabled): - theme.set_stylebox('disabled', 'Button', load(boxes_stylebox_disabled)) + layer_theme.set_stylebox(&'disabled', &'Button', load(boxes_stylebox_disabled) as StyleBox) if ResourceLoader.exists(boxes_stylebox_focused): - theme.set_stylebox('focus', 'Button', load(boxes_stylebox_focused)) + layer_theme.set_stylebox(&'focus', &'Button', load(boxes_stylebox_focused) as StyleBox) - $Choices.add_theme_constant_override("separation", boxes_v_separation) + choices.add_theme_constant_override(&"separation", boxes_v_separation) - for choice in $Choices.get_children(): - if not choice is DialogicNode_ChoiceButton: + for child : Node in choices.get_children(): + if not child is DialogicNode_ChoiceButton: continue + var choice : DialogicNode_ChoiceButton = child as DialogicNode_ChoiceButton if boxes_fill_width: choice.size_flags_horizontal = Control.SIZE_FILL @@ -101,10 +104,10 @@ func _apply_export_overrides(): choice.custom_minimum_size = boxes_min_size - self.theme = theme + self.theme = layer_theme # apply sound settings - %DialogicNode_ButtonSound.volume_db = sounds_volume - %DialogicNode_ButtonSound.sound_pressed = load(sounds_pressed) - %DialogicNode_ButtonSound.sound_hover = load(sounds_hover) - %DialogicNode_ButtonSound.sound_focus = load(sounds_focus) + button_sound.volume_db = sounds_volume + button_sound.sound_pressed = load(sounds_pressed) + button_sound.sound_hover = load(sounds_hover) + button_sound.sound_focus = load(sounds_focus) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd index 9f9095efd..05f7054a4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd @@ -4,12 +4,11 @@ extends DialogicLayoutLayer ## A layer that allows showing 5 portraits, like in a visual novel. ## The canvas layer that the portraits are on. -@export var portrait_size_mode := DialogicNode_PortraitContainer.SizeModes.FIT_SCALE_HEIGHT +@export var portrait_size_mode : DialogicNode_PortraitContainer.SizeModes = DialogicNode_PortraitContainer.SizeModes.FIT_SCALE_HEIGHT -func _apply_export_overrides(): +func _apply_export_overrides() -> void: # apply portrait size - for child in %Portraits.get_children(): + for child : DialogicNode_PortraitContainer in %Portraits.get_children(): child.size_mode = portrait_size_mode child.update_portrait_transforms() - diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn index 374bc60ff..d90d49281 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn @@ -29,6 +29,15 @@ anchor_bottom = 1.0 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 +position_index = 0 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits"] @@ -40,7 +49,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 1 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits"] @@ -52,7 +69,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 2 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits"] @@ -64,7 +89,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 3 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits"] @@ -77,5 +110,13 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 4 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index 076d62229..b1e18646d 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -11,16 +11,16 @@ var animation_in : AnimationsIn var animation_out : AnimationsOut var animation_new_text : AnimationsNewText -var full_clear := true +var full_clear : bool = true -func _ready(): +func _ready() -> void: DialogicUtil.autoload().Text.animation_textbox_hide.connect(_on_textbox_hide) DialogicUtil.autoload().Text.animation_textbox_show.connect(_on_textbox_show) DialogicUtil.autoload().Text.animation_textbox_new_text.connect(_on_textbox_new_text) DialogicUtil.autoload().Text.about_to_show_text.connect(_on_about_to_show_text) -func _on_textbox_show(): +func _on_textbox_show() -> void: if animation_in == AnimationsIn.NONE: return play('RESET') @@ -36,7 +36,7 @@ func _on_textbox_show(): animation_finished.connect(DialogicUtil.autoload().Animation.animation_finished, CONNECT_ONE_SHOT) -func _on_textbox_hide(): +func _on_textbox_hide() -> void: if animation_out == AnimationsOut.NONE: return play('RESET') diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd index 009a3d9e1..aa702f4c2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd @@ -1,8 +1,8 @@ extends Range -var enabled := true +var enabled : bool = true -func _process(delta): +func _process(_delta : float) -> void: if !enabled: hide() return diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd index 987802055..93d0bf5c9 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd @@ -21,15 +21,15 @@ enum AnimationsNewText {NONE, WIGGLE} @export_group("Text") @export_subgroup("Alignment & Size") @export var text_alignment :Alignments= Alignments.LEFT -@export var text_use_global_size := true -@export var text_size := 15 +@export var text_use_global_size : bool = true +@export var text_size : int = 15 @export_subgroup("Color") -@export var text_use_global_color := true +@export var text_use_global_color : bool = true @export var text_custom_color : Color = Color.WHITE @export_subgroup('Font') -@export var text_use_global_font := true +@export var text_use_global_font : bool = true @export_file('*.ttf') var normal_font:String = "" @export_file('*.ttf') var bold_font:String = "" @export_file('*.ttf') var italic_font:String = "" @@ -37,184 +37,194 @@ enum AnimationsNewText {NONE, WIGGLE} @export_group("Box") @export_subgroup("Panel") -@export_file("*.tres") var box_panel := this_folder.path_join("vn_textbox_default_panel.tres") +@export_file("*.tres") var box_panel : String = this_folder.path_join("vn_textbox_default_panel.tres") @export_subgroup("Color") -@export var box_color_use_global := true +@export var box_color_use_global : bool = true @export var box_color_custom : Color = Color.BLACK @export_subgroup("Size & Position") @export var box_size : Vector2 = Vector2(550, 110) -@export var box_margin_bottom := 15 +@export var box_margin_bottom : int = 15 @export_subgroup("Animation") -@export var box_animation_in := AnimationsIn.FADE_UP -@export var box_animation_out := AnimationsOut.FADE_DOWN -@export var box_animation_new_text := AnimationsNewText.NONE +@export var box_animation_in : AnimationsIn = AnimationsIn.FADE_UP +@export var box_animation_out : AnimationsOut = AnimationsOut.FADE_DOWN +@export var box_animation_new_text : AnimationsNewText = AnimationsNewText.NONE @export_group("Name Label") @export_subgroup('Color') -@export var name_label_use_global_color := true -@export var name_label_use_character_color := true -@export var name_label_custom_color := Color.WHITE +@export var name_label_use_global_color : bool= true +@export var name_label_use_character_color : bool = true +@export var name_label_custom_color : Color = Color.WHITE @export_subgroup('Font') -@export var name_label_use_global_font := true +@export var name_label_use_global_font : bool = true @export_file('*.ttf') var name_label_font : String = "" -@export var name_label_use_global_font_size := true -@export var name_label_custom_font_size := 15 +@export var name_label_use_global_font_size : bool = true +@export var name_label_custom_font_size : int = 15 @export_subgroup('Box') -@export_file("*.tres") var name_label_box_panel := this_folder.path_join("vn_textbox_name_label_panel.tres") -@export var name_label_box_use_global_color := true +@export_file("*.tres") var name_label_box_panel : String = this_folder.path_join("vn_textbox_name_label_panel.tres") +@export var name_label_box_use_global_color : bool = true @export var name_label_box_modulate : Color = box_color_custom @export_subgroup('Alignment') -@export var name_label_alignment := Alignments.LEFT -@export var name_label_box_offset := Vector2.ZERO +@export var name_label_alignment : Alignments = Alignments.LEFT +@export var name_label_box_offset : Vector2 = Vector2.ZERO @export_group("Indicators") @export_subgroup("Next Indicator") -@export var next_indicator_enabled := true -@export var next_indicator_show_on_questions := true -@export var next_indicator_show_on_autoadvance := false -@export_enum('bounce', 'blink', 'none') var next_indicator_animation := 0 -@export_file("*.png","*.svg") var next_indicator_texture := '' -@export var next_indicator_size := Vector2(25,25) +@export var next_indicator_enabled : bool = true +@export var next_indicator_show_on_questions : bool = true +@export var next_indicator_show_on_autoadvance : bool = false +@export_enum('bounce', 'blink', 'none') var next_indicator_animation : int = 0 +@export_file("*.png","*.svg") var next_indicator_texture : String = '' +@export var next_indicator_size : Vector2 = Vector2(25,25) @export_subgroup("Autoadvance") -@export var autoadvance_progressbar := true +@export var autoadvance_progressbar : bool = true @export_group('Sounds') @export_subgroup('Typing Sounds') -@export var typing_sounds_enabled := true -@export var typing_sounds_mode := DialogicNode_TypeSounds.Modes.INTERRUPT -@export_dir var typing_sounds_sounds_folder := "res://addons/dialogic/Example Assets/sound-effects/" -@export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound := "" -@export_range(1, 999, 1) var typing_sounds_every_nths_character := 1 -@export_range(0.01, 4, 0.01) var typing_sounds_pitch := 1.0 -@export_range(0.0, 3.0) var typing_sounds_pitch_variance := 0.0 -@export_range(-80, 24, 0.01) var typing_sounds_volume := -10 -@export_range(0.0, 10) var typing_sounds_volume_variance := 0.0 -@export var typing_sounds_ignore_characters := " .,!?" - - -func _apply_export_overrides(): +@export var typing_sounds_enabled : bool = true +@export var typing_sounds_mode : DialogicNode_TypeSounds.Modes = DialogicNode_TypeSounds.Modes.INTERRUPT +@export_dir var typing_sounds_sounds_folder : String = "res://addons/dialogic/Example Assets/sound-effects/" +@export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound : String = "" +@export_range(1, 999, 1) var typing_sounds_every_nths_character : int = 1 +@export_range(0.01, 4, 0.01) var typing_sounds_pitch : float = 1.0 +@export_range(0.0, 3.0) var typing_sounds_pitch_variance : float = 0.0 +@export_range(-80, 24, 0.01) var typing_sounds_volume : float = -10 +@export_range(0.0, 10) var typing_sounds_volume_variance : float = 0.0 +@export var typing_sounds_ignore_characters : String = " .,!?" + +@onready var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText +@onready var dialog_text_panel : PanelContainer = %DialogTextPanel +@onready var sizer : Control = %Sizer +@onready var animations : AnimationPlayer = %Animations +@onready var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel +@onready var name_label_panel : PanelContainer = %NameLabelPanel +@onready var next_indicator : DNextIndicator = %NextIndicator +@onready var type_sounds : DialogicNode_TypeSounds = %DialogicNode_TypeSounds +@onready var progress_bar : ProgressBar = %AutoAdvanceProgressbar + + +func _apply_export_overrides() -> void: if !is_inside_tree(): await ready ## FONT SETTINGS - %DialogicNode_DialogText.alignment = text_alignment + dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment if text_use_global_size: - text_size = get_global_setting('font_size', text_size) - %DialogicNode_DialogText.add_theme_font_size_override("normal_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("bold_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("italics_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("bold_italics_font_size", text_size) + text_size = get_global_setting(&'font_size', text_size) + dialog_text.add_theme_font_size_override(&"normal_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_font_size", text_size) + dialog_text.add_theme_font_size_override(&"italics_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size) if text_use_global_color: - %DialogicNode_DialogText.add_theme_color_override("default_color", get_global_setting('font_color', text_custom_color)) + dialog_text.add_theme_color_override(&"default_color", get_global_setting(&'font_color', text_custom_color) as Color) else: - %DialogicNode_DialogText.add_theme_color_override("default_color", text_custom_color) + dialog_text.add_theme_color_override(&"default_color", text_custom_color) - if text_use_global_font and get_global_setting('font', false): - %DialogicNode_DialogText.add_theme_font_override("normal_font", load(get_global_setting('font', ''))) + if text_use_global_font and get_global_setting(&'font', false): + dialog_text.add_theme_font_override(&"normal_font", load(get_global_setting(&'font', '') as String) as Font) elif !normal_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("normal_font", load(normal_font)) + dialog_text.add_theme_font_override(&"normal_font", load(normal_font) as Font) if !bold_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("bold_font", load(bold_font)) + dialog_text.add_theme_font_override(&"bold_font", load(bold_font) as Font) if !italic_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("italitc_font", load(italic_font)) + dialog_text.add_theme_font_override(&"italitc_font", load(italic_font) as Font) if !bold_italic_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("bold_italics_font", load(bold_italic_font)) + dialog_text.add_theme_font_override(&"bold_italics_font", load(bold_italic_font) as Font) ## BOX SETTINGS if ResourceLoader.exists(box_panel): - %DialogTextPanel.add_theme_stylebox_override('panel', load(box_panel)) + dialog_text_panel.add_theme_stylebox_override(&'panel', load(box_panel) as StyleBox) if box_color_use_global: - %DialogTextPanel.self_modulate = get_global_setting('bg_color', box_color_custom) + dialog_text_panel.self_modulate = get_global_setting(&'bg_color', box_color_custom) else: - %DialogTextPanel.self_modulate = box_color_custom + dialog_text_panel.self_modulate = box_color_custom - #%DialogTextPanel.hide() + #dialog_text_panel.hide() #%Minimizer.size = Vector2.ZERO #%Minimizer.position = Vector2(0, -box_margin_bottom) #%Minimizer.grow_vertical = Container.GROW_DIRECTION_BEGIN - #%DialogTextPanel.custom_minimum_size = box_size - #%DialogTextPanel.show() - %Sizer.size = box_size - %Sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom) + #dialog_text_panel.custom_minimum_size = box_size + #dialog_text_panel.show() + sizer.size = box_size + sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom) ## BOX ANIMATIONS - %Animations.animation_in = box_animation_in - %Animations.animation_out = box_animation_out - %Animations.animation_new_text = box_animation_new_text + animations.set(&'animation_in', box_animation_in) + animations.set(&'animation_out', box_animation_out) + animations.set(&'animation_new_text', box_animation_new_text) ## NAME LABEL SETTINGS if name_label_use_global_font_size: - %DialogicNode_NameLabel.add_theme_font_size_override("font_size", get_global_setting('font_size', name_label_custom_font_size)) + name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_font_size) as int) else: - %DialogicNode_NameLabel.add_theme_font_size_override("font_size", name_label_custom_font_size) + name_label.add_theme_font_size_override(&"font_size", name_label_custom_font_size) - if name_label_use_global_font and get_global_setting('font', false): - %DialogicNode_NameLabel.add_theme_font_override('font', load(get_global_setting('font', ''))) + if name_label_use_global_font and get_global_setting(&'font', false): + name_label.add_theme_font_override(&'font', load(get_global_setting(&'font', '') as String) as Font) elif not name_label_font.is_empty(): - %DialogicNode_NameLabel.add_theme_font_override('font', load(name_label_font)) + name_label.add_theme_font_override(&'font', load(name_label_font) as Font) if name_label_use_global_color: - %DialogicNode_NameLabel.add_theme_color_override("font_color", get_global_setting('font_color', name_label_custom_color)) + name_label.add_theme_color_override(&"font_color", get_global_setting(&'font_color', name_label_custom_color) as Color) else: - %DialogicNode_NameLabel.add_theme_color_override("font_color", name_label_custom_color) + name_label.add_theme_color_override(&"font_color", name_label_custom_color) - %DialogicNode_NameLabel.use_character_color = name_label_use_character_color + name_label.use_character_color = name_label_use_character_color if ResourceLoader.exists(name_label_box_panel): - %NameLabelPanel.add_theme_stylebox_override('panel', load(name_label_box_panel)) + name_label_panel.add_theme_stylebox_override(&'panel', load(name_label_box_panel) as StyleBox) else: - %NameLabelPanel.add_theme_stylebox_override('panel', load(this_folder.path_join("vn_textbox_name_label_panel.tres"))) + name_label_panel.add_theme_stylebox_override(&'panel', load(this_folder.path_join("vn_textbox_name_label_panel.tres")) as StyleBox) if name_label_box_use_global_color: - %NameLabelPanel.self_modulate = get_global_setting('bg_color', name_label_box_modulate) + name_label_panel.self_modulate = get_global_setting(&'bg_color', name_label_box_modulate) else: - %NameLabelPanel.self_modulate = name_label_box_modulate + name_label_panel.self_modulate = name_label_box_modulate - %NameLabelPanel.position = name_label_box_offset+Vector2(0, -40) - %NameLabelPanel.position -= Vector2( - %DialogTextPanel.get_theme_stylebox('panel', 'PanelContainer').content_margin_left, - %DialogTextPanel.get_theme_stylebox('panel', 'PanelContainer').content_margin_top) - %NameLabelPanel.anchor_left = name_label_alignment/2.0 - %NameLabelPanel.anchor_right = name_label_alignment/2.0 - %NameLabelPanel.grow_horizontal = [1, 2, 0][name_label_alignment] + name_label_panel.position = name_label_box_offset+Vector2(0, -40) + name_label_panel.position -= Vector2( + dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_left, + dialog_text_panel.get_theme_stylebox(&'panel', &'PanelContainer').content_margin_top) + name_label_panel.anchor_left = name_label_alignment/2.0 + name_label_panel.anchor_right = name_label_alignment/2.0 + name_label_panel.grow_horizontal = [1, 2, 0][name_label_alignment] ## NEXT INDICATOR SETTINGS - %NextIndicator.enabled = next_indicator_enabled + next_indicator.enabled = next_indicator_enabled if next_indicator_enabled: - %NextIndicator.animation = next_indicator_animation + next_indicator.animation = next_indicator_animation if FileAccess.file_exists(next_indicator_texture): - %NextIndicator.texture = load(next_indicator_texture) - %NextIndicator.show_on_questions = next_indicator_show_on_questions - %NextIndicator.show_on_autoadvance = next_indicator_show_on_autoadvance - %NextIndicator.texture_size = next_indicator_size + next_indicator.texture = load(next_indicator_texture) + next_indicator.show_on_questions = next_indicator_show_on_questions + next_indicator.show_on_autoadvance = next_indicator_show_on_autoadvance + next_indicator.texture_size = next_indicator_size ## OTHER - %AutoAdvanceProgressbar.enabled = autoadvance_progressbar + progress_bar.set(&'enabled', autoadvance_progressbar) #### SOUNDS ## TYPING SOUNDS - %DialogicNode_TypeSounds.enabled = typing_sounds_enabled - %DialogicNode_TypeSounds.mode = typing_sounds_mode + type_sounds.enabled = typing_sounds_enabled + type_sounds.mode = typing_sounds_mode if not typing_sounds_sounds_folder.is_empty(): - %DialogicNode_TypeSounds.sounds = %DialogicNode_TypeSounds.load_sounds_from_path(typing_sounds_sounds_folder) + type_sounds.sounds = DialogicNode_TypeSounds.load_sounds_from_path(typing_sounds_sounds_folder) else: - %DialogicNode_TypeSounds.sounds.clear() + type_sounds.sounds.clear() if not typing_sounds_end_sound.is_empty(): - %DialogicNode_TypeSounds.end_sound = load(typing_sounds_end_sound) + type_sounds.end_sound = load(typing_sounds_end_sound) else: - %DialogicNode_TypeSounds.end_sound = null - - %DialogicNode_TypeSounds.play_every_character = typing_sounds_every_nths_character - %DialogicNode_TypeSounds.base_pitch = typing_sounds_pitch - %DialogicNode_TypeSounds.base_volume = typing_sounds_volume - %DialogicNode_TypeSounds.pitch_variance = typing_sounds_pitch_variance - %DialogicNode_TypeSounds.volume_variance = typing_sounds_volume_variance - %DialogicNode_TypeSounds.ignore_characters = typing_sounds_ignore_characters + type_sounds.end_sound = null + + type_sounds.play_every_character = typing_sounds_every_nths_character + type_sounds.base_pitch = typing_sounds_pitch + type_sounds.base_volume = typing_sounds_volume + type_sounds.pitch_variance = typing_sounds_pitch_variance + type_sounds.volume_variance = typing_sounds_volume_variance + type_sounds.ignore_characters = typing_sounds_ignore_characters diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn index 263440079..924c69fe4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn @@ -291,7 +291,14 @@ textbox_root = NodePath("..") [node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel/DialogicNode_DialogText"] unique_name_in_owner = true script = ExtResource("4_ma5mw") +enabled = true +mode = 0 +sounds = Array[AudioStream]([]) +end_sound = null play_every_character = 0 +pitch_variance = 0.0 +volume_variance = 0.0 +ignore_characters = " .," [node name="NextIndicator" type="Control" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel"] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/Glossary/subsystem_glossary.gd b/addons/dialogic/Modules/Glossary/subsystem_glossary.gd index 7a8d29567..9e8de93a9 100644 --- a/addons/dialogic/Modules/Glossary/subsystem_glossary.gd +++ b/addons/dialogic/Modules/Glossary/subsystem_glossary.gd @@ -1,4 +1,5 @@ extends DialogicSubsystem +class_name DialogicSubsystemGlossary ## Subsystem that handles glossaries. diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index 0dca6410c..b6bbd9305 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -1,24 +1,25 @@ extends DialogicSubsystem +class_name DialogicSubsystemHistory ## Subsystem that manages history storing. ## Simple history that stores limited information ## Used for the history display -var simple_history_enabled := true +var simple_history_enabled : bool = true var simple_history_content : Array[Dictionary] = [] signal simple_history_changed ## Full event history (can be used for undo) -var full_event_history_enabled := false -var full_event_history_content := [] +var full_event_history_enabled : bool = false +var full_event_history_content : Array = [] signal full_event_history_changed ## Read text history ## Stores which text events and choices have already been visited -var already_read_history_enabled := false -var already_read_history_content := {} -var _was_last_event_already_read := false +var already_read_history_enabled : bool = false +var already_read_history_content : Dictionary = {} +var _was_last_event_already_read : bool = false signal already_read_event_reached signal not_read_event_reached @@ -46,7 +47,7 @@ func _ready() -> void: ## SIMPLE HISTORY #################################################################################################### -func store_simple_history_entry(text:String, event_type:String, extra_info := {}) -> void: +func store_simple_history_entry(text:String, event_type:String, extra_info : Dictionary = {}) -> void: if !simple_history_enabled: return extra_info['text'] = text extra_info['event_type'] = event_type @@ -77,9 +78,9 @@ func store_full_event(event:DialogicEvent) -> void: ## Takes the current timeline event and creates a unique key for it. ## Uses the timeline resource path as well. func _current_event_key() -> String: - var resource_path = dialogic.current_timeline.resource_path - var event_idx = str(dialogic.current_event_idx) - var event_key = resource_path+event_idx + var resource_path : String = dialogic.current_timeline.resource_path + var event_idx : String = str(dialogic.current_event_idx) + var event_key : String = resource_path+event_idx return event_key @@ -88,7 +89,7 @@ func event_was_read(_event: DialogicEvent) -> void: if !already_read_history_enabled: return - var event_key = _current_event_key() + var event_key : String = _current_event_key() already_read_history_content[event_key] = dialogic.current_event_idx @@ -103,7 +104,7 @@ func check_already_read(event: DialogicEvent) -> void: if event.event_name != "Text": return - var event_key = _current_event_key() + var event_key : String = _current_event_key() if event_key in already_read_history_content: already_read_event_reached.emit() diff --git a/addons/dialogic/Modules/Text/node_dialog_text.gd b/addons/dialogic/Modules/Text/node_dialog_text.gd index 450f84266..e5d0a4891 100644 --- a/addons/dialogic/Modules/Text/node_dialog_text.gd +++ b/addons/dialogic/Modules/Text/node_dialog_text.gd @@ -4,30 +4,31 @@ extends RichTextLabel ## Dialogic node that can reveal text at a given (changeable speed). signal started_revealing_text() -signal continued_revealing_text(new_character) +signal continued_revealing_text(new_character : Variant) signal finished_revealing_text() enum Alignment {LEFT, CENTER, RIGHT} -@export var enabled := true -@export var alignment := Alignment.LEFT -@export var textbox_root : Node = self +@export var enabled : bool = true +@export var alignment : Alignment = Alignment.LEFT +@export var textbox_root : CanvasItem = self -@export var hide_when_empty := false -@export var start_hidden := true +@export var hide_when_empty : bool = false +@export var start_hidden : bool = true -var revealing := false -var base_visible_characters := 0 +var revealing : bool = false +var base_visible_characters : int = 0 # time per character var lspeed:float = 0.01 var speed_counter:float = 0 -func _set(property, what): - if property == 'text' and typeof(what) == TYPE_STRING: +func _set(property : StringName, what : Variant) -> bool: + if property == &'text' and typeof(what) == TYPE_STRING: text = what if hide_when_empty: - textbox_root.visible = !what.is_empty() + textbox_root.visible = !text.is_empty() return true + return false func _ready() -> void: @@ -44,7 +45,7 @@ func _ready() -> void: # this is called by the DialogicGameHandler to set text -func reveal_text(_text:String, keep_previous:=false) -> void: +func reveal_text(_text:String, keep_previous: bool =false) -> void: if !enabled: return show() diff --git a/addons/dialogic/Modules/Text/node_name_label.gd b/addons/dialogic/Modules/Text/node_name_label.gd index 86ae58966..c6c75f4b2 100644 --- a/addons/dialogic/Modules/Text/node_name_label.gd +++ b/addons/dialogic/Modules/Text/node_name_label.gd @@ -3,21 +3,22 @@ extends Label class_name DialogicNode_NameLabel # If true, the label will be hidden if no character speaks. -@export var hide_when_empty := true -@export var name_label_root :Node = self -@export var use_character_color := true +@export var hide_when_empty : bool = true +@export var name_label_root : CanvasItem = self +@export var use_character_color : bool = true -func _ready(): +func _ready() -> void: add_to_group('dialogic_name_label') if hide_when_empty: name_label_root.visible = false text = "" -func _set(property, what): +func _set(property : StringName, what : Variant) -> bool: if property == 'text' and typeof(what) == TYPE_STRING: text = what if hide_when_empty: - name_label_root.visible = !what.is_empty() + name_label_root.visible = !text.is_empty() else: name_label_root.show() return true + return false diff --git a/addons/dialogic/Modules/Text/node_next_indicator.gd b/addons/dialogic/Modules/Text/node_next_indicator.gd index 9f7a7fcc4..fb29cd8fa 100644 --- a/addons/dialogic/Modules/Text/node_next_indicator.gd +++ b/addons/dialogic/Modules/Text/node_next_indicator.gd @@ -5,40 +5,41 @@ extends Control ## Node that is shown when the text is fully revealed. ## The default implementation allows to set an icon and animation. +const TEXTURE : String = 'Texture' -@export var enabled := true +@export var enabled : bool = true ## If true the next indicator will also be shown if the text is a question. -@export var show_on_questions := false +@export var show_on_questions : bool = false ## If true the next indicator will be shown even if dialogic will autocontinue. -@export var show_on_autoadvance := false +@export var show_on_autoadvance : bool = false ## What animation should the indicator do. -@export_enum('bounce', 'blink', 'none') var animation := 0 +@export_enum('bounce', 'blink', 'none') var animation : int = 0 ## Set the image to use as the indicator. -@export var texture := preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png"): +@export var texture : Texture = preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png"): set(_texture): texture = _texture - if has_node('Texture'): - get_node('Texture').texture = texture + if has_node(TEXTURE): + get_node(TEXTURE).set(&'texture', texture) -@export var texture_size := Vector2(32,32): +@export var texture_size : Vector2 = Vector2(32,32): set(_texture_size): texture_size = _texture_size - if has_node('Texture'): - get_node('Texture').size = _texture_size - get_node('Texture').position = -_texture_size + if has_node(TEXTURE): + get_node(TEXTURE).set(&'size', _texture_size) + get_node(TEXTURE).set(&'position', -_texture_size) var tween: Tween -func _ready(): +func _ready() -> void: add_to_group('dialogic_next_indicator') # Creating texture if texture: - var icon := TextureRect.new() - icon.name = 'Texture' - icon.ignore_texture_size = true + var icon : TextureRect = TextureRect.new() + icon.name = TEXTURE + icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED icon.size = texture_size icon.position = -icon.size @@ -49,19 +50,19 @@ func _ready(): visibility_changed.connect(_on_visibility_changed) -func _on_visibility_changed(): +func _on_visibility_changed() -> void: if visible: play_animation(animation, 1.0) -func play_animation(animation: int, time:float) -> void: +func play_animation(anim: int, time: float) -> void: # clean up previous tween to prevent slipping if tween: tween.stop() - if animation == 0: + if anim == 0: tween = (create_tween() as Tween) - var distance := 4 + var distance : int = 4 tween.set_parallel(false) tween.set_trans(Tween.TRANS_SINE) tween.set_ease(Tween.EASE_IN_OUT) @@ -69,7 +70,7 @@ func play_animation(animation: int, time:float) -> void: tween.tween_property(self, 'position', Vector2(0,distance), time*0.3).as_relative() tween.tween_property(self, 'position', - Vector2(0,distance), time*0.3).as_relative() - if animation == 1: + if anim == 1: tween = (create_tween() as Tween) tween.set_parallel(false) tween.set_trans(Tween.TRANS_SINE) diff --git a/addons/dialogic/Modules/Text/node_type_sound.gd b/addons/dialogic/Modules/Text/node_type_sound.gd index ada86fffb..0f01e025c 100644 --- a/addons/dialogic/Modules/Text/node_type_sound.gd +++ b/addons/dialogic/Modules/Text/node_type_sound.gd @@ -6,48 +6,54 @@ extends AudioStreamPlayer ## Should be the child of a DialogicNode_DialogText node! ## Usefull if you want to change the sounds of different node's sounds -@export var enabled := true +@export var enabled : bool = true enum Modes {INTERRUPT, OVERLAP, AWAIT} ## If true, interrupts the current sound to play a new one -@export var mode := Modes.INTERRUPT +@export var mode : Modes = Modes.INTERRUPT ## Array of sounds. Will pick a random one each time. @export var sounds: Array[AudioStream] = [] ## A sound to be played as the last sound. @export var end_sound:AudioStream ## Determines how many characters are between each sound. Default is 1 for playing it every character. -@export var play_every_character := 1 +@export var play_every_character : int = 1 ## Allows changing the pitch by a random value from (pitch - pitch_variance) to (pitch + pitch_variance) -@export_range(0, 3, 0.01) var pitch_variance := 0.0 +@export_range(0, 3, 0.01) var pitch_variance : float = 0.0 ## Allows changing the volume by a random value from (volume - volume_variance) to (volume + volume_variance) -@export_range(0, 10, 0.01) var volume_variance := 0.0 +@export_range(0, 10, 0.01) var volume_variance : float = 0.0 ## Characters that don't increase the 'characters_since_last_sound' variable, useful for the space or fullstop @export var ignore_characters:String = ' .,' var characters_since_last_sound: int = 0 var base_pitch :float = pitch_scale var base_volume :float = volume_db -var RNG := RandomNumberGenerator.new() +var RNG : RandomNumberGenerator = RandomNumberGenerator.new() -var current_overwrite_data := {} +var current_overwrite_data : Dictionary = {} -func _ready(): +func _ready() -> void: # add to necessary group add_to_group('dialogic_type_sounds') - if !Engine.is_editor_hint() and get_parent() is DialogicNode_DialogText: - get_parent().started_revealing_text.connect(_on_started_revealing_text) - get_parent().continued_revealing_text.connect(_on_continued_revealing_text) - get_parent().finished_revealing_text.connect(_on_finished_revealing_text) + if !Engine.is_editor_hint(): + var dialog_text : DialogicNode_DialogText = get_dialog_text() + if dialog_text: + dialog_text.started_revealing_text.connect(_on_started_revealing_text) + dialog_text.continued_revealing_text.connect(_on_continued_revealing_text) + dialog_text.finished_revealing_text.connect(_on_finished_revealing_text) + + +func get_dialog_text() -> DialogicNode_DialogText: + return get_parent() as DialogicNode_DialogText func _on_started_revealing_text() -> void: - if !enabled or (get_parent() is DialogicNode_DialogText and !get_parent().enabled): + if !enabled or (get_dialog_text() != null and !get_dialog_text().enabled): return characters_since_last_sound = current_overwrite_data.get('skip_characters', play_every_character-1)+1 func _on_continued_revealing_text(new_character:String) -> void: - if !enabled or (get_parent() is DialogicNode_DialogText and !get_parent().enabled): + if !enabled or (get_dialog_text() != null and !get_dialog_text().enabled): return # We don't want to play type sounds if Auto-Skip is enabled. @@ -55,16 +61,16 @@ func _on_continued_revealing_text(new_character:String) -> void: return # don't play if a voice-track is running - if !Engine.is_editor_hint() and get_parent() is DialogicNode_DialogText: + if !Engine.is_editor_hint() and get_dialog_text() != null: if DialogicUtil.autoload().has_subsystem("Voice") and DialogicUtil.autoload().Voice.is_running(): return # if sound playing and can't interrupt - if playing and current_overwrite_data.get('mode', mode) == Modes.AWAIT: + if playing and current_overwrite_data.get(&'mode', mode) == Modes.AWAIT: return # if no sounds were given - if current_overwrite_data.get('sounds', sounds).size() == 0: + if current_overwrite_data.get(&'sounds', sounds).size() == 0: return # if the new character is not allowed @@ -72,30 +78,30 @@ func _on_continued_revealing_text(new_character:String) -> void: return characters_since_last_sound += 1 - if characters_since_last_sound < current_overwrite_data.get('skip_characters', play_every_character-1)+1: + if characters_since_last_sound < current_overwrite_data.get(&'skip_characters', play_every_character-1)+1: return characters_since_last_sound = 0 var audio_player : AudioStreamPlayer = self - if current_overwrite_data.get('mode', mode) == Modes.OVERLAP: + if current_overwrite_data.get(&'mode', mode) == Modes.OVERLAP: audio_player = AudioStreamPlayer.new() audio_player.bus = bus add_child(audio_player) - elif current_overwrite_data.get('mode', mode) == Modes.INTERRUPT: + elif current_overwrite_data.get(&'mode', mode) == Modes.INTERRUPT: stop() #choose the random sound - audio_player.stream = current_overwrite_data.get('sounds', sounds)[RNG.randi_range(0, current_overwrite_data.get('sounds', sounds).size() - 1)] + audio_player.stream = current_overwrite_data.get(&'sounds', sounds)[RNG.randi_range(0, current_overwrite_data.get(&'sounds', sounds).size() - 1)] #choose a random pitch and volume - audio_player.pitch_scale = max(0, current_overwrite_data.get('pitch_base', base_pitch) + current_overwrite_data.get('pitch_variance', pitch_variance) * RNG.randf_range(-1.0, 1.0)) - audio_player.volume_db = current_overwrite_data.get('volume_base', base_volume) + current_overwrite_data.get('volume_variance',volume_variance) * RNG.randf_range(-1.0, 1.0) + audio_player.pitch_scale = max(0, current_overwrite_data.get(&'pitch_base', base_pitch) + current_overwrite_data.get(&'pitch_variance', pitch_variance) * RNG.randf_range(-1.0, 1.0)) + audio_player.volume_db = current_overwrite_data.get(&'volume_base', base_volume) + current_overwrite_data.get(&'volume_variance',volume_variance) * RNG.randf_range(-1.0, 1.0) #play the sound audio_player.play(0) - if current_overwrite_data.get('mode', mode) == Modes.OVERLAP: + if current_overwrite_data.get(&'mode', mode) == Modes.OVERLAP: audio_player.finished.connect(audio_player.queue_free) @@ -111,8 +117,8 @@ func _on_finished_revealing_text() -> void: func load_overwrite(dictionary:Dictionary) -> void: current_overwrite_data = dictionary - if dictionary.has('sound_path'): - current_overwrite_data['sounds'] = load_sounds_from_path(dictionary.sound_path) + if dictionary.has(&'sound_path'): + current_overwrite_data[&'sounds'] = load_sounds_from_path(dictionary.sound_path) static func load_sounds_from_path(path:String) -> Array[AudioStream]: @@ -129,7 +135,7 @@ static func load_sounds_from_path(path:String) -> Array[AudioStream]: ############# USER INTERFACE ################################################### -func _get_configuration_warnings(): +func _get_configuration_warnings() -> PackedStringArray: if not get_parent() is DialogicNode_DialogText: return ["This should be the child of a DialogText node!"] return [] diff --git a/addons/dialogic/Modules/Text/subsystem_text.gd b/addons/dialogic/Modules/Text/subsystem_text.gd index f16d36877..af9b81aac 100644 --- a/addons/dialogic/Modules/Text/subsystem_text.gd +++ b/addons/dialogic/Modules/Text/subsystem_text.gd @@ -1,4 +1,5 @@ extends DialogicSubsystem +class_name DialogicSubsystemText ## Subsystem that handles showing of dialog text (+text effects & modifiers), name label, and next indicator diff --git a/addons/dialogic/Other/DialogicGameHandler.gd b/addons/dialogic/Other/DialogicGameHandler.gd index c4558bc5c..0a2a8fa4e 100644 --- a/addons/dialogic/Other/DialogicGameHandler.gd +++ b/addons/dialogic/Other/DialogicGameHandler.gd @@ -34,28 +34,28 @@ var current_event_idx: int = 0 ## relevant for the current situation var current_state_info: Dictionary = {} ## Current state (see [States] enum) -var current_state := States.IDLE: +var current_state : States = States.IDLE: get: return current_state set(new_state): current_state = new_state emit_signal('state_changed', new_state) ## Emitted when [current_state] change. -signal state_changed(new_state) +signal state_changed(new_state : States) ## When true, many dialogic process won't continue until it's false again. -var paused := false: +var paused : bool = false: set(value): paused = value if paused: - for subsystem in get_children(): - if subsystem.has_method('pause'): - subsystem.pause() + for subsystem : Node in get_children(): + if subsystem.has_method(&'pause'): + subsystem.call(&'pause') dialogic_paused.emit() else: - for subsystem in get_children(): - if subsystem.has_method('resume'): - subsystem.resume() + for subsystem : Node in get_children(): + if subsystem.has_method(&'resume'): + subsystem.call(&'resume') dialogic_resumed.emit() ## Emitted when [paused] changes to true. @@ -66,12 +66,12 @@ signal dialogic_resumed signal timeline_ended() signal timeline_started() -signal event_handled(resource) +signal event_handled(resource : Variant) ## Emitted when the Signal event was reached -signal signal_event(argument) +signal signal_event(argument : Variant) ## Emitted when [signal] effect was reached in text. -signal text_signal(argument) +signal text_signal(argument : Variant) ## Autoloads are added first, so this happens REALLY early on game startup. diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 013399f4e..7722566ea 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -28,6 +28,23 @@ static func autoload() -> DialogicGameHandler: return null return Engine.get_main_loop().root.get_node("Dialogic") + +static func get_text() -> DialogicSubsystemText: + return DialogicUtil.autoload().Text + + +static func get_input() -> DialogicSubsystemInput: + return DialogicUtil.autoload().Input + + +static func get_glossary() -> DialogicSubsystemGlossary: + return DialogicUtil.autoload().Glossary + + +static func get_history() -> DialogicSubsystemHistory: + return DialogicUtil.autoload().History + + #region FILE SYSTEM ################################################################################ static func listdir(path: String, files_only: bool = true, throw_error:bool = true, full_file_path:bool = false, include_imports := false) -> Array: diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index a346b494a..90b591a8b 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -1,22 +1,22 @@ @tool class_name DialogicLayoutBase -extends Node +extends CanvasLayer ## Base class that should be extended by custom layouts. -func add_layer(layer:DialogicLayoutLayer) -> Node: - add_child(layer) - return layer +func add_dialogic_layer(dialogic_layer:DialogicLayoutLayer) -> DialogicLayoutLayer: + add_child(dialogic_layer) + return dialogic_layer -func get_layer(index:int) -> Node: +func get_dialogic_layer(index:int) -> DialogicLayoutLayer: return get_child(index) -func get_layers() -> Array: - var layers := [] - for child in get_children(): +func get_layers() -> Array[DialogicLayoutLayer]: + var layers : Array[DialogicLayoutLayer] = [] + for child : Node in get_children(): if child is DialogicLayoutLayer: layers.append(child) return layers @@ -24,9 +24,9 @@ func get_layers() -> Array: func appply_export_overrides() -> void: _apply_export_overrides() - for child in get_children(): + for child : Node in get_children(): if child.has_method('_apply_export_overrides'): - child._apply_export_overrides() + child.call('_apply_export_overrides') func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index cccae3a91..693386d95 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -1,19 +1,19 @@ @tool class_name DialogicLayoutLayer -extends Node +extends Control ## Base class that should be extended by custom dialogic layout layers. @export_group('Layer') @export_subgroup('Disabled') -@export var disabled := false +@export var disabled : bool = false ## This is turned on automatically when the layout is realized [br] [br] ## Turn it off, if you want to modify the settings of the nodes yourself. @export_group('Private') -@export var apply_overrides_on_ready := false +@export var apply_overrides_on_ready : bool = false -var this_folder: String = get_script().resource_path.get_base_dir() +var this_folder: String = (get_script() as Resource).resource_path.get_base_dir() func _ready() -> void: if apply_overrides_on_ready and not Engine.is_editor_hint(): @@ -39,6 +39,10 @@ func apply_export_overrides() -> void: _apply_export_overrides() +func get_layout() -> DialogicLayoutBase: + return get_parent() as DialogicLayoutBase + + ## Use this to get potential global settings. func get_global_setting(setting_name:StringName, default:Variant) -> Variant: - return get_parent().get_global_setting(setting_name, default) + return get_layout().get_global_setting(setting_name, default) From b21d8197155f12d25920bea427b0d0d0d210fbae Mon Sep 17 00:00:00 2001 From: nlupugla Date: Sun, 31 Dec 2023 17:27:54 -0500 Subject: [PATCH 02/12] Added types to the textbubble and speaker_textbubble examples --- .../Modules/Core/subsystem_animation.gd | 1 + .../Base_Default/default_layout_base.gd | 2 +- .../Layer_Glossary/glossary_popup_layer.gd | 20 +-- .../Layer_History/history_layer.gd | 6 +- .../Layer_Textbubble/text_bubble.gd | 32 +++-- .../Layer_Textbubble/text_bubble_layer.gd | 127 +++++++++--------- .../Layer_VN_Textbox/animations.gd | 44 +++--- .../Layer_VN_Textbox/autoadvance_indicator.gd | 5 +- .../Modules/History/subsystem_history.gd | 16 +-- addons/dialogic/Other/DialogicUtil.gd | 24 +--- .../Resources/dialogic_layout_base.gd | 2 +- .../Resources/dialogic_layout_layer.gd | 4 +- addons/dialogic/Resources/dialogic_style.gd | 3 - 13 files changed, 143 insertions(+), 143 deletions(-) diff --git a/addons/dialogic/Modules/Core/subsystem_animation.gd b/addons/dialogic/Modules/Core/subsystem_animation.gd index ad80a9513..943e7a1bf 100644 --- a/addons/dialogic/Modules/Core/subsystem_animation.gd +++ b/addons/dialogic/Modules/Core/subsystem_animation.gd @@ -1,4 +1,5 @@ extends DialogicSubsystem +class_name DialogicSubsystemAnimation ## Subsystem that allows entering and leaving an animation state. diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd index ddda2fdb6..a5aece6ae 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd @@ -14,6 +14,6 @@ extends DialogicLayoutBase func _apply_export_overrides() -> void: # apply layer - self.layer = canvas_layer + set(&'layer', canvas_layer) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 9c1c3f6f8..df8aa7a2a 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -52,16 +52,18 @@ func _ready() -> void: return pointer.hide() - var text_system : DialogicSubsystemText = DialogicUtil.get_text() - text_system.animation_textbox_hide.connect(pointer.hide) - text_system.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) - text_system.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) - text_system.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) + var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') + var _error : int = 0 + _error = text_system.animation_textbox_hide.connect(pointer.hide) + _error = text_system.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) + _error = text_system.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) + _error = text_system.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var info: Dictionary = DialogicUtil.get_glossary().get_entry(meta) + var glossary_system : DialogicSubsystemGlossary = DialogicUtil.autoload().get(&'Glossary') + var info: Dictionary = glossary_system.get_entry(meta) if not info: return @@ -86,7 +88,7 @@ func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: panel.self_modulate = info.get(&'color', Color.WHITE) panel_point.self_modulate = info.get(&'color', Color.WHITE) - DialogicUtil.get_input().action_was_consumed = true + (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = true ## Method that keeps the bubble at mouse position when visible @@ -101,11 +103,11 @@ func _process(_delta : float) -> void: ## Method that hides the bubble func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: pointer.hide() - DialogicUtil.get_input().action_was_consumed = false + (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = false func _on_dialogic_display_dialog_text_meta_clicked(_meta:String) -> void: - DialogicUtil.get_input().action_was_consumed = true + (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = true func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index f86353bfa..9b5f759a8 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -47,7 +47,7 @@ func _ready() -> void: func _apply_export_overrides() -> void: if DialogicUtil.autoload().has_subsystem('History'): - show_history_button.visible = show_open_button and DialogicUtil.get_history().simple_history_enabled + show_history_button.visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled else: self.visible = false @@ -88,7 +88,7 @@ func show_history() -> void: for child : Node in history_log.get_children(): child.queue_free() - for info : Dictionary in DialogicUtil.get_history().get_simple_history(): + for info : Dictionary in (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).get_simple_history(): var history_item : Node = HistoryItem.instantiate() history_item.set(&'theme', history_item_theme) match info.event_type: @@ -133,4 +133,4 @@ func _on_hide_history_pressed() -> void: DialogicUtil.autoload().paused = false history_box.hide() hide_history_button.hide() - show_history_button.visible = show_open_button and DialogicUtil.get_history().simple_history_enabled + show_history_button.visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd index c2282c019..5d8b62f7b 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd @@ -1,7 +1,6 @@ extends Control +class_name DialogicNode_TextBubble -@onready var tail : Line2D = $Tail -@onready var bubble : Control = $Background var speaker_node : Node = null var character : DialogicCharacter = null var max_width := 300 @@ -13,6 +12,13 @@ var base_direction := Vector2(1.0, -1.0).normalized() var safe_zone := 50.0 var padding := Vector2() +@onready var tail : Line2D = $Tail +@onready var bubble : Control = $Background +@onready var choice_container : Container = $DialogText/ChoiceContainer +@onready var name_label_panel : PanelContainer = $DialogText/NameLabel +@onready var name_label : DialogicNode_NameLabel = %NameLabel +@onready var dialog_text : DialogicNode_DialogText = %DialogText + func _ready() -> void: scale = Vector2.ZERO modulate.a = 0.0 @@ -61,7 +67,7 @@ func _process(delta): func open() -> void: show() - %DialogText.enabled = true + dialog_text.enabled = true var open_tween := create_tween().set_parallel(true) open_tween.tween_property(self, "scale", Vector2.ONE, 0.1).from(Vector2.ZERO) open_tween.tween_property(self, "modulate:a", 1.0, 0.1).from(0.0) @@ -69,7 +75,7 @@ func open() -> void: func close() -> void: - %DialogText.enabled = false + dialog_text.enabled = false var close_tween := create_tween().set_parallel(true) close_tween.tween_property(self, "scale", Vector2.ONE * 0.8, 0.1) close_tween.tween_property(self, "modulate:a", 0.0, 0.1) @@ -78,27 +84,27 @@ func close() -> void: func _on_dialog_text_started_revealing_text(): - var font :Font = %DialogText.get_theme_font("normal_font") - %DialogText.size = font.get_multiline_string_size(%DialogText.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, %DialogText.get_theme_font_size("normal_font_size")) + var font :Font = dialog_text.get_theme_font("normal_font") + dialog_text.size = font.get_multiline_string_size(dialog_text.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, %DialogText.get_theme_font_size("normal_font_size")) if DialogicUtil.autoload().Choices.is_question(DialogicUtil.autoload().current_event_idx): font = $DialogText/ChoiceContainer/DialogicNode_ChoiceButton.get_theme_font('font') - %DialogText.size.y += font.get_string_size(%DialogText.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, $DialogText/ChoiceContainer/DialogicNode_ChoiceButton.get_theme_font_size("font_size")).y - %DialogText.position = -%DialogText.size/2 + dialog_text.size.y += font.get_string_size(dialog_text.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, $DialogText/ChoiceContainer/DialogicNode_ChoiceButton.get_theme_font_size("font_size")).y + dialog_text.position = -dialog_text.size/2 _resize_bubble() func _resize_bubble() -> void: - var bubble_size :Vector2 = %DialogText.size+(padding*2) + var bubble_size :Vector2 = dialog_text.size+(padding*2) var half_size :Vector2= (bubble_size / 2.0) - %DialogText.pivot_offset = half_size + dialog_text.pivot_offset = half_size bubble.pivot_offset = half_size bubble_rect = Rect2(position, bubble_size * Vector2(1.1, 1.1)) bubble.size = bubble_size bubble.position = -half_size - var t := create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK) - t.tween_property(bubble, "scale", Vector2.ONE, 0.2).from(Vector2.ZERO) + var t : Tween = create_tween().set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_BACK) + t.tween_property(bubble, ^"scale", Vector2.ONE, 0.2).from(Vector2.ZERO) # set bubble's ratio var bubble_ratio := Vector2.ONE @@ -107,5 +113,5 @@ func _resize_bubble() -> void: else: bubble_ratio.x = bubble_rect.size.x / bubble_rect.size.y - bubble.material.set("shader_parameter/ratio", bubble_ratio) + bubble.material.set(&"shader_parameter/ratio", bubble_ratio) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd index dad37a310..37d5573c5 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd @@ -5,53 +5,53 @@ extends DialogicLayoutLayer @export_group("Main") @export_subgroup("Text") -@export var text_size := 15 +@export var text_size : int = 15 @export var text_color: Color = Color.BLACK @export_file('*.ttf') var normal_font: String = "" @export_file('*.ttf') var bold_font: String = "" @export_file('*.ttf') var italic_font: String = "" @export_file('*.ttf') var bold_italic_font: String = "" -@export var text_max_width := 300 +@export var text_max_width : int = 300 @export_subgroup('Box') -@export var box_modulate := Color.WHITE -@export var box_modulate_by_character_color := false -@export var box_padding := Vector2(10,10) -@export_range(0.1, 2) var box_corner_radius := 0.3 -@export_range(0.1, 5) var box_wobble_speed := 1 -@export_range(0, 1) var box_wobbliness := 0.2 +@export var box_modulate : Color = Color.WHITE +@export var box_modulate_by_character_color : bool = false +@export var box_padding : Vector2 = Vector2(10,10) +@export_range(0.1, 2) var box_corner_radius : float = 0.3 +@export_range(0.1, 5) var box_wobble_speed : float= 1 +@export_range(0, 1) var box_wobbliness : float = 0.2 @export_subgroup('Behaviour') -@export var behaviour_distance := 50 -@export var behaviour_direction := Vector2(1, -1) +@export var behaviour_distance : int = 50 +@export var behaviour_direction : Vector2 = Vector2(1, -1) @export_group('Name Label & Choices') @export_subgroup("Name Label") -@export var name_label_enabled := true -@export var name_label_font_size := 15 +@export var name_label_enabled : bool = true +@export var name_label_font_size : int = 15 @export_file('*.ttf') var name_label_font: String = "" -@export var name_label_use_character_color := true -@export var name_label_color := Color.BLACK +@export var name_label_use_character_color : bool = true +@export var name_label_color : Color = Color.BLACK @export var name_label_box_modulate : Color = Color.WHITE -@export var name_label_padding := Vector2(5,0) -@export var name_label_offset := Vector2(0,0) +@export var name_label_padding : Vector2 = Vector2(5,0) +@export var name_label_offset : Vector2 = Vector2(0,0) @export_subgroup('Choices Text') -@export var choices_text_size := 15 -@export var choices_text_color := Color.LIGHT_SLATE_GRAY -@export var choices_text_color_hover := Color.DARK_GRAY -@export var choices_text_color_focus := Color.BLACK +@export var choices_text_size : int = 15 +@export var choices_text_color : Color = Color.LIGHT_SLATE_GRAY +@export var choices_text_color_hover : Color = Color.DARK_GRAY +@export var choices_text_color_focus : Color = Color.BLACK -var bubbles: Array = [] -var fallback_bubble: Control = null +var bubbles: Array[DialogicNode_TextBubble] = [] +var fallback_bubble: DialogicNode_TextBubble = null @export_group('Private') @export var textbubble_scene: PackedScene = null -func add_bubble() -> Control: - var new_bubble: Control = textbubble_scene.instantiate() +func add_bubble() -> DialogicNode_TextBubble: + var new_bubble: DialogicNode_TextBubble = textbubble_scene.instantiate() add_child(new_bubble) bubble_apply_overrides(new_bubble) bubbles.append(new_bubble) @@ -60,64 +60,65 @@ func add_bubble() -> Control: ## Called by dialogic whenever export overrides might change -func _apply_export_overrides(): - for bubble in bubbles: +func _apply_export_overrides() -> void: + for bubble : DialogicNode_TextBubble in bubbles: bubble_apply_overrides(bubble) if fallback_bubble: bubble_apply_overrides(fallback_bubble) -func bubble_apply_overrides(bubble:Control) -> void: +func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## TEXT FONT AND COLOR - var rtl : RichTextLabel = bubble.get_node('DialogText') - rtl.add_theme_font_size_override('normal_font', text_size) - rtl.add_theme_font_size_override("normal_font_size", text_size) - rtl.add_theme_font_size_override("bold_font_size", text_size) - rtl.add_theme_font_size_override("italics_font_size", text_size) - rtl.add_theme_font_size_override("bold_italics_font_size", text_size) + var rtl : RichTextLabel = bubble.dialog_text + rtl.add_theme_font_size_override(&'normal_font', text_size) + rtl.add_theme_font_size_override(&"normal_font_size", text_size) + rtl.add_theme_font_size_override(&"bold_font_size", text_size) + rtl.add_theme_font_size_override(&"italics_font_size", text_size) + rtl.add_theme_font_size_override(&"bold_italics_font_size", text_size) - rtl.add_theme_color_override("default_color", text_color) + rtl.add_theme_color_override(&"default_color", text_color) if !normal_font.is_empty(): - rtl.add_theme_font_override("normal_font", load(normal_font)) + rtl.add_theme_font_override(&"normal_font", load(normal_font) as Font) if !bold_font.is_empty(): - rtl.add_theme_font_override("bold_font", load(bold_font)) + rtl.add_theme_font_override(&"bold_font", load(bold_font) as Font) if !italic_font.is_empty(): - rtl.add_theme_font_override("italitc_font", load(italic_font)) + rtl.add_theme_font_override(&"italitc_font", load(italic_font) as Font) if !bold_italic_font.is_empty(): - rtl.add_theme_font_override("bold_italics_font", load(bold_italic_font)) - bubble.max_width = text_max_width + rtl.add_theme_font_override(&"bold_italics_font", load(bold_italic_font) as Font) + bubble.set(&'max_width', text_max_width) ## BOX & TAIL COLOR - bubble.get_node('Tail').default_color = box_modulate - bubble.get_node('Background').color = box_modulate - bubble.get_node('Background').material.set_shader_parameter('radius', box_corner_radius) - bubble.get_node('Background').material.set_shader_parameter('crease', box_wobbliness*0.1) - bubble.get_node('Background').material.set_shader_parameter('speed', box_wobble_speed) + bubble.tail.default_color = box_modulate + bubble.bubble.set(&'color', box_modulate) + var bubble_material : ShaderMaterial = bubble.bubble.get(&'material') + bubble_material.set_shader_parameter(&'radius', box_corner_radius) + bubble_material.set_shader_parameter(&'crease', box_wobbliness*0.1) + bubble_material.set_shader_parameter(&'speed', box_wobble_speed) if box_modulate_by_character_color and bubble.character != null: - bubble.get_node('Tail').modulate = bubble.character.color - bubble.get_node('Background').modulate = bubble.character.color + bubble.tail.modulate = bubble.character.color + bubble.bubble.modulate = bubble.character.color bubble.padding = box_padding ## NAME LABEL SETTINGS - var nl : Label = bubble.get_node('%NameLabel') - nl.add_theme_font_size_override("font_size", name_label_font_size) + var nl : DialogicNode_NameLabel = bubble.name_label + nl.add_theme_font_size_override(&"font_size", name_label_font_size) if !name_label_font.is_empty(): - nl.add_theme_font_override('font', load(name_label_font)) + nl.add_theme_font_override(&'font', load(name_label_font) as Font) nl.use_character_color = name_label_use_character_color if !nl.use_character_color: - nl.add_theme_color_override("font_color", name_label_color) + nl.add_theme_color_override(&"font_color", name_label_color) - var nlp : Container = bubble.get_node('DialogText/NameLabel') + var nlp : PanelContainer = bubble.name_label_panel nlp.self_modulate = name_label_box_modulate - nlp.get_theme_stylebox('panel').content_margin_left = name_label_padding.x - nlp.get_theme_stylebox('panel').content_margin_right = name_label_padding.x - nlp.get_theme_stylebox('panel').content_margin_top = name_label_padding.y - nlp.get_theme_stylebox('panel').content_margin_bottom = name_label_padding.y + nlp.get_theme_stylebox(&'panel').content_margin_left = name_label_padding.x + nlp.get_theme_stylebox(&'panel').content_margin_right = name_label_padding.x + nlp.get_theme_stylebox(&'panel').content_margin_top = name_label_padding.y + nlp.get_theme_stylebox(&'panel').content_margin_bottom = name_label_padding.y nlp.position += name_label_offset if !name_label_enabled: @@ -125,14 +126,14 @@ func bubble_apply_overrides(bubble:Control) -> void: ## CHOICE SETTINGS - var choice_theme := Theme.new() - choice_theme.set_font_size('font_size', 'Button', choices_text_size) - choice_theme.set_color('font_color', 'Button', choices_text_color) - choice_theme.set_color('font_pressed_color', 'Button', choices_text_color) - choice_theme.set_color('font_hover_color', 'Button', choices_text_color_hover) - choice_theme.set_color('font_focus_color', 'Button', choices_text_color_focus) - - bubble.get_node('DialogText/ChoiceContainer').theme = choice_theme + var choice_theme : Theme = Theme.new() + choice_theme.set_font_size(&'font_size', &'Button', choices_text_size) + choice_theme.set_color(&'font_color', &'Button', choices_text_color) + choice_theme.set_color(&'font_pressed_color', &'Button', choices_text_color) + choice_theme.set_color(&'font_hover_color', &'Button', choices_text_color_hover) + choice_theme.set_color(&'font_focus_color', &'Button', choices_text_color_focus) + + bubble.choice_container.theme = choice_theme ## BEHAVIOUR bubble.safe_zone = behaviour_distance diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index b1e18646d..537650fd2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -13,61 +13,69 @@ var animation_new_text : AnimationsNewText var full_clear : bool = true +@onready var text_panel : PanelContainer = %DialogTextPanel +@onready var dialog : DialogicNode_DialogText = %DialogicNode_DialogText + func _ready() -> void: - DialogicUtil.autoload().Text.animation_textbox_hide.connect(_on_textbox_hide) - DialogicUtil.autoload().Text.animation_textbox_show.connect(_on_textbox_show) - DialogicUtil.autoload().Text.animation_textbox_new_text.connect(_on_textbox_new_text) - DialogicUtil.autoload().Text.about_to_show_text.connect(_on_about_to_show_text) + var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') + var _error : int = 0 + _error = text_system.animation_textbox_hide.connect(_on_textbox_hide) + _error = text_system.animation_textbox_show.connect(_on_textbox_show) + _error = text_system.animation_textbox_new_text.connect(_on_textbox_new_text) + _error = text_system.about_to_show_text.connect(_on_about_to_show_text) func _on_textbox_show() -> void: if animation_in == AnimationsIn.NONE: return play('RESET') - DialogicUtil.autoload().Animation.start_animating() - %DialogTextPanel.get_parent().get_parent().modulate = Color.TRANSPARENT - %DialogicNode_DialogText.text = "" + var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') + animation_system.start_animating() + text_panel.get_parent().get_parent().set(&'modulate', Color.TRANSPARENT) + dialog.text = "" match animation_in: AnimationsIn.POP_IN: play("textbox_pop") AnimationsIn.FADE_UP: play("textbox_fade_up") - if not animation_finished.is_connected(DialogicUtil.autoload().Animation.animation_finished): - animation_finished.connect(DialogicUtil.autoload().Animation.animation_finished, CONNECT_ONE_SHOT) + if not animation_finished.is_connected(animation_system.animation_finished): + var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) func _on_textbox_hide() -> void: if animation_out == AnimationsOut.NONE: return play('RESET') - DialogicUtil.autoload().Animation.start_animating() + var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') + animation_system.start_animating() match animation_out: AnimationsOut.POP_OUT: play_backwards("textbox_pop") AnimationsOut.FADE_DOWN: play_backwards("textbox_fade_up") - if not animation_finished.is_connected(DialogicUtil.autoload().Animation.animation_finished): - animation_finished.connect(DialogicUtil.autoload().Animation.animation_finished, CONNECT_ONE_SHOT) + if not animation_finished.is_connected(animation_system.animation_finished): + var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) func _on_about_to_show_text(info:Dictionary) -> void: full_clear = !info.append -func _on_textbox_new_text(): - if DialogicUtil.autoload().Input.auto_skip.enabled: +func _on_textbox_new_text() -> void: + if (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).auto_skip.enabled: return if animation_new_text == AnimationsNewText.NONE: return - DialogicUtil.autoload().Animation.start_animating() + var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') + animation_system.start_animating() if full_clear: - %DialogicNode_DialogText.text = "" + dialog.text = "" match animation_new_text: AnimationsNewText.WIGGLE: play("new_text") - if not animation_finished.is_connected(DialogicUtil.autoload().Animation.animation_finished): - animation_finished.connect(DialogicUtil.autoload().Animation.animation_finished, CONNECT_ONE_SHOT) + if not animation_finished.is_connected(animation_system.animation_finished): + var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd index aa702f4c2..4e0a21240 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd @@ -6,8 +6,9 @@ func _process(_delta : float) -> void: if !enabled: hide() return - if DialogicUtil.autoload().Input.auto_advance.get_progress() < 0: + var input_system : DialogicSubsystemInput = DialogicUtil.autoload().get(&'Input') + if input_system.auto_advance.get_progress() < 0: hide() else: show() - value = DialogicUtil.autoload().Input.auto_advance.get_progress() + value = input_system.auto_advance.get_progress() diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index b6bbd9305..b0eb3e990 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -6,20 +6,20 @@ class_name DialogicSubsystemHistory ## Simple history that stores limited information ## Used for the history display -var simple_history_enabled : bool = true +var simple_history_enabled := true var simple_history_content : Array[Dictionary] = [] signal simple_history_changed ## Full event history (can be used for undo) -var full_event_history_enabled : bool = false -var full_event_history_content : Array = [] +var full_event_history_enabled := false +var full_event_history_content := [] signal full_event_history_changed ## Read text history ## Stores which text events and choices have already been visited -var already_read_history_enabled : bool = false -var already_read_history_content : Dictionary = {} -var _was_last_event_already_read : bool = false +var already_read_history_enabled := false +var already_read_history_content := {} +var _was_last_event_already_read := false signal already_read_event_reached signal not_read_event_reached @@ -47,7 +47,7 @@ func _ready() -> void: ## SIMPLE HISTORY #################################################################################################### -func store_simple_history_entry(text:String, event_type:String, extra_info : Dictionary = {}) -> void: +func store_simple_history_entry(text:String, event_type:String, extra_info := {}) -> void: if !simple_history_enabled: return extra_info['text'] = text extra_info['event_type'] = event_type @@ -80,7 +80,7 @@ func store_full_event(event:DialogicEvent) -> void: func _current_event_key() -> String: var resource_path : String = dialogic.current_timeline.resource_path var event_idx : String = str(dialogic.current_event_idx) - var event_key : String = resource_path+event_idx + var event_key : String = resource_path + event_idx return event_key diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 7722566ea..e993e576f 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -13,9 +13,9 @@ static func get_editor_scale() -> float: ## Although this does in fact always return a EditorPlugin node, ## that class is apparently not present in export and referencing it here creates a crash. static func get_dialogic_plugin() -> Node: - for child in Engine.get_main_loop().get_root().get_children(): + for child : Node in Engine.get_main_loop().get_root().get_children(): if child.get_class() == "EditorNode": - return child.get_node('DialogicPlugin') + return child.get_node(^'DialogicPlugin') return null #endregion @@ -24,25 +24,9 @@ static func get_dialogic_plugin() -> Node: static func autoload() -> DialogicGameHandler: if Engine.is_editor_hint(): return null - if not Engine.get_main_loop().root.has_node("Dialogic"): + if not Engine.get_main_loop().root.has_node(^"Dialogic"): return null - return Engine.get_main_loop().root.get_node("Dialogic") - - -static func get_text() -> DialogicSubsystemText: - return DialogicUtil.autoload().Text - - -static func get_input() -> DialogicSubsystemInput: - return DialogicUtil.autoload().Input - - -static func get_glossary() -> DialogicSubsystemGlossary: - return DialogicUtil.autoload().Glossary - - -static func get_history() -> DialogicSubsystemHistory: - return DialogicUtil.autoload().History + return Engine.get_main_loop().root.get_node(^"Dialogic") #region FILE SYSTEM diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index 90b591a8b..c197c9505 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutBase -extends CanvasLayer +extends Node ## Base class that should be extended by custom layouts. diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index 693386d95..b253693b5 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -29,11 +29,11 @@ func _apply_export_overrides() -> void: func apply_export_overrides() -> void: if disabled: if "visible" in self: - set('visible', false) + set(&'visible', false) process_mode = Node.PROCESS_MODE_DISABLED else: if "visible" in self: - set('visible', true) + set(&'visible', true) process_mode = Node.PROCESS_MODE_INHERIT _apply_export_overrides() diff --git a/addons/dialogic/Resources/dialogic_style.gd b/addons/dialogic/Resources/dialogic_style.gd index 4256864a5..ccd48f3df 100644 --- a/addons/dialogic/Resources/dialogic_style.gd +++ b/addons/dialogic/Resources/dialogic_style.gd @@ -86,9 +86,6 @@ func move_layer(from_index:int, to_index:int) -> void: if not has_layer(from_index) or not has_layer(to_index-1): return - if from_index < to_index: - to_index -1 - var info: DialogicLayoutLayer = layers.pop_at(from_index) layers.insert(to_index, info) changed.emit() From 703cb38685be3e1a2d21fc36bb10d424d14c71c4 Mon Sep 17 00:00:00 2001 From: nlupugla Date: Sun, 31 Dec 2023 20:35:22 -0500 Subject: [PATCH 03/12] Reverted some changes that were unnecessary. --- .../Layer_History/history_layer.gd | 2 +- .../Layer_History/history_layer.tscn | 7 ++ .../speaker_portrait_textbox_layer.gd | 116 +++++++++--------- .../Layer_TextInput/text_input_layer.gd | 9 +- .../Layer_VN_Choices/vn_choice_layer.gd | 2 +- .../Layer_VN_Portraits/vn_portrait_layer.tscn | 41 ------- .../Layer_VN_Textbox/vn_textbox_layer.tscn | 7 -- .../Modules/History/subsystem_history.gd | 10 +- .../dialogic/Modules/Text/node_dialog_text.gd | 2 +- addons/dialogic/Other/DialogicGameHandler.gd | 24 ++-- addons/dialogic/Other/DialogicUtil.gd | 9 +- .../Resources/dialogic_layout_layer.gd | 2 +- addons/dialogic/Resources/dialogic_style.gd | 3 + 13 files changed, 101 insertions(+), 133 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index 9b5f759a8..c95c2bf8f 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -49,7 +49,7 @@ func _apply_export_overrides() -> void: if DialogicUtil.autoload().has_subsystem('History'): show_history_button.visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled else: - self.visible = false + set(&'visible', false) history_item_theme = Theme.new() diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn index 3c602e6d6..53f7f3563 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn @@ -27,7 +27,14 @@ size_flags_horizontal = 3 size_flags_vertical = 3 mouse_filter = 2 script = ExtResource("1_4mqm3") +font_use_global_size = null +font_custom_size = null +font_use_global_fonts = null +font_custom_normal = null +font_custom_bold = null +font_custom_italics = null HistoryItem = ExtResource("2_x1xgk") +disabled = null [node name="HistoryBox" type="ScrollContainer" parent="."] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd index 6d6712d1e..fdbe59fdc 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd @@ -8,13 +8,13 @@ enum LimitedAlignments {LEFT=0, RIGHT=1} @export_subgroup("Text") @export var text_alignment :Alignments= Alignments.LEFT @export_subgroup('Size') -@export var text_use_global_size := true -@export var text_custom_size := 15 +@export var text_use_global_size : bool = true +@export var text_custom_size : int = 15 @export_subgroup('Color') -@export var text_use_global_color := true +@export var text_use_global_color : bool = true @export var text_custom_color : Color = Color.WHITE @export_subgroup('Fonts') -@export var use_global_fonts := true +@export var use_global_fonts : bool = true @export_file('*.ttf') var custom_normal_font:String = "" @export_file('*.ttf') var custom_bold_font:String = "" @export_file('*.ttf') var custom_italic_font:String = "" @@ -23,101 +23,107 @@ enum LimitedAlignments {LEFT=0, RIGHT=1} @export_group('Name Label') @export_subgroup("Color") enum NameLabelColorModes {GLOBAL_COLOR, CHARACTER_COLOR, CUSTOM_COLOR} -@export var name_label_color_mode := NameLabelColorModes.GLOBAL_COLOR -@export var name_label_custom_color := Color.WHITE +@export var name_label_color_mode : NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR +@export var name_label_custom_color : Color = Color.WHITE @export_subgroup("Behaviour") -@export var name_label_alignment := Alignments.LEFT -@export var name_label_hide_when_no_character := false +@export var name_label_alignment : Alignments = Alignments.LEFT +@export var name_label_hide_when_no_character : bool = false @export_subgroup("Font & Size") -@export var name_label_use_global_size := true -@export var name_label_custom_size := 15 -@export var name_label_use_global_font := true +@export var name_label_use_global_size : bool = true +@export var name_label_custom_size : int = 15 +@export var name_label_use_global_font : bool = true @export_file('*.ttf') var name_label_customfont : String = "" @export_group('Box') @export_subgroup("Box") -@export_file('*.tres') var box_panel := this_folder.path_join("default_stylebox.tres") -@export var box_modulate_global_color := true +@export_file('*.tres') var box_panel : String = this_folder.path_join("default_stylebox.tres") +@export var box_modulate_global_color : bool = true @export var box_modulate_custom_color : Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658) @export var box_size : Vector2 = Vector2(600, 160) -@export var box_distance := 25 +@export var box_distance : int = 25 @export_group('Portrait') @export_subgroup('Portrait') -@export var portrait_stretch_factor = 0.3 -@export var portrait_position :LimitedAlignments = LimitedAlignments.LEFT -@export var portrait_bg_modulate := Color(0, 0, 0, 0.5137255191803) +@export var portrait_stretch_factor : float = 0.3 +@export var portrait_position : LimitedAlignments = LimitedAlignments.LEFT +@export var portrait_bg_modulate : Color = Color(0, 0, 0, 0.5137255191803) + +@onready var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText +@onready var panel : PanelContainer = %Panel +@onready var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel +@onready var portrait_panel : Panel = %PortraitPanel +@onready var portrait_background_color : ColorRect = %PortraitBackgroundColor ## Called by dialogic whenever export overrides might change -func _apply_export_overrides(): +func _apply_export_overrides() -> void: ## FONT SETTINGS - %DialogicNode_DialogText.alignment = text_alignment + dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment - var text_size := text_custom_size + var text_size : int = text_custom_size if text_use_global_size: - text_size = get_global_setting('font_size', text_custom_size) + text_size = get_global_setting(&'font_size', text_custom_size) - %DialogicNode_DialogText.add_theme_font_size_override("normal_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("bold_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("italics_font_size", text_size) - %DialogicNode_DialogText.add_theme_font_size_override("bold_italics_font_size", text_size) + dialog_text.add_theme_font_size_override(&"normal_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_font_size", text_size) + dialog_text.add_theme_font_size_override(&"italics_font_size", text_size) + dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size) - var text_color := text_custom_color + var text_color : Color = text_custom_color if text_use_global_color: - text_color = get_global_setting('font_color', text_custom_color) - %DialogicNode_DialogText.add_theme_color_override("default_color", text_color) + text_color = get_global_setting(&'font_color', text_custom_color) + dialog_text.add_theme_color_override(&"default_color", text_color) - var normal_font := custom_normal_font - if use_global_fonts and ResourceLoader.exists(get_global_setting('font', '')): - normal_font = get_global_setting('font', '') + var normal_font : String = custom_normal_font + if use_global_fonts and ResourceLoader.exists(get_global_setting(&'font', '') as String): + normal_font = get_global_setting(&'font', '') if !normal_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("normal_font", load(normal_font)) + dialog_text.add_theme_font_override(&"normal_font", load(normal_font) as Font) if !custom_bold_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("bold_font", load(custom_bold_font)) + dialog_text.add_theme_font_override(&"bold_font", load(custom_bold_font) as Font) if !custom_italic_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("italitc_font", load(custom_italic_font)) + dialog_text.add_theme_font_override(&"italitc_font", load(custom_italic_font) as Font) if !custom_bold_italic_font.is_empty(): - %DialogicNode_DialogText.add_theme_font_override("bold_italics_font", load(custom_bold_italic_font)) + dialog_text.add_theme_font_override(&"bold_italics_font", load(custom_bold_italic_font) as Font) ## BOX SETTINGS if box_modulate_global_color: - %Panel.self_modulate = get_global_setting('bg_color', box_modulate_custom_color) + panel.self_modulate = get_global_setting(&'bg_color', box_modulate_custom_color) else: - %Panel.self_modulate = box_modulate_custom_color - %Panel.size = box_size - %Panel.position = Vector2(-box_size.x/2, -box_size.y-box_distance) - %PortraitPanel.size_flags_stretch_ratio = portrait_stretch_factor + panel.self_modulate = box_modulate_custom_color + panel.size = box_size + panel.position = Vector2(-box_size.x/2, -box_size.y-box_distance) + portrait_panel.size_flags_stretch_ratio = portrait_stretch_factor var stylebox: StyleBoxFlat = load(box_panel) - %Panel.add_theme_stylebox_override('panel', stylebox) + panel.add_theme_stylebox_override(&'panel', stylebox) ## PORTRAIT SETTINGS - %PortraitBackgroundColor.color = portrait_bg_modulate - %PortraitPanel.get_parent().move_child(%PortraitPanel, portrait_position) + portrait_background_color.color = portrait_bg_modulate + portrait_panel.get_parent().move_child(portrait_panel, portrait_position) ## NAME LABEL SETTINGS if name_label_use_global_size: - %DialogicNode_NameLabel.add_theme_font_size_override("font_size", get_global_setting('font_size', name_label_custom_size)) + name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_size) as int) else: - %DialogicNode_NameLabel.add_theme_font_size_override("font_size", name_label_custom_size) + name_label.add_theme_font_size_override(&"font_size", name_label_custom_size) - var name_label_font := name_label_customfont - if name_label_use_global_font and ResourceLoader.exists(get_global_setting('font', '')): - name_label_font = get_global_setting('font', '') + var name_label_font : String = name_label_customfont + if name_label_use_global_font and ResourceLoader.exists(get_global_setting(&'font', '') as String): + name_label_font = get_global_setting(&'font', '') if !name_label_font.is_empty(): - %DialogicNode_NameLabel.add_theme_font_override('font', load(name_label_font)) + name_label.add_theme_font_override(&'font', load(name_label_font) as Font) - %DialogicNode_NameLabel.use_character_color = false + name_label.use_character_color = false match name_label_color_mode: NameLabelColorModes.GLOBAL_COLOR: - %DialogicNode_NameLabel.add_theme_color_override("font_color", get_global_setting('font_color', name_label_custom_color)) + name_label.add_theme_color_override(&"font_color", get_global_setting(&'font_color', name_label_custom_color) as Color) NameLabelColorModes.CUSTOM_COLOR: - %DialogicNode_NameLabel.add_theme_color_override("font_color", name_label_custom_color) + name_label.add_theme_color_override(&"font_color", name_label_custom_color) NameLabelColorModes.CHARACTER_COLOR: - %DialogicNode_NameLabel.use_character_color = true + name_label.use_character_color = true - %DialogicNode_NameLabel.horizontal_alignment = name_label_alignment - %DialogicNode_NameLabel.hide_when_empty = name_label_hide_when_no_character + name_label.horizontal_alignment = name_label_alignment as HorizontalAlignment + name_label.hide_when_empty = name_label_hide_when_no_character diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd index a9adae158..3b38d5b3b 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd @@ -5,9 +5,10 @@ extends DialogicLayoutLayer func _apply_export_overrides() -> void: - if self.theme == null: - self.theme = Theme.new() + var layer_theme : Theme = get(&'theme') + if layer_theme == null: + layer_theme = Theme.new() if get_global_setting(&'font', ''): - self.theme.default_font = load(get_global_setting(&'font', '') as String) - self.theme.default_font_size = get_global_setting(&'font_size', 0) + layer_theme.default_font = load(get_global_setting(&'font', '') as String) + layer_theme.default_font_size = get_global_setting(&'font_size', 0) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index 6147f1a7b..c26304c26 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -104,7 +104,7 @@ func _apply_export_overrides() -> void: choice.custom_minimum_size = boxes_min_size - self.theme = layer_theme + set(&'theme', layer_theme) # apply sound settings button_sound.volume_db = sounds_volume diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn index d90d49281..374bc60ff 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn @@ -29,15 +29,6 @@ anchor_bottom = 1.0 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 -position_index = 0 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits"] @@ -49,15 +40,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 1 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits"] @@ -69,15 +52,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 2 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits"] @@ -89,15 +64,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 3 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits"] @@ -110,13 +77,5 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 4 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn index 924c69fe4..263440079 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn @@ -291,14 +291,7 @@ textbox_root = NodePath("..") [node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel/DialogicNode_DialogText"] unique_name_in_owner = true script = ExtResource("4_ma5mw") -enabled = true -mode = 0 -sounds = Array[AudioStream]([]) -end_sound = null play_every_character = 0 -pitch_variance = 0.0 -volume_variance = 0.0 -ignore_characters = " .," [node name="NextIndicator" type="Control" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel"] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index b0eb3e990..f9e917487 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -78,9 +78,9 @@ func store_full_event(event:DialogicEvent) -> void: ## Takes the current timeline event and creates a unique key for it. ## Uses the timeline resource path as well. func _current_event_key() -> String: - var resource_path : String = dialogic.current_timeline.resource_path - var event_idx : String = str(dialogic.current_event_idx) - var event_key : String = resource_path + event_idx + var resource_path = dialogic.current_timeline.resource_path + var event_idx = str(dialogic.current_event_idx) + var event_key = resource_path+event_idx return event_key @@ -89,7 +89,7 @@ func event_was_read(_event: DialogicEvent) -> void: if !already_read_history_enabled: return - var event_key : String = _current_event_key() + var event_key = _current_event_key() already_read_history_content[event_key] = dialogic.current_event_idx @@ -104,7 +104,7 @@ func check_already_read(event: DialogicEvent) -> void: if event.event_name != "Text": return - var event_key : String = _current_event_key() + var event_key = _current_event_key() if event_key in already_read_history_content: already_read_event_reached.emit() diff --git a/addons/dialogic/Modules/Text/node_dialog_text.gd b/addons/dialogic/Modules/Text/node_dialog_text.gd index e5d0a4891..71442bf9c 100644 --- a/addons/dialogic/Modules/Text/node_dialog_text.gd +++ b/addons/dialogic/Modules/Text/node_dialog_text.gd @@ -4,7 +4,7 @@ extends RichTextLabel ## Dialogic node that can reveal text at a given (changeable speed). signal started_revealing_text() -signal continued_revealing_text(new_character : Variant) +signal continued_revealing_text(new_character : String) signal finished_revealing_text() enum Alignment {LEFT, CENTER, RIGHT} diff --git a/addons/dialogic/Other/DialogicGameHandler.gd b/addons/dialogic/Other/DialogicGameHandler.gd index 0a2a8fa4e..c4558bc5c 100644 --- a/addons/dialogic/Other/DialogicGameHandler.gd +++ b/addons/dialogic/Other/DialogicGameHandler.gd @@ -34,28 +34,28 @@ var current_event_idx: int = 0 ## relevant for the current situation var current_state_info: Dictionary = {} ## Current state (see [States] enum) -var current_state : States = States.IDLE: +var current_state := States.IDLE: get: return current_state set(new_state): current_state = new_state emit_signal('state_changed', new_state) ## Emitted when [current_state] change. -signal state_changed(new_state : States) +signal state_changed(new_state) ## When true, many dialogic process won't continue until it's false again. -var paused : bool = false: +var paused := false: set(value): paused = value if paused: - for subsystem : Node in get_children(): - if subsystem.has_method(&'pause'): - subsystem.call(&'pause') + for subsystem in get_children(): + if subsystem.has_method('pause'): + subsystem.pause() dialogic_paused.emit() else: - for subsystem : Node in get_children(): - if subsystem.has_method(&'resume'): - subsystem.call(&'resume') + for subsystem in get_children(): + if subsystem.has_method('resume'): + subsystem.resume() dialogic_resumed.emit() ## Emitted when [paused] changes to true. @@ -66,12 +66,12 @@ signal dialogic_resumed signal timeline_ended() signal timeline_started() -signal event_handled(resource : Variant) +signal event_handled(resource) ## Emitted when the Signal event was reached -signal signal_event(argument : Variant) +signal signal_event(argument) ## Emitted when [signal] effect was reached in text. -signal text_signal(argument : Variant) +signal text_signal(argument) ## Autoloads are added first, so this happens REALLY early on game startup. diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index e993e576f..013399f4e 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -13,9 +13,9 @@ static func get_editor_scale() -> float: ## Although this does in fact always return a EditorPlugin node, ## that class is apparently not present in export and referencing it here creates a crash. static func get_dialogic_plugin() -> Node: - for child : Node in Engine.get_main_loop().get_root().get_children(): + for child in Engine.get_main_loop().get_root().get_children(): if child.get_class() == "EditorNode": - return child.get_node(^'DialogicPlugin') + return child.get_node('DialogicPlugin') return null #endregion @@ -24,10 +24,9 @@ static func get_dialogic_plugin() -> Node: static func autoload() -> DialogicGameHandler: if Engine.is_editor_hint(): return null - if not Engine.get_main_loop().root.has_node(^"Dialogic"): + if not Engine.get_main_loop().root.has_node("Dialogic"): return null - return Engine.get_main_loop().root.get_node(^"Dialogic") - + return Engine.get_main_loop().root.get_node("Dialogic") #region FILE SYSTEM ################################################################################ diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index b253693b5..d6402029b 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutLayer -extends Control +extends Node ## Base class that should be extended by custom dialogic layout layers. diff --git a/addons/dialogic/Resources/dialogic_style.gd b/addons/dialogic/Resources/dialogic_style.gd index ccd48f3df..4256864a5 100644 --- a/addons/dialogic/Resources/dialogic_style.gd +++ b/addons/dialogic/Resources/dialogic_style.gd @@ -86,6 +86,9 @@ func move_layer(from_index:int, to_index:int) -> void: if not has_layer(from_index) or not has_layer(to_index-1): return + if from_index < to_index: + to_index -1 + var info: DialogicLayoutLayer = layers.pop_at(from_index) layers.insert(to_index, info) changed.emit() From 678aab35691454c703374cb813c47e89efdcd4bd Mon Sep 17 00:00:00 2001 From: nlupugla Date: Tue, 2 Jan 2024 13:30:54 -0500 Subject: [PATCH 04/12] Replaced @onready node variables with getters --- .../Layer_Glossary/glossary_popup_layer.gd | 69 ++++++++++++------- .../Layer_History/example_history_item.gd | 34 +++++---- .../Layer_History/history_layer.gd | 43 +++++++----- .../speaker_portrait_textbox_layer.gd | 12 ++-- .../Layer_Textbubble/text_bubble.gd | 46 +++++++++---- .../Layer_Textbubble/text_bubble_layer.gd | 21 +++--- .../Layer_VN_Choices/vn_choice_layer.gd | 14 ++-- .../Layer_VN_Portraits/vn_portrait_layer.gd | 1 + .../Layer_VN_Textbox/animations.gd | 15 ++-- .../Layer_VN_Textbox/vn_textbox_layer.gd | 19 +++-- .../Resources/dialogic_layout_base.gd | 4 +- .../Resources/dialogic_layout_layer.gd | 6 +- 12 files changed, 177 insertions(+), 107 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index df8aa7a2a..5e1f95e36 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -39,22 +39,38 @@ enum ModulateModes {BASE_COLOR_ONLY, ENTRY_COLOR_ON_BOX, GLOBAL_BG_COLOR} @export_subgroup("Size") @export var box_width : int = 200 -@onready var pointer : Control = $Pointer -@onready var title : Label = %Title -@onready var text : RichTextLabel = %Text -@onready var extra : RichTextLabel = %Extra -@onready var panel : PanelContainer = %Panel -@onready var panel_point : PanelContainer = %PanelPoint +func get_pointer() -> Control: + return $Pointer + + +func get_title() -> Label: + return %Title + + +func get_text() -> RichTextLabel: + return %Text + + +func get_extra() -> RichTextLabel: + return %Extra + + +func get_panel() -> PanelContainer: + return %Panel + + +func get_panel_point() -> PanelContainer: + return %PanelPoint func _ready() -> void: if Engine.is_editor_hint(): return - pointer.hide() + get_pointer().hide() var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') var _error : int = 0 - _error = text_system.animation_textbox_hide.connect(pointer.hide) + _error = text_system.animation_textbox_hide.connect(get_pointer().hide) _error = text_system.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) _error = text_system.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) _error = text_system.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) @@ -68,25 +84,25 @@ func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: if not info: return - pointer.show() - title.text = info.get(&'title', '') - text.text = info.get(&'text', '') - text.text = ['', '[center]', '[right]'][text_alignment] + text.text - extra.text = info.get(&'extra', '') - extra.text = ['', '[center]', '[right]'][extra_alignment] + extra.text - pointer.global_position = pointer.get_global_mouse_position() + get_pointer().show() + get_title().text = info.get(&'title', '') + get_text().text = info.get(&'text', '') + get_text().text = ['', '[center]', '[right]'][text_alignment] + get_text().text + get_extra().text = info.get(&'extra', '') + get_extra().text = ['', '[center]', '[right]'][extra_alignment] + get_extra().text + get_pointer().global_position = get_pointer().get_global_mouse_position() if title_color_mode == TextColorModes.ENTRY: - title.add_theme_color_override(&"font_color", info.get(&'color', title_custom_color) as Color) + get_title().add_theme_color_override(&"font_color", info.get(&'color', title_custom_color) as Color) if text_color_mode == TextColorModes.ENTRY: - text.add_theme_color_override(&"default_color", info.get(&'color', text_custom_color) as Color) + get_text().add_theme_color_override(&"default_color", info.get(&'color', text_custom_color) as Color) if extra_color_mode == TextColorModes.ENTRY: - extra.add_theme_color_override(&"default_color", info.get(&'color', extra_custom_color) as Color) + get_extra().add_theme_color_override(&"default_color", info.get(&'color', extra_custom_color) as Color) match box_modulate_mode: ModulateModes.ENTRY_COLOR_ON_BOX: - panel.self_modulate = info.get(&'color', Color.WHITE) - panel_point.self_modulate = info.get(&'color', Color.WHITE) + get_panel().self_modulate = info.get(&'color', Color.WHITE) + get_panel_point().self_modulate = info.get(&'color', Color.WHITE) (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = true @@ -96,13 +112,14 @@ func _process(_delta : float) -> void: if Engine.is_editor_hint(): return + var pointer : Control = get_pointer() if pointer.visible: pointer.global_position = pointer.get_global_mouse_position() ## Method that hides the bubble func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: - pointer.hide() + get_pointer().hide() (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = false @@ -118,13 +135,14 @@ func _apply_export_overrides() -> void: elif ResourceLoader.exists(font_custom): font = load(font_custom) + var title : Label = get_title() if font: title.add_theme_font_override(&"font", font) title.horizontal_alignment = title_alignment as HorizontalAlignment # Apply font & sizes title.add_theme_font_size_override(&"font_size", font_title_size) - var labels : Array[RichTextLabel] = [text, extra] + var labels : Array[RichTextLabel] = [get_text(), get_extra()] var sizes : PackedInt32Array = [font_text_size, font_extra_size] for i : int in len(labels): if font: @@ -138,7 +156,7 @@ func _apply_export_overrides() -> void: # Apply text colors - var controls : Array[Control] = [title, text, extra] + var controls : Array[Control] = [get_title(), get_text(), get_extra()] var global_settings : Array[StringName] = [&'font_color', &'default_color', &'default_color'] var color_modes : Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode] var custom_colors : PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color] @@ -150,6 +168,7 @@ func _apply_export_overrides() -> void: controls[i].add_theme_color_override(global_settings[i], custom_colors[i]) # Apply box size + var panel : PanelContainer = get_panel() panel.size.x = box_width panel.position.x = -box_width/2.0 @@ -157,8 +176,8 @@ func _apply_export_overrides() -> void: match box_modulate_mode: ModulateModes.BASE_COLOR_ONLY: panel.self_modulate = box_base_modulate - panel_point.self_modulate = box_base_modulate + get_panel_point().self_modulate = box_base_modulate ModulateModes.GLOBAL_BG_COLOR: panel.self_modulate = get_global_setting(&'bg_color', box_base_modulate) - panel_point.self_modulate = get_global_setting(&'bg_color', box_base_modulate) + get_panel_point().self_modulate = get_global_setting(&'bg_color', box_base_modulate) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd index ec1d25bb3..c3031b0e2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/example_history_item.gd @@ -1,18 +1,28 @@ extends Container -@onready var text_box : RichTextLabel = %TextBox -@onready var name_label : Label = %NameLabel -@onready var icon_node : TextureRect = %Icon +func get_text_box() -> RichTextLabel: + return %TextBox + + +func get_name_label() -> Label: + return %NameLabel + + +func get_icon() -> TextureRect: + return %Icon func load_info(text:String, character:String = "", character_color: Color =Color(), icon:Texture= null) -> void: - text_box.text = text + get_text_box().text = text + var name_label : Label = get_name_label() if character: name_label.text = character name_label.add_theme_color_override('font_color', character_color) name_label.show() else: name_label.hide() + + var icon_node : TextureRect = get_icon() if icon == null: icon_node.hide() else: @@ -21,11 +31,11 @@ func load_info(text:String, character:String = "", character_color: Color =Color # #func prepare_textbox(history_root:Node) -> void: - #text_box.add_theme_font_override("normal_font", history_root.history_font_normal) - #name_label.add_theme_font_override("font", history_root.history_font_normal) - #name_label.add_theme_font_size_override("font_size", history_root.history_font_size) - #text_box.add_theme_font_override("bold_font", history_root.history_font_bold) - #text_box.add_theme_font_override("italics_font", history_root.history_font_italics) - #text_box.add_theme_font_size_override("normal_font_size", history_root.history_font_size) - #text_box.add_theme_font_size_override("bold_font_size", history_root.history_font_size) - #text_box.add_theme_font_size_override("italics_font_size", history_root.history_font_size) + #get_text_box().add_theme_font_override("normal_font", history_root.history_font_normal) + #get_name_label().add_theme_font_override("font", history_root.history_font_normal) + #get_name_label().add_theme_font_size_override("font_size", history_root.history_font_size) + #get_text_box().add_theme_font_override("bold_font", history_root.history_font_bold) + #get_text_box().add_theme_font_override("italics_font", history_root.history_font_italics) + #get_text_box().add_theme_font_size_override("normal_font_size", history_root.history_font_size) + #get_text_box().add_theme_font_size_override("bold_font_size", history_root.history_font_size) + #get_text_box().add_theme_font_size_override("italics_font_size", history_root.history_font_size) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index c95c2bf8f..9d22ec2a2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -34,10 +34,20 @@ var scroll_to_bottom_flag: bool = false var history_item_theme : Theme = null -@onready var show_history_button : Button = $ShowHistory -@onready var hide_history_button : Button = $HideHistory -@onready var history_box : ScrollContainer = %HistoryBox -@onready var history_log : VBoxContainer = %HistoryLog +func get_show_history_button() -> Button: + return $ShowHistory + + +func get_hide_history_button() -> Button: + return $HideHistory + + +func get_history_box() -> ScrollContainer: + return %HistoryBox + + +func get_history_log() -> VBoxContainer: + return %HistoryLog func _ready() -> void: @@ -46,8 +56,9 @@ func _ready() -> void: func _apply_export_overrides() -> void: - if DialogicUtil.autoload().has_subsystem('History'): - show_history_button.visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled + var history_subsystem : DialogicSubsystemHistory = DialogicUtil.autoload().get(&'History') + if history_subsystem != null: + get_show_history_button().visible = show_open_button and history_subsystem.simple_history_enabled else: set(&'visible', false) @@ -73,9 +84,9 @@ func _apply_export_overrides() -> void: func _process(_delta : float) -> void: if Engine.is_editor_hint(): return - if scroll_to_bottom_flag and history_box.visible and history_log.get_child_count(): + if scroll_to_bottom_flag and get_history_box().visible and get_history_log().get_child_count(): await get_tree().process_frame - history_box.ensure_control_visible(history_log.get_children()[-1] as Control) + get_history_box().ensure_control_visible(get_history_log().get_children()[-1] as Control) scroll_to_bottom_flag = false @@ -85,7 +96,7 @@ func _on_show_history_pressed() -> void: func show_history() -> void: - for child : Node in history_log.get_children(): + for child : Node in get_history_log().get_children(): child.queue_free() for info : Dictionary in (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).get_simple_history(): @@ -119,18 +130,18 @@ func show_history() -> void: choices_text += "- [b]"+info['text']+"[/b]\n" history_item.call(&'load_info', choices_text) - history_log.add_child(history_item) + get_history_log().add_child(history_item) if scroll_to_bottom: scroll_to_bottom_flag = true - show_history_button.hide() - hide_history_button.visible = show_close_button - history_box.show() + get_show_history_button().hide() + get_hide_history_button().visible = show_close_button + get_history_box().show() func _on_hide_history_pressed() -> void: DialogicUtil.autoload().paused = false - history_box.hide() - hide_history_button.hide() - show_history_button.visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled + get_history_box().hide() + get_hide_history_button().hide() + get_show_history_button().visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd index fdbe59fdc..f108b295f 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd @@ -48,16 +48,11 @@ enum NameLabelColorModes {GLOBAL_COLOR, CHARACTER_COLOR, CUSTOM_COLOR} @export var portrait_position : LimitedAlignments = LimitedAlignments.LEFT @export var portrait_bg_modulate : Color = Color(0, 0, 0, 0.5137255191803) -@onready var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText -@onready var panel : PanelContainer = %Panel -@onready var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel -@onready var portrait_panel : Panel = %PortraitPanel -@onready var portrait_background_color : ColorRect = %PortraitBackgroundColor - ## Called by dialogic whenever export overrides might change func _apply_export_overrides() -> void: ## FONT SETTINGS + var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment var text_size : int = text_custom_size @@ -89,6 +84,8 @@ func _apply_export_overrides() -> void: dialog_text.add_theme_font_override(&"bold_italics_font", load(custom_bold_italic_font) as Font) ## BOX SETTINGS + var panel : PanelContainer = %Panel + var portrait_panel : Panel = %PortraitPanel if box_modulate_global_color: panel.self_modulate = get_global_setting(&'bg_color', box_modulate_custom_color) else: @@ -101,10 +98,13 @@ func _apply_export_overrides() -> void: panel.add_theme_stylebox_override(&'panel', stylebox) ## PORTRAIT SETTINGS + var portrait_background_color : ColorRect = %PortraitBackgroundColor portrait_background_color.color = portrait_bg_modulate + portrait_panel.get_parent().move_child(portrait_panel, portrait_position) ## NAME LABEL SETTINGS + var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel if name_label_use_global_size: name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_size) as int) else: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd index 5d8b62f7b..05781033a 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd @@ -12,12 +12,30 @@ var base_direction := Vector2(1.0, -1.0).normalized() var safe_zone := 50.0 var padding := Vector2() -@onready var tail : Line2D = $Tail -@onready var bubble : Control = $Background -@onready var choice_container : Container = $DialogText/ChoiceContainer -@onready var name_label_panel : PanelContainer = $DialogText/NameLabel -@onready var name_label : DialogicNode_NameLabel = %NameLabel -@onready var dialog_text : DialogicNode_DialogText = %DialogText + +func get_tail() -> Line2D: + return $Tail + + +func get_bubble() -> Control: + return $Background + + +func get_choice_container() -> Container: + return $DialogText/ChoiceContainer + + +func get_name_label_panel() -> PanelContainer: + return $DialogText/NameLabel + + +func get_name_label() -> DialogicNode_NameLabel: + return %NameLabel + + +func get_dialog_text() -> DialogicNode_DialogText: + return %DialogText + func _ready() -> void: scale = Vector2.ZERO @@ -61,13 +79,13 @@ func _process(delta): var direction_point := Vector2(0, (point_b.y - point_a.y)) curve.add_point(point_a, Vector2.ZERO, direction_point * 0.5) curve.add_point(point_b) - tail.points = curve.tessellate(5) - tail.width = bubble_rect.size.x * 0.15 + get_tail().points = curve.tessellate(5) + get_tail().width = bubble_rect.size.x * 0.15 func open() -> void: show() - dialog_text.enabled = true + get_dialog_text().enabled = true var open_tween := create_tween().set_parallel(true) open_tween.tween_property(self, "scale", Vector2.ONE, 0.1).from(Vector2.ZERO) open_tween.tween_property(self, "modulate:a", 1.0, 0.1).from(0.0) @@ -75,7 +93,7 @@ func open() -> void: func close() -> void: - dialog_text.enabled = false + get_dialog_text().enabled = false var close_tween := create_tween().set_parallel(true) close_tween.tween_property(self, "scale", Vector2.ONE * 0.8, 0.1) close_tween.tween_property(self, "modulate:a", 0.0, 0.1) @@ -84,8 +102,9 @@ func close() -> void: func _on_dialog_text_started_revealing_text(): + var dialog_text : DialogicNode_DialogText = get_dialog_text() var font :Font = dialog_text.get_theme_font("normal_font") - dialog_text.size = font.get_multiline_string_size(dialog_text.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, %DialogText.get_theme_font_size("normal_font_size")) + dialog_text.size = font.get_multiline_string_size(dialog_text.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, dialog_text.get_theme_font_size("normal_font_size")) if DialogicUtil.autoload().Choices.is_question(DialogicUtil.autoload().current_event_idx): font = $DialogText/ChoiceContainer/DialogicNode_ChoiceButton.get_theme_font('font') dialog_text.size.y += font.get_string_size(dialog_text.get_parsed_text(), HORIZONTAL_ALIGNMENT_LEFT, max_width, $DialogText/ChoiceContainer/DialogicNode_ChoiceButton.get_theme_font_size("font_size")).y @@ -95,9 +114,10 @@ func _on_dialog_text_started_revealing_text(): func _resize_bubble() -> void: - var bubble_size :Vector2 = dialog_text.size+(padding*2) + var bubble : Control = get_bubble() + var bubble_size :Vector2 = get_dialog_text().size+(padding*2) var half_size :Vector2= (bubble_size / 2.0) - dialog_text.pivot_offset = half_size + get_dialog_text().pivot_offset = half_size bubble.pivot_offset = half_size bubble_rect = Rect2(position, bubble_size * Vector2(1.1, 1.1)) bubble.size = bubble_size diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd index 37d5573c5..a59193ee2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd @@ -70,7 +70,7 @@ func _apply_export_overrides() -> void: func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## TEXT FONT AND COLOR - var rtl : RichTextLabel = bubble.dialog_text + var rtl : RichTextLabel = bubble.get_dialog_text() rtl.add_theme_font_size_override(&'normal_font', text_size) rtl.add_theme_font_size_override(&"normal_font_size", text_size) rtl.add_theme_font_size_override(&"bold_font_size", text_size) @@ -91,19 +91,22 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## BOX & TAIL COLOR - bubble.tail.default_color = box_modulate - bubble.bubble.set(&'color', box_modulate) - var bubble_material : ShaderMaterial = bubble.bubble.get(&'material') + var tail : Line2D = bubble.get_tail() + var background : Control = bubble.get_bubble() + var bubble_material : ShaderMaterial = background.get(&'material') + + tail.default_color = box_modulate + background.set(&'color', box_modulate) bubble_material.set_shader_parameter(&'radius', box_corner_radius) bubble_material.set_shader_parameter(&'crease', box_wobbliness*0.1) bubble_material.set_shader_parameter(&'speed', box_wobble_speed) if box_modulate_by_character_color and bubble.character != null: - bubble.tail.modulate = bubble.character.color - bubble.bubble.modulate = bubble.character.color + tail.modulate = bubble.character.color + background.modulate = bubble.character.color bubble.padding = box_padding ## NAME LABEL SETTINGS - var nl : DialogicNode_NameLabel = bubble.name_label + var nl : DialogicNode_NameLabel = bubble.get_name_label() nl.add_theme_font_size_override(&"font_size", name_label_font_size) if !name_label_font.is_empty(): @@ -113,7 +116,7 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: if !nl.use_character_color: nl.add_theme_color_override(&"font_color", name_label_color) - var nlp : PanelContainer = bubble.name_label_panel + var nlp : PanelContainer = bubble.get_name_label_panel() nlp.self_modulate = name_label_box_modulate nlp.get_theme_stylebox(&'panel').content_margin_left = name_label_padding.x nlp.get_theme_stylebox(&'panel').content_margin_right = name_label_padding.x @@ -133,7 +136,7 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: choice_theme.set_color(&'font_hover_color', &'Button', choices_text_color_hover) choice_theme.set_color(&'font_focus_color', &'Button', choices_text_color_focus) - bubble.choice_container.theme = choice_theme + bubble.get_choice_container().theme = choice_theme ## BEHAVIOUR bubble.safe_zone = behaviour_distance diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index c26304c26..7e50d6d3a 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -38,8 +38,13 @@ extends DialogicLayoutLayer @export_file("*.wav", "*.ogg", "*.mp3") var sounds_hover : String = "res://addons/dialogic/Example Assets/sound-effects/typing2.wav" @export_file("*.wav", "*.ogg", "*.mp3") var sounds_focus : String = "res://addons/dialogic/Example Assets/sound-effects/typing4.wav" -@onready var choices : VBoxContainer = $Choices -@onready var button_sound : DialogicNode_ButtonSound = %DialogicNode_ButtonSound +func get_choices() -> VBoxContainer: + return $Choices + + +func get_button_sound() -> DialogicNode_ButtonSound: + return %DialogicNode_ButtonSound + ## Method that applies all exported settings func _apply_export_overrides() -> void: @@ -90,9 +95,9 @@ func _apply_export_overrides() -> void: if ResourceLoader.exists(boxes_stylebox_focused): layer_theme.set_stylebox(&'focus', &'Button', load(boxes_stylebox_focused) as StyleBox) - choices.add_theme_constant_override(&"separation", boxes_v_separation) + get_choices().add_theme_constant_override(&"separation", boxes_v_separation) - for child : Node in choices.get_children(): + for child : Node in get_choices().get_children(): if not child is DialogicNode_ChoiceButton: continue var choice : DialogicNode_ChoiceButton = child as DialogicNode_ChoiceButton @@ -107,6 +112,7 @@ func _apply_export_overrides() -> void: set(&'theme', layer_theme) # apply sound settings + var button_sound : DialogicNode_ButtonSound = get_button_sound() button_sound.volume_db = sounds_volume button_sound.sound_pressed = load(sounds_pressed) button_sound.sound_hover = load(sounds_hover) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd index 05f7054a4..dfc880318 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd @@ -12,3 +12,4 @@ func _apply_export_overrides() -> void: for child : DialogicNode_PortraitContainer in %Portraits.get_children(): child.size_mode = portrait_size_mode child.update_portrait_transforms() + diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index 537650fd2..07c2c9778 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -13,8 +13,13 @@ var animation_new_text : AnimationsNewText var full_clear : bool = true -@onready var text_panel : PanelContainer = %DialogTextPanel -@onready var dialog : DialogicNode_DialogText = %DialogicNode_DialogText +func get_text_panel() -> PanelContainer: + return %DialogTextPanel + + +func get_dialog() -> DialogicNode_DialogText: + return %DialogicNode_DialogText + func _ready() -> void: var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') @@ -31,8 +36,8 @@ func _on_textbox_show() -> void: play('RESET') var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') animation_system.start_animating() - text_panel.get_parent().get_parent().set(&'modulate', Color.TRANSPARENT) - dialog.text = "" + get_text_panel().get_parent().get_parent().set(&'modulate', Color.TRANSPARENT) + get_dialog().text = "" match animation_in: AnimationsIn.POP_IN: play("textbox_pop") @@ -72,7 +77,7 @@ func _on_textbox_new_text() -> void: var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') animation_system.start_animating() if full_clear: - dialog.text = "" + get_dialog().text = "" match animation_new_text: AnimationsNewText.WIGGLE: play("new_text") diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd index 93d0bf5c9..451954693 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd @@ -92,22 +92,13 @@ enum AnimationsNewText {NONE, WIGGLE} @export_range(0.0, 10) var typing_sounds_volume_variance : float = 0.0 @export var typing_sounds_ignore_characters : String = " .,!?" -@onready var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText -@onready var dialog_text_panel : PanelContainer = %DialogTextPanel -@onready var sizer : Control = %Sizer -@onready var animations : AnimationPlayer = %Animations -@onready var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel -@onready var name_label_panel : PanelContainer = %NameLabelPanel -@onready var next_indicator : DNextIndicator = %NextIndicator -@onready var type_sounds : DialogicNode_TypeSounds = %DialogicNode_TypeSounds -@onready var progress_bar : ProgressBar = %AutoAdvanceProgressbar - func _apply_export_overrides() -> void: if !is_inside_tree(): await ready ## FONT SETTINGS + var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment if text_use_global_size: @@ -134,6 +125,7 @@ func _apply_export_overrides() -> void: dialog_text.add_theme_font_override(&"bold_italics_font", load(bold_italic_font) as Font) ## BOX SETTINGS + var dialog_text_panel : PanelContainer = %DialogTextPanel if ResourceLoader.exists(box_panel): dialog_text_panel.add_theme_stylebox_override(&'panel', load(box_panel) as StyleBox) @@ -148,16 +140,19 @@ func _apply_export_overrides() -> void: #%Minimizer.grow_vertical = Container.GROW_DIRECTION_BEGIN #dialog_text_panel.custom_minimum_size = box_size #dialog_text_panel.show() + var sizer : Control = %Sizer sizer.size = box_size sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom) ## BOX ANIMATIONS + var animations : AnimationPlayer = %Animations animations.set(&'animation_in', box_animation_in) animations.set(&'animation_out', box_animation_out) animations.set(&'animation_new_text', box_animation_new_text) ## NAME LABEL SETTINGS + var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel if name_label_use_global_font_size: name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_font_size) as int) else: @@ -175,6 +170,7 @@ func _apply_export_overrides() -> void: name_label.use_character_color = name_label_use_character_color + var name_label_panel : PanelContainer = %NameLabelPanel if ResourceLoader.exists(name_label_box_panel): name_label_panel.add_theme_stylebox_override(&'panel', load(name_label_box_panel) as StyleBox) else: @@ -194,6 +190,7 @@ func _apply_export_overrides() -> void: name_label_panel.grow_horizontal = [1, 2, 0][name_label_alignment] ## NEXT INDICATOR SETTINGS + var next_indicator : DNextIndicator = %NextIndicator next_indicator.enabled = next_indicator_enabled if next_indicator_enabled: @@ -205,11 +202,13 @@ func _apply_export_overrides() -> void: next_indicator.texture_size = next_indicator_size ## OTHER + var progress_bar : ProgressBar = %AutoAdvanceProgressbar progress_bar.set(&'enabled', autoadvance_progressbar) #### SOUNDS ## TYPING SOUNDS + var type_sounds : DialogicNode_TypeSounds = %DialogicNode_TypeSounds type_sounds.enabled = typing_sounds_enabled type_sounds.mode = typing_sounds_mode if not typing_sounds_sounds_folder.is_empty(): diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index c197c9505..77cecfbe4 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -5,12 +5,12 @@ extends Node ## Base class that should be extended by custom layouts. -func add_dialogic_layer(dialogic_layer:DialogicLayoutLayer) -> DialogicLayoutLayer: +func add_layer(dialogic_layer:DialogicLayoutLayer) -> DialogicLayoutLayer: add_child(dialogic_layer) return dialogic_layer -func get_dialogic_layer(index:int) -> DialogicLayoutLayer: +func get_layer(index:int) -> DialogicLayoutLayer: return get_child(index) diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index d6402029b..7194ce0f9 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -39,10 +39,6 @@ func apply_export_overrides() -> void: _apply_export_overrides() -func get_layout() -> DialogicLayoutBase: - return get_parent() as DialogicLayoutBase - - ## Use this to get potential global settings. func get_global_setting(setting_name:StringName, default:Variant) -> Variant: - return get_layout().get_global_setting(setting_name, default) + return (get_parent() as DialogicLayoutBase).get_global_setting(setting_name, default) From 6a0a242a51787444edcde9dcbc4bf6df6b5da15c Mon Sep 17 00:00:00 2001 From: nlupugla Date: Thu, 28 Dec 2023 16:50:06 -0500 Subject: [PATCH 05/12] Add static type hints to visual novel example --- .../Layer_History/history_layer.tscn | 7 ---- .../Layer_VN_Choices/vn_choice_layer.gd | 2 + .../Layer_VN_Portraits/vn_portrait_layer.gd | 1 - .../Layer_VN_Portraits/vn_portrait_layer.tscn | 41 +++++++++++++++++++ .../Layer_VN_Textbox/vn_textbox_layer.tscn | 7 ++++ .../Modules/History/subsystem_history.gd | 24 +++++------ addons/dialogic/Other/DialogicGameHandler.gd | 24 +++++------ addons/dialogic/Other/DialogicUtil.gd | 17 ++++++++ .../Resources/dialogic_layout_base.gd | 2 +- .../Resources/dialogic_layout_layer.gd | 6 ++- 10 files changed, 97 insertions(+), 34 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn index 53f7f3563..3c602e6d6 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn @@ -27,14 +27,7 @@ size_flags_horizontal = 3 size_flags_vertical = 3 mouse_filter = 2 script = ExtResource("1_4mqm3") -font_use_global_size = null -font_custom_size = null -font_use_global_fonts = null -font_custom_normal = null -font_custom_bold = null -font_custom_italics = null HistoryItem = ExtResource("2_x1xgk") -disabled = null [node name="HistoryBox" type="ScrollContainer" parent="."] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index 7e50d6d3a..866e9094c 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -45,6 +45,8 @@ func get_choices() -> VBoxContainer: func get_button_sound() -> DialogicNode_ButtonSound: return %DialogicNode_ButtonSound +@onready var choices : VBoxContainer = $Choices +@onready var button_sound : DialogicNode_ButtonSound = %DialogicNode_ButtonSound ## Method that applies all exported settings func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd index dfc880318..05f7054a4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd @@ -12,4 +12,3 @@ func _apply_export_overrides() -> void: for child : DialogicNode_PortraitContainer in %Portraits.get_children(): child.size_mode = portrait_size_mode child.update_portrait_transforms() - diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn index 374bc60ff..d90d49281 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn @@ -29,6 +29,15 @@ anchor_bottom = 1.0 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 +position_index = 0 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits"] @@ -40,7 +49,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 1 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits"] @@ -52,7 +69,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 2 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits"] @@ -64,7 +89,15 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 3 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits"] @@ -77,5 +110,13 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") +mode = 0 position_index = 4 +portrait_prefix = "" +size_mode = 3 +mirrored = false +origin_anchor = 7 +origin_offset = Vector2(0, 0) +debug_character = null +debug_character_portrait = "" metadata/_edit_use_anchors_ = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn index 263440079..924c69fe4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn @@ -291,7 +291,14 @@ textbox_root = NodePath("..") [node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel/DialogicNode_DialogText"] unique_name_in_owner = true script = ExtResource("4_ma5mw") +enabled = true +mode = 0 +sounds = Array[AudioStream]([]) +end_sound = null play_every_character = 0 +pitch_variance = 0.0 +volume_variance = 0.0 +ignore_characters = " .," [node name="NextIndicator" type="Control" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel"] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index f9e917487..b6bbd9305 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -6,20 +6,20 @@ class_name DialogicSubsystemHistory ## Simple history that stores limited information ## Used for the history display -var simple_history_enabled := true +var simple_history_enabled : bool = true var simple_history_content : Array[Dictionary] = [] signal simple_history_changed ## Full event history (can be used for undo) -var full_event_history_enabled := false -var full_event_history_content := [] +var full_event_history_enabled : bool = false +var full_event_history_content : Array = [] signal full_event_history_changed ## Read text history ## Stores which text events and choices have already been visited -var already_read_history_enabled := false -var already_read_history_content := {} -var _was_last_event_already_read := false +var already_read_history_enabled : bool = false +var already_read_history_content : Dictionary = {} +var _was_last_event_already_read : bool = false signal already_read_event_reached signal not_read_event_reached @@ -47,7 +47,7 @@ func _ready() -> void: ## SIMPLE HISTORY #################################################################################################### -func store_simple_history_entry(text:String, event_type:String, extra_info := {}) -> void: +func store_simple_history_entry(text:String, event_type:String, extra_info : Dictionary = {}) -> void: if !simple_history_enabled: return extra_info['text'] = text extra_info['event_type'] = event_type @@ -78,9 +78,9 @@ func store_full_event(event:DialogicEvent) -> void: ## Takes the current timeline event and creates a unique key for it. ## Uses the timeline resource path as well. func _current_event_key() -> String: - var resource_path = dialogic.current_timeline.resource_path - var event_idx = str(dialogic.current_event_idx) - var event_key = resource_path+event_idx + var resource_path : String = dialogic.current_timeline.resource_path + var event_idx : String = str(dialogic.current_event_idx) + var event_key : String = resource_path+event_idx return event_key @@ -89,7 +89,7 @@ func event_was_read(_event: DialogicEvent) -> void: if !already_read_history_enabled: return - var event_key = _current_event_key() + var event_key : String = _current_event_key() already_read_history_content[event_key] = dialogic.current_event_idx @@ -104,7 +104,7 @@ func check_already_read(event: DialogicEvent) -> void: if event.event_name != "Text": return - var event_key = _current_event_key() + var event_key : String = _current_event_key() if event_key in already_read_history_content: already_read_event_reached.emit() diff --git a/addons/dialogic/Other/DialogicGameHandler.gd b/addons/dialogic/Other/DialogicGameHandler.gd index c4558bc5c..0a2a8fa4e 100644 --- a/addons/dialogic/Other/DialogicGameHandler.gd +++ b/addons/dialogic/Other/DialogicGameHandler.gd @@ -34,28 +34,28 @@ var current_event_idx: int = 0 ## relevant for the current situation var current_state_info: Dictionary = {} ## Current state (see [States] enum) -var current_state := States.IDLE: +var current_state : States = States.IDLE: get: return current_state set(new_state): current_state = new_state emit_signal('state_changed', new_state) ## Emitted when [current_state] change. -signal state_changed(new_state) +signal state_changed(new_state : States) ## When true, many dialogic process won't continue until it's false again. -var paused := false: +var paused : bool = false: set(value): paused = value if paused: - for subsystem in get_children(): - if subsystem.has_method('pause'): - subsystem.pause() + for subsystem : Node in get_children(): + if subsystem.has_method(&'pause'): + subsystem.call(&'pause') dialogic_paused.emit() else: - for subsystem in get_children(): - if subsystem.has_method('resume'): - subsystem.resume() + for subsystem : Node in get_children(): + if subsystem.has_method(&'resume'): + subsystem.call(&'resume') dialogic_resumed.emit() ## Emitted when [paused] changes to true. @@ -66,12 +66,12 @@ signal dialogic_resumed signal timeline_ended() signal timeline_started() -signal event_handled(resource) +signal event_handled(resource : Variant) ## Emitted when the Signal event was reached -signal signal_event(argument) +signal signal_event(argument : Variant) ## Emitted when [signal] effect was reached in text. -signal text_signal(argument) +signal text_signal(argument : Variant) ## Autoloads are added first, so this happens REALLY early on game startup. diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 013399f4e..7722566ea 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -28,6 +28,23 @@ static func autoload() -> DialogicGameHandler: return null return Engine.get_main_loop().root.get_node("Dialogic") + +static func get_text() -> DialogicSubsystemText: + return DialogicUtil.autoload().Text + + +static func get_input() -> DialogicSubsystemInput: + return DialogicUtil.autoload().Input + + +static func get_glossary() -> DialogicSubsystemGlossary: + return DialogicUtil.autoload().Glossary + + +static func get_history() -> DialogicSubsystemHistory: + return DialogicUtil.autoload().History + + #region FILE SYSTEM ################################################################################ static func listdir(path: String, files_only: bool = true, throw_error:bool = true, full_file_path:bool = false, include_imports := false) -> Array: diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index 77cecfbe4..a89fbed24 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutBase -extends Node +extends CanvasLayer ## Base class that should be extended by custom layouts. diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index 7194ce0f9..fb05822ad 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutLayer -extends Node +extends Control ## Base class that should be extended by custom dialogic layout layers. @@ -39,6 +39,10 @@ func apply_export_overrides() -> void: _apply_export_overrides() +func get_layout() -> DialogicLayoutBase: + return get_parent() as DialogicLayoutBase + + ## Use this to get potential global settings. func get_global_setting(setting_name:StringName, default:Variant) -> Variant: return (get_parent() as DialogicLayoutBase).get_global_setting(setting_name, default) From 212d108a701639324e4f5aa85f1944d42ca240ab Mon Sep 17 00:00:00 2001 From: nlupugla Date: Sun, 31 Dec 2023 17:27:54 -0500 Subject: [PATCH 06/12] Added types to the textbubble and speaker_textbubble examples --- .../Modules/History/subsystem_history.gd | 16 ++++++------- addons/dialogic/Other/DialogicUtil.gd | 24 ++++--------------- .../Resources/dialogic_layout_base.gd | 2 +- addons/dialogic/Resources/dialogic_style.gd | 3 --- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index b6bbd9305..b0eb3e990 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -6,20 +6,20 @@ class_name DialogicSubsystemHistory ## Simple history that stores limited information ## Used for the history display -var simple_history_enabled : bool = true +var simple_history_enabled := true var simple_history_content : Array[Dictionary] = [] signal simple_history_changed ## Full event history (can be used for undo) -var full_event_history_enabled : bool = false -var full_event_history_content : Array = [] +var full_event_history_enabled := false +var full_event_history_content := [] signal full_event_history_changed ## Read text history ## Stores which text events and choices have already been visited -var already_read_history_enabled : bool = false -var already_read_history_content : Dictionary = {} -var _was_last_event_already_read : bool = false +var already_read_history_enabled := false +var already_read_history_content := {} +var _was_last_event_already_read := false signal already_read_event_reached signal not_read_event_reached @@ -47,7 +47,7 @@ func _ready() -> void: ## SIMPLE HISTORY #################################################################################################### -func store_simple_history_entry(text:String, event_type:String, extra_info : Dictionary = {}) -> void: +func store_simple_history_entry(text:String, event_type:String, extra_info := {}) -> void: if !simple_history_enabled: return extra_info['text'] = text extra_info['event_type'] = event_type @@ -80,7 +80,7 @@ func store_full_event(event:DialogicEvent) -> void: func _current_event_key() -> String: var resource_path : String = dialogic.current_timeline.resource_path var event_idx : String = str(dialogic.current_event_idx) - var event_key : String = resource_path+event_idx + var event_key : String = resource_path + event_idx return event_key diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index 7722566ea..e993e576f 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -13,9 +13,9 @@ static func get_editor_scale() -> float: ## Although this does in fact always return a EditorPlugin node, ## that class is apparently not present in export and referencing it here creates a crash. static func get_dialogic_plugin() -> Node: - for child in Engine.get_main_loop().get_root().get_children(): + for child : Node in Engine.get_main_loop().get_root().get_children(): if child.get_class() == "EditorNode": - return child.get_node('DialogicPlugin') + return child.get_node(^'DialogicPlugin') return null #endregion @@ -24,25 +24,9 @@ static func get_dialogic_plugin() -> Node: static func autoload() -> DialogicGameHandler: if Engine.is_editor_hint(): return null - if not Engine.get_main_loop().root.has_node("Dialogic"): + if not Engine.get_main_loop().root.has_node(^"Dialogic"): return null - return Engine.get_main_loop().root.get_node("Dialogic") - - -static func get_text() -> DialogicSubsystemText: - return DialogicUtil.autoload().Text - - -static func get_input() -> DialogicSubsystemInput: - return DialogicUtil.autoload().Input - - -static func get_glossary() -> DialogicSubsystemGlossary: - return DialogicUtil.autoload().Glossary - - -static func get_history() -> DialogicSubsystemHistory: - return DialogicUtil.autoload().History + return Engine.get_main_loop().root.get_node(^"Dialogic") #region FILE SYSTEM diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index a89fbed24..77cecfbe4 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutBase -extends CanvasLayer +extends Node ## Base class that should be extended by custom layouts. diff --git a/addons/dialogic/Resources/dialogic_style.gd b/addons/dialogic/Resources/dialogic_style.gd index 4256864a5..ccd48f3df 100644 --- a/addons/dialogic/Resources/dialogic_style.gd +++ b/addons/dialogic/Resources/dialogic_style.gd @@ -86,9 +86,6 @@ func move_layer(from_index:int, to_index:int) -> void: if not has_layer(from_index) or not has_layer(to_index-1): return - if from_index < to_index: - to_index -1 - var info: DialogicLayoutLayer = layers.pop_at(from_index) layers.insert(to_index, info) changed.emit() From 4ab1dc7b6cf38cdaff74b5f847274e09e6980eab Mon Sep 17 00:00:00 2001 From: nlupugla Date: Sun, 31 Dec 2023 20:35:22 -0500 Subject: [PATCH 07/12] Reverted some changes that were unnecessary. --- .../Layer_History/history_layer.tscn | 7 ++++ .../Layer_VN_Portraits/vn_portrait_layer.tscn | 41 ------------------- .../Layer_VN_Textbox/vn_textbox_layer.tscn | 7 ---- .../Modules/History/subsystem_history.gd | 10 ++--- addons/dialogic/Other/DialogicGameHandler.gd | 24 +++++------ addons/dialogic/Other/DialogicUtil.gd | 9 ++-- .../Resources/dialogic_layout_layer.gd | 2 +- addons/dialogic/Resources/dialogic_style.gd | 3 ++ 8 files changed, 32 insertions(+), 71 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn index 3c602e6d6..53f7f3563 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.tscn @@ -27,7 +27,14 @@ size_flags_horizontal = 3 size_flags_vertical = 3 mouse_filter = 2 script = ExtResource("1_4mqm3") +font_use_global_size = null +font_custom_size = null +font_use_global_fonts = null +font_custom_normal = null +font_custom_bold = null +font_custom_italics = null HistoryItem = ExtResource("2_x1xgk") +disabled = null [node name="HistoryBox" type="ScrollContainer" parent="."] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn index d90d49281..374bc60ff 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.tscn @@ -29,15 +29,6 @@ anchor_bottom = 1.0 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 -position_index = 0 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer2" type="Control" parent="Portraits"] @@ -49,15 +40,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 1 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer3" type="Control" parent="Portraits"] @@ -69,15 +52,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 2 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer4" type="Control" parent="Portraits"] @@ -89,15 +64,7 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 3 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true [node name="DialogicNode_PortraitContainer5" type="Control" parent="Portraits"] @@ -110,13 +77,5 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 script = ExtResource("1_rxdcc") -mode = 0 position_index = 4 -portrait_prefix = "" -size_mode = 3 -mirrored = false -origin_anchor = 7 -origin_offset = Vector2(0, 0) -debug_character = null -debug_character_portrait = "" metadata/_edit_use_anchors_ = true diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn index 924c69fe4..263440079 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.tscn @@ -291,14 +291,7 @@ textbox_root = NodePath("..") [node name="DialogicNode_TypeSounds" type="AudioStreamPlayer" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel/DialogicNode_DialogText"] unique_name_in_owner = true script = ExtResource("4_ma5mw") -enabled = true -mode = 0 -sounds = Array[AudioStream]([]) -end_sound = null play_every_character = 0 -pitch_variance = 0.0 -volume_variance = 0.0 -ignore_characters = " .," [node name="NextIndicator" type="Control" parent="DialogicTextAnchor/DialogTextAnimationParent/Sizer/DialogTextPanel"] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index b0eb3e990..f9e917487 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -78,9 +78,9 @@ func store_full_event(event:DialogicEvent) -> void: ## Takes the current timeline event and creates a unique key for it. ## Uses the timeline resource path as well. func _current_event_key() -> String: - var resource_path : String = dialogic.current_timeline.resource_path - var event_idx : String = str(dialogic.current_event_idx) - var event_key : String = resource_path + event_idx + var resource_path = dialogic.current_timeline.resource_path + var event_idx = str(dialogic.current_event_idx) + var event_key = resource_path+event_idx return event_key @@ -89,7 +89,7 @@ func event_was_read(_event: DialogicEvent) -> void: if !already_read_history_enabled: return - var event_key : String = _current_event_key() + var event_key = _current_event_key() already_read_history_content[event_key] = dialogic.current_event_idx @@ -104,7 +104,7 @@ func check_already_read(event: DialogicEvent) -> void: if event.event_name != "Text": return - var event_key : String = _current_event_key() + var event_key = _current_event_key() if event_key in already_read_history_content: already_read_event_reached.emit() diff --git a/addons/dialogic/Other/DialogicGameHandler.gd b/addons/dialogic/Other/DialogicGameHandler.gd index 0a2a8fa4e..c4558bc5c 100644 --- a/addons/dialogic/Other/DialogicGameHandler.gd +++ b/addons/dialogic/Other/DialogicGameHandler.gd @@ -34,28 +34,28 @@ var current_event_idx: int = 0 ## relevant for the current situation var current_state_info: Dictionary = {} ## Current state (see [States] enum) -var current_state : States = States.IDLE: +var current_state := States.IDLE: get: return current_state set(new_state): current_state = new_state emit_signal('state_changed', new_state) ## Emitted when [current_state] change. -signal state_changed(new_state : States) +signal state_changed(new_state) ## When true, many dialogic process won't continue until it's false again. -var paused : bool = false: +var paused := false: set(value): paused = value if paused: - for subsystem : Node in get_children(): - if subsystem.has_method(&'pause'): - subsystem.call(&'pause') + for subsystem in get_children(): + if subsystem.has_method('pause'): + subsystem.pause() dialogic_paused.emit() else: - for subsystem : Node in get_children(): - if subsystem.has_method(&'resume'): - subsystem.call(&'resume') + for subsystem in get_children(): + if subsystem.has_method('resume'): + subsystem.resume() dialogic_resumed.emit() ## Emitted when [paused] changes to true. @@ -66,12 +66,12 @@ signal dialogic_resumed signal timeline_ended() signal timeline_started() -signal event_handled(resource : Variant) +signal event_handled(resource) ## Emitted when the Signal event was reached -signal signal_event(argument : Variant) +signal signal_event(argument) ## Emitted when [signal] effect was reached in text. -signal text_signal(argument : Variant) +signal text_signal(argument) ## Autoloads are added first, so this happens REALLY early on game startup. diff --git a/addons/dialogic/Other/DialogicUtil.gd b/addons/dialogic/Other/DialogicUtil.gd index e993e576f..013399f4e 100644 --- a/addons/dialogic/Other/DialogicUtil.gd +++ b/addons/dialogic/Other/DialogicUtil.gd @@ -13,9 +13,9 @@ static func get_editor_scale() -> float: ## Although this does in fact always return a EditorPlugin node, ## that class is apparently not present in export and referencing it here creates a crash. static func get_dialogic_plugin() -> Node: - for child : Node in Engine.get_main_loop().get_root().get_children(): + for child in Engine.get_main_loop().get_root().get_children(): if child.get_class() == "EditorNode": - return child.get_node(^'DialogicPlugin') + return child.get_node('DialogicPlugin') return null #endregion @@ -24,10 +24,9 @@ static func get_dialogic_plugin() -> Node: static func autoload() -> DialogicGameHandler: if Engine.is_editor_hint(): return null - if not Engine.get_main_loop().root.has_node(^"Dialogic"): + if not Engine.get_main_loop().root.has_node("Dialogic"): return null - return Engine.get_main_loop().root.get_node(^"Dialogic") - + return Engine.get_main_loop().root.get_node("Dialogic") #region FILE SYSTEM ################################################################################ diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index fb05822ad..aceef4110 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -1,6 +1,6 @@ @tool class_name DialogicLayoutLayer -extends Control +extends Node ## Base class that should be extended by custom dialogic layout layers. diff --git a/addons/dialogic/Resources/dialogic_style.gd b/addons/dialogic/Resources/dialogic_style.gd index ccd48f3df..4256864a5 100644 --- a/addons/dialogic/Resources/dialogic_style.gd +++ b/addons/dialogic/Resources/dialogic_style.gd @@ -86,6 +86,9 @@ func move_layer(from_index:int, to_index:int) -> void: if not has_layer(from_index) or not has_layer(to_index-1): return + if from_index < to_index: + to_index -1 + var info: DialogicLayoutLayer = layers.pop_at(from_index) layers.insert(to_index, info) changed.emit() From 09b5d8df810114983eb536dd77db7a2a06727c55 Mon Sep 17 00:00:00 2001 From: nlupugla Date: Tue, 2 Jan 2024 13:30:54 -0500 Subject: [PATCH 08/12] Replaced @onready node variables with getters --- .../Layer_VN_Portraits/vn_portrait_layer.gd | 1 + addons/dialogic/Resources/dialogic_layout_layer.gd | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd index 05f7054a4..dfc880318 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd @@ -12,3 +12,4 @@ func _apply_export_overrides() -> void: for child : DialogicNode_PortraitContainer in %Portraits.get_children(): child.size_mode = portrait_size_mode child.update_portrait_transforms() + diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index aceef4110..7194ce0f9 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -39,10 +39,6 @@ func apply_export_overrides() -> void: _apply_export_overrides() -func get_layout() -> DialogicLayoutBase: - return get_parent() as DialogicLayoutBase - - ## Use this to get potential global settings. func get_global_setting(setting_name:StringName, default:Variant) -> Variant: return (get_parent() as DialogicLayoutBase).get_global_setting(setting_name, default) From d293c91f6ea7a73e15b2a4c385ddea4a0042304d Mon Sep 17 00:00:00 2001 From: nlupugla Date: Mon, 8 Jan 2024 10:05:46 -0500 Subject: [PATCH 09/12] Removed changes to subsystems --- .../Modules/Core/subsystem_animation.gd | 1 - .../dialogic/Modules/Core/subsystem_input.gd | 1 - .../Layer_Glossary/glossary_popup_layer.gd | 19 +++++++-------- .../Layer_History/history_layer.gd | 8 +++---- .../Layer_VN_Textbox/animations.gd | 24 +++++++++---------- .../Layer_VN_Textbox/autoadvance_indicator.gd | 6 ++--- .../Modules/Glossary/subsystem_glossary.gd | 1 - .../Modules/History/subsystem_history.gd | 1 - .../dialogic/Modules/Text/subsystem_text.gd | 1 - 9 files changed, 28 insertions(+), 34 deletions(-) diff --git a/addons/dialogic/Modules/Core/subsystem_animation.gd b/addons/dialogic/Modules/Core/subsystem_animation.gd index 943e7a1bf..ad80a9513 100644 --- a/addons/dialogic/Modules/Core/subsystem_animation.gd +++ b/addons/dialogic/Modules/Core/subsystem_animation.gd @@ -1,5 +1,4 @@ extends DialogicSubsystem -class_name DialogicSubsystemAnimation ## Subsystem that allows entering and leaving an animation state. diff --git a/addons/dialogic/Modules/Core/subsystem_input.gd b/addons/dialogic/Modules/Core/subsystem_input.gd index 49ed62219..4f0102489 100644 --- a/addons/dialogic/Modules/Core/subsystem_input.gd +++ b/addons/dialogic/Modules/Core/subsystem_input.gd @@ -1,5 +1,4 @@ extends DialogicSubsystem -class_name DialogicSubsystemInput ## Subsystem that handles input, autoadvance & skipping. diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 5e1f95e36..08a3d7276 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -68,18 +68,17 @@ func _ready() -> void: return get_pointer().hide() - var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') + var text_system : Node = DialogicUtil.autoload().get(&'Text') var _error : int = 0 - _error = text_system.animation_textbox_hide.connect(get_pointer().hide) - _error = text_system.meta_hover_started.connect(_on_dialogic_display_dialog_text_meta_hover_started) - _error = text_system.meta_hover_ended.connect(_on_dialogic_display_dialog_text_meta_hover_ended) - _error = text_system.meta_clicked.connect(_on_dialogic_display_dialog_text_meta_clicked) + _error = text_system.connect(&'animation_textbox_hide', get_pointer().hide) + _error = text_system.connect(&'meta_hover_started', _on_dialogic_display_dialog_text_meta_hover_started) + _error = text_system.connect(&'meta_hover_ended', _on_dialogic_display_dialog_text_meta_hover_ended) + _error = text_system.connect(&'meta_clicked', _on_dialogic_display_dialog_text_meta_clicked) ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var glossary_system : DialogicSubsystemGlossary = DialogicUtil.autoload().get(&'Glossary') - var info: Dictionary = glossary_system.get_entry(meta) + var info : Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta) if not info: return @@ -104,7 +103,7 @@ func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: get_panel().self_modulate = info.get(&'color', Color.WHITE) get_panel_point().self_modulate = info.get(&'color', Color.WHITE) - (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = true + DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', true) ## Method that keeps the bubble at mouse position when visible @@ -120,11 +119,11 @@ func _process(_delta : float) -> void: ## Method that hides the bubble func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: get_pointer().hide() - (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = false + DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', false) func _on_dialogic_display_dialog_text_meta_clicked(_meta:String) -> void: - (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).action_was_consumed = true + DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', true) func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index 9d22ec2a2..b9bddfef0 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -56,9 +56,9 @@ func _ready() -> void: func _apply_export_overrides() -> void: - var history_subsystem : DialogicSubsystemHistory = DialogicUtil.autoload().get(&'History') + var history_subsystem : Node = DialogicUtil.autoload().get(&'History') if history_subsystem != null: - get_show_history_button().visible = show_open_button and history_subsystem.simple_history_enabled + get_show_history_button().visible = show_open_button and history_subsystem.get(&'simple_history_enabled') else: set(&'visible', false) @@ -99,7 +99,7 @@ func show_history() -> void: for child : Node in get_history_log().get_children(): child.queue_free() - for info : Dictionary in (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).get_simple_history(): + for info : Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'): var history_item : Node = HistoryItem.instantiate() history_item.set(&'theme', history_item_theme) match info.event_type: @@ -144,4 +144,4 @@ func _on_hide_history_pressed() -> void: DialogicUtil.autoload().paused = false get_history_box().hide() get_hide_history_button().hide() - get_show_history_button().visible = show_open_button and (DialogicUtil.autoload().get(&'History') as DialogicSubsystemHistory).simple_history_enabled + get_show_history_button().visible = show_open_button and DialogicUtil.autoload().get(&'History').get(&'simple_history_enabled') diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index 07c2c9778..c2b1916ab 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -22,20 +22,20 @@ func get_dialog() -> DialogicNode_DialogText: func _ready() -> void: - var text_system : DialogicSubsystemText = DialogicUtil.autoload().get(&'Text') + var text_system : Node = DialogicUtil.autoload().get(&'Text') var _error : int = 0 - _error = text_system.animation_textbox_hide.connect(_on_textbox_hide) - _error = text_system.animation_textbox_show.connect(_on_textbox_show) - _error = text_system.animation_textbox_new_text.connect(_on_textbox_new_text) - _error = text_system.about_to_show_text.connect(_on_about_to_show_text) + _error = text_system.connect(&'animation_textbox_hide', _on_textbox_hide) + _error = text_system.connect(&'animation_textbox_show', _on_textbox_show) + _error = text_system.connect(&'animation_textbox_new_text', _on_textbox_new_text) + _error = text_system.connect(&'about_to_show_text', _on_about_to_show_text) func _on_textbox_show() -> void: if animation_in == AnimationsIn.NONE: return play('RESET') - var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') - animation_system.start_animating() + var animation_system : Node = DialogicUtil.autoload().get(&'Animation') + animation_system.call(&'start_animating') get_text_panel().get_parent().get_parent().set(&'modulate', Color.TRANSPARENT) get_dialog().text = "" match animation_in: @@ -51,8 +51,8 @@ func _on_textbox_hide() -> void: if animation_out == AnimationsOut.NONE: return play('RESET') - var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') - animation_system.start_animating() + var animation_system : Node = DialogicUtil.autoload().get(&'Animation') + animation_system.call(&'start_animating') match animation_out: AnimationsOut.POP_OUT: play_backwards("textbox_pop") @@ -68,14 +68,14 @@ func _on_about_to_show_text(info:Dictionary) -> void: func _on_textbox_new_text() -> void: - if (DialogicUtil.autoload().get(&'Input') as DialogicSubsystemInput).auto_skip.enabled: + if DialogicUtil.autoload().get(&'Input').get(&'auto_skip').get(&'enabled'): return if animation_new_text == AnimationsNewText.NONE: return - var animation_system : DialogicSubsystemAnimation = DialogicUtil.autoload().get(&'Animation') - animation_system.start_animating() + var animation_system : Node = DialogicUtil.autoload().get(&'Animation') + animation_system.call(&'start_animating') if full_clear: get_dialog().text = "" match animation_new_text: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd index 4e0a21240..ca7dc1ae7 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd @@ -6,9 +6,9 @@ func _process(_delta : float) -> void: if !enabled: hide() return - var input_system : DialogicSubsystemInput = DialogicUtil.autoload().get(&'Input') - if input_system.auto_advance.get_progress() < 0: + var auto_advance : DialogicAutoAdvance = DialogicUtil.autoload().get(&'Input').get(&'auto_advance') + if auto_advance.get_progress() < 0: hide() else: show() - value = input_system.auto_advance.get_progress() + value = auto_advance.get_progress() diff --git a/addons/dialogic/Modules/Glossary/subsystem_glossary.gd b/addons/dialogic/Modules/Glossary/subsystem_glossary.gd index 9e8de93a9..7a8d29567 100644 --- a/addons/dialogic/Modules/Glossary/subsystem_glossary.gd +++ b/addons/dialogic/Modules/Glossary/subsystem_glossary.gd @@ -1,5 +1,4 @@ extends DialogicSubsystem -class_name DialogicSubsystemGlossary ## Subsystem that handles glossaries. diff --git a/addons/dialogic/Modules/History/subsystem_history.gd b/addons/dialogic/Modules/History/subsystem_history.gd index f9e917487..0dca6410c 100644 --- a/addons/dialogic/Modules/History/subsystem_history.gd +++ b/addons/dialogic/Modules/History/subsystem_history.gd @@ -1,5 +1,4 @@ extends DialogicSubsystem -class_name DialogicSubsystemHistory ## Subsystem that manages history storing. diff --git a/addons/dialogic/Modules/Text/subsystem_text.gd b/addons/dialogic/Modules/Text/subsystem_text.gd index af9b81aac..f16d36877 100644 --- a/addons/dialogic/Modules/Text/subsystem_text.gd +++ b/addons/dialogic/Modules/Text/subsystem_text.gd @@ -1,5 +1,4 @@ extends DialogicSubsystem -class_name DialogicSubsystemText ## Subsystem that handles showing of dialog text (+text effects & modifiers), name label, and next indicator From 73995f94ee8a25d9a74b24d198a03de2950ad1ff Mon Sep 17 00:00:00 2001 From: Jowan-Spooner Date: Tue, 9 Jan 2024 13:38:37 +0100 Subject: [PATCH 10/12] Adjust static typing spaces As Cake pointed out var inferred := 123 var explicit: int = 123 So I tried to enforce that on the layers. --- .../Base_Default/default_layout_base.gd | 10 +- .../Layer_Glossary/glossary_popup_layer.gd | 58 ++++----- .../Layer_History/history_layer.gd | 22 ++-- .../speaker_portrait_textbox_layer.gd | 72 ++++++------ .../Layer_TextInput/text_input_layer.gd | 2 +- .../Layer_Textbubble/text_bubble_layer.gd | 58 ++++----- .../Layer_VN_Choices/vn_choice_layer.gd | 54 ++++----- .../Layer_VN_Portraits/vn_portrait_layer.gd | 4 +- .../Layer_VN_Textbox/vn_textbox_layer.gd | 111 ++++++++---------- 9 files changed, 192 insertions(+), 199 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd index a5aece6ae..0c76508ed 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Base_Default/default_layout_base.gd @@ -3,13 +3,13 @@ extends DialogicLayoutBase ## The default layout base scene. -@export var canvas_layer : int = 1 +@export var canvas_layer: int = 1 @export_subgroup("Global") -@export var global_bg_color : Color = Color(0, 0, 0, 0.9) -@export var global_font_color : Color = Color("white") -@export_file('*.ttf') var global_font : String = "" -@export var global_font_size : int = 18 +@export var global_bg_color: Color = Color(0, 0, 0, 0.9) +@export var global_font_color: Color = Color("white") +@export_file('*.ttf') var global_font: String = "" +@export var global_font_size: int = 18 func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 08a3d7276..1c4799eaa 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -7,37 +7,37 @@ extends DialogicLayoutLayer @export_group('Text') enum Alignment {LEFT, CENTER, RIGHT} -@export var title_alignment : Alignment = Alignment.LEFT -@export var text_alignment : Alignment = Alignment.LEFT -@export var extra_alignment : Alignment = Alignment.RIGHT +@export var title_alignment: Alignment = Alignment.LEFT +@export var text_alignment: Alignment = Alignment.LEFT +@export var extra_alignment: Alignment = Alignment.RIGHT @export_subgroup("Colors") enum TextColorModes {GLOBAL, ENTRY, CUSTOM} -@export var title_color_mode : TextColorModes = TextColorModes.ENTRY -@export var title_custom_color : Color = Color.WHITE -@export var text_color_mode : TextColorModes = TextColorModes.ENTRY -@export var text_custom_color : Color = Color.WHITE -@export var extra_color_mode : TextColorModes = TextColorModes.ENTRY -@export var extra_custom_color : Color = Color.WHITE +@export var title_color_mode: TextColorModes = TextColorModes.ENTRY +@export var title_custom_color: Color = Color.WHITE +@export var text_color_mode: TextColorModes = TextColorModes.ENTRY +@export var text_custom_color: Color = Color.WHITE +@export var extra_color_mode: TextColorModes = TextColorModes.ENTRY +@export var extra_custom_color: Color = Color.WHITE @export_group("Font") -@export var font_use_global : bool = true -@export_file('*.ttf') var font_custom : String = "" +@export var font_use_global: bool = true +@export_file('*.ttf') var font_custom: String = "" @export_subgroup('Sizes') -@export var font_title_size : int = 18 -@export var font_text_size : int = 17 -@export var font_extra_size : int = 15 +@export var font_title_size: int = 18 +@export var font_text_size: int = 17 +@export var font_extra_size: int = 15 @export_group("Box") @export_subgroup("Color") enum ModulateModes {BASE_COLOR_ONLY, ENTRY_COLOR_ON_BOX, GLOBAL_BG_COLOR} -@export var box_modulate_mode : ModulateModes = ModulateModes.ENTRY_COLOR_ON_BOX -@export var box_base_modulate : Color = Color.WHITE +@export var box_modulate_mode: ModulateModes = ModulateModes.ENTRY_COLOR_ON_BOX +@export var box_base_modulate: Color = Color.WHITE @export_subgroup("Size") -@export var box_width : int = 200 +@export var box_width: int = 200 func get_pointer() -> Control: return $Pointer @@ -68,8 +68,8 @@ func _ready() -> void: return get_pointer().hide() - var text_system : Node = DialogicUtil.autoload().get(&'Text') - var _error : int = 0 + var text_system: Node = DialogicUtil.autoload().get(&'Text') + var _error: int = 0 _error = text_system.connect(&'animation_textbox_hide', get_pointer().hide) _error = text_system.connect(&'meta_hover_started', _on_dialogic_display_dialog_text_meta_hover_started) _error = text_system.connect(&'meta_hover_ended', _on_dialogic_display_dialog_text_meta_hover_ended) @@ -78,7 +78,7 @@ func _ready() -> void: ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var info : Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta) + var info: Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta) if not info: return @@ -111,7 +111,7 @@ func _process(_delta : float) -> void: if Engine.is_editor_hint(): return - var pointer : Control = get_pointer() + var pointer: Control = get_pointer() if pointer.visible: pointer.global_position = pointer.get_global_mouse_position() @@ -134,15 +134,15 @@ func _apply_export_overrides() -> void: elif ResourceLoader.exists(font_custom): font = load(font_custom) - var title : Label = get_title() + var title: Label = get_title() if font: title.add_theme_font_override(&"font", font) title.horizontal_alignment = title_alignment as HorizontalAlignment # Apply font & sizes title.add_theme_font_size_override(&"font_size", font_title_size) - var labels : Array[RichTextLabel] = [get_text(), get_extra()] - var sizes : PackedInt32Array = [font_text_size, font_extra_size] + var labels: Array[RichTextLabel] = [get_text(), get_extra()] + var sizes: PackedInt32Array = [font_text_size, font_extra_size] for i : int in len(labels): if font: labels[i].add_theme_font_override(&'normal_font', font) @@ -155,10 +155,10 @@ func _apply_export_overrides() -> void: # Apply text colors - var controls : Array[Control] = [get_title(), get_text(), get_extra()] - var global_settings : Array[StringName] = [&'font_color', &'default_color', &'default_color'] - var color_modes : Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode] - var custom_colors : PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color] + var controls: Array[Control] = [get_title(), get_text(), get_extra()] + var global_settings: Array[StringName] = [&'font_color', &'default_color', &'default_color'] + var color_modes: Array[TextColorModes] = [title_color_mode, text_color_mode, extra_color_mode] + var custom_colors: PackedColorArray = [title_custom_color, text_custom_color, extra_custom_color] for i : int in len(controls): match color_modes[i]: TextColorModes.GLOBAL: @@ -167,7 +167,7 @@ func _apply_export_overrides() -> void: controls[i].add_theme_color_override(global_settings[i], custom_colors[i]) # Apply box size - var panel : PanelContainer = get_panel() + var panel: PanelContainer = get_panel() panel.size.x = box_width panel.position.x = -box_width/2.0 diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index b9bddfef0..4febcc707 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -6,12 +6,12 @@ extends DialogicLayoutLayer @export_group('Look') @export_subgroup('Font') -@export var font_use_global_size : bool = true -@export var font_custom_size : int = 15 -@export var font_use_global_fonts : bool = true -@export_file('*.ttf') var font_custom_normal : String = "" -@export_file('*.ttf') var font_custom_bold : String = "" -@export_file('*.ttf') var font_custom_italics : String = "" +@export var font_use_global_size: bool = true +@export var font_custom_size: int = 15 +@export var font_use_global_fonts: bool = true +@export_file('*.ttf') var font_custom_normal: String = "" +@export_file('*.ttf') var font_custom_bold: String = "" +@export_file('*.ttf') var font_custom_italics: String = "" @export_subgroup('Buttons') @export var show_open_button: bool = true @@ -32,7 +32,7 @@ var scroll_to_bottom_flag: bool = false @export_group('Private') @export var HistoryItem: PackedScene = null -var history_item_theme : Theme = null +var history_item_theme: Theme = null func get_show_history_button() -> Button: return $ShowHistory @@ -56,7 +56,7 @@ func _ready() -> void: func _apply_export_overrides() -> void: - var history_subsystem : Node = DialogicUtil.autoload().get(&'History') + var history_subsystem: Node = DialogicUtil.autoload().get(&'History') if history_subsystem != null: get_show_history_button().visible = show_open_button and history_subsystem.get(&'simple_history_enabled') else: @@ -96,10 +96,10 @@ func _on_show_history_pressed() -> void: func show_history() -> void: - for child : Node in get_history_log().get_children(): + for child: Node in get_history_log().get_children(): child.queue_free() - for info : Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'): + for info: Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'): var history_item : Node = HistoryItem.instantiate() history_item.set(&'theme', history_item_theme) match info.event_type: @@ -117,7 +117,7 @@ func show_history() -> void: continue history_item.call(&'load_info', '[i]'+info['text']) "Choice": - var choices_text : String = "" + var choices_text: String = "" if show_all_choices: for i : String in info['all_choices']: if i.ends_with('#disabled'): diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd index f108b295f..0b97cce5a 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_SpeakerPortraitTextbox/speaker_portrait_textbox_layer.gd @@ -6,56 +6,56 @@ enum LimitedAlignments {LEFT=0, RIGHT=1} @export_group('Text') @export_subgroup("Text") -@export var text_alignment :Alignments= Alignments.LEFT +@export var text_alignment: Alignments = Alignments.LEFT @export_subgroup('Size') -@export var text_use_global_size : bool = true -@export var text_custom_size : int = 15 +@export var text_use_global_size: bool = true +@export var text_custom_size: int = 15 @export_subgroup('Color') -@export var text_use_global_color : bool = true -@export var text_custom_color : Color = Color.WHITE +@export var text_use_global_color: bool = true +@export var text_custom_color: Color = Color.WHITE @export_subgroup('Fonts') -@export var use_global_fonts : bool = true -@export_file('*.ttf') var custom_normal_font:String = "" -@export_file('*.ttf') var custom_bold_font:String = "" -@export_file('*.ttf') var custom_italic_font:String = "" -@export_file('*.ttf') var custom_bold_italic_font:String = "" +@export var use_global_fonts: bool = true +@export_file('*.ttf') var custom_normal_font: String = "" +@export_file('*.ttf') var custom_bold_font: String = "" +@export_file('*.ttf') var custom_italic_font: String = "" +@export_file('*.ttf') var custom_bold_italic_font: String = "" @export_group('Name Label') @export_subgroup("Color") enum NameLabelColorModes {GLOBAL_COLOR, CHARACTER_COLOR, CUSTOM_COLOR} -@export var name_label_color_mode : NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR -@export var name_label_custom_color : Color = Color.WHITE +@export var name_label_color_mode: NameLabelColorModes = NameLabelColorModes.GLOBAL_COLOR +@export var name_label_custom_color: Color = Color.WHITE @export_subgroup("Behaviour") -@export var name_label_alignment : Alignments = Alignments.LEFT -@export var name_label_hide_when_no_character : bool = false +@export var name_label_alignment: Alignments = Alignments.LEFT +@export var name_label_hide_when_no_character: bool = false @export_subgroup("Font & Size") -@export var name_label_use_global_size : bool = true -@export var name_label_custom_size : int = 15 -@export var name_label_use_global_font : bool = true -@export_file('*.ttf') var name_label_customfont : String = "" +@export var name_label_use_global_size: bool = true +@export var name_label_custom_size: int = 15 +@export var name_label_use_global_font: bool = true +@export_file('*.ttf') var name_label_customfont: String = "" @export_group('Box') @export_subgroup("Box") -@export_file('*.tres') var box_panel : String = this_folder.path_join("default_stylebox.tres") -@export var box_modulate_global_color : bool = true -@export var box_modulate_custom_color : Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658) -@export var box_size : Vector2 = Vector2(600, 160) -@export var box_distance : int = 25 +@export_file('*.tres') var box_panel: String = this_folder.path_join("default_stylebox.tres") +@export var box_modulate_global_color: bool = true +@export var box_modulate_custom_color: Color = Color(0.47247135639191, 0.31728461384773, 0.16592600941658) +@export var box_size: Vector2 = Vector2(600, 160) +@export var box_distance: int = 25 @export_group('Portrait') @export_subgroup('Portrait') -@export var portrait_stretch_factor : float = 0.3 -@export var portrait_position : LimitedAlignments = LimitedAlignments.LEFT -@export var portrait_bg_modulate : Color = Color(0, 0, 0, 0.5137255191803) +@export var portrait_stretch_factor: float = 0.3 +@export var portrait_position: LimitedAlignments = LimitedAlignments.LEFT +@export var portrait_bg_modulate: Color = Color(0, 0, 0, 0.5137255191803) ## Called by dialogic whenever export overrides might change func _apply_export_overrides() -> void: ## FONT SETTINGS - var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText + var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment - var text_size : int = text_custom_size + var text_size: int = text_custom_size if text_use_global_size: text_size = get_global_setting(&'font_size', text_custom_size) @@ -65,12 +65,12 @@ func _apply_export_overrides() -> void: dialog_text.add_theme_font_size_override(&"bold_italics_font_size", text_size) - var text_color : Color = text_custom_color + var text_color: Color = text_custom_color if text_use_global_color: text_color = get_global_setting(&'font_color', text_custom_color) dialog_text.add_theme_color_override(&"default_color", text_color) - var normal_font : String = custom_normal_font + var normal_font: String = custom_normal_font if use_global_fonts and ResourceLoader.exists(get_global_setting(&'font', '') as String): normal_font = get_global_setting(&'font', '') @@ -84,8 +84,8 @@ func _apply_export_overrides() -> void: dialog_text.add_theme_font_override(&"bold_italics_font", load(custom_bold_italic_font) as Font) ## BOX SETTINGS - var panel : PanelContainer = %Panel - var portrait_panel : Panel = %PortraitPanel + var panel: PanelContainer = %Panel + var portrait_panel: Panel = %PortraitPanel if box_modulate_global_color: panel.self_modulate = get_global_setting(&'bg_color', box_modulate_custom_color) else: @@ -98,19 +98,19 @@ func _apply_export_overrides() -> void: panel.add_theme_stylebox_override(&'panel', stylebox) ## PORTRAIT SETTINGS - var portrait_background_color : ColorRect = %PortraitBackgroundColor + var portrait_background_color: ColorRect = %PortraitBackgroundColor portrait_background_color.color = portrait_bg_modulate - + portrait_panel.get_parent().move_child(portrait_panel, portrait_position) ## NAME LABEL SETTINGS - var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel + var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel if name_label_use_global_size: name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_size) as int) else: name_label.add_theme_font_size_override(&"font_size", name_label_custom_size) - var name_label_font : String = name_label_customfont + var name_label_font: String = name_label_customfont if name_label_use_global_font and ResourceLoader.exists(get_global_setting(&'font', '') as String): name_label_font = get_global_setting(&'font', '') if !name_label_font.is_empty(): diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd index 3b38d5b3b..bd853aab0 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_TextInput/text_input_layer.gd @@ -5,7 +5,7 @@ extends DialogicLayoutLayer func _apply_export_overrides() -> void: - var layer_theme : Theme = get(&'theme') + var layer_theme: Theme = get(&'theme') if layer_theme == null: layer_theme = Theme.new() diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd index a59193ee2..c155de286 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble_layer.gd @@ -5,42 +5,42 @@ extends DialogicLayoutLayer @export_group("Main") @export_subgroup("Text") -@export var text_size : int = 15 +@export var text_size: int = 15 @export var text_color: Color = Color.BLACK @export_file('*.ttf') var normal_font: String = "" @export_file('*.ttf') var bold_font: String = "" @export_file('*.ttf') var italic_font: String = "" @export_file('*.ttf') var bold_italic_font: String = "" -@export var text_max_width : int = 300 +@export var text_max_width: int = 300 @export_subgroup('Box') -@export var box_modulate : Color = Color.WHITE -@export var box_modulate_by_character_color : bool = false -@export var box_padding : Vector2 = Vector2(10,10) -@export_range(0.1, 2) var box_corner_radius : float = 0.3 -@export_range(0.1, 5) var box_wobble_speed : float= 1 -@export_range(0, 1) var box_wobbliness : float = 0.2 +@export var box_modulate: Color = Color.WHITE +@export var box_modulate_by_character_color: bool = false +@export var box_padding: Vector2 = Vector2(10,10) +@export_range(0.1, 2) var box_corner_radius: float = 0.3 +@export_range(0.1, 5) var box_wobble_speed: float= 1 +@export_range(0, 1) var box_wobbliness: float = 0.2 @export_subgroup('Behaviour') -@export var behaviour_distance : int = 50 -@export var behaviour_direction : Vector2 = Vector2(1, -1) +@export var behaviour_distance: int = 50 +@export var behaviour_direction: Vector2 = Vector2(1, -1) @export_group('Name Label & Choices') @export_subgroup("Name Label") -@export var name_label_enabled : bool = true -@export var name_label_font_size : int = 15 +@export var name_label_enabled: bool = true +@export var name_label_font_size: int = 15 @export_file('*.ttf') var name_label_font: String = "" -@export var name_label_use_character_color : bool = true -@export var name_label_color : Color = Color.BLACK -@export var name_label_box_modulate : Color = Color.WHITE -@export var name_label_padding : Vector2 = Vector2(5,0) -@export var name_label_offset : Vector2 = Vector2(0,0) +@export var name_label_use_character_color: bool = true +@export var name_label_color: Color = Color.BLACK +@export var name_label_box_modulate: Color = Color.WHITE +@export var name_label_padding: Vector2 = Vector2(5,0) +@export var name_label_offset: Vector2 = Vector2(0,0) @export_subgroup('Choices Text') -@export var choices_text_size : int = 15 -@export var choices_text_color : Color = Color.LIGHT_SLATE_GRAY -@export var choices_text_color_hover : Color = Color.DARK_GRAY -@export var choices_text_color_focus : Color = Color.BLACK +@export var choices_text_size: int = 15 +@export var choices_text_color: Color = Color.LIGHT_SLATE_GRAY +@export var choices_text_color_hover: Color = Color.DARK_GRAY +@export var choices_text_color_focus: Color = Color.BLACK var bubbles: Array[DialogicNode_TextBubble] = [] @@ -61,7 +61,7 @@ func add_bubble() -> DialogicNode_TextBubble: ## Called by dialogic whenever export overrides might change func _apply_export_overrides() -> void: - for bubble : DialogicNode_TextBubble in bubbles: + for bubble: DialogicNode_TextBubble in bubbles: bubble_apply_overrides(bubble) if fallback_bubble: @@ -70,7 +70,7 @@ func _apply_export_overrides() -> void: func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## TEXT FONT AND COLOR - var rtl : RichTextLabel = bubble.get_dialog_text() + var rtl: RichTextLabel = bubble.get_dialog_text() rtl.add_theme_font_size_override(&'normal_font', text_size) rtl.add_theme_font_size_override(&"normal_font_size", text_size) rtl.add_theme_font_size_override(&"bold_font_size", text_size) @@ -91,9 +91,9 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## BOX & TAIL COLOR - var tail : Line2D = bubble.get_tail() - var background : Control = bubble.get_bubble() - var bubble_material : ShaderMaterial = background.get(&'material') + var tail: Line2D = bubble.get_tail() + var background: Control = bubble.get_bubble() + var bubble_material: ShaderMaterial = background.get(&'material') tail.default_color = box_modulate background.set(&'color', box_modulate) @@ -106,7 +106,7 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: bubble.padding = box_padding ## NAME LABEL SETTINGS - var nl : DialogicNode_NameLabel = bubble.get_name_label() + var nl: DialogicNode_NameLabel = bubble.get_name_label() nl.add_theme_font_size_override(&"font_size", name_label_font_size) if !name_label_font.is_empty(): @@ -116,7 +116,7 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: if !nl.use_character_color: nl.add_theme_color_override(&"font_color", name_label_color) - var nlp : PanelContainer = bubble.get_name_label_panel() + var nlp: PanelContainer = bubble.get_name_label_panel() nlp.self_modulate = name_label_box_modulate nlp.get_theme_stylebox(&'panel').content_margin_left = name_label_padding.x nlp.get_theme_stylebox(&'panel').content_margin_right = name_label_padding.x @@ -129,7 +129,7 @@ func bubble_apply_overrides(bubble:DialogicNode_TextBubble) -> void: ## CHOICE SETTINGS - var choice_theme : Theme = Theme.new() + var choice_theme: Theme = Theme.new() choice_theme.set_font_size(&'font_size', &'Button', choices_text_size) choice_theme.set_color(&'font_color', &'Button', choices_text_color) choice_theme.set_color(&'font_pressed_color', &'Button', choices_text_color) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index 866e9094c..722fd136e 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -6,37 +6,37 @@ extends DialogicLayoutLayer @export_group("Text") @export_subgroup('Font') -@export var font_use_global : bool = true -@export_file('*.ttf') var font_custom : String = "" +@export var font_use_global: bool = true +@export_file('*.ttf') var font_custom: String = "" @export_subgroup('Size') -@export var font_size_use_global : bool = true -@export var font_size_custom : int = 16 +@export var font_size_use_global: bool = true +@export var font_size_custom: int = 16 @export_subgroup('Color') -@export var text_color_use_global : bool = true -@export var text_color_custom : Color = Color.WHITE -@export var text_color_pressed : Color = Color.WHITE -@export var text_color_hovered : Color = Color.GRAY -@export var text_color_disabled : Color = Color.DARK_GRAY -@export var text_color_focused : Color = Color.WHITE +@export var text_color_use_global: bool = true +@export var text_color_custom: Color = Color.WHITE +@export var text_color_pressed: Color = Color.WHITE +@export var text_color_hovered: Color = Color.GRAY +@export var text_color_disabled: Color = Color.DARK_GRAY +@export var text_color_focused: Color = Color.WHITE @export_group('Boxes') @export_subgroup('Panels') -@export_file('*.tres') var boxes_stylebox_normal : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_normal.tres" -@export_file('*.tres') var boxes_stylebox_hovered : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_hover.tres" -@export_file('*.tres') var boxes_stylebox_pressed : String = "" -@export_file('*.tres') var boxes_stylebox_disabled : String = "" -@export_file('*.tres') var boxes_stylebox_focused : String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_focus.tres" +@export_file('*.tres') var boxes_stylebox_normal: String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_normal.tres" +@export_file('*.tres') var boxes_stylebox_hovered: String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_hover.tres" +@export_file('*.tres') var boxes_stylebox_pressed: String = "" +@export_file('*.tres') var boxes_stylebox_disabled: String = "" +@export_file('*.tres') var boxes_stylebox_focused: String = "res://addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/choice_panel_focus.tres" @export_subgroup('Modulate') @export_subgroup('Size & Position') -@export var boxes_v_separation : int = 10 -@export var boxes_fill_width : bool = true -@export var boxes_min_size : Vector2 = Vector2() +@export var boxes_v_separation: int = 10 +@export var boxes_fill_width: bool = true +@export var boxes_min_size: Vector2 = Vector2() @export_group('Sounds') -@export_range(-80, 24, 0.01) var sounds_volume : float = -10 -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_pressed : String = "res://addons/dialogic/Example Assets/sound-effects/typing1.wav" -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_hover : String = "res://addons/dialogic/Example Assets/sound-effects/typing2.wav" -@export_file("*.wav", "*.ogg", "*.mp3") var sounds_focus : String = "res://addons/dialogic/Example Assets/sound-effects/typing4.wav" +@export_range(-80, 24, 0.01) var sounds_volume: float = -10 +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_pressed: String = "res://addons/dialogic/Example Assets/sound-effects/typing1.wav" +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_hover: String = "res://addons/dialogic/Example Assets/sound-effects/typing2.wav" +@export_file("*.wav", "*.ogg", "*.mp3") var sounds_focus: String = "res://addons/dialogic/Example Assets/sound-effects/typing4.wav" func get_choices() -> VBoxContainer: return $Choices @@ -45,8 +45,8 @@ func get_choices() -> VBoxContainer: func get_button_sound() -> DialogicNode_ButtonSound: return %DialogicNode_ButtonSound -@onready var choices : VBoxContainer = $Choices -@onready var button_sound : DialogicNode_ButtonSound = %DialogicNode_ButtonSound +@onready var choices: VBoxContainer = $Choices +@onready var button_sound: DialogicNode_ButtonSound = %DialogicNode_ButtonSound ## Method that applies all exported settings func _apply_export_overrides() -> void: @@ -99,10 +99,10 @@ func _apply_export_overrides() -> void: get_choices().add_theme_constant_override(&"separation", boxes_v_separation) - for child : Node in get_choices().get_children(): + for child: Node in get_choices().get_children(): if not child is DialogicNode_ChoiceButton: continue - var choice : DialogicNode_ChoiceButton = child as DialogicNode_ChoiceButton + var choice: DialogicNode_ChoiceButton = child as DialogicNode_ChoiceButton if boxes_fill_width: choice.size_flags_horizontal = Control.SIZE_FILL @@ -114,7 +114,7 @@ func _apply_export_overrides() -> void: set(&'theme', layer_theme) # apply sound settings - var button_sound : DialogicNode_ButtonSound = get_button_sound() + var button_sound: DialogicNode_ButtonSound = get_button_sound() button_sound.volume_db = sounds_volume button_sound.sound_pressed = load(sounds_pressed) button_sound.sound_hover = load(sounds_hover) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd index dfc880318..4844cc85b 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Portraits/vn_portrait_layer.gd @@ -4,12 +4,12 @@ extends DialogicLayoutLayer ## A layer that allows showing 5 portraits, like in a visual novel. ## The canvas layer that the portraits are on. -@export var portrait_size_mode : DialogicNode_PortraitContainer.SizeModes = DialogicNode_PortraitContainer.SizeModes.FIT_SCALE_HEIGHT +@export var portrait_size_mode: DialogicNode_PortraitContainer.SizeModes = DialogicNode_PortraitContainer.SizeModes.FIT_SCALE_HEIGHT func _apply_export_overrides() -> void: # apply portrait size - for child : DialogicNode_PortraitContainer in %Portraits.get_children(): + for child: DialogicNode_PortraitContainer in %Portraits.get_children(): child.size_mode = portrait_size_mode child.update_portrait_transforms() diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd index 451954693..8dcb73a2f 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/vn_textbox_layer.gd @@ -20,16 +20,16 @@ enum AnimationsNewText {NONE, WIGGLE} @export_group("Text") @export_subgroup("Alignment & Size") -@export var text_alignment :Alignments= Alignments.LEFT -@export var text_use_global_size : bool = true -@export var text_size : int = 15 +@export var text_alignment: Alignments= Alignments.LEFT +@export var text_use_global_size: bool = true +@export var text_size: int = 15 @export_subgroup("Color") -@export var text_use_global_color : bool = true -@export var text_custom_color : Color = Color.WHITE +@export var text_use_global_color: bool = true +@export var text_custom_color: Color = Color.WHITE @export_subgroup('Font') -@export var text_use_global_font : bool = true +@export var text_use_global_font: bool = true @export_file('*.ttf') var normal_font:String = "" @export_file('*.ttf') var bold_font:String = "" @export_file('*.ttf') var italic_font:String = "" @@ -37,60 +37,60 @@ enum AnimationsNewText {NONE, WIGGLE} @export_group("Box") @export_subgroup("Panel") -@export_file("*.tres") var box_panel : String = this_folder.path_join("vn_textbox_default_panel.tres") +@export_file("*.tres") var box_panel: String = this_folder.path_join("vn_textbox_default_panel.tres") @export_subgroup("Color") -@export var box_color_use_global : bool = true -@export var box_color_custom : Color = Color.BLACK +@export var box_color_use_global: bool = true +@export var box_color_custom: Color = Color.BLACK @export_subgroup("Size & Position") -@export var box_size : Vector2 = Vector2(550, 110) -@export var box_margin_bottom : int = 15 +@export var box_size: Vector2 = Vector2(550, 110) +@export var box_margin_bottom: int = 15 @export_subgroup("Animation") -@export var box_animation_in : AnimationsIn = AnimationsIn.FADE_UP -@export var box_animation_out : AnimationsOut = AnimationsOut.FADE_DOWN -@export var box_animation_new_text : AnimationsNewText = AnimationsNewText.NONE +@export var box_animation_in: AnimationsIn = AnimationsIn.FADE_UP +@export var box_animation_out: AnimationsOut = AnimationsOut.FADE_DOWN +@export var box_animation_new_text: AnimationsNewText = AnimationsNewText.NONE @export_group("Name Label") @export_subgroup('Color') -@export var name_label_use_global_color : bool= true -@export var name_label_use_character_color : bool = true -@export var name_label_custom_color : Color = Color.WHITE +@export var name_label_use_global_color: bool= true +@export var name_label_use_character_color: bool = true +@export var name_label_custom_color: Color = Color.WHITE @export_subgroup('Font') -@export var name_label_use_global_font : bool = true -@export_file('*.ttf') var name_label_font : String = "" -@export var name_label_use_global_font_size : bool = true -@export var name_label_custom_font_size : int = 15 +@export var name_label_use_global_font: bool = true +@export_file('*.ttf') var name_label_font: String = "" +@export var name_label_use_global_font_size: bool = true +@export var name_label_custom_font_size: int = 15 @export_subgroup('Box') -@export_file("*.tres") var name_label_box_panel : String = this_folder.path_join("vn_textbox_name_label_panel.tres") -@export var name_label_box_use_global_color : bool = true -@export var name_label_box_modulate : Color = box_color_custom +@export_file("*.tres") var name_label_box_panel: String = this_folder.path_join("vn_textbox_name_label_panel.tres") +@export var name_label_box_use_global_color: bool = true +@export var name_label_box_modulate: Color = box_color_custom @export_subgroup('Alignment') -@export var name_label_alignment : Alignments = Alignments.LEFT -@export var name_label_box_offset : Vector2 = Vector2.ZERO +@export var name_label_alignment: Alignments = Alignments.LEFT +@export var name_label_box_offset: Vector2 = Vector2.ZERO @export_group("Indicators") @export_subgroup("Next Indicator") -@export var next_indicator_enabled : bool = true -@export var next_indicator_show_on_questions : bool = true -@export var next_indicator_show_on_autoadvance : bool = false -@export_enum('bounce', 'blink', 'none') var next_indicator_animation : int = 0 -@export_file("*.png","*.svg") var next_indicator_texture : String = '' -@export var next_indicator_size : Vector2 = Vector2(25,25) +@export var next_indicator_enabled: bool = true +@export var next_indicator_show_on_questions: bool = true +@export var next_indicator_show_on_autoadvance: bool = false +@export_enum('bounce', 'blink', 'none') var next_indicator_animation: int = 0 +@export_file("*.png","*.svg") var next_indicator_texture: String = '' +@export var next_indicator_size: Vector2 = Vector2(25,25) @export_subgroup("Autoadvance") -@export var autoadvance_progressbar : bool = true +@export var autoadvance_progressbar: bool = true @export_group('Sounds') @export_subgroup('Typing Sounds') -@export var typing_sounds_enabled : bool = true -@export var typing_sounds_mode : DialogicNode_TypeSounds.Modes = DialogicNode_TypeSounds.Modes.INTERRUPT -@export_dir var typing_sounds_sounds_folder : String = "res://addons/dialogic/Example Assets/sound-effects/" -@export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound : String = "" -@export_range(1, 999, 1) var typing_sounds_every_nths_character : int = 1 -@export_range(0.01, 4, 0.01) var typing_sounds_pitch : float = 1.0 -@export_range(0.0, 3.0) var typing_sounds_pitch_variance : float = 0.0 -@export_range(-80, 24, 0.01) var typing_sounds_volume : float = -10 -@export_range(0.0, 10) var typing_sounds_volume_variance : float = 0.0 -@export var typing_sounds_ignore_characters : String = " .,!?" +@export var typing_sounds_enabled: bool = true +@export var typing_sounds_mode: DialogicNode_TypeSounds.Modes = DialogicNode_TypeSounds.Modes.INTERRUPT +@export_dir var typing_sounds_sounds_folder: String = "res://addons/dialogic/Example Assets/sound-effects/" +@export_file("*.wav", "*.ogg", "*.mp3") var typing_sounds_end_sound: String = "" +@export_range(1, 999, 1) var typing_sounds_every_nths_character: int = 1 +@export_range(0.01, 4, 0.01) var typing_sounds_pitch: float = 1.0 +@export_range(0.0, 3.0) var typing_sounds_pitch_variance: float = 0.0 +@export_range(-80, 24, 0.01) var typing_sounds_volume: float = -10 +@export_range(0.0, 10) var typing_sounds_volume_variance: float = 0.0 +@export var typing_sounds_ignore_characters: String = " .,!?" func _apply_export_overrides() -> void: @@ -98,7 +98,7 @@ func _apply_export_overrides() -> void: await ready ## FONT SETTINGS - var dialog_text : DialogicNode_DialogText = %DialogicNode_DialogText + var dialog_text: DialogicNode_DialogText = %DialogicNode_DialogText dialog_text.alignment = text_alignment as DialogicNode_DialogText.Alignment if text_use_global_size: @@ -125,7 +125,7 @@ func _apply_export_overrides() -> void: dialog_text.add_theme_font_override(&"bold_italics_font", load(bold_italic_font) as Font) ## BOX SETTINGS - var dialog_text_panel : PanelContainer = %DialogTextPanel + var dialog_text_panel: PanelContainer = %DialogTextPanel if ResourceLoader.exists(box_panel): dialog_text_panel.add_theme_stylebox_override(&'panel', load(box_panel) as StyleBox) @@ -134,25 +134,18 @@ func _apply_export_overrides() -> void: else: dialog_text_panel.self_modulate = box_color_custom - #dialog_text_panel.hide() - #%Minimizer.size = Vector2.ZERO - #%Minimizer.position = Vector2(0, -box_margin_bottom) - #%Minimizer.grow_vertical = Container.GROW_DIRECTION_BEGIN - #dialog_text_panel.custom_minimum_size = box_size - #dialog_text_panel.show() - var sizer : Control = %Sizer + var sizer: Control = %Sizer sizer.size = box_size sizer.position = box_size * Vector2(-0.5, -1)+Vector2(0, -box_margin_bottom) - ## BOX ANIMATIONS - var animations : AnimationPlayer = %Animations + var animations: AnimationPlayer = %Animations animations.set(&'animation_in', box_animation_in) animations.set(&'animation_out', box_animation_out) animations.set(&'animation_new_text', box_animation_new_text) ## NAME LABEL SETTINGS - var name_label : DialogicNode_NameLabel = %DialogicNode_NameLabel + var name_label: DialogicNode_NameLabel = %DialogicNode_NameLabel if name_label_use_global_font_size: name_label.add_theme_font_size_override(&"font_size", get_global_setting(&'font_size', name_label_custom_font_size) as int) else: @@ -170,7 +163,7 @@ func _apply_export_overrides() -> void: name_label.use_character_color = name_label_use_character_color - var name_label_panel : PanelContainer = %NameLabelPanel + var name_label_panel: PanelContainer = %NameLabelPanel if ResourceLoader.exists(name_label_box_panel): name_label_panel.add_theme_stylebox_override(&'panel', load(name_label_box_panel) as StyleBox) else: @@ -190,7 +183,7 @@ func _apply_export_overrides() -> void: name_label_panel.grow_horizontal = [1, 2, 0][name_label_alignment] ## NEXT INDICATOR SETTINGS - var next_indicator : DNextIndicator = %NextIndicator + var next_indicator: DNextIndicator = %NextIndicator next_indicator.enabled = next_indicator_enabled if next_indicator_enabled: @@ -202,13 +195,13 @@ func _apply_export_overrides() -> void: next_indicator.texture_size = next_indicator_size ## OTHER - var progress_bar : ProgressBar = %AutoAdvanceProgressbar + var progress_bar: ProgressBar = %AutoAdvanceProgressbar progress_bar.set(&'enabled', autoadvance_progressbar) #### SOUNDS ## TYPING SOUNDS - var type_sounds : DialogicNode_TypeSounds = %DialogicNode_TypeSounds + var type_sounds: DialogicNode_TypeSounds = %DialogicNode_TypeSounds type_sounds.enabled = typing_sounds_enabled type_sounds.mode = typing_sounds_mode if not typing_sounds_sounds_folder.is_empty(): From 9727cbb403129013d70d14dcfe8f50073cf6a49e Mon Sep 17 00:00:00 2001 From: nlupugla Date: Tue, 9 Jan 2024 12:41:58 -0500 Subject: [PATCH 11/12] Reverted changes to dialogic nodes and applied some misc static type fixes --- .../Character/node_portrait_container.gd | 26 ++++---- .../Layer_Glossary/glossary_popup_layer.gd | 12 ++-- .../Layer_History/history_layer.gd | 6 +- .../Layer_VN_Choices/vn_choice_layer.gd | 2 - .../Layer_VN_Textbox/animations.gd | 16 ++--- .../Layer_VN_Textbox/autoadvance_indicator.gd | 3 +- .../dialogic/Modules/Text/node_dialog_text.gd | 18 +++--- .../dialogic/Modules/Text/node_name_label.gd | 13 ++-- .../Modules/Text/node_next_indicator.gd | 41 +++++++------ .../dialogic/Modules/Text/node_type_sound.gd | 60 +++++++++---------- .../Resources/dialogic_layout_base.gd | 18 +++--- .../Resources/dialogic_layout_layer.gd | 12 ++-- 12 files changed, 113 insertions(+), 114 deletions(-) diff --git a/addons/dialogic/Modules/Character/node_portrait_container.gd b/addons/dialogic/Modules/Character/node_portrait_container.gd index 89c085949..9a2307f36 100644 --- a/addons/dialogic/Modules/Character/node_portrait_container.gd +++ b/addons/dialogic/Modules/Character/node_portrait_container.gd @@ -9,17 +9,17 @@ enum PositionModes { SPEAKER, ## This container has no index and is joined/left automatically based on the speaker. } -@export var mode : PositionModes = PositionModes.POSITION +@export var mode := PositionModes.POSITION @export_subgroup('Mode: Position') ## The position this node corresponds to. -@export var position_index : int = 0 +@export var position_index := 0 @export_subgroup('Mode: Speaker') ## Can be used to use a different portrait. ## E.g. "Faces/" would mean instead of "happy" it will use portrait "Faces/happy" -@export var portrait_prefix : String = '' +@export var portrait_prefix := '' @export_subgroup('Portrait Placement') enum SizeModes {KEEP, FIT_STRETCH, FIT_IGNORE_SCALE, FIT_SCALE_HEIGHT} @@ -30,7 +30,7 @@ enum SizeModes {KEEP, FIT_STRETCH, FIT_IGNORE_SCALE, FIT_SCALE_HEIGHT} _update_debug_portrait_size_position() ## If true, portraits will be mirrored in this position. -@export var mirrored : bool = false : +@export var mirrored := false : set(mirror): mirrored = mirror _update_debug_portrait_scene() @@ -45,7 +45,7 @@ enum OriginAnchors {TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_MIDDLE, CENTER, RIGHT_ _update_debug_origin() ## An offset to apply to the origin. Rarely useful. -@export var origin_offset : Vector2 = Vector2() : +@export var origin_offset := Vector2() : set(offset): origin_offset = offset _update_debug_origin() @@ -65,12 +65,12 @@ enum OriginAnchors {TOP_LEFT, TOP_CENTER, TOP_RIGHT, LEFT_MIDDLE, CENTER, RIGHT_ var debug_character_holder_node :Node2D = null var debug_character_scene_node : Node = null var debug_origin : Sprite2D = null -var default_portrait_scene : String = DialogicUtil.get_module_path('Character').path_join("default_portrait.tscn") +var default_portrait_scene :String = DialogicUtil.get_module_path('Character').path_join("default_portrait.tscn") # Used if no debug character is specified -var default_debug_character : Resource = load(DialogicUtil.get_module_path('Character').path_join("preview_character.tres")) +var default_debug_character := load(DialogicUtil.get_module_path('Character').path_join("preview_character.tres")) -func _ready() -> void: +func _ready(): match mode: PositionModes.POSITION: add_to_group('dialogic_portrait_con_position') @@ -80,7 +80,7 @@ func _ready() -> void: if Engine.is_editor_hint(): resized.connect(_update_debug_origin) - if ProjectSettings.get_setting('dialogic/portraits/default_portrait', '') != "": + if !ProjectSettings.get_setting('dialogic/portraits/default_portrait', '').is_empty(): default_portrait_scene = ProjectSettings.get_setting('dialogic/portraits/default_portrait', '') debug_origin = Sprite2D.new() @@ -97,13 +97,13 @@ func _ready() -> void: ## MAIN METHODS ################################################################################ -func update_portrait_transforms() -> void: - for child : Node in get_children(): +func update_portrait_transforms(): + for child in get_children(): DialogicUtil.autoload().Portraits._update_portrait_transform(child) ## Returns a Rect2 with the position as the position and the scale as the size. -func get_local_portrait_transform(portrait_rect:Rect2, character_scale: float =1.0) -> Rect2: - var transform : Rect2 = Rect2() +func get_local_portrait_transform(portrait_rect:Rect2, character_scale:=1.0) -> Rect2: + var transform := Rect2() transform.position = _get_origin_position() # Mode that ignores the containers size diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 1c4799eaa..4d5d5a98f 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -78,7 +78,8 @@ func _ready() -> void: ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var info: Dictionary = DialogicUtil.autoload().get(&'Glossary').call(&'get_entry', meta) + var glossary_system: Node = DialogicUtil.autoload().get(&'Glossary') + var info: Dictionary = glossary_system.call(&'get_entry', meta) if not info: return @@ -103,7 +104,8 @@ func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: get_panel().self_modulate = info.get(&'color', Color.WHITE) get_panel_point().self_modulate = info.get(&'color', Color.WHITE) - DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', true) + var input_system: Node = DialogicUtil.autoload().get(&'Input') + input_system.set(&'action_was_consumed', true) ## Method that keeps the bubble at mouse position when visible @@ -119,11 +121,13 @@ func _process(_delta : float) -> void: ## Method that hides the bubble func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: get_pointer().hide() - DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', false) + var input_system: Node = DialogicUtil.autoload().get(&'Input') + input_system.set(&'action_was_consumed', false) func _on_dialogic_display_dialog_text_meta_clicked(_meta:String) -> void: - DialogicUtil.autoload().get(&'Input').set(&'action_was_consume', true) + var input_system: Node = DialogicUtil.autoload().get(&'Input') + input_system.set(&'action_was_consumed', true) func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd index 4febcc707..98170a0fe 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_History/history_layer.gd @@ -99,7 +99,8 @@ func show_history() -> void: for child: Node in get_history_log().get_children(): child.queue_free() - for info: Dictionary in DialogicUtil.autoload().get(&'History').call(&'get_simple_history'): + var history_subsystem: Node = DialogicUtil.autoload().get(&'History') + for info: Dictionary in history_subsystem.call(&'get_simple_history'): var history_item : Node = HistoryItem.instantiate() history_item.set(&'theme', history_item_theme) match info.event_type: @@ -144,4 +145,5 @@ func _on_hide_history_pressed() -> void: DialogicUtil.autoload().paused = false get_history_box().hide() get_hide_history_button().hide() - get_show_history_button().visible = show_open_button and DialogicUtil.autoload().get(&'History').get(&'simple_history_enabled') + var history_subsystem: Node = DialogicUtil.autoload().get(&'History') + get_show_history_button().visible = show_open_button and history_subsystem.get(&'simple_history_enabled') diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd index 722fd136e..7430824d2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Choices/vn_choice_layer.gd @@ -45,8 +45,6 @@ func get_choices() -> VBoxContainer: func get_button_sound() -> DialogicNode_ButtonSound: return %DialogicNode_ButtonSound -@onready var choices: VBoxContainer = $Choices -@onready var button_sound: DialogicNode_ButtonSound = %DialogicNode_ButtonSound ## Method that applies all exported settings func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index c2b1916ab..9c5cf1b43 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -43,8 +43,8 @@ func _on_textbox_show() -> void: play("textbox_pop") AnimationsIn.FADE_UP: play("textbox_fade_up") - if not animation_finished.is_connected(animation_system.animation_finished): - var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) + if not is_connected(&'animation_finished', Callable(animation_system, &'animation_finished')): + var _error : int = connect(&'animation_finished', Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) func _on_textbox_hide() -> void: @@ -59,8 +59,8 @@ func _on_textbox_hide() -> void: AnimationsOut.FADE_DOWN: play_backwards("textbox_fade_up") - if not animation_finished.is_connected(animation_system.animation_finished): - var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) + if not is_connected(&'animation_finished', Callable(animation_system, &'animation_finished')): + var _error : int = connect(&'animation_finished', Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) func _on_about_to_show_text(info:Dictionary) -> void: @@ -68,7 +68,9 @@ func _on_about_to_show_text(info:Dictionary) -> void: func _on_textbox_new_text() -> void: - if DialogicUtil.autoload().get(&'Input').get(&'auto_skip').get(&'enabled'): + var input_system: Node = DialogicUtil.autoload().get(&'Input') + var auto_skip: DialogicAutoAdvance = input_system.get(&'auto_skip') + if auto_skip.get(&'enabled'): return if animation_new_text == AnimationsNewText.NONE: @@ -82,5 +84,5 @@ func _on_textbox_new_text() -> void: AnimationsNewText.WIGGLE: play("new_text") - if not animation_finished.is_connected(animation_system.animation_finished): - var _error : int = animation_finished.connect(animation_system.animation_finished, CONNECT_ONE_SHOT) + if not is_connected(&'animation_finished', Callable(animation_system, &'animation_finished')): + var _error : int = connect(&'animation_finished', Callable(animation_system, &'animation_finished'), CONNECT_ONE_SHOT) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd index ca7dc1ae7..d9fe259fb 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd @@ -6,7 +6,8 @@ func _process(_delta : float) -> void: if !enabled: hide() return - var auto_advance : DialogicAutoAdvance = DialogicUtil.autoload().get(&'Input').get(&'auto_advance') + var input_system : Node = DialogicUtil.autoload().get(&'Input') + var auto_advance : DialogicAutoAdvance = input_system.get(&'auto_advance') if auto_advance.get_progress() < 0: hide() else: diff --git a/addons/dialogic/Modules/Text/node_dialog_text.gd b/addons/dialogic/Modules/Text/node_dialog_text.gd index 71442bf9c..047a78f6e 100644 --- a/addons/dialogic/Modules/Text/node_dialog_text.gd +++ b/addons/dialogic/Modules/Text/node_dialog_text.gd @@ -8,21 +8,21 @@ signal continued_revealing_text(new_character : String) signal finished_revealing_text() enum Alignment {LEFT, CENTER, RIGHT} -@export var enabled : bool = true -@export var alignment : Alignment = Alignment.LEFT -@export var textbox_root : CanvasItem = self +@export var enabled := true +@export var alignment := Alignment.LEFT +@export var textbox_root : Node = self -@export var hide_when_empty : bool = false -@export var start_hidden : bool = true +@export var hide_when_empty := false +@export var start_hidden := true -var revealing : bool = false -var base_visible_characters : int = 0 +var revealing := false +var base_visible_characters := 0 # time per character var lspeed:float = 0.01 var speed_counter:float = 0 -func _set(property : StringName, what : Variant) -> bool: +func _set(property:StringName, what:Variant) -> bool: if property == &'text' and typeof(what) == TYPE_STRING: text = what if hide_when_empty: @@ -45,7 +45,7 @@ func _ready() -> void: # this is called by the DialogicGameHandler to set text -func reveal_text(_text:String, keep_previous: bool =false) -> void: +func reveal_text(_text:String, keep_previous:bool=false) -> void: if !enabled: return show() diff --git a/addons/dialogic/Modules/Text/node_name_label.gd b/addons/dialogic/Modules/Text/node_name_label.gd index c6c75f4b2..86ae58966 100644 --- a/addons/dialogic/Modules/Text/node_name_label.gd +++ b/addons/dialogic/Modules/Text/node_name_label.gd @@ -3,22 +3,21 @@ extends Label class_name DialogicNode_NameLabel # If true, the label will be hidden if no character speaks. -@export var hide_when_empty : bool = true -@export var name_label_root : CanvasItem = self -@export var use_character_color : bool = true +@export var hide_when_empty := true +@export var name_label_root :Node = self +@export var use_character_color := true -func _ready() -> void: +func _ready(): add_to_group('dialogic_name_label') if hide_when_empty: name_label_root.visible = false text = "" -func _set(property : StringName, what : Variant) -> bool: +func _set(property, what): if property == 'text' and typeof(what) == TYPE_STRING: text = what if hide_when_empty: - name_label_root.visible = !text.is_empty() + name_label_root.visible = !what.is_empty() else: name_label_root.show() return true - return false diff --git a/addons/dialogic/Modules/Text/node_next_indicator.gd b/addons/dialogic/Modules/Text/node_next_indicator.gd index fb29cd8fa..9f7a7fcc4 100644 --- a/addons/dialogic/Modules/Text/node_next_indicator.gd +++ b/addons/dialogic/Modules/Text/node_next_indicator.gd @@ -5,41 +5,40 @@ extends Control ## Node that is shown when the text is fully revealed. ## The default implementation allows to set an icon and animation. -const TEXTURE : String = 'Texture' -@export var enabled : bool = true +@export var enabled := true ## If true the next indicator will also be shown if the text is a question. -@export var show_on_questions : bool = false +@export var show_on_questions := false ## If true the next indicator will be shown even if dialogic will autocontinue. -@export var show_on_autoadvance : bool = false +@export var show_on_autoadvance := false ## What animation should the indicator do. -@export_enum('bounce', 'blink', 'none') var animation : int = 0 +@export_enum('bounce', 'blink', 'none') var animation := 0 ## Set the image to use as the indicator. -@export var texture : Texture = preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png"): +@export var texture := preload("res://addons/dialogic/Example Assets/next-indicator/next-indicator.png"): set(_texture): texture = _texture - if has_node(TEXTURE): - get_node(TEXTURE).set(&'texture', texture) + if has_node('Texture'): + get_node('Texture').texture = texture -@export var texture_size : Vector2 = Vector2(32,32): +@export var texture_size := Vector2(32,32): set(_texture_size): texture_size = _texture_size - if has_node(TEXTURE): - get_node(TEXTURE).set(&'size', _texture_size) - get_node(TEXTURE).set(&'position', -_texture_size) + if has_node('Texture'): + get_node('Texture').size = _texture_size + get_node('Texture').position = -_texture_size var tween: Tween -func _ready() -> void: +func _ready(): add_to_group('dialogic_next_indicator') # Creating texture if texture: - var icon : TextureRect = TextureRect.new() - icon.name = TEXTURE - icon.expand_mode = TextureRect.EXPAND_IGNORE_SIZE + var icon := TextureRect.new() + icon.name = 'Texture' + icon.ignore_texture_size = true icon.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED icon.size = texture_size icon.position = -icon.size @@ -50,19 +49,19 @@ func _ready() -> void: visibility_changed.connect(_on_visibility_changed) -func _on_visibility_changed() -> void: +func _on_visibility_changed(): if visible: play_animation(animation, 1.0) -func play_animation(anim: int, time: float) -> void: +func play_animation(animation: int, time:float) -> void: # clean up previous tween to prevent slipping if tween: tween.stop() - if anim == 0: + if animation == 0: tween = (create_tween() as Tween) - var distance : int = 4 + var distance := 4 tween.set_parallel(false) tween.set_trans(Tween.TRANS_SINE) tween.set_ease(Tween.EASE_IN_OUT) @@ -70,7 +69,7 @@ func play_animation(anim: int, time: float) -> void: tween.tween_property(self, 'position', Vector2(0,distance), time*0.3).as_relative() tween.tween_property(self, 'position', - Vector2(0,distance), time*0.3).as_relative() - if anim == 1: + if animation == 1: tween = (create_tween() as Tween) tween.set_parallel(false) tween.set_trans(Tween.TRANS_SINE) diff --git a/addons/dialogic/Modules/Text/node_type_sound.gd b/addons/dialogic/Modules/Text/node_type_sound.gd index 0f01e025c..ada86fffb 100644 --- a/addons/dialogic/Modules/Text/node_type_sound.gd +++ b/addons/dialogic/Modules/Text/node_type_sound.gd @@ -6,54 +6,48 @@ extends AudioStreamPlayer ## Should be the child of a DialogicNode_DialogText node! ## Usefull if you want to change the sounds of different node's sounds -@export var enabled : bool = true +@export var enabled := true enum Modes {INTERRUPT, OVERLAP, AWAIT} ## If true, interrupts the current sound to play a new one -@export var mode : Modes = Modes.INTERRUPT +@export var mode := Modes.INTERRUPT ## Array of sounds. Will pick a random one each time. @export var sounds: Array[AudioStream] = [] ## A sound to be played as the last sound. @export var end_sound:AudioStream ## Determines how many characters are between each sound. Default is 1 for playing it every character. -@export var play_every_character : int = 1 +@export var play_every_character := 1 ## Allows changing the pitch by a random value from (pitch - pitch_variance) to (pitch + pitch_variance) -@export_range(0, 3, 0.01) var pitch_variance : float = 0.0 +@export_range(0, 3, 0.01) var pitch_variance := 0.0 ## Allows changing the volume by a random value from (volume - volume_variance) to (volume + volume_variance) -@export_range(0, 10, 0.01) var volume_variance : float = 0.0 +@export_range(0, 10, 0.01) var volume_variance := 0.0 ## Characters that don't increase the 'characters_since_last_sound' variable, useful for the space or fullstop @export var ignore_characters:String = ' .,' var characters_since_last_sound: int = 0 var base_pitch :float = pitch_scale var base_volume :float = volume_db -var RNG : RandomNumberGenerator = RandomNumberGenerator.new() +var RNG := RandomNumberGenerator.new() -var current_overwrite_data : Dictionary = {} +var current_overwrite_data := {} -func _ready() -> void: +func _ready(): # add to necessary group add_to_group('dialogic_type_sounds') - if !Engine.is_editor_hint(): - var dialog_text : DialogicNode_DialogText = get_dialog_text() - if dialog_text: - dialog_text.started_revealing_text.connect(_on_started_revealing_text) - dialog_text.continued_revealing_text.connect(_on_continued_revealing_text) - dialog_text.finished_revealing_text.connect(_on_finished_revealing_text) - - -func get_dialog_text() -> DialogicNode_DialogText: - return get_parent() as DialogicNode_DialogText + if !Engine.is_editor_hint() and get_parent() is DialogicNode_DialogText: + get_parent().started_revealing_text.connect(_on_started_revealing_text) + get_parent().continued_revealing_text.connect(_on_continued_revealing_text) + get_parent().finished_revealing_text.connect(_on_finished_revealing_text) func _on_started_revealing_text() -> void: - if !enabled or (get_dialog_text() != null and !get_dialog_text().enabled): + if !enabled or (get_parent() is DialogicNode_DialogText and !get_parent().enabled): return characters_since_last_sound = current_overwrite_data.get('skip_characters', play_every_character-1)+1 func _on_continued_revealing_text(new_character:String) -> void: - if !enabled or (get_dialog_text() != null and !get_dialog_text().enabled): + if !enabled or (get_parent() is DialogicNode_DialogText and !get_parent().enabled): return # We don't want to play type sounds if Auto-Skip is enabled. @@ -61,16 +55,16 @@ func _on_continued_revealing_text(new_character:String) -> void: return # don't play if a voice-track is running - if !Engine.is_editor_hint() and get_dialog_text() != null: + if !Engine.is_editor_hint() and get_parent() is DialogicNode_DialogText: if DialogicUtil.autoload().has_subsystem("Voice") and DialogicUtil.autoload().Voice.is_running(): return # if sound playing and can't interrupt - if playing and current_overwrite_data.get(&'mode', mode) == Modes.AWAIT: + if playing and current_overwrite_data.get('mode', mode) == Modes.AWAIT: return # if no sounds were given - if current_overwrite_data.get(&'sounds', sounds).size() == 0: + if current_overwrite_data.get('sounds', sounds).size() == 0: return # if the new character is not allowed @@ -78,30 +72,30 @@ func _on_continued_revealing_text(new_character:String) -> void: return characters_since_last_sound += 1 - if characters_since_last_sound < current_overwrite_data.get(&'skip_characters', play_every_character-1)+1: + if characters_since_last_sound < current_overwrite_data.get('skip_characters', play_every_character-1)+1: return characters_since_last_sound = 0 var audio_player : AudioStreamPlayer = self - if current_overwrite_data.get(&'mode', mode) == Modes.OVERLAP: + if current_overwrite_data.get('mode', mode) == Modes.OVERLAP: audio_player = AudioStreamPlayer.new() audio_player.bus = bus add_child(audio_player) - elif current_overwrite_data.get(&'mode', mode) == Modes.INTERRUPT: + elif current_overwrite_data.get('mode', mode) == Modes.INTERRUPT: stop() #choose the random sound - audio_player.stream = current_overwrite_data.get(&'sounds', sounds)[RNG.randi_range(0, current_overwrite_data.get(&'sounds', sounds).size() - 1)] + audio_player.stream = current_overwrite_data.get('sounds', sounds)[RNG.randi_range(0, current_overwrite_data.get('sounds', sounds).size() - 1)] #choose a random pitch and volume - audio_player.pitch_scale = max(0, current_overwrite_data.get(&'pitch_base', base_pitch) + current_overwrite_data.get(&'pitch_variance', pitch_variance) * RNG.randf_range(-1.0, 1.0)) - audio_player.volume_db = current_overwrite_data.get(&'volume_base', base_volume) + current_overwrite_data.get(&'volume_variance',volume_variance) * RNG.randf_range(-1.0, 1.0) + audio_player.pitch_scale = max(0, current_overwrite_data.get('pitch_base', base_pitch) + current_overwrite_data.get('pitch_variance', pitch_variance) * RNG.randf_range(-1.0, 1.0)) + audio_player.volume_db = current_overwrite_data.get('volume_base', base_volume) + current_overwrite_data.get('volume_variance',volume_variance) * RNG.randf_range(-1.0, 1.0) #play the sound audio_player.play(0) - if current_overwrite_data.get(&'mode', mode) == Modes.OVERLAP: + if current_overwrite_data.get('mode', mode) == Modes.OVERLAP: audio_player.finished.connect(audio_player.queue_free) @@ -117,8 +111,8 @@ func _on_finished_revealing_text() -> void: func load_overwrite(dictionary:Dictionary) -> void: current_overwrite_data = dictionary - if dictionary.has(&'sound_path'): - current_overwrite_data[&'sounds'] = load_sounds_from_path(dictionary.sound_path) + if dictionary.has('sound_path'): + current_overwrite_data['sounds'] = load_sounds_from_path(dictionary.sound_path) static func load_sounds_from_path(path:String) -> Array[AudioStream]: @@ -135,7 +129,7 @@ static func load_sounds_from_path(path:String) -> Array[AudioStream]: ############# USER INTERFACE ################################################### -func _get_configuration_warnings() -> PackedStringArray: +func _get_configuration_warnings(): if not get_parent() is DialogicNode_DialogText: return ["This should be the child of a DialogText node!"] return [] diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index 77cecfbe4..a346b494a 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -5,18 +5,18 @@ extends Node ## Base class that should be extended by custom layouts. -func add_layer(dialogic_layer:DialogicLayoutLayer) -> DialogicLayoutLayer: - add_child(dialogic_layer) - return dialogic_layer +func add_layer(layer:DialogicLayoutLayer) -> Node: + add_child(layer) + return layer -func get_layer(index:int) -> DialogicLayoutLayer: +func get_layer(index:int) -> Node: return get_child(index) -func get_layers() -> Array[DialogicLayoutLayer]: - var layers : Array[DialogicLayoutLayer] = [] - for child : Node in get_children(): +func get_layers() -> Array: + var layers := [] + for child in get_children(): if child is DialogicLayoutLayer: layers.append(child) return layers @@ -24,9 +24,9 @@ func get_layers() -> Array[DialogicLayoutLayer]: func appply_export_overrides() -> void: _apply_export_overrides() - for child : Node in get_children(): + for child in get_children(): if child.has_method('_apply_export_overrides'): - child.call('_apply_export_overrides') + child._apply_export_overrides() func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Resources/dialogic_layout_layer.gd b/addons/dialogic/Resources/dialogic_layout_layer.gd index 7194ce0f9..cccae3a91 100644 --- a/addons/dialogic/Resources/dialogic_layout_layer.gd +++ b/addons/dialogic/Resources/dialogic_layout_layer.gd @@ -6,14 +6,14 @@ extends Node @export_group('Layer') @export_subgroup('Disabled') -@export var disabled : bool = false +@export var disabled := false ## This is turned on automatically when the layout is realized [br] [br] ## Turn it off, if you want to modify the settings of the nodes yourself. @export_group('Private') -@export var apply_overrides_on_ready : bool = false +@export var apply_overrides_on_ready := false -var this_folder: String = (get_script() as Resource).resource_path.get_base_dir() +var this_folder: String = get_script().resource_path.get_base_dir() func _ready() -> void: if apply_overrides_on_ready and not Engine.is_editor_hint(): @@ -29,11 +29,11 @@ func _apply_export_overrides() -> void: func apply_export_overrides() -> void: if disabled: if "visible" in self: - set(&'visible', false) + set('visible', false) process_mode = Node.PROCESS_MODE_DISABLED else: if "visible" in self: - set(&'visible', true) + set('visible', true) process_mode = Node.PROCESS_MODE_INHERIT _apply_export_overrides() @@ -41,4 +41,4 @@ func apply_export_overrides() -> void: ## Use this to get potential global settings. func get_global_setting(setting_name:StringName, default:Variant) -> Variant: - return (get_parent() as DialogicLayoutBase).get_global_setting(setting_name, default) + return get_parent().get_global_setting(setting_name, default) From f54738be616112c2130990b786adeffa7a4406bb Mon Sep 17 00:00:00 2001 From: nlupugla Date: Tue, 9 Jan 2024 13:48:40 -0500 Subject: [PATCH 12/12] Reverted some changes involving DialogicSubsystem. WARNING: this commit will raise GDScript errors until the subsystems get types. --- .../Layer_Glossary/glossary_popup_layer.gd | 12 ++++-------- .../Layer_VN_Textbox/animations.gd | 4 +--- .../Layer_VN_Textbox/autoadvance_indicator.gd | 6 ++---- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd index 4d5d5a98f..de9e4e265 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Glossary/glossary_popup_layer.gd @@ -78,8 +78,7 @@ func _ready() -> void: ## Method that shows the bubble and fills in the info func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: - var glossary_system: Node = DialogicUtil.autoload().get(&'Glossary') - var info: Dictionary = glossary_system.call(&'get_entry', meta) + var info: Dictionary = DialogicUtil.autoload().Glossary.get_entry(meta) if not info: return @@ -104,8 +103,7 @@ func _on_dialogic_display_dialog_text_meta_hover_started(meta:String) -> void: get_panel().self_modulate = info.get(&'color', Color.WHITE) get_panel_point().self_modulate = info.get(&'color', Color.WHITE) - var input_system: Node = DialogicUtil.autoload().get(&'Input') - input_system.set(&'action_was_consumed', true) + DialogicUtil.autoload().Input.action_was_consumed = true ## Method that keeps the bubble at mouse position when visible @@ -121,13 +119,11 @@ func _process(_delta : float) -> void: ## Method that hides the bubble func _on_dialogic_display_dialog_text_meta_hover_ended(_meta:String) -> void: get_pointer().hide() - var input_system: Node = DialogicUtil.autoload().get(&'Input') - input_system.set(&'action_was_consumed', false) + DialogicUtil.autoload().Input.action_was_consumed = false func _on_dialogic_display_dialog_text_meta_clicked(_meta:String) -> void: - var input_system: Node = DialogicUtil.autoload().get(&'Input') - input_system.set(&'action_was_consumed', true) + DialogicUtil.autoload().Input.action_was_consumed = true func _apply_export_overrides() -> void: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd index 9c5cf1b43..9ca0200b0 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/animations.gd @@ -68,9 +68,7 @@ func _on_about_to_show_text(info:Dictionary) -> void: func _on_textbox_new_text() -> void: - var input_system: Node = DialogicUtil.autoload().get(&'Input') - var auto_skip: DialogicAutoAdvance = input_system.get(&'auto_skip') - if auto_skip.get(&'enabled'): + if DialogicUtil.autoload().Input.auto_skip.enabled: return if animation_new_text == AnimationsNewText.NONE: diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd index d9fe259fb..aa702f4c2 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_VN_Textbox/autoadvance_indicator.gd @@ -6,10 +6,8 @@ func _process(_delta : float) -> void: if !enabled: hide() return - var input_system : Node = DialogicUtil.autoload().get(&'Input') - var auto_advance : DialogicAutoAdvance = input_system.get(&'auto_advance') - if auto_advance.get_progress() < 0: + if DialogicUtil.autoload().Input.auto_advance.get_progress() < 0: hide() else: show() - value = auto_advance.get_progress() + value = DialogicUtil.autoload().Input.auto_advance.get_progress()