diff --git a/addons/dialogic/Modules/Choice/subsystem_choices.gd b/addons/dialogic/Modules/Choice/subsystem_choices.gd index 8f0567fb8..615b82278 100644 --- a/addons/dialogic/Modules/Choice/subsystem_choices.gd +++ b/addons/dialogic/Modules/Choice/subsystem_choices.gd @@ -6,7 +6,7 @@ extends DialogicSubsystem signal choice_selected(info:Dictionary) ## Emitted when a set of choices is reached and shown. ## Info includes the keys 'choices' (an array of dictionaries with infos on all the choices). -signal choices_shown(info:Dictionary) +signal question_shown(info:Dictionary) ## Contains information on the latest question. var last_question_info := {} @@ -68,10 +68,6 @@ func hide_all_choices() -> void: node.disconnect('button_up', _on_choice_selected) - -func show_choices() -> void: - hide_all_choices() - ## Collects information on all the choices of the current question. ## The result is a dictionary like this: ## {'choices': @@ -182,7 +178,9 @@ func show_current_question(instant:=true) -> void: if node.pressed.is_connected(_on_choice_selected): node.pressed.disconnect(_on_choice_selected) node.pressed.connect(_on_choice_selected.bind(choice)) + _choice_blocker.start(block_delay) + question_shown.emit(question_info) if missing_button: printerr("[Dialogic] The layout you are using doesn't have enough Choice Buttons for the choices you are trying to display.") diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd b/addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd index 15f4b45c1..ed4707ab4 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Base_TextBubble/text_bubble_base.gd @@ -24,12 +24,32 @@ func _ready() -> void: add_bubble() -func register_character(character:DialogicCharacter, node:Node): +func register_character(character:Variant, node:Node): + if typeof(character) == TYPE_STRING: + var character_string: String = character + if character.begins_with("res://"): + character = load(character) + else: + character = DialogicResourceUtil.get_character_resource(character) + if not character: + printerr("[Dialogic] Textbubble: Tried registering character from invalid string '", character_string, "'.") + registered_characters[character] = node if len(registered_characters) > len(bubbles) and len(bubbles) < bubble_count: add_bubble() +func _get_persistent_info() -> Dictionary: + return {"textbubble_registers": registered_characters} + + +func _load_persistent_info(info: Dictionary) -> void: + var register_info: Dictionary = info.get("textbubble_registers", {}) + for character in register_info: + if is_instance_valid(register_info[character]): + register_character(character, register_info[character]) + + func add_bubble() -> void: if not has_node('TextBubbleLayer'): return diff --git a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd index 6e2e0e403..669c2e2ff 100644 --- a/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd +++ b/addons/dialogic/Modules/DefaultLayoutParts/Layer_Textbubble/text_bubble.gd @@ -32,7 +32,7 @@ var bg_padding := 30 func _ready() -> void: reset() - DialogicUtil.autoload().Choices.choices_shown.connect(_on_choices_shown) + DialogicUtil.autoload().Choices.question_shown.connect(_on_question_shown) func reset() -> void: @@ -133,7 +133,7 @@ func _resize_bubble(content_size:Vector2, popup:=false) -> void: name_label_holder.size.x = text.size.x -func _on_choices_shown(info:Dictionary) -> void: +func _on_question_shown(info:Dictionary) -> void: if !is_visible_in_tree(): return diff --git a/addons/dialogic/Resources/dialogic_layout_base.gd b/addons/dialogic/Resources/dialogic_layout_base.gd index bb6f1d30e..16a2ee4a2 100644 --- a/addons/dialogic/Resources/dialogic_layout_base.gd +++ b/addons/dialogic/Resources/dialogic_layout_base.gd @@ -5,15 +5,18 @@ extends Node ## Base class that should be extended by custom layouts. +## Method that adds a node as a layer func add_layer(layer:DialogicLayoutLayer) -> Node: add_child(layer) return layer +## Method that returns the given child func get_layer(index:int) -> Node: return get_child(index) +## Method to return all the layers func get_layers() -> Array: var layers := [] for child in get_children(): @@ -22,6 +25,9 @@ func get_layers() -> Array: return layers +## Method that is called to load the export overrides. +## This happens when the style is first introduced, +## but also when switching to a different style using the same scene! func apply_export_overrides() -> void: _apply_export_overrides() for child in get_children(): @@ -29,10 +35,8 @@ func apply_export_overrides() -> void: child._apply_export_overrides() -func _apply_export_overrides() -> void: - pass - - +## Returns a setting on this base. +## This is useful so that layers can share settings like base_color, etc. func get_global_setting(setting:StringName, default:Variant) -> Variant: if setting in self: return get(setting) @@ -44,3 +48,31 @@ func get_global_setting(setting:StringName, default:Variant) -> Variant: return get('global_'+str(setting)) return default + + +## To be overwritten. Apply the settings to your scene here. +func _apply_export_overrides() -> void: + pass + + +#region HANDLE PERSISTENT DATA +################################################################################ + +func _enter_tree() -> void: + _load_persistent_info(Engine.get_meta("dialogic_persistent_style_info", {})) + + +func _exit_tree() -> void: + Engine.set_meta("dialogic_persistent_style_info", _get_persistent_info()) + + +## To be overwritten. Return any info that a later used style might want to know. +func _get_persistent_info() -> Dictionary: + return {} + + +## To be overwritten. Apply any info that a previous style might have stored and this style should use. +func _load_persistent_info(info: Dictionary) -> void: + pass + +#endregion