From 1a2dc047709ef529f29c3b638546fa9c7bb41062 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:47:50 +0100 Subject: [PATCH] Cleanup visual editor field scenes & scripts (#2004) * Begin cleanup * Finish cleanup * Small fixes --- .../char_edit_p_section_layout.tscn | 2 +- .../char_edit_p_section_main.tscn | 2 +- .../char_edit_section_portraits.tscn | 4 +- .../Editor/Common/reference_manager.tscn | 2 +- .../Editor/Events/EventBlock/event_block.gd | 379 +++++++----------- .../Editor/Events/EventBlock/event_block.tscn | 32 +- .../dialogic/Editor/Events/Fields/Array.tscn | 12 - addons/dialogic/Editor/Events/Fields/Bool.gd | 23 -- .../Editor/Events/Fields/BoolButton.tscn | 8 - .../Editor/Events/Fields/ConditionPicker.tscn | 104 ----- addons/dialogic/Editor/Events/Fields/Label.gd | 11 - .../dialogic/Editor/Events/Fields/Label.tscn | 18 - .../Editor/Events/Fields/SinglelineText.gd | 29 -- .../Fields/{ArrayValue.gd => array_part.gd} | 2 +- .../{ArrayValue.tscn => array_part.tscn} | 4 +- ...eyValuePairValue.gd => dictionary_part.gd} | 0 ...luePairValue.tscn => dictionary_part.tscn} | 2 +- .../Fields/{Array.gd => field_array.gd} | 16 +- .../Editor/Events/Fields/field_array.tscn | 27 ++ .../{BoolButton.gd => field_bool_button.gd} | 26 +- .../Events/Fields/field_bool_button.tscn | 13 + .../Editor/Events/Fields/field_bool_check.gd | 30 ++ .../{Bool.tscn => field_bool_check.tscn} | 6 +- ...{ConditionPicker.gd => field_condition.gd} | 37 +- .../Editor/Events/Fields/field_condition.tscn | 101 +++++ .../{KeyValuePairs.gd => field_dictionary.gd} | 29 +- ...yValuePairs.tscn => field_dictionary.tscn} | 18 +- .../Fields/{FilePicker.gd => field_file.gd} | 63 ++- .../{FilePicker.tscn => field_file.tscn} | 22 +- .../Fields/{Number.gd => field_number.gd} | 37 +- .../Fields/{Number.tscn => field_number.tscn} | 14 +- ...plexPicker.gd => field_options_dynamic.gd} | 192 ++++----- ...Picker.tscn => field_options_dynamic.tscn} | 19 +- ...tionSelector.gd => field_options_fixed.gd} | 38 +- ...Selector.tscn => field_options_fixed.tscn} | 4 +- ...ltilineText.gd => field_text_multiline.gd} | 67 ++-- ...ineText.tscn => field_text_multiline.tscn} | 14 +- .../Events/Fields/field_text_singleline.gd | 40 ++ ...neText.tscn => field_text_singleline.tscn} | 6 +- .../Fields/{Vector2.gd => field_vector2.gd} | 17 +- .../{Vector2.tscn => field_vector2.tscn} | 12 +- addons/dialogic/Editor/Events/event_field.gd | 35 ++ .../Editor/Settings/settings_general.tscn | 2 +- .../Editor/Settings/settings_translation.tscn | 4 +- .../VisualEditor/timeline_editor_visual.gd | 70 ++-- addons/dialogic/Modules/Audio/event_music.gd | 4 +- addons/dialogic/Modules/Audio/event_sound.gd | 10 +- .../Modules/Background/event_background.gd | 4 +- addons/dialogic/Modules/Call/event_call.gd | 4 +- .../Modules/Character/event_character.gd | 29 +- .../Modules/Character/event_position.gd | 8 +- .../Modules/Character/settings_portraits.gd | 4 +- .../Modules/Character/settings_portraits.tscn | 16 +- .../dialogic/Modules/Choice/event_choice.gd | 4 +- addons/dialogic/Modules/Clear/event_clear.gd | 14 +- .../Modules/Condition/event_condition.gd | 14 +- .../dialogic/Modules/History/event_history.gd | 8 +- addons/dialogic/Modules/Jump/event_jump.gd | 48 +-- .../Modules/Settings/event_setting.gd | 42 +- .../dialogic/Modules/Signal/event_signal.gd | 4 +- .../Modules/Style/character_settings_style.gd | 1 - .../Style/character_settings_style.tscn | 2 +- addons/dialogic/Modules/Style/event_style.gd | 2 +- .../character_moods_settings.tscn | 4 +- .../character_portrait_mood_settings.tscn | 2 +- addons/dialogic/Modules/Text/event_text.gd | 5 +- .../dialogic/Modules/Text/settings_text.tscn | 4 +- .../Modules/TextInput/event_text_input.gd | 2 +- .../Modules/Variable/event_variable.gd | 18 +- addons/dialogic/Modules/Voice/event_voice.gd | 2 +- addons/dialogic/Modules/Wait/event_wait.gd | 2 +- addons/dialogic/Other/DialogicUtil.gd | 4 +- addons/dialogic/Resources/event.gd | 29 +- 73 files changed, 954 insertions(+), 929 deletions(-) delete mode 100644 addons/dialogic/Editor/Events/Fields/Array.tscn delete mode 100644 addons/dialogic/Editor/Events/Fields/Bool.gd delete mode 100644 addons/dialogic/Editor/Events/Fields/BoolButton.tscn delete mode 100644 addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn delete mode 100644 addons/dialogic/Editor/Events/Fields/Label.gd delete mode 100644 addons/dialogic/Editor/Events/Fields/Label.tscn delete mode 100644 addons/dialogic/Editor/Events/Fields/SinglelineText.gd rename addons/dialogic/Editor/Events/Fields/{ArrayValue.gd => array_part.gd} (99%) rename addons/dialogic/Editor/Events/Fields/{ArrayValue.tscn => array_part.tscn} (98%) rename addons/dialogic/Editor/Events/Fields/{KeyValuePairValue.gd => dictionary_part.gd} (100%) rename addons/dialogic/Editor/Events/Fields/{KeyValuePairValue.tscn => dictionary_part.tscn} (99%) rename addons/dialogic/Editor/Events/Fields/{Array.gd => field_array.gd} (79%) create mode 100644 addons/dialogic/Editor/Events/Fields/field_array.tscn rename addons/dialogic/Editor/Events/Fields/{BoolButton.gd => field_bool_button.gd} (52%) create mode 100644 addons/dialogic/Editor/Events/Fields/field_bool_button.tscn create mode 100644 addons/dialogic/Editor/Events/Fields/field_bool_check.gd rename addons/dialogic/Editor/Events/Fields/{Bool.tscn => field_bool_check.tscn} (56%) rename addons/dialogic/Editor/Events/Fields/{ConditionPicker.gd => field_condition.gd} (97%) create mode 100644 addons/dialogic/Editor/Events/Fields/field_condition.tscn rename addons/dialogic/Editor/Events/Fields/{KeyValuePairs.gd => field_dictionary.gd} (74%) rename addons/dialogic/Editor/Events/Fields/{KeyValuePairs.tscn => field_dictionary.tscn} (92%) rename addons/dialogic/Editor/Events/Fields/{FilePicker.gd => field_file.gd} (65%) rename addons/dialogic/Editor/Events/Fields/{FilePicker.tscn => field_file.tscn} (93%) rename addons/dialogic/Editor/Events/Fields/{Number.gd => field_number.gd} (73%) rename addons/dialogic/Editor/Events/Fields/{Number.tscn => field_number.tscn} (94%) rename addons/dialogic/Editor/Events/Fields/{ComplexPicker.gd => field_options_dynamic.gd} (56%) rename addons/dialogic/Editor/Events/Fields/{ComplexPicker.tscn => field_options_dynamic.tscn} (94%) rename addons/dialogic/Editor/Events/Fields/{OptionSelector.gd => field_options_fixed.gd} (53%) rename addons/dialogic/Editor/Events/Fields/{OptionSelector.tscn => field_options_fixed.tscn} (79%) rename addons/dialogic/Editor/Events/Fields/{MultilineText.gd => field_text_multiline.gd} (69%) rename addons/dialogic/Editor/Events/Fields/{MultilineText.tscn => field_text_multiline.tscn} (74%) create mode 100644 addons/dialogic/Editor/Events/Fields/field_text_singleline.gd rename addons/dialogic/Editor/Events/Fields/{SinglelineText.tscn => field_text_singleline.tscn} (63%) rename addons/dialogic/Editor/Events/Fields/{Vector2.gd => field_vector2.gd} (72%) rename addons/dialogic/Editor/Events/Fields/{Vector2.tscn => field_vector2.tscn} (55%) create mode 100644 addons/dialogic/Editor/Events/event_field.gd diff --git a/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.tscn b/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.tscn index 10454082f..9fa25c2d5 100644 --- a/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.tscn +++ b/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://crke8suvv52c6"] [ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.gd" id="1_76vf2"] -[ext_resource type="PackedScene" uid="uid://dtimnsj014cu" path="res://addons/dialogic/Editor/Events/Fields/Vector2.tscn" id="2_c8kyi"] +[ext_resource type="PackedScene" uid="uid://dtimnsj014cu" path="res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn" id="2_c8kyi"] [node name="Layout" type="HFlowContainer"] offset_right = 428.0 diff --git a/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.tscn b/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.tscn index db9dd0079..db355bd9f 100644 --- a/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.tscn +++ b/addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://djq4aasoihexj"] [ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.gd" id="1_ht8lu"] -[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="2_k8xs0"] +[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/field_file.tscn" id="2_k8xs0"] [sub_resource type="Image" id="Image_sbh6e"] data = { diff --git a/addons/dialogic/Editor/CharacterEditor/char_edit_section_portraits.tscn b/addons/dialogic/Editor/CharacterEditor/char_edit_section_portraits.tscn index ac66bd9a7..0f1874a29 100644 --- a/addons/dialogic/Editor/CharacterEditor/char_edit_section_portraits.tscn +++ b/addons/dialogic/Editor/CharacterEditor/char_edit_section_portraits.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://cmrgbo8qi145o"] [ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_section_portraits.gd" id="1_6sxsl"] -[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn" id="2_birla"] -[ext_resource type="PackedScene" uid="uid://dtimnsj014cu" path="res://addons/dialogic/Editor/Events/Fields/Vector2.tscn" id="3_vcvin"] +[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="2_birla"] +[ext_resource type="PackedScene" uid="uid://dtimnsj014cu" path="res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn" id="3_vcvin"] [node name="Portraits" type="GridContainer"] offset_right = 453.0 diff --git a/addons/dialogic/Editor/Common/reference_manager.tscn b/addons/dialogic/Editor/Common/reference_manager.tscn index 56c49955e..db2914853 100644 --- a/addons/dialogic/Editor/Common/reference_manager.tscn +++ b/addons/dialogic/Editor/Common/reference_manager.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/reference_manager.gd" id="1_3t531"] [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/broken_reference_manager.gd" id="1_agmg4"] [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/ReferenceManager_AddReplacementPanel.gd" id="2_tt4jd"] -[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn" id="3_yomsc"] +[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="3_yomsc"] [ext_resource type="Script" path="res://addons/dialogic/Editor/Common/unique_identifiers_manager.gd" id="5_wnvbq"] [sub_resource type="ButtonGroup" id="ButtonGroup_l6uiy"] diff --git a/addons/dialogic/Editor/Events/EventBlock/event_block.gd b/addons/dialogic/Editor/Events/EventBlock/event_block.gd index 3fb64c0d5..86f154d19 100644 --- a/addons/dialogic/Editor/Events/EventBlock/event_block.gd +++ b/addons/dialogic/Editor/Events/EventBlock/event_block.gd @@ -3,68 +3,117 @@ extends MarginContainer ## Scene that represents an event in the visual timeline editor. -signal option_action(action_name) signal content_changed() -# Resource +## REFERENCES var resource : DialogicEvent - -var selected : bool = false - -### internal node eferences -@onready var warning := %Warning -@onready var icon_texture := %IconTexture -@onready var header_content_container := %HeaderContent -@onready var body_container := %Body -@onready var body_content_container := %BodyContent - -# is the body visible -var expanded := true - -# was the body content loaded -var body_was_build := false - -# does the body have elements? -var has_any_enabled_body_content := false - -# list that stores visibility conditions -var field_list := [] - +var editor_reference # for choice and condition -var end_node:Node = null: +var end_node: Node = null: get: return end_node set(node): end_node = node %CollapseButton.visible = true if end_node else false + +## FLAGS +var selected := false +# Whether the body is visible +var expanded := true +var body_was_build := false +var has_any_enabled_body_content := false +# Whether contained events (e.g. in choices) are visible var collapsed := false -### extarnal node references -var editor_reference -### Icon size -var icon_size := 28 +## CONSTANTS +const icon_size := 28 +const indent_size := 22 -### the indent size -var indent_size := 22 +## STATE +# List that stores visibility conditions +var field_list := [] var current_indent_level := 1 -# Setting this to true will ignore the event while saving -# Useful for making placeholder events in drag and drop -var ignore_save := false + +#region UI AND LOGIC INITIALIZATION +################################################################################ + +func _ready(): + if get_parent() is SubViewport: + return + + if not resource: + printerr("[Dialogic] Event block was added without a resource specified.") + return + + initialize_logic() + initialize_ui() -## ***************************************************************************** -## PUBLIC METHODS -## ***************************************************************************** +func initialize_ui() -> void: + var _scale := DialogicUtil.get_editor_scale() + + $PanelContainer.self_modulate = get_theme_color("accent_color", "Editor") + + # Warning Icon + %Warning.texture = get_theme_icon("NodeWarning", "EditorIcons") + %Warning.size = Vector2(16 * _scale, 16 * _scale) + %Warning.position = Vector2(-5 * _scale, -10 * _scale) + + # Expand Button + %ExpandButton.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons") + %ExpandButton.modulate = get_theme_color("readonly_color", "Editor") + + # Icon Panel + %IconPanel.tooltip_text = resource.event_name + %IconPanel.self_modulate = resource.event_color + + # Event Icon + %IconTexture.texture = resource._get_icon() + + %IconPanel.custom_minimum_size = Vector2(icon_size, icon_size) * _scale + %IconTexture.custom_minimum_size = %IconPanel.custom_minimum_size + + var custom_style: StyleBoxFlat = %IconPanel.get_theme_stylebox('panel') + custom_style.set_corner_radius_all(5 * _scale) + + # Focus Mode + set_focus_mode(1) # Allowing this node to grab focus + + # Separation on the header + %Header.add_theme_constant_override("custom_constants/separation", 5 * _scale) + + # Collapse Button + %CollapseButton.toggled.connect(_on_collapse_toggled) + %CollapseButton.icon = get_theme_icon("Collapse", "EditorIcons") + %CollapseButton.hide() + + visual_deselect() + + +func initialize_logic() -> void: + resized.connect(get_parent().get_parent().queue_redraw) + + resource.ui_update_needed.connect(_on_resource_ui_update_needed) + resource.ui_update_warning.connect(set_warning) + + _on_ExpandButton_toggled(resource.expand_by_default) + + content_changed.connect(recalculate_field_visibility) + +#endregion + + +#region VISUAL METHODS +################################################################################ func visual_select() -> void: $PanelContainer.add_theme_stylebox_override('panel', load("res://addons/dialogic/Editor/Events/styles/selected_styleboxflat.tres")) selected = true %IconPanel.self_modulate = resource.event_color %IconTexture.modulate = get_theme_color("icon_saturation", "Editor") -# %IconTexture.self_modulate.a = 1 func visual_deselect() -> void: @@ -72,66 +121,50 @@ func visual_deselect() -> void: selected = false %IconPanel.self_modulate = resource.event_color.lerp(Color.DARK_SLATE_GRAY, 0.1) %IconTexture.modulate = get_theme_color('font_color', 'Label') -# %IconTexture.self_modulate.a = 0.7 func is_selected() -> bool: return selected -# called by the timeline before adding it to the tree -func load_data(data:DialogicEvent) -> void: - resource = data - func set_warning(text:String= "") -> void: if !text.is_empty(): - warning.show() - warning.tooltip_text = text + %Warning.show() + %Warning.tooltip_text = text else: - warning.hide() + %Warning.hide() func set_indent(indent: int) -> void: - add_theme_constant_override("margin_left", indent_size*indent) + add_theme_constant_override("margin_left", indent_size*indent*DialogicUtil.get_editor_scale()) current_indent_level = indent +#endregion -## ***************************************************************************** -## PRIVATE METHODS -## ***************************************************************************** - -func _set_event_icon(icon: Texture) -> void: - icon_texture.texture = icon - var _scale := DialogicUtil.get_editor_scale() - var ip := %IconPanel - var ipc := icon_texture - - # Resizing the icon acording to the scale - - ip.custom_minimum_size = Vector2(icon_size, icon_size) * _scale - ipc.custom_minimum_size = ip.custom_minimum_size - - # Updating the theme properties to scale - var custom_style :StyleBox = ip.get_theme_stylebox('panel') - custom_style.corner_radius_top_left = 5 * _scale - custom_style.corner_radius_top_right = 5 * _scale - custom_style.corner_radius_bottom_left = 5 * _scale - custom_style.corner_radius_bottom_right = 5 * _scale +#region EVENT FIELDS +################################################################################ -func toggle_collapse(toggled:bool) -> void: - collapsed = toggled - var timeline_editor = find_parent('VisualEditor') - if (timeline_editor != null): - # @todo select item and clear selection is marked as "private" in TimelineEditor.gd - # consider to make it "public" or add a public helper function - timeline_editor.indent_events() - +var FIELD_SCENES := { + DialogicEvent.ValueType.MULTILINE_TEXT: "res://addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn", + DialogicEvent.ValueType.SINGLELINE_TEXT: "res://addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn", + DialogicEvent.ValueType.FILE: "res://addons/dialogic/Editor/Events/Fields/field_file.tscn", + DialogicEvent.ValueType.BOOL: "res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn", + DialogicEvent.ValueType.BOOL_BUTTON: "res://addons/dialogic/Editor/Events/Fields/field_bool_button.tscn", + DialogicEvent.ValueType.CONDITION: "res://addons/dialogic/Editor/Events/Fields/field_condition.tscn", + DialogicEvent.ValueType.ARRAY: "res://addons/dialogic/Editor/Events/Fields/field_array.tscn", + DialogicEvent.ValueType.DICTIONARY: "res://addons/dialogic/Editor/Events/Fields/field_dictionary.tscn", + DialogicEvent.ValueType.DYNAMIC_OPTIONS: "res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn", + DialogicEvent.ValueType.FIXED_OPTIONS : "res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn", + DialogicEvent.ValueType.NUMBER: "res://addons/dialogic/Editor/Events/Fields/field_number.tscn", + DialogicEvent.ValueType.VECTOR2: "res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn", + } func build_editor(build_header:bool = true, build_body:bool = false) -> void: - var current_body_container :HFlowContainer = null + var current_body_container: HFlowContainer = null + if build_body and body_was_build: + build_body = false - if build_body and body_was_build: build_body = false if build_body: if body_was_build: return @@ -162,84 +195,17 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: %BodyContent.add_child(current_body_container) continue - ### STRINGS - elif p.dialogic_type == resource.ValueType.MULTILINE_TEXT: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/MultilineText.tscn").instantiate() - elif p.dialogic_type == resource.ValueType.SINGLELINE_TEXT: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/SinglelineText.tscn").instantiate() - editor_node.placeholder = p.display_info.get('placeholder', '') - elif p.dialogic_type == resource.ValueType.BOOL: - if p.display_info.has('icon') or p.display_info.has('editor_icon'): - editor_node = load("res://addons/dialogic/Editor/Events/Fields/BoolButton.tscn").instantiate() - if p.display_info.has('editor_icon'): - editor_node.icon = callv('get_theme_icon', p.display_info.editor_icon) - else: - editor_node.icon = p.display_info.get('icon', null) - else: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Bool.tscn").instantiate() - editor_node.tooltip_text = p.display_info.get('tooltip', "") - elif p.dialogic_type == resource.ValueType.FILE: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn").instantiate() - editor_node.file_filter = p.display_info.get('file_filter', '') - editor_node.placeholder = p.display_info.get('placeholder', '') - editor_node.resource_icon = p.display_info.get('icon', null) - if editor_node.resource_icon == null and p.display_info.has('editor_icon'): - editor_node.resource_icon = callv('get_theme_icon', p.display_info.editor_icon) - - elif p.dialogic_type == resource.ValueType.CONDITION: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn").instantiate() - - ## Complex Picker - elif p.dialogic_type == resource.ValueType.COMPLEX_PICKER: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn").instantiate() - - editor_node.file_extension = p.display_info.get('file_extension', '') - editor_node.collapse_when_empty = p.display_info.get('collapse_when_empty', false) - editor_node.get_suggestions_func = p.display_info.get('suggestions_func', editor_node.get_suggestions_func) - editor_node.empty_text = p.display_info.get('empty_text', '') - editor_node.placeholder_text = p.display_info.get('placeholder', 'Select Resource') - editor_node.resource_icon = p.display_info.get('icon', null) - editor_node.enable_pretty_name = p.display_info.get('enable_pretty_name', false) - if editor_node.resource_icon == null and p.display_info.has('editor_icon'): - editor_node.resource_icon = callv('get_theme_icon', p.display_info.editor_icon) - - ## INTEGERS - elif p.dialogic_type == resource.ValueType.INTEGER: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Number.tscn").instantiate() - editor_node.use_int_mode() - editor_node.max = p.display_info.get('max', 9999) - editor_node.min = p.display_info.get('min', -9999) - elif p.dialogic_type == resource.ValueType.FLOAT: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Number.tscn").instantiate() - editor_node.use_float_mode() - editor_node.max = p.display_info.get('max', 9999) - editor_node.min = p.display_info.get('min', 0) - elif p.dialogic_type == resource.ValueType.DECIBEL: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Number.tscn").instantiate() - editor_node.use_decibel_mode() - elif p.dialogic_type == resource.ValueType.FIXED_OPTION_SELECTOR: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/OptionSelector.tscn").instantiate() - editor_node.options = p.display_info.get('selector_options', []) - editor_node.disabled = p.display_info.get('disabled', false) - editor_node.symbol_only = p.display_info.get('symbol_only', false) - - elif p.dialogic_type == resource.ValueType.VECTOR2: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Vector2.tscn").instantiate() - - elif p.dialogic_type == resource.ValueType.ARRAY: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/Array.tscn").instantiate() - - elif p.dialogic_type == resource.ValueType.KEY_VALUE_PAIRS: - editor_node = load("res://addons/dialogic/Editor/Events/Fields/KeyValuePairs.tscn").instantiate() - - - elif p.dialogic_type == resource.ValueType.LABEL: + elif p.field_type in FIELD_SCENES: + editor_node = load(FIELD_SCENES[p.field_type]).instantiate() + + elif p.field_type == resource.ValueType.LABEL: editor_node = Label.new() editor_node.text = p.display_info.text editor_node.vertical_alignment = VERTICAL_ALIGNMENT_CENTER editor_node.set('custom_colors/font_color', Color("#7b7b7b")) editor_node.add_theme_color_override('font_color', resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.8)) - elif p.dialogic_type == resource.ValueType.BUTTON: + + elif p.field_type == resource.ValueType.BUTTON: editor_node = Button.new() editor_node.text = p.display_info.text if typeof(p.display_info.icon) == TYPE_ARRAY: @@ -249,8 +215,9 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: editor_node.flat = true editor_node.custom_minimum_size.x = 30*DialogicUtil.get_editor_scale() editor_node.pressed.connect(p.display_info.callable) + ## CUSTOM - elif p.dialogic_type == resource.ValueType.CUSTOM: + elif p.field_type == resource.ValueType.CUSTOM: if p.display_info.has('path'): editor_node = load(p.display_info.path).instantiate() @@ -260,26 +227,37 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: editor_node.text = p.name editor_node.add_theme_color_override('font_color', resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.8)) + + field_list[-1]['node'] = editor_node ### -------------------------------------------------------------------- - ### 2. ADD IT TO THE RIGHT PLACE (HEADER/BODY) + # Some things need to be called BEFORE the field is added to the tree + if editor_node is DialogicVisualEditorField: + editor_node.event_resource = resource + + editor_node.property_name = p.name + field_list[-1]['property'] = p.name + + editor_node._load_display_info(p.display_info) + var location: Control = %HeaderContent if p.location == 1: location = current_body_container location.add_child(editor_node) - ### -------------------------------------------------------------------- - ### 3. FILL THE NEW NODE WITH INFORMATION AND LISTEN TO CHANGES - field_list[-1]['node'] = editor_node - if "event_resource" in editor_node: - editor_node.event_resource = resource - if 'property_name' in editor_node: - editor_node.property_name = p.name - field_list[-1]['property'] = p.name - if editor_node.has_method('set_value'): - editor_node.set_value(resource.get(p.name)) - if editor_node.has_signal('value_changed'): + # Some things need to be called AFTER the field is added to the tree + if editor_node is DialogicVisualEditorField: + editor_node._set_value(resource.get(p.name)) + editor_node.value_changed.connect(set_property) - editor_node.tooltip_text = p.display_info.get('tooltip', '') + + editor_node.tooltip_text = p.display_info.get('tooltip', '') + + # Apply autofocus + if resource.created_by_button and p.display_info.get('autofocus', false): + editor_node.call_deferred('take_autofocus') + + ### -------------------------------------------------------------------- + ### 4. ADD LEFT AND RIGHT TEXT var left_label: Label = null var right_label: Label = null if !p.get('left_text', '').is_empty(): @@ -297,6 +275,8 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: location.add_child(right_label) location.move_child(right_label, editor_node.get_index()+1) + ### -------------------------------------------------------------------- + ### 5. REGISTER CONDITION if p.has('condition'): field_list[-1]['condition'] = p.condition if left_label: @@ -304,15 +284,11 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: if right_label: field_list.append({'node': right_label, 'condition':p.condition, 'location':p.location}) - ### -------------------------------------------------------------------- - ### 4. GETTING THE PATH OF THE FIELD WE WANT TO FOCUS (in case we want) - if resource.created_by_button and p.display_info.get('autofocus', false) and editor_node.has_method('take_autofocus'): - editor_node.call_deferred('take_autofocus') if build_body: if current_body_container.get_child_count() == 0: expanded = false - body_container.visible = false + %Body.visible = false recalculate_field_visibility() @@ -355,60 +331,17 @@ func _on_resource_ui_update_needed() -> void: recalculate_field_visibility() -func _update_color() -> void: - if resource.dialogic_color_name != '': - %IconPanel.self_modulate = DialogicUtil.get_color(resource.dialogic_color_name) - - -######################## OVERRIDES ############################################# +#region SIGNALS ################################################################################ -func _ready(): - resized.connect(get_parent().get_parent().queue_redraw) - - ## DO SOME STYLING - var _scale := DialogicUtil.get_editor_scale() - $PanelContainer.self_modulate = get_theme_color("accent_color", "Editor") - warning.texture = get_theme_icon("NodeWarning", "EditorIcons") - warning.size = Vector2(16 * _scale, 16 * _scale) - warning.position = Vector2(-5 * _scale, -10 * _scale) - - indent_size = indent_size * DialogicUtil.get_editor_scale() - - %ExpandButton.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons") - %ExpandButton.modulate = get_theme_color("readonly_color", "Editor") - - if resource: - if resource.event_name: - %TitleLabel.add_theme_color_override("font_color", resource.event_color.lightened(0.4)) - %TitleLabel.add_theme_font_override("font", get_theme_font("title", "EditorFonts")) - %TitleLabel.text = resource.event_name - %IconPanel.tooltip_text = resource.event_name - if resource._get_icon() != null: - _set_event_icon(resource._get_icon()) - resource.ui_update_needed.connect(_on_resource_ui_update_needed) - resource.ui_update_warning.connect(set_warning) - - %IconPanel.self_modulate = resource.event_color - - _on_ExpandButton_toggled(resource.expand_by_default) - - set_focus_mode(1) # Allowing this node to grab focus - - # signals - # TODO godot4 react to changes of the colors, the signal was removed - #ProjectSettings.project_settings_changed.connect(_update_color) - - # Separation on the header - %Header.add_theme_constant_override("custom_constants/separation", 5 * _scale) - - content_changed.connect(recalculate_field_visibility) +func _on_collapse_toggled(toggled:bool) -> void: + collapsed = toggled + var timeline_editor = find_parent('VisualEditor') + if (timeline_editor != null): + # @todo select item and clear selection is marked as "private" in TimelineEditor.gd + # consider to make it "public" or add a public helper function + timeline_editor.indent_events() -# _on_Indent_visibility_changed() - %CollapseButton.toggled.connect(toggle_collapse) - %CollapseButton.icon = get_theme_icon("Collapse", "EditorIcons") - %CollapseButton.hide() - visual_deselect() func _on_ExpandButton_toggled(button_pressed:bool) -> void: @@ -420,8 +353,8 @@ func _on_ExpandButton_toggled(button_pressed:bool) -> void: else: %ExpandButton.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons") expanded = button_pressed - body_container.visible = button_pressed - body_container.add_theme_constant_override("margin_left", icon_size*DialogicUtil.get_editor_scale()) + %Body.visible = button_pressed + %Body.add_theme_constant_override("margin_left", icon_size*DialogicUtil.get_editor_scale()) if find_parent('VisualEditor') != null: find_parent('VisualEditor').indent_events() diff --git a/addons/dialogic/Editor/Events/EventBlock/event_block.tscn b/addons/dialogic/Editor/Events/EventBlock/event_block.tscn index 9d0a1cf79..f0b363c0c 100644 --- a/addons/dialogic/Editor/Events/EventBlock/event_block.tscn +++ b/addons/dialogic/Editor/Events/EventBlock/event_block.tscn @@ -11,7 +11,7 @@ corner_radius_top_right = 5 corner_radius_bottom_right = 5 corner_radius_bottom_left = 5 -[sub_resource type="Image" id="Image_y3447"] +[sub_resource type="Image" id="Image_ng2y4"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -20,8 +20,8 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_vg181"] -image = SubResource("Image_y3447") +[sub_resource type="ImageTexture" id="ImageTexture_rc1wh"] +image = SubResource("Image_ng2y4") [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ee4ub"] @@ -80,25 +80,13 @@ stretch_mode = 5 unique_name_in_owner = true visible = false layout_mode = 0 -offset_left = -5.0 -offset_top = -10.0 -offset_right = 11.0 -offset_bottom = 6.0 -texture = SubResource("ImageTexture_vg181") +offset_left = -5.5 +offset_top = -11.0 +offset_right = 12.1 +offset_bottom = 6.6 +texture = SubResource("ImageTexture_rc1wh") stretch_mode = 5 -[node name="TitleLabel" type="Label" parent="PanelContainer/VBoxContainer/Header"] -unique_name_in_owner = true -visible = false -layout_mode = 2 -vertical_alignment = 1 - -[node name="VSeparator" type="VSeparator" parent="PanelContainer/VBoxContainer/Header"] -visible = false -custom_minimum_size = Vector2(0, 20) -layout_mode = 2 -size_flags_vertical = 4 - [node name="HeaderContent" type="HBoxContainer" parent="PanelContainer/VBoxContainer/Header"] unique_name_in_owner = true layout_mode = 2 @@ -111,7 +99,7 @@ size_flags_horizontal = 0 tooltip_text = "Fold/Unfold Settings" theme_override_styles/focus = SubResource("StyleBoxEmpty_ee4ub") toggle_mode = true -icon = SubResource("ImageTexture_vg181") +icon = SubResource("ImageTexture_rc1wh") flat = true [node name="CollapseButton" type="Button" parent="PanelContainer/VBoxContainer/Header"] @@ -121,7 +109,7 @@ layout_mode = 2 size_flags_horizontal = 10 tooltip_text = "Collapse Contained Events" toggle_mode = true -icon = SubResource("ImageTexture_vg181") +icon = SubResource("ImageTexture_rc1wh") flat = true [node name="Body" type="MarginContainer" parent="PanelContainer/VBoxContainer"] diff --git a/addons/dialogic/Editor/Events/Fields/Array.tscn b/addons/dialogic/Editor/Events/Fields/Array.tscn deleted file mode 100644 index 53ed4b036..000000000 --- a/addons/dialogic/Editor/Events/Fields/Array.tscn +++ /dev/null @@ -1,12 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://btmy7ageqpyq1"] - -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/Array.gd" id="2"] - -[node name="Array" type="HFlowContainer"] -size_flags_horizontal = 3 -script = ExtResource("2") - -[node name="Add" type="Button" parent="."] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Add another value" diff --git a/addons/dialogic/Editor/Events/Fields/Bool.gd b/addons/dialogic/Editor/Events/Fields/Bool.gd deleted file mode 100644 index 69e1df52e..000000000 --- a/addons/dialogic/Editor/Events/Fields/Bool.gd +++ /dev/null @@ -1,23 +0,0 @@ -@tool -extends CheckButton - -## Event block field for boolean values. - -signal value_changed -var property_name : String - - -func _ready() -> void: - toggled.connect(_on_value_changed) - - -func set_value(value:Variant) -> void: - match DialogicUtil.get_variable_value_type(value): - DialogicUtil.VarTypes.STRING: - button_pressed = value and not value == "false" - _: - button_pressed = value and true - - -func _on_value_changed(value:bool) -> void: - value_changed.emit(property_name, value) diff --git a/addons/dialogic/Editor/Events/Fields/BoolButton.tscn b/addons/dialogic/Editor/Events/Fields/BoolButton.tscn deleted file mode 100644 index efad7b8d5..000000000 --- a/addons/dialogic/Editor/Events/Fields/BoolButton.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://iypxcctv080u"] - -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/BoolButton.gd" id="1_5iob7"] - -[node name="Bool" type="Button"] -toggle_mode = true -flat = true -script = ExtResource("1_5iob7") diff --git a/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn b/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn deleted file mode 100644 index 1946d02f3..000000000 --- a/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn +++ /dev/null @@ -1,104 +0,0 @@ -[gd_scene load_steps=9 format=3 uid="uid://ir6334lqtuwt"] - -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/ConditionPicker.gd" id="1_q5p62"] -[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn" id="1_rr7mq"] -[ext_resource type="PackedScene" uid="uid://d3bhehatwoio" path="res://addons/dialogic/Editor/Events/Fields/OptionSelector.tscn" id="4_27ir8"] -[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/Number.tscn" id="4_al48y"] -[ext_resource type="PackedScene" uid="uid://c0vkcehgjsjy" path="res://addons/dialogic/Editor/Events/Fields/SinglelineText.tscn" id="4_b5vlr"] -[ext_resource type="PackedScene" uid="uid://dm5hxmhyyxgq" path="res://addons/dialogic/Editor/Events/Fields/Bool.tscn" id="6_ltaor"] - -[sub_resource type="Image" id="Image_2qcj3"] -data = { -"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 225, 225, 225, 76, 224, 224, 224, 228, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 228, 224, 224, 224, 73, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 229, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 226, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 224, 224, 224, 185, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 225, 225, 225, 190, 224, 224, 224, 184, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 188, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 228, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 225, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 73, 224, 224, 224, 226, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 224, 224, 224, 255, 255, 255, 255, 0, 255, 255, 255, 0, 224, 224, 224, 255, 224, 224, 224, 225, 226, 226, 226, 70, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), -"format": "RGBA8", -"height": 12, -"mipmaps": false, -"width": 16 -} - -[sub_resource type="ImageTexture" id="ImageTexture_v5qxy"] -image = SubResource("Image_2qcj3") - -[node name="ConditionPicker" type="HBoxContainer"] -offset_right = 77.0 -offset_bottom = 31.0 -script = ExtResource("1_q5p62") - -[node name="SimpleEditor" type="HBoxContainer" parent="."] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value1Type" parent="SimpleEditor" instance=ExtResource("4_27ir8")] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Change type" -theme_override_colors/font_disabled_color = Color(0.8025, 0.81, 0.8225, 1) -text = "" - -[node name="Value1Text" parent="SimpleEditor" instance=ExtResource("4_b5vlr")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value1Number" parent="SimpleEditor" instance=ExtResource("4_al48y")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value1Bool" parent="SimpleEditor" instance=ExtResource("6_ltaor")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value1Variable" parent="SimpleEditor" instance=ExtResource("1_rr7mq")] -unique_name_in_owner = true -layout_mode = 2 -placeholder_text = "Variable" - -[node name="Operator" parent="SimpleEditor" instance=ExtResource("4_27ir8")] -unique_name_in_owner = true -layout_mode = 2 -theme_override_colors/font_disabled_color = Color(0.8025, 0.81, 0.8225, 1) - -[node name="Value2Type" parent="SimpleEditor" instance=ExtResource("4_27ir8")] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Change type" -theme_override_colors/font_disabled_color = Color(0.8025, 0.81, 0.8225, 1) -text = "" - -[node name="Value2Text" parent="SimpleEditor" instance=ExtResource("4_b5vlr")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value2Number" parent="SimpleEditor" instance=ExtResource("4_al48y")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="Value2Variable" parent="SimpleEditor" instance=ExtResource("1_rr7mq")] -unique_name_in_owner = true -layout_mode = 2 -placeholder_text = "Variable" - -[node name="Value2Bool" parent="SimpleEditor" instance=ExtResource("6_ltaor")] -unique_name_in_owner = true -layout_mode = 2 - -[node name="ComplexEditor" type="LineEdit" parent="."] -unique_name_in_owner = true -visible = false -custom_minimum_size = Vector2(150, 0) -layout_mode = 2 -mouse_filter = 1 -theme_type_variation = &"DialogicEventEdit" -text = "VAR.Player.Health > 20 and VAR.Counter < 3 and randi()%3 == 2" -placeholder_text = "Enter condition" -expand_to_text_length = true - -[node name="ToggleComplex" type="Button" parent="."] -unique_name_in_owner = true -layout_mode = 2 -tooltip_text = "Use complex expression" -toggle_mode = true -icon = SubResource("ImageTexture_v5qxy") - -[connection signal="value_changed" from="SimpleEditor/Value1Variable" to="." method="_on_value_1_variable_value_changed"] -[connection signal="text_changed" from="ComplexEditor" to="." method="_on_complex_editor_text_changed"] -[connection signal="toggled" from="ToggleComplex" to="." method="_on_toggle_complex_toggled"] diff --git a/addons/dialogic/Editor/Events/Fields/Label.gd b/addons/dialogic/Editor/Events/Fields/Label.gd deleted file mode 100644 index b1625f1d2..000000000 --- a/addons/dialogic/Editor/Events/Fields/Label.gd +++ /dev/null @@ -1,11 +0,0 @@ -@tool -extends Control - - -@export var text: String = "Hello World" - - -func _ready(): - $Label.text = text - $Label.set('custom_colors/font_color', Color("#7b7b7b")) - diff --git a/addons/dialogic/Editor/Events/Fields/Label.tscn b/addons/dialogic/Editor/Events/Fields/Label.tscn deleted file mode 100644 index 6eae67bcc..000000000 --- a/addons/dialogic/Editor/Events/Fields/Label.tscn +++ /dev/null @@ -1,18 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://addons/dialogic/Editor/Events/Fields/Label.gd" type="Script" id=1] - -[node name="Control" type="CenterContainer"] -anchor_right = 1.0 -anchor_bottom = 1.0 -mouse_filter = 1 -script = ExtResource( 1 ) - -[node name="Label" type="Label" parent="."] -margin_left = 474.0 -margin_top = 293.0 -margin_right = 550.0 -margin_bottom = 307.0 -size_flags_horizontal = 3 -custom_colors/font_color = Color( 0.482353, 0.482353, 0.482353, 1 ) -text = "Hello World" diff --git a/addons/dialogic/Editor/Events/Fields/SinglelineText.gd b/addons/dialogic/Editor/Events/Fields/SinglelineText.gd deleted file mode 100644 index 0dddfdf4b..000000000 --- a/addons/dialogic/Editor/Events/Fields/SinglelineText.gd +++ /dev/null @@ -1,29 +0,0 @@ -@tool -extends LineEdit - -## Event block field for a single line of text. - -signal value_changed -var property_name : String - -var placeholder :String= "": - set(value): - placeholder = value - placeholder_text = placeholder - - -func _ready() -> void: - text_changed.connect(_on_text_changed) -# add_theme_stylebox_override('normal', get_theme_stylebox('normal', 'LineEdit')) -# add_theme_stylebox_override('focus', get_theme_stylebox('focus', 'LineEdit')) - - -func _on_text_changed(value := "") -> void: - value_changed.emit(property_name, text) - - -func set_value(value:String) -> void: - text = str(value) - -func take_autofocus(): - grab_focus() diff --git a/addons/dialogic/Editor/Events/Fields/ArrayValue.gd b/addons/dialogic/Editor/Events/Fields/array_part.gd similarity index 99% rename from addons/dialogic/Editor/Events/Fields/ArrayValue.gd rename to addons/dialogic/Editor/Events/Fields/array_part.gd index 6fb2f58d1..97352d8ad 100644 --- a/addons/dialogic/Editor/Events/Fields/ArrayValue.gd +++ b/addons/dialogic/Editor/Events/Fields/array_part.gd @@ -115,7 +115,7 @@ func change_field_type(type:int) -> void: value_field.text_changed.connect(_on_str_text_changed) value_field.expand_to_text_length = true TYPE_FLOAT, TYPE_INT: - value_field = load("res://addons/dialogic/Editor/Events/Fields/Number.tscn").instantiate() + value_field = load("res://addons/dialogic/Editor/Events/Fields/field_number.tscn").instantiate() if type == TYPE_FLOAT: value_field.use_float_mode() else: diff --git a/addons/dialogic/Editor/Events/Fields/ArrayValue.tscn b/addons/dialogic/Editor/Events/Fields/array_part.tscn similarity index 98% rename from addons/dialogic/Editor/Events/Fields/ArrayValue.tscn rename to addons/dialogic/Editor/Events/Fields/array_part.tscn index ca2a34e2f..72ae7ebdc 100644 --- a/addons/dialogic/Editor/Events/Fields/ArrayValue.tscn +++ b/addons/dialogic/Editor/Events/Fields/array_part.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://ch4j2lesn1sis"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/ArrayValue.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/array_part.gd" id="1"] [ext_resource type="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="2"] -[ext_resource type="PackedScene" uid="uid://d3bhehatwoio" path="res://addons/dialogic/Editor/Events/Fields/OptionSelector.tscn" id="3_otpho"] +[ext_resource type="PackedScene" uid="uid://d3bhehatwoio" path="res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn" id="3_otpho"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fe32l"] content_margin_left = 2.0 diff --git a/addons/dialogic/Editor/Events/Fields/KeyValuePairValue.gd b/addons/dialogic/Editor/Events/Fields/dictionary_part.gd similarity index 100% rename from addons/dialogic/Editor/Events/Fields/KeyValuePairValue.gd rename to addons/dialogic/Editor/Events/Fields/dictionary_part.gd diff --git a/addons/dialogic/Editor/Events/Fields/KeyValuePairValue.tscn b/addons/dialogic/Editor/Events/Fields/dictionary_part.tscn similarity index 99% rename from addons/dialogic/Editor/Events/Fields/KeyValuePairValue.tscn rename to addons/dialogic/Editor/Events/Fields/dictionary_part.tscn index 17287fd09..aa012bb62 100644 --- a/addons/dialogic/Editor/Events/Fields/KeyValuePairValue.tscn +++ b/addons/dialogic/Editor/Events/Fields/dictionary_part.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://b27yweami3mxi"] [ext_resource type="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="1_4ehmb"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/KeyValuePairValue.gd" id="2_q88pg"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/dictionary_part.gd" id="2_q88pg"] [sub_resource type="Image" id="Image_esvau"] data = { diff --git a/addons/dialogic/Editor/Events/Fields/Array.gd b/addons/dialogic/Editor/Events/Fields/field_array.gd similarity index 79% rename from addons/dialogic/Editor/Events/Fields/Array.gd rename to addons/dialogic/Editor/Events/Fields/field_array.gd index 08a1d43b4..6e0d59c5f 100644 --- a/addons/dialogic/Editor/Events/Fields/Array.gd +++ b/addons/dialogic/Editor/Events/Fields/field_array.gd @@ -1,25 +1,25 @@ @tool -extends HFlowContainer +extends DialogicVisualEditorField ## Event block field for editing arrays. -signal value_changed -var property_name : String -const ArrayValue := "res://addons/dialogic/Editor/Events/Fields/ArrayValue.tscn" +const ArrayValue := "res://addons/dialogic/Editor/Events/Fields/array_part.tscn" + func _ready(): %Add.icon = get_theme_icon("Add", "EditorIcons") %Add.pressed.connect(_on_AddButton_pressed) -func set_value(value:Array) -> void: + +func _set_value(value:Variant) -> void: + value = value as Array for child in get_children(): if child != %Add: child.queue_free() - for item in value: - var x :Node= load(ArrayValue).instantiate() + var x: Node = load(ArrayValue).instantiate() add_child(x) x.set_value(item) x.value_changed.connect(recalculate_values) @@ -27,7 +27,7 @@ func set_value(value:Array) -> void: func _on_value_changed(value:Variant) -> void: - emit_signal("value_changed", property_name, value) + value_changed.emit(property_name, value) func recalculate_values() -> void: diff --git a/addons/dialogic/Editor/Events/Fields/field_array.tscn b/addons/dialogic/Editor/Events/Fields/field_array.tscn new file mode 100644 index 000000000..7cffed150 --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/field_array.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=4 format=3 uid="uid://btmy7ageqpyq1"] + +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_array.gd" id="2"] + +[sub_resource type="Image" id="Image_u0aqk"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_7iwuk"] +image = SubResource("Image_u0aqk") + +[node name="Field_Array" type="HFlowContainer"] +offset_right = 329.0 +offset_bottom = 256.0 +size_flags_horizontal = 3 +script = ExtResource("2") + +[node name="Add" type="Button" parent="."] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Add another value" +icon = SubResource("ImageTexture_7iwuk") diff --git a/addons/dialogic/Editor/Events/Fields/BoolButton.gd b/addons/dialogic/Editor/Events/Fields/field_bool_button.gd similarity index 52% rename from addons/dialogic/Editor/Events/Fields/BoolButton.gd rename to addons/dialogic/Editor/Events/Fields/field_bool_button.gd index dd9bf242b..b4373e79f 100644 --- a/addons/dialogic/Editor/Events/Fields/BoolButton.gd +++ b/addons/dialogic/Editor/Events/Fields/field_bool_button.gd @@ -1,11 +1,10 @@ @tool -extends Button +extends DialogicVisualEditorField ## Event block field for boolean values. -signal value_changed -var property_name : String - +#region MAIN METHODS +################################################################################ func _ready() -> void: add_theme_color_override("icon_normal_color", get_theme_color("disabled_font_color", "Editor")) @@ -13,12 +12,25 @@ func _ready() -> void: add_theme_color_override("icon_pressed_color", get_theme_color("icon_saturation", "Editor")) add_theme_color_override("icon_hover_pressed_color", get_theme_color("warning_color", "Editor")) add_theme_color_override("icon_focus_color", get_theme_color("disabled_font_color", "Editor")) - toggled.connect(_on_value_changed) + self.toggled.connect(_on_value_changed) + + +func _load_display_info(info:Dictionary) -> void: + if info.has('editor_icon'): + self.icon = callv('get_theme_icon', info.editor_icon) + else: + self.icon = info.get('icon', null) + + +func _set_value(value:Variant) -> void: + self.button_pressed = true if value else false +#endregion -func set_value(value:bool) -> void: - button_pressed = value +#region SIGNAL METHODS +################################################################################ func _on_value_changed(value:bool) -> void: value_changed.emit(property_name, value) +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/field_bool_button.tscn b/addons/dialogic/Editor/Events/Fields/field_bool_button.tscn new file mode 100644 index 000000000..e4f7d0adf --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/field_bool_button.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=3 uid="uid://iypxcctv080u"] + +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_bool_button.gd" id="1_t1n1f"] + +[node name="Field_BoolButton" type="Button"] +theme_override_colors/icon_normal_color = Color(0, 0, 0, 1) +theme_override_colors/icon_pressed_color = Color(0, 0, 0, 1) +theme_override_colors/icon_hover_color = Color(0, 0, 0, 1) +theme_override_colors/icon_hover_pressed_color = Color(0, 0, 0, 1) +theme_override_colors/icon_focus_color = Color(0, 0, 0, 1) +toggle_mode = true +flat = true +script = ExtResource("1_t1n1f") diff --git a/addons/dialogic/Editor/Events/Fields/field_bool_check.gd b/addons/dialogic/Editor/Events/Fields/field_bool_check.gd new file mode 100644 index 000000000..98cfd32df --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/field_bool_check.gd @@ -0,0 +1,30 @@ +@tool +extends DialogicVisualEditorField + +## Event block field for boolean values. + +#region MAIN METHODS +################################################################################ +func _ready() -> void: + self.toggled.connect(_on_value_changed) + + +func _load_display_info(info:Dictionary) -> void: + pass + + +func _set_value(value:Variant) -> void: + match DialogicUtil.get_variable_value_type(value): + DialogicUtil.VarTypes.STRING: + self.button_pressed = value and not value == "false" + _: + self.button_pressed = value and true +#endregion + + +#region SIGNAL METHODS +################################################################################ +func _on_value_changed(value:bool) -> void: + value_changed.emit(property_name, value) + +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/Bool.tscn b/addons/dialogic/Editor/Events/Fields/field_bool_check.tscn similarity index 56% rename from addons/dialogic/Editor/Events/Fields/Bool.tscn rename to addons/dialogic/Editor/Events/Fields/field_bool_check.tscn index c995c1c43..395caf50d 100644 --- a/addons/dialogic/Editor/Events/Fields/Bool.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_bool_check.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=2 format=3 uid="uid://dm5hxmhyyxgq"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/Bool.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_bool_check.gd" id="1_ckmtx"] -[node name="Bool" type="CheckButton"] +[node name="Field_BoolCheck" type="CheckButton"] offset_right = 44.0 offset_bottom = 24.0 -script = ExtResource("1") +script = ExtResource("1_ckmtx") diff --git a/addons/dialogic/Editor/Events/Fields/ConditionPicker.gd b/addons/dialogic/Editor/Events/Fields/field_condition.gd similarity index 97% rename from addons/dialogic/Editor/Events/Fields/ConditionPicker.gd rename to addons/dialogic/Editor/Events/Fields/field_condition.gd index afaf695e7..cf547a1fe 100644 --- a/addons/dialogic/Editor/Events/Fields/ConditionPicker.gd +++ b/addons/dialogic/Editor/Events/Fields/field_condition.gd @@ -1,17 +1,32 @@ @tool -extends Control +extends DialogicVisualEditorField ## Event block field for displaying conditions in either a simple or complex way. -signal value_changed -var property_name : String -var event_resource : DialogicEvent = null - var _current_value1 :Variant = "" var _current_value2 :Variant = "" -func _ready() -> void: +#region MAIN METHODS +################################################################################ + +func _set_value(value:Variant) -> void: + var too_complex := is_too_complex(value) + %ToggleComplex.disabled = too_complex + %ToggleComplex.button_pressed = too_complex + %ComplexEditor.visible = too_complex + %SimpleEditor.visible = !too_complex + %ComplexEditor.text = value + if not too_complex: + load_simple_editor(value) + + +func _autofocus(): + %Value1Variable.grab_focus() + +#endregion + +func _ready() -> void: for i in [%Value1Type, %Value2Type]: i.options = [{ 'label': 'String', @@ -62,16 +77,6 @@ func _ready() -> void: ] -func set_value(value:String) -> void: - var too_complex := is_too_complex(value) - %ToggleComplex.disabled = too_complex - %ToggleComplex.button_pressed = too_complex - %ComplexEditor.visible = too_complex - %SimpleEditor.visible = !too_complex - %ComplexEditor.text = value - if not too_complex: - load_simple_editor(value) - func load_simple_editor(condition_string:String) -> void: var data := complex2simple(condition_string) diff --git a/addons/dialogic/Editor/Events/Fields/field_condition.tscn b/addons/dialogic/Editor/Events/Fields/field_condition.tscn new file mode 100644 index 000000000..ea515f7fd --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/field_condition.tscn @@ -0,0 +1,101 @@ +[gd_scene load_steps=9 format=3 uid="uid://ir6334lqtuwt"] + +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_condition.gd" id="1_owjj0"] +[ext_resource type="PackedScene" uid="uid://d3bhehatwoio" path="res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn" id="2_f6v80"] +[ext_resource type="PackedScene" uid="uid://c0vkcehgjsjy" path="res://addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn" id="3_3kfwc"] +[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/field_number.tscn" id="4_6q3a6"] +[ext_resource type="PackedScene" uid="uid://dm5hxmhyyxgq" path="res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn" id="5_1x02a"] +[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="6_5a2xd"] + +[sub_resource type="Image" id="Image_cgfp5"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), +"format": "RGBA8", +"height": 16, +"mipmaps": false, +"width": 16 +} + +[sub_resource type="ImageTexture" id="ImageTexture_4jujf"] +image = SubResource("Image_cgfp5") + +[node name="Field_Condition" type="HBoxContainer"] +offset_right = 77.0 +offset_bottom = 31.0 +script = ExtResource("1_owjj0") + +[node name="SimpleEditor" type="HBoxContainer" parent="."] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value1Type" parent="SimpleEditor" instance=ExtResource("2_f6v80")] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Change type" +text = "" + +[node name="Value1Text" parent="SimpleEditor" instance=ExtResource("3_3kfwc")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value1Number" parent="SimpleEditor" instance=ExtResource("4_6q3a6")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value1Bool" parent="SimpleEditor" instance=ExtResource("5_1x02a")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value1Variable" parent="SimpleEditor" instance=ExtResource("6_5a2xd")] +unique_name_in_owner = true +layout_mode = 2 +placeholder_text = "Variable" + +[node name="Operator" parent="SimpleEditor" instance=ExtResource("2_f6v80")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value2Type" parent="SimpleEditor" instance=ExtResource("2_f6v80")] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Change type" +text = "" + +[node name="Value2Text" parent="SimpleEditor" instance=ExtResource("3_3kfwc")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value2Number" parent="SimpleEditor" instance=ExtResource("4_6q3a6")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="Value2Variable" parent="SimpleEditor" instance=ExtResource("6_5a2xd")] +unique_name_in_owner = true +layout_mode = 2 +placeholder_text = "Variable" + +[node name="Value2Bool" parent="SimpleEditor" instance=ExtResource("5_1x02a")] +unique_name_in_owner = true +layout_mode = 2 + +[node name="ComplexEditor" type="LineEdit" parent="."] +unique_name_in_owner = true +visible = false +custom_minimum_size = Vector2(150, 0) +layout_mode = 2 +mouse_filter = 1 +theme_type_variation = &"DialogicEventEdit" +text = "VAR.Player.Health > 20 and VAR.Counter < 3 and randi()%3 == 2" +placeholder_text = "Enter condition" +expand_to_text_length = true + +[node name="ToggleComplex" type="Button" parent="."] +unique_name_in_owner = true +layout_mode = 2 +tooltip_text = "Use complex expression" +toggle_mode = true +icon = SubResource("ImageTexture_4jujf") + +[connection signal="value_changed" from="SimpleEditor/Value1Variable" to="." method="_on_value_1_variable_value_changed"] +[connection signal="text_changed" from="ComplexEditor" to="." method="_on_complex_editor_text_changed"] +[connection signal="toggled" from="ToggleComplex" to="." method="_on_toggle_complex_toggled"] diff --git a/addons/dialogic/Editor/Events/Fields/KeyValuePairs.gd b/addons/dialogic/Editor/Events/Fields/field_dictionary.gd similarity index 74% rename from addons/dialogic/Editor/Events/Fields/KeyValuePairs.gd rename to addons/dialogic/Editor/Events/Fields/field_dictionary.gd index e209c8484..194f130a5 100644 --- a/addons/dialogic/Editor/Events/Fields/KeyValuePairs.gd +++ b/addons/dialogic/Editor/Events/Fields/field_dictionary.gd @@ -1,22 +1,20 @@ @tool -extends VBoxContainer +extends DialogicVisualEditorField -## Event block field for editing arrays. +## Event block field for editing arrays. -signal value_changed -var property_name : String - -const PairValue = "res://addons/dialogic/Editor/Events/Fields/KeyValuePairValue.tscn" +const PairValue = "res://addons/dialogic/Editor/Events/Fields/dictionary_part.tscn" func _ready(): %Add.icon = get_theme_icon("Add", "EditorIcons") -func set_value(value) -> void: + +func _set_value(value:Variant) -> void: for child in %Values.get_children(): child.queue_free() - + var dict : Dictionary - + # attempt to take dictionary values, create a fresh one if not possible if typeof(value) == TYPE_DICTIONARY: dict = value @@ -29,10 +27,10 @@ func set_value(value) -> void: dict = Dictionary() else: dict = Dictionary() - + var keys := dict.keys() var values := dict.values() - + for index in dict.size(): var x :Node = load(PairValue).instantiate() %Values.add_child(x) @@ -42,7 +40,7 @@ func set_value(value) -> void: func _on_value_changed(value:Variant) -> void: - emit_signal("value_changed", property_name, value) + value_changed.emit(property_name, value) func recalculate_values() -> void: @@ -60,10 +58,3 @@ func _on_AddButton_pressed() -> void: x.set_value("") x.value_changed.connect(recalculate_values) recalculate_values() - - -## Overridable -func set_left_text(value:String) -> void: - %LeftText.text = str(value) - %LeftText.visible = value.is_empty() - diff --git a/addons/dialogic/Editor/Events/Fields/KeyValuePairs.tscn b/addons/dialogic/Editor/Events/Fields/field_dictionary.tscn similarity index 92% rename from addons/dialogic/Editor/Events/Fields/KeyValuePairs.tscn rename to addons/dialogic/Editor/Events/Fields/field_dictionary.tscn index cee9b7573..3bcaa1188 100644 --- a/addons/dialogic/Editor/Events/Fields/KeyValuePairs.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_dictionary.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=5 format=3 uid="uid://c74bnmhefu72w"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/KeyValuePairs.gd" id="1_3mn6b"] -[ext_resource type="PackedScene" uid="uid://b27yweami3mxi" path="res://addons/dialogic/Editor/Events/Fields/KeyValuePairValue.tscn" id="2_g20vj"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_dictionary.gd" id="1_p4kmu"] +[ext_resource type="PackedScene" uid="uid://b27yweami3mxi" path="res://addons/dialogic/Editor/Events/Fields/dictionary_part.tscn" id="2_fg1gy"] -[sub_resource type="Image" id="Image_esvau"] +[sub_resource type="Image" id="Image_5s534"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -12,11 +12,11 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_bywig"] -image = SubResource("Image_esvau") +[sub_resource type="ImageTexture" id="ImageTexture_bnwpy"] +image = SubResource("Image_5s534") [node name="Pairs" type="VBoxContainer"] -script = ExtResource("1_3mn6b") +script = ExtResource("1_p4kmu") [node name="Editing" type="HBoxContainer" parent="."] layout_mode = 2 @@ -31,16 +31,16 @@ size_flags_horizontal = 3 [node name="Add" type="Button" parent="Editing"] unique_name_in_owner = true layout_mode = 2 -icon = SubResource("ImageTexture_bywig") +icon = SubResource("ImageTexture_bnwpy") [node name="Values" type="VBoxContainer" parent="."] unique_name_in_owner = true layout_mode = 2 -[node name="Value" parent="Values" instance=ExtResource("2_g20vj")] +[node name="Value" parent="Values" instance=ExtResource("2_fg1gy")] layout_mode = 2 -[node name="Value2" parent="Values" instance=ExtResource("2_g20vj")] +[node name="Value2" parent="Values" instance=ExtResource("2_fg1gy")] layout_mode = 2 [connection signal="pressed" from="Editing/Add" to="." method="_on_AddButton_pressed"] diff --git a/addons/dialogic/Editor/Events/Fields/FilePicker.gd b/addons/dialogic/Editor/Events/Fields/field_file.gd similarity index 65% rename from addons/dialogic/Editor/Events/Fields/FilePicker.gd rename to addons/dialogic/Editor/Events/Fields/field_file.gd index 625912a51..15d3dd8b9 100644 --- a/addons/dialogic/Editor/Events/Fields/FilePicker.gd +++ b/addons/dialogic/Editor/Events/Fields/field_file.gd @@ -1,15 +1,15 @@ @tool -extends Control +extends DialogicVisualEditorField ## Event block field for selecting a file or directory. -signal value_changed(property_name:String, value:String) -var property_name : String +#region VARIABLES +################################################################################ @export var file_filter := "" @export var placeholder := "" @export var file_mode : EditorFileDialog.FileMode = EditorFileDialog.FILE_MODE_OPEN_FILE -@export var resource_icon:Texture = null: +var resource_icon:Texture: get: return resource_icon set(new_icon): @@ -20,29 +20,51 @@ var property_name : String else: %Field.theme_type_variation = "LineEditWithIcon" -var max_text_length := 16 +var max_width := 200 var current_value : String var hide_reset:bool = false +#endregion + + +#region MAIN METHODS +################################################################################ + func _ready() -> void: $FocusStyle.add_theme_stylebox_override('panel', get_theme_stylebox('focus', 'DialogicEventEdit')) + %OpenButton.icon = get_theme_icon("Folder", "EditorIcons") - %ClearButton.icon = get_theme_icon("Reload", "EditorIcons") %OpenButton.button_down.connect(_on_OpenButton_pressed) + + %ClearButton.icon = get_theme_icon("Reload", "EditorIcons") %ClearButton.button_up.connect(clear_path) %ClearButton.visible = !hide_reset + %Field.set_drag_forwarding(Callable(), self._can_drop_data_fw, self._drop_data_fw) %Field.placeholder_text = placeholder -func set_value(value:String) -> void: +func _load_display_info(info:Dictionary) -> void: + file_filter = info.get('file_filter', '') + placeholder = info.get('placeholder', '') + resource_icon = info.get('icon', null) + await ready + if resource_icon == null and info.has('editor_icon'): + resource_icon = callv('get_theme_icon', info.editor_icon) + + +func _set_value(value:Variant) -> void: current_value = value var text := value if file_mode != EditorFileDialog.FILE_MODE_OPEN_DIR: text = value.get_file() %Field.tooltip_text = value - if len(text) > max_text_length: + + if %Field.get_theme_font('font').get_string_size( + text, 0, -1, + %Field.get_theme_font_size('font_size')).x > max_width: %Field.expand_to_text_length = false + %Field.custom_minimum_size.x = max_width %Field.size.x = 0 else: %Field.custom_minimum_size.x = 0 @@ -53,25 +75,31 @@ func set_value(value:String) -> void: %ClearButton.visible = !value.is_empty() and !hide_reset -func set_enabled(is_enabled: bool) -> void: - %Field.editable = is_enabled - %OpenButton.disabled = !is_enabled - %ClearButton.disabled = !is_enabled +#endregion + +#region BUTTONS +################################################################################ func _on_OpenButton_pressed() -> void: find_parent('EditorView').godot_file_dialog(_on_file_dialog_selected, file_filter, file_mode, "Open "+ property_name) func _on_file_dialog_selected(path:String) -> void: - set_value(path) + _set_value(path) emit_signal("value_changed", property_name, path) func clear_path() -> void: - set_value("") + _set_value("") emit_signal("value_changed", property_name, "") +#endregion + + +#region DRAG AND DROP +################################################################################ + func _can_drop_data_fw(at_position: Vector2, data: Variant) -> bool: if typeof(data) == TYPE_DICTIONARY and data.has('files') and len(data.files) == 1: if file_filter: @@ -83,6 +111,11 @@ func _can_drop_data_fw(at_position: Vector2, data: Variant) -> bool: func _drop_data_fw(at_position: Vector2, data: Variant) -> void: _on_file_dialog_selected(data.files[0]) +#endregion + + +#region VISUALS FOR FOCUS +################################################################################ func _on_field_focus_entered(): $FocusStyle.show() @@ -90,3 +123,5 @@ func _on_field_focus_entered(): func _on_field_focus_exited(): $FocusStyle.hide() _on_file_dialog_selected(%Field.text) + +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/FilePicker.tscn b/addons/dialogic/Editor/Events/Fields/field_file.tscn similarity index 93% rename from addons/dialogic/Editor/Events/Fields/FilePicker.tscn rename to addons/dialogic/Editor/Events/Fields/field_file.tscn index c472e7155..c0e51dace 100644 --- a/addons/dialogic/Editor/Events/Fields/FilePicker.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_file.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=3 uid="uid://7mvxuaulctcq"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.gd" id="1_838yp"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_file.gd" id="1_0grcf"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tr837"] @@ -8,7 +8,7 @@ [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_6b7on"] -[sub_resource type="Image" id="Image_80ipm"] +[sub_resource type="Image" id="Image_kg01j"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -17,10 +17,10 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_u1qpa"] -image = SubResource("Image_80ipm") +[sub_resource type="ImageTexture" id="ImageTexture_j8aof"] +image = SubResource("Image_kg01j") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p6jdu"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_raavq"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -33,11 +33,11 @@ border_width_right = 2 border_width_bottom = 2 corner_detail = 1 -[node name="FilePicker" type="MarginContainer"] -offset_right = 160.0 +[node name="Field_File" type="MarginContainer"] +offset_right = 314.0 offset_bottom = 40.0 theme_type_variation = &"DialogicEventEdit" -script = ExtResource("1_838yp") +script = ExtResource("1_0grcf") [node name="BG" type="PanelContainer" parent="."] layout_mode = 2 @@ -67,20 +67,20 @@ expand_to_text_length = true [node name="OpenButton" type="Button" parent="BG/HBox"] unique_name_in_owner = true layout_mode = 2 -icon = SubResource("ImageTexture_u1qpa") +icon = SubResource("ImageTexture_j8aof") flat = true [node name="ClearButton" type="Button" parent="BG/HBox"] unique_name_in_owner = true layout_mode = 2 -icon = SubResource("ImageTexture_u1qpa") +icon = SubResource("ImageTexture_j8aof") flat = true [node name="FocusStyle" type="Panel" parent="."] visible = false layout_mode = 2 mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_p6jdu") +theme_override_styles/panel = SubResource("StyleBoxFlat_raavq") [connection signal="focus_entered" from="BG/HBox/Field" to="." method="_on_field_focus_entered"] [connection signal="focus_exited" from="BG/HBox/Field" to="." method="_on_field_focus_exited"] diff --git a/addons/dialogic/Editor/Events/Fields/Number.gd b/addons/dialogic/Editor/Events/Fields/field_number.gd similarity index 73% rename from addons/dialogic/Editor/Events/Fields/Number.gd rename to addons/dialogic/Editor/Events/Fields/field_number.gd index a15f25209..4c7c7c3c5 100644 --- a/addons/dialogic/Editor/Events/Fields/Number.gd +++ b/addons/dialogic/Editor/Events/Fields/field_number.gd @@ -1,11 +1,8 @@ @tool -extends Control +extends DialogicVisualEditorField ## Event block field for integers and floats. Improved version of the native spinbox. -signal value_changed -var property_name : String - @export var allow_string :bool = false @export var step:float = 0.1 @export var enforce_step:bool = true @@ -14,17 +11,38 @@ var property_name : String @export var value = 0 @export var suffix := "" + +#region MAIN METHODS +################################################################################ + func _ready() -> void: if $Value.text.is_empty(): set_value(value) $Spin.icon = get_theme_icon("updown", "SpinBox") -func set_value(new_value:Variant) -> void: +func _load_display_info(info:Dictionary) -> void: + match info.get('mode', 0): + 0: #FLOAT + use_float_mode() + 1: #INT + use_int_mode() + 2: #DECIBLE: + use_decibel_mode() + + max = info.get('max', max) + min = info.get('min', min) + + +func _set_value(new_value:Variant) -> void: _on_value_text_submitted(str(new_value), true) $Value.tooltip_text = tooltip_text +func _autofocus(): + $Value.grab_focus() + + func get_value() -> float: return value @@ -38,6 +56,7 @@ func use_float_mode() -> void: func use_int_mode() -> void: step = 1 suffix = "" + enforce_step = true func use_decibel_mode() -> void: @@ -45,7 +64,11 @@ func use_decibel_mode() -> void: suffix = "dB" min = -80 +#endregion + +#region SIGNAL METHODS +################################################################################ func _on_spin_gui_input(event:InputEvent) -> void: if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: if event.position.y < size.y/2.0: @@ -72,6 +95,4 @@ func _on_value_text_submitted(new_text:String, no_signal:= false) -> void: func _on_value_focus_exited() -> void: _on_value_text_submitted($Value.text) - -func take_autofocus(): - $Value.grab_focus() +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/Number.tscn b/addons/dialogic/Editor/Events/Fields/field_number.tscn similarity index 94% rename from addons/dialogic/Editor/Events/Fields/Number.tscn rename to addons/dialogic/Editor/Events/Fields/field_number.tscn index e41eceb85..88feb08c4 100644 --- a/addons/dialogic/Editor/Events/Fields/Number.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_number.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://kdpp3mibml33"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/Number.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_number.gd" id="1_0jdnn"] -[sub_resource type="Image" id="Image_yitwe"] +[sub_resource type="Image" id="Image_6ljqy"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 76, 255, 255, 255, 75, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 99, 255, 255, 255, 191, 255, 255, 255, 191, 255, 255, 255, 99, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 4, 255, 255, 255, 122, 255, 255, 255, 191, 255, 255, 255, 188, 255, 255, 255, 188, 255, 255, 255, 191, 255, 255, 255, 121, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 12, 255, 255, 255, 142, 255, 255, 255, 191, 255, 255, 255, 181, 255, 255, 255, 53, 255, 255, 255, 54, 255, 255, 255, 181, 255, 255, 255, 191, 255, 255, 255, 142, 255, 255, 255, 12, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 71, 255, 255, 255, 191, 255, 255, 255, 171, 255, 255, 255, 36, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 36, 255, 255, 255, 171, 255, 255, 255, 191, 255, 255, 255, 71, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 86, 255, 255, 255, 22, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 22, 255, 255, 255, 86, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 86, 255, 255, 255, 22, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 22, 255, 255, 255, 86, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 71, 255, 255, 255, 191, 255, 255, 255, 171, 255, 255, 255, 36, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 36, 255, 255, 255, 171, 255, 255, 255, 191, 255, 255, 255, 71, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 12, 255, 255, 255, 142, 255, 255, 255, 191, 255, 255, 255, 181, 255, 255, 255, 54, 255, 255, 255, 54, 255, 255, 255, 182, 255, 255, 255, 191, 255, 255, 255, 142, 255, 255, 255, 12, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 4, 255, 255, 255, 121, 255, 255, 255, 191, 255, 255, 255, 188, 255, 255, 255, 188, 255, 255, 255, 191, 255, 255, 255, 121, 255, 255, 255, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 98, 255, 255, 255, 191, 255, 255, 255, 191, 255, 255, 255, 98, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -11,10 +11,10 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_uwu06"] -image = SubResource("Image_yitwe") +[sub_resource type="ImageTexture" id="ImageTexture_eaxil"] +image = SubResource("Image_6ljqy") -[node name="NumberValue" type="HBoxContainer"] +[node name="Field_Number" type="HBoxContainer"] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -23,7 +23,7 @@ offset_bottom = -615.0 grow_horizontal = 2 grow_vertical = 2 theme_override_constants/separation = 0 -script = ExtResource("1") +script = ExtResource("1_0jdnn") value = 0.0 [node name="Value" type="LineEdit" parent="."] @@ -37,7 +37,7 @@ expand_to_text_length = true layout_mode = 2 size_flags_vertical = 4 focus_mode = 0 -icon = SubResource("ImageTexture_uwu06") +icon = SubResource("ImageTexture_eaxil") flat = true [connection signal="focus_exited" from="Value" to="." method="_on_value_focus_exited"] diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd similarity index 56% rename from addons/dialogic/Editor/Events/Fields/ComplexPicker.gd rename to addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd index 25df4dab5..7356194b9 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd +++ b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd @@ -1,22 +1,18 @@ @tool -extends Control +extends DialogicVisualEditorField -## Event block field for resources/options. +## Event block field for strings. Options are determined by a function. -# this signal is on all event parts and informs the event that a change happened. -signal value_changed(property_name, value) -var property_name : String -var event_resource : DialogicEvent = null -### SETTINGS FOR THE RESOURCE PICKER -@export var placeholder_text : String = "Select Resource" +## SETTINGS +@export var placeholder_text := "Select Resource" +@export var empty_text := "" +enum Modes {PURE_STRING, PRETTY_PATH, IDENTIFIER} +@export var mode := Modes.PURE_STRING +@export var fit_text_length := true var collapse_when_empty := false -var file_extension : String = "" -var get_suggestions_func : Callable = get_default_suggestions -var empty_text : String = "" -@export var enable_pretty_name : bool = false -@export var fit_text_length : bool = true -var force_string := false +var valid_file_drop_extension := "" +var get_suggestions_func : Callable var resource_icon : Texture = null: get: @@ -25,77 +21,78 @@ var resource_icon : Texture = null: resource_icon = new_icon %Icon.texture = new_icon -## STORING VALUE AND REFERENCE TO RESOURCE -var current_value :Variant # Dynamic +## STATE +var current_value: String +var current_selected := 0 -var current_selected = 0 -################################################################################ -## BASIC EVENT PART FUNCTIONS +#region FIELD METHODS ################################################################################ -func set_value(value:Variant, text : String = '') -> void: - %Search.show() +func _set_value(value:Variant, text:String = '') -> void: if value == null or value.is_empty(): %Search.text = empty_text - if collapse_when_empty: - %Search.hide() - elif file_extension != "" and file_extension != ".dch" and file_extension != ".dtl": - %Search.text = value.resource_path - %Search.tooltip_text = value.resource_path - elif value: - if enable_pretty_name: - %Search.text = DialogicUtil.pretty_name(value) - else: - %Search.text = value else: - %Search.text = empty_text - if text: - %Search.text = text - - current_value = value - + match mode: + Modes.PRETTY_PATH: + %Search.text = DialogicUtil.pretty_name(value) + Modes.IDENTIFIER when value.begins_with("res://"): + %Search.text = DialogicResourceUtil.get_unique_identifier(value) + _: + %Search.text = str(value) + + %Search.visible = not collapse_when_empty or value + current_value = str(value) + + +func _load_display_info(info:Dictionary) -> void: + valid_file_drop_extension = info.get('file_extension', '') + collapse_when_empty = info.get('collapse_when_empty', false) + get_suggestions_func = info.get('suggestions_func', get_suggestions_func) + empty_text = info.get('empty_text', '') + placeholder_text = info.get('placeholder', 'Select Resource') + mode = info.get("mode", 0) + resource_icon = info.get('icon', null) + await ready + if resource_icon == null and info.has('editor_icon'): + resource_icon = callv('get_theme_icon', info.editor_icon) + + +func _autofocus() -> void: + %Search.grab_focus() -func changed_to_empty() -> void: - if file_extension != "" and file_extension != ".dch" and !force_string: - emit_signal("value_changed", property_name, null) - else: - emit_signal("value_changed", property_name, "") +#endregion +#region BASIC ################################################################################ -## BASIC -################################################################################ -func _ready(): + +func _ready() -> void: %Focus.add_theme_stylebox_override('panel', get_theme_stylebox('focus', 'DialogicEventEdit')) + %Search.text_changed.connect(_on_Search_text_changed) %Search.text_submitted.connect(_on_Search_text_entered) - %SelectButton.icon = get_theme_icon("Collapse", "EditorIcons") %Search.placeholder_text = placeholder_text %Search.expand_to_text_length = fit_text_length + + %SelectButton.icon = get_theme_icon("Collapse", "EditorIcons") + %Suggestions.add_theme_stylebox_override('bg', load("res://addons/dialogic/Editor/Events/styles/ResourceMenuPanelBackground.tres")) %Suggestions.hide() %Suggestions.item_selected.connect(suggestion_selected) %Suggestions.item_clicked.connect(suggestion_selected) + if resource_icon == null: self.resource_icon = null +func change_to_empty() -> void: + value_changed.emit(property_name, "") -func _exit_tree(): - # Explicitly free any open cache resources on close, so we don't get leaked resource errors on shutdown - event_resource = null +#endregion -func take_autofocus(): - %Search.grab_focus() - - -func set_enabled(is_enabled: bool) -> void: - %SelectButton.disabled = !is_enabled - -################################################################################ -## SEARCH & SUGGESTION POPUP +#region SEARCH & SUGGESTION POPUP ################################################################################ func _on_Search_text_entered(new_text:String) -> void: if %Suggestions.get_item_count(): @@ -104,18 +101,18 @@ func _on_Search_text_entered(new_text:String) -> void: else: suggestion_selected(0) else: - changed_to_empty() + change_to_empty() func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void: %Suggestions.clear() if new_text == "" and !just_update: - changed_to_empty() + change_to_empty() else: %Search.show() - var suggestions :Dictionary = get_suggestions_func.call(new_text) + var suggestions: Dictionary = get_suggestions_func.call(new_text) var line_length:int = 0 var idx:int = 0 @@ -138,22 +135,14 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void: #%Suggestions.position = Vector2() %Suggestions.size.x = max(%Search.size.x, line_length) %Suggestions.size.y = min(%Suggestions.get_item_count()*35*DialogicUtil.get_editor_scale(), 200*DialogicUtil.get_editor_scale()) + if %Suggestions.get_item_count(): %Suggestions.select(0) current_selected = 0 else: current_selected = -1 - %Search.grab_focus() - -func get_default_suggestions(input:String) -> Dictionary: - if file_extension.is_empty(): - return {'Nothing found!':{'value':''}} - - var suggestions: Dictionary = {} - for resource in DialogicResourceUtil.list_resources_of_type(file_extension): - suggestions[resource] = {'value':resource, 'tooltip':resource} - return suggestions + %Search.grab_focus() func suggestion_selected(index : int, position:=Vector2(), button_index:=MOUSE_BUTTON_LEFT) -> void: @@ -165,21 +154,18 @@ func suggestion_selected(index : int, position:=Vector2(), button_index:=MOUSE_B %Search.text = %Suggestions.get_item_text(index) if %Suggestions.get_item_metadata(index) == null: - current_value = null + current_value = "" - # if this is a resource, then load it instead of assigning the string: - elif file_extension != "" and file_extension != ".dch" and file_extension != ".dtl": - var file = load(%Suggestions.get_item_metadata(index)) - current_value = file else: current_value = %Suggestions.get_item_metadata(index) hide_suggestions() - %Search.grab_focus() - emit_signal("value_changed", property_name, current_value) + grab_focus() + value_changed.emit(property_name, current_value) + -func _input(event:InputEvent): +func _input(event:InputEvent) -> void: if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: if %Suggestions.visible: if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()) and \ @@ -200,11 +186,12 @@ func _on_SelectButton_toggled(button_pressed:bool) -> void: else: hide_suggestions() -func _on_focus_entered(): + +func _on_focus_entered() -> void: %Search.grab_focus() -func _on_search_gui_input(event): +func _on_search_gui_input(event: InputEvent) -> void: if event is InputEventKey and (event.keycode == KEY_DOWN or event.keycode == KEY_UP) and event.pressed: if !%Suggestions.visible: _on_Search_text_changed('', true) @@ -217,46 +204,39 @@ func _on_search_gui_input(event): %Suggestions.ensure_current_is_visible() -func _on_search_focus_entered(): - if %Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()): +func _on_search_focus_entered() -> void: + if %Search.text == "" or current_value == "": _on_Search_text_changed("") %Search.call_deferred('select_all') %Focus.show() -func _on_search_focus_exited(): +func _on_search_focus_exited() -> void: %Focus.hide() if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()): hide_suggestions() -################################################################################ -## DRAG AND DROP +#endregion + + +#region DRAG AND DROP ################################################################################ -func _can_drop_data(position, data) -> bool: +func _can_drop_data(position:Vector2, data:Variant) -> bool: if typeof(data) == TYPE_DICTIONARY and data.has('files') and len(data.files) == 1: - if file_extension: - if data.files[0].ends_with(file_extension): + if valid_file_drop_extension: + if data.files[0].ends_with(valid_file_drop_extension): return true else: return false return false -func _drop_data(position, data) -> void: - if data.files[0].ends_with('.dch'): - var character_directory := DialogicResourceUtil.get_character_directory() - for character in character_directory: - if character_directory[character] == data.files[0]: - set_value(character) - break - elif data.files[0].ends_with('dtl'): - var timeline_directory := DialogicResourceUtil.get_timeline_directory() - for timeline in timeline_directory: - if timeline_directory[timeline] == data.files[0]: - set_value(timeline) - break - else: - var file := load(data.files[0]) - set_value(file) - value_changed.emit(property_name, file) +func _drop_data(position:Vector2, data:Variant) -> void: + var path := str(data.files[0]) + if mode == Modes.IDENTIFIER: + path = DialogicResourceUtil.get_unique_identifier(path) + _set_value(path) + value_changed.emit(property_name, path) + +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn similarity index 94% rename from addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn rename to addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn index c05473d4a..8b6e0a22b 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=7 format=3 uid="uid://dpwhshre1n4t6"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd" id="1_b07gq"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tmt5n"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vennf"] -[sub_resource type="Image" id="Image_tmsys"] +[sub_resource type="Image" id="Image_kg01j"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -15,10 +15,10 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_wps7w"] -image = SubResource("Image_tmsys") +[sub_resource type="ImageTexture" id="ImageTexture_j8aof"] +image = SubResource("Image_kg01j") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_j1gic"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_raavq"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -31,7 +31,7 @@ border_width_right = 2 border_width_bottom = 2 corner_detail = 1 -[node name="ComplexPicker" type="HBoxContainer"] +[node name="Field_DynamicStringOptions" type="HBoxContainer"] anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 @@ -42,7 +42,7 @@ offset_bottom = -622.0 grow_horizontal = 2 grow_vertical = 2 focus_mode = 2 -script = ExtResource("1") +script = ExtResource("1_b07gq") placeholder_text = "" [node name="PanelContainer" type="MarginContainer" parent="."] @@ -115,15 +115,14 @@ layout_mode = 2 focus_mode = 0 toggle_mode = true shortcut_in_tooltip = false -icon = SubResource("ImageTexture_wps7w") +icon = SubResource("ImageTexture_j8aof") flat = true [node name="Focus" type="Panel" parent="PanelContainer"] unique_name_in_owner = true -visible = false layout_mode = 2 mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_j1gic") +theme_override_styles/panel = SubResource("StyleBoxFlat_raavq") metadata/_edit_use_anchors_ = true [connection signal="focus_entered" from="." to="." method="_on_focus_entered"] diff --git a/addons/dialogic/Editor/Events/Fields/OptionSelector.gd b/addons/dialogic/Editor/Events/Fields/field_options_fixed.gd similarity index 53% rename from addons/dialogic/Editor/Events/Fields/OptionSelector.gd rename to addons/dialogic/Editor/Events/Fields/field_options_fixed.gd index 62d8d16ea..0b379f50e 100644 --- a/addons/dialogic/Editor/Events/Fields/OptionSelector.gd +++ b/addons/dialogic/Editor/Events/Fields/field_options_fixed.gd @@ -1,11 +1,8 @@ @tool -extends MenuButton +extends DialogicVisualEditorField ## Event block field for constant options. For varying options use ComplexPicker. -signal value_changed -var property_name : String - var options : Array = [] ## if true, only the symbol will be displayed. In the dropdown text will be visible. @@ -13,24 +10,31 @@ var options : Array = [] var symbol_only := false: set(value): symbol_only = value - if value: text = "" + if value: self.text = "" + +var current_value: Variant = -1 -var current_value :Variant = -1 func _ready() -> void: add_theme_color_override("font_disabled_color", get_theme_color("font_color", "MenuButton")) - about_to_popup.connect(insert_options) - get_popup().index_pressed.connect(index_pressed) + self.about_to_popup.connect(insert_options) + call("get_popup").index_pressed.connect(index_pressed) + + +func _load_display_info(info:Dictionary) -> void: + options = info.get('options', []) + self.disabled = info.get('disabled', false) + symbol_only = info.get('symbol_only', false) -func set_value(value) -> void: +func _set_value(value:Variant) -> void: for option in options: if option['value'] == value: if typeof(option.get('icon')) == TYPE_ARRAY: option.icon = callv('get_theme_icon', option.get('icon')) if !symbol_only: - text = option['label'] - icon = option.get('icon', null) + self.text = option['label'] + self.icon = option.get('icon', null) current_value = value @@ -39,20 +43,20 @@ func get_value() -> Variant: func insert_options() -> void: - get_popup().clear() + call("get_popup").clear() var idx := 0 for option in options: if typeof(option.get('icon')) == TYPE_ARRAY: option.icon = callv('get_theme_icon', option.get('icon')) - get_popup().add_icon_item(option.get('icon', null), option['label']) - get_popup().set_item_metadata(idx, option['value']) + call("get_popup").add_icon_item(option.get('icon', null), option['label']) + call("get_popup").set_item_metadata(idx, option['value']) idx += 1 func index_pressed(idx:int) -> void: current_value = idx if !symbol_only: - text = get_popup().get_item_text(idx) - icon = get_popup().get_item_icon(idx) - value_changed.emit(property_name, get_popup().get_item_metadata(idx)) + self.text = call("get_popup").get_item_text(idx) + self.icon =call("get_popup").get_item_icon(idx) + value_changed.emit(property_name, call("get_popup").get_item_metadata(idx)) diff --git a/addons/dialogic/Editor/Events/Fields/OptionSelector.tscn b/addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn similarity index 79% rename from addons/dialogic/Editor/Events/Fields/OptionSelector.tscn rename to addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn index 15c24588d..550160c24 100644 --- a/addons/dialogic/Editor/Events/Fields/OptionSelector.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=2 format=3 uid="uid://d3bhehatwoio"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/OptionSelector.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_options_fixed.gd" id="1"] -[node name="OptionSelector" type="MenuButton"] +[node name="Field_FixedOptions" type="MenuButton"] offset_right = 137.0 offset_bottom = 43.0 focus_mode = 2 diff --git a/addons/dialogic/Editor/Events/Fields/MultilineText.gd b/addons/dialogic/Editor/Events/Fields/field_text_multiline.gd similarity index 69% rename from addons/dialogic/Editor/Events/Fields/MultilineText.gd rename to addons/dialogic/Editor/Events/Fields/field_text_multiline.gd index a609d793f..8d9d54114 100644 --- a/addons/dialogic/Editor/Events/Fields/MultilineText.gd +++ b/addons/dialogic/Editor/Events/Fields/field_text_multiline.gd @@ -1,25 +1,44 @@ @tool -extends CodeEdit +extends DialogicVisualEditorField ## Event block field that allows entering multiline text (mainly text event). -var property_name : String -signal value_changed - -@onready var code_completion_helper :Node= find_parent('EditorsManager').get_node('CodeCompletionHelper') +@onready var code_completion_helper: Node = find_parent('EditorsManager').get_node('CodeCompletionHelper') var previous_width := 0 var height_recalculation_queued := false + +#region MAIN METHODS +################################################################################ + func _ready() -> void: - text_changed.connect(_on_text_changed) - syntax_highlighter = code_completion_helper.text_syntax_highlighter + self.text_changed.connect(_on_text_changed) + self.syntax_highlighter = code_completion_helper.text_syntax_highlighter resized.connect(_resized) +func _load_display_info(info:Dictionary) -> void: + pass + + +func _set_value(value:Variant) -> void: + self.text = str(value) + queue_height_recalculation() + + +func _autofocus() -> void: + grab_focus() + +#endregion + + +#region SIGNAL METHODS +################################################################################ + func _on_text_changed(value := "") -> void: - emit_signal("value_changed", property_name, text) - request_code_completion(true) + value_changed.emit(property_name, self.text) + _request_code_completion(true) queue_height_recalculation() @@ -28,6 +47,11 @@ func _resized() -> void: queue_height_recalculation() previous_width = size.x +#endregion + + +#region HEIGHT CALCULATION +################################################################################ func queue_height_recalculation(): if !is_node_ready(): @@ -39,26 +63,18 @@ func queue_height_recalculation(): ## This shouldn't be necessary bug [fit_content_height] creates a crash. -## Remove again once https://github.com/godotengine/godot/issues/80546 is fixed. +## TODO Remove again once https://github.com/godotengine/godot/issues/80546 is fixed. func recalculate_height() -> void: height_recalculation_queued = false var font :Font = get_theme_font("font") - var text_size = font.get_multiline_string_size(text+' ', HORIZONTAL_ALIGNMENT_LEFT, size.x, get_theme_font_size("font_size")) + var text_size = font.get_multiline_string_size(self.text+' ', HORIZONTAL_ALIGNMENT_LEFT, size.x, get_theme_font_size("font_size")) custom_minimum_size.y = text_size.y+20+4*(floor(text_size.y/get_theme_font_size("font_size"))) - scroll_vertical = 0 + self.scroll_vertical = 0 - -func set_value(value:Variant) -> void: - text = str(value) - queue_height_recalculation() +#endregion -func take_autofocus() -> void: - grab_focus() - - -################################################################################ -## AUTO COMPLETION +#region AUTO COMPLETION ################################################################################ ## Called if something was typed @@ -77,9 +93,10 @@ func _filter_code_completion_candidates(candidates:Array) -> Array: func _confirm_code_completion(replace:bool) -> void: code_completion_helper.confirm_code_completion(replace, self) +#endregion -################################################################################ -## SYMBOL CLICKING + +#region SYMBOL CLICKING ################################################################################ ## Performs an action (like opening a link) when a valid symbol was clicked @@ -90,3 +107,5 @@ func _on_symbol_lookup(symbol, line, column): ## Called to test if a symbol can be clicked func _on_symbol_validate(symbol:String) -> void: code_completion_helper.symbol_validate(symbol, self) + +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/MultilineText.tscn b/addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn similarity index 74% rename from addons/dialogic/Editor/Events/Fields/MultilineText.tscn rename to addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn index 5e2bd3cfe..b73197b80 100644 --- a/addons/dialogic/Editor/Events/Fields/MultilineText.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn @@ -1,18 +1,18 @@ [gd_scene load_steps=5 format=3 uid="uid://dyp7m2nvab1aj"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/MultilineText.gd" id="1"] -[ext_resource type="StyleBox" uid="uid://cu8otiwksn8ma" path="res://addons/dialogic/Editor/Events/styles/TextBackground.tres" id="1_dkxlh"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd" id="1_wj4ha"] +[ext_resource type="StyleBox" uid="uid://cu8otiwksn8ma" path="res://addons/dialogic/Editor/Events/styles/TextBackground.tres" id="1_xq18n"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd" id="2_ww6ga"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_text_multiline.gd" id="3_q7600"] [sub_resource type="SyntaxHighlighter" id="SyntaxHighlighter_2q5dk"] -script = ExtResource("1_wj4ha") +script = ExtResource("2_ww6ga") -[node name="MultilineText" type="CodeEdit"] +[node name="Field_Text_Multiline" type="CodeEdit"] offset_right = 413.0 offset_bottom = 15.0 size_flags_horizontal = 3 size_flags_vertical = 3 -theme_override_styles/normal = ExtResource("1_dkxlh") +theme_override_styles/normal = ExtResource("1_xq18n") wrap_mode = 1 syntax_highlighter = SubResource("SyntaxHighlighter_2q5dk") symbol_lookup_on_click = true @@ -25,4 +25,4 @@ auto_brace_completion_pairs = { "[": "]", "{": "}" } -script = ExtResource("1") +script = ExtResource("3_q7600") diff --git a/addons/dialogic/Editor/Events/Fields/field_text_singleline.gd b/addons/dialogic/Editor/Events/Fields/field_text_singleline.gd new file mode 100644 index 000000000..c6378eec4 --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/field_text_singleline.gd @@ -0,0 +1,40 @@ +@tool +extends DialogicVisualEditorField + +## Event block field for a single line of text. + + +var placeholder :String= "": + set(value): + placeholder = value + self.placeholder_text = placeholder + + +#region MAIN METHODS +################################################################################ + +func _ready() -> void: + self.text_changed.connect(_on_text_changed) + + +func _load_display_info(info:Dictionary) -> void: + self.placeholder = info.get('placeholder', '') + + +func _set_value(value:Variant) -> void: + self.text = str(value) + + +func _autofocus(): + grab_focus() + +#endregion + + +#region SIGNAL METHODS +################################################################################ + +func _on_text_changed(value := "") -> void: + value_changed.emit(property_name, self.text) + +#endregion diff --git a/addons/dialogic/Editor/Events/Fields/SinglelineText.tscn b/addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn similarity index 63% rename from addons/dialogic/Editor/Events/Fields/SinglelineText.tscn rename to addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn index 327083c49..d90d3b05d 100644 --- a/addons/dialogic/Editor/Events/Fields/SinglelineText.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=2 format=3 uid="uid://c0vkcehgjsjy"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/SinglelineText.gd" id="1"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_text_singleline.gd" id="1_4vnxv"] -[node name="SingleLineText" type="LineEdit"] +[node name="Field_Text_Singleline" type="LineEdit"] offset_right = 1152.0 offset_bottom = 81.0 theme_type_variation = &"DialogicEventEdit" expand_to_text_length = true -script = ExtResource("1") +script = ExtResource("1_4vnxv") diff --git a/addons/dialogic/Editor/Events/Fields/Vector2.gd b/addons/dialogic/Editor/Events/Fields/field_vector2.gd similarity index 72% rename from addons/dialogic/Editor/Events/Fields/Vector2.gd rename to addons/dialogic/Editor/Events/Fields/field_vector2.gd index 3c02d2e03..3c1d7f1d3 100644 --- a/addons/dialogic/Editor/Events/Fields/Vector2.gd +++ b/addons/dialogic/Editor/Events/Fields/field_vector2.gd @@ -1,11 +1,8 @@ @tool -extends Control +extends DialogicVisualEditorField ## Event block field for a vector. -signal value_changed -var property_name : String - var current_value := Vector2() func _ready() -> void: @@ -13,14 +10,14 @@ func _ready() -> void: $Y.value_changed.connect(_on_value_changed) -func _on_value_changed(property:String, value:float) -> void: - current_value = Vector2($X.value, $Y.value) - emit_signal("value_changed", property_name, current_value) - - -func set_value(value:Vector2) -> void: +func _set_value(value:Variant) -> void: $X.tooltip_text = tooltip_text $Y.tooltip_text = tooltip_text $X.set_value(value.x) $Y.set_value(value.y) current_value = value + + +func _on_value_changed(property:String, value:float) -> void: + current_value = Vector2($X.value, $Y.value) + value_changed.emit(property_name, current_value) diff --git a/addons/dialogic/Editor/Events/Fields/Vector2.tscn b/addons/dialogic/Editor/Events/Fields/field_vector2.tscn similarity index 55% rename from addons/dialogic/Editor/Events/Fields/Vector2.tscn rename to addons/dialogic/Editor/Events/Fields/field_vector2.tscn index 6e55d69f9..919fb8b00 100644 --- a/addons/dialogic/Editor/Events/Fields/Vector2.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_vector2.tscn @@ -1,22 +1,22 @@ [gd_scene load_steps=3 format=3 uid="uid://dtimnsj014cu"] -[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/Vector2.gd" id="1_288li"] -[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/Number.tscn" id="3_l3bum"] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/field_vector2.gd" id="1_v6lp0"] +[ext_resource type="PackedScene" uid="uid://kdpp3mibml33" path="res://addons/dialogic/Editor/Events/Fields/field_number.tscn" id="2_a0b6y"] -[node name="Vector2" type="HBoxContainer"] +[node name="Field_Vector2" type="HBoxContainer"] offset_right = 40.0 offset_bottom = 40.0 theme_override_constants/separation = -7 -script = ExtResource("1_288li") +script = ExtResource("1_v6lp0") -[node name="X" parent="." instance=ExtResource("3_l3bum")] +[node name="X" parent="." instance=ExtResource("2_a0b6y")] layout_mode = 2 step = 1.0 min = -9999.0 max = 9999.0 suffix = "x" -[node name="Y" parent="." instance=ExtResource("3_l3bum")] +[node name="Y" parent="." instance=ExtResource("2_a0b6y")] layout_mode = 2 step = 1.0 min = -9999.0 diff --git a/addons/dialogic/Editor/Events/event_field.gd b/addons/dialogic/Editor/Events/event_field.gd new file mode 100644 index 000000000..f5db871fd --- /dev/null +++ b/addons/dialogic/Editor/Events/event_field.gd @@ -0,0 +1,35 @@ +@tool +class_name DialogicVisualEditorField +extends Control + +signal value_changed(property_name:String, value:Variant) +var property_name := "" + +var event_resource: DialogicEvent = null + +#region OVERWRITES +################################################################################ + +## To be overwritten +func _load_display_info(info:Dictionary) -> void: + pass + + +## To be overwritten +func _set_value(value:Variant) -> void: + pass + + +## To be overwritten +func _autofocus() -> void: + pass + +#endregion + + +func set_value(value:Variant) -> void: + _set_value(value) + + +func take_autofocus() -> void: + _autofocus() diff --git a/addons/dialogic/Editor/Settings/settings_general.tscn b/addons/dialogic/Editor/Settings/settings_general.tscn index 51f73205a..a3f9ce777 100644 --- a/addons/dialogic/Editor/Settings/settings_general.tscn +++ b/addons/dialogic/Editor/Settings/settings_general.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Settings/settings_general.gd" id="2"] [ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_kqhx5"] -[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="3_i7rug"] +[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/field_file.tscn" id="3_i7rug"] [sub_resource type="Image" id="Image_e2a0f"] data = { diff --git a/addons/dialogic/Editor/Settings/settings_translation.tscn b/addons/dialogic/Editor/Settings/settings_translation.tscn index 0da6cbb30..79edcc829 100644 --- a/addons/dialogic/Editor/Settings/settings_translation.tscn +++ b/addons/dialogic/Editor/Settings/settings_translation.tscn @@ -2,8 +2,8 @@ [ext_resource type="Script" path="res://addons/dialogic/Editor/Settings/settings_translation.gd" id="1_dvmyi"] [ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_k2lou"] -[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn" id="3_dq4j2"] -[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="4_kvsma"] +[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="3_dq4j2"] +[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/field_file.tscn" id="4_kvsma"] [sub_resource type="Image" id="Image_e2a0f"] data = { diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd index 2b9583f62..874448030 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd @@ -332,36 +332,36 @@ func add_event_node(event_resource:DialogicEvent, at_index:int = -1, auto_select if event_resource['event_node_as_text'] != "": event_resource._load_from_string(event_resource['event_node_as_text']) - var piece :Control = event_node.instantiate() - piece.resource = event_resource - event_resource._editor_node = piece + var block: Control = event_node.instantiate() + block.resource = event_resource + event_resource._editor_node = block event_resource._enter_visual_editor(timeline_editor) - piece.content_changed.connect(something_changed) + block.content_changed.connect(something_changed) if event_resource.event_name == "Label": - piece.content_changed.connect(update_content_list) + block.content_changed.connect(update_content_list) if at_index == -1: if len(selected_items) != 0: - selected_items[0].add_sibling(piece) + selected_items[0].add_sibling(block) else: - %Timeline.add_child(piece) + %Timeline.add_child(block) else: - %Timeline.add_child(piece) - %Timeline.move_child(piece, at_index) + %Timeline.add_child(block) + %Timeline.move_child(block, at_index) - piece.gui_input.connect(_on_event_block_gui_input.bind(piece)) + block.gui_input.connect(_on_event_block_gui_input.bind(block)) # Building editing part - piece.build_editor(true, event_resource.expand_by_default) + block.build_editor(true, event_resource.expand_by_default) if auto_select: - select_item(piece, false) + select_item(block, false) # Indent on create if indent: indent_events() - return piece + return block func create_end_branch_event(at_index:int, parent_node:Node) -> Node: @@ -828,54 +828,54 @@ func indent_events() -> void: # will be applied to the indent after the current event var delayed_indent: int = 0 - for event in event_list: - if (not "resource" in event): + for block in event_list: + if (not "resource" in block): continue - if (not currently_hidden) and event.resource.can_contain_events and event.end_node and event.collapsed: + if (not currently_hidden) and block.resource.can_contain_events and block.end_node and block.collapsed: currently_hidden = true - hidden_until = event.end_node + hidden_until = block.end_node hidden_count = 0 - elif currently_hidden and event == hidden_until: - event.update_hidden_events_indicator(hidden_count) + elif currently_hidden and block == hidden_until: + block.update_hidden_events_indicator(hidden_count) currently_hidden = false hidden_until = null elif currently_hidden: - event.hide() + block.hide() hidden_count += 1 else: - event.show() - if event.resource is DialogicEndBranchEvent: - event.update_hidden_events_indicator(0) + block.show() + if block.resource is DialogicEndBranchEvent: + block.update_hidden_events_indicator(0) delayed_indent = 0 - if event.resource.can_contain_events: + if block.resource.can_contain_events: delayed_indent = 1 - if event.resource.needs_parent_event: - var current_block_above := get_block_above(event) + if block.resource.needs_parent_event: + var current_block_above := get_block_above(block) while current_block_above != null and current_block_above.resource is DialogicEndBranchEvent: - if current_block_above.parent_node == event: + if current_block_above.parent_node == block: break current_block_above = get_block_above(current_block_above.parent_node) - if current_block_above != null and event.resource.is_expected_parent_event(current_block_above.resource): + if current_block_above != null and block.resource.is_expected_parent_event(current_block_above.resource): indent += 1 - event.set_warning() + block.set_warning() else: - event.set_warning('This event needs a specific parent event!') + block.set_warning('This event needs a specific parent event!') - elif event.resource is DialogicEndBranchEvent: - event.parent_node_changed() + elif block.resource is DialogicEndBranchEvent: + block.parent_node_changed() delayed_indent -= 1 - if event.parent_node.resource.needs_parent_event: + if block.parent_node.resource.needs_parent_event: delayed_indent -= 1 if indent >= 0: - event.set_indent(indent) + block.set_indent(indent) else: - event.set_indent(0) + block.set_indent(0) indent += delayed_indent %TimelineArea.queue_redraw() diff --git a/addons/dialogic/Modules/Audio/event_music.gd b/addons/dialogic/Modules/Audio/event_music.gd index 177289f02..d75dbdf63 100644 --- a/addons/dialogic/Modules/Audio/event_music.gd +++ b/addons/dialogic/Modules/Audio/event_music.gd @@ -72,8 +72,8 @@ func build_event_editor(): 'file_filter' : "*.mp3, *.ogg, *.wav; Supported Audio Files", 'placeholder' : "No music", 'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]}) - add_body_edit('fade_length', ValueType.FLOAT, {'left_text':'Fade Time:'}) - add_body_edit('volume', ValueType.DECIBEL, {'left_text':'Volume:'}, '!file_path.is_empty()') + add_body_edit('fade_length', ValueType.NUMBER, {'left_text':'Fade Time:'}) + add_body_edit('volume', ValueType.NUMBER, {'left_text':'Volume:', 'mode':2}, '!file_path.is_empty()') add_body_edit('audio_bus', ValueType.SINGLELINE_TEXT, {'left_text':'Audio Bus:'}, '!file_path.is_empty()') add_body_edit('loop', ValueType.BOOL, {'left_text':'Loop:'}, '!file_path.is_empty() and not file_path.to_lower().ends_with(".wav")') diff --git a/addons/dialogic/Modules/Audio/event_sound.gd b/addons/dialogic/Modules/Audio/event_sound.gd index 1c1ba7ad6..3d8308bc4 100644 --- a/addons/dialogic/Modules/Audio/event_sound.gd +++ b/addons/dialogic/Modules/Audio/event_sound.gd @@ -54,7 +54,7 @@ func get_shortcode_parameters() -> Dictionary: #param_name : property_name "path" : {"property": "file_path", "default": "",}, "volume" : {"property": "volume", "default": 0}, - "bus" : {"property": "audio_bus", "default": "Master", + "bus" : {"property": "audio_bus", "default": "Master", "suggestions": get_bus_suggestions}, "loop" : {"property": "loop", "default": false}, } @@ -65,12 +65,12 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('file_path', ValueType.FILE, + add_header_edit('file_path', ValueType.FILE, {'left_text' : 'Play', - 'file_filter' : '*.mp3, *.ogg, *.wav; Supported Audio Files', - 'placeholder' : "Select file", + 'file_filter' : '*.mp3, *.ogg, *.wav; Supported Audio Files', + 'placeholder' : "Select file", 'editor_icon' : ["AudioStreamPlayer", "EditorIcons"]}) - add_body_edit('volume', ValueType.DECIBEL, {'left_text':'Volume:'}, '!file_path.is_empty()') + add_body_edit('volume', ValueType.NUMBER, {'left_text':'Volume:', 'mode':2}, '!file_path.is_empty()') add_body_edit('audio_bus', ValueType.SINGLELINE_TEXT, {'left_text':'Audio Bus:'}, '!file_path.is_empty()') func get_bus_suggestions() -> Dictionary: diff --git a/addons/dialogic/Modules/Background/event_background.gd b/addons/dialogic/Modules/Background/event_background.gd index 005af8ff4..4e9279d85 100644 --- a/addons/dialogic/Modules/Background/event_background.gd +++ b/addons/dialogic/Modules/Background/event_background.gd @@ -83,12 +83,12 @@ func build_event_editor(): 'placeholder': "Default scene", 'editor_icon':["PackedScene", "EditorIcons"]}) add_body_edit('argument', ValueType.SINGLELINE_TEXT, {'left_text':'Argument:'}, 'scene != ""') - add_body_edit("transition", ValueType.COMPLEX_PICKER, + add_body_edit("transition", ValueType.DYNAMIC_OPTIONS, {'left_text':'Transition:', 'empty_text':'Simple Fade', 'suggestions_func':get_transition_suggestions, 'editor_icon':["PopupMenu", "EditorIcons"]}) - add_body_edit("fade", ValueType.FLOAT, {'left_text':'Fade Time:'}) + add_body_edit("fade", ValueType.NUMBER, {'left_text':'Fade Time:'}) func get_transition_suggestions(filter:String="") -> Dictionary: diff --git a/addons/dialogic/Modules/Call/event_call.gd b/addons/dialogic/Modules/Call/event_call.gd index 2680a17d7..b0239b858 100644 --- a/addons/dialogic/Modules/Call/event_call.gd +++ b/addons/dialogic/Modules/Call/event_call.gd @@ -126,11 +126,11 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('autoload_name', ValueType.COMPLEX_PICKER, {'left_text':'On autoload', + add_header_edit('autoload_name', ValueType.DYNAMIC_OPTIONS, {'left_text':'On autoload', 'empty_text':'Autoload', 'suggestions_func':get_autoload_suggestions, 'editor_icon':["Node", "EditorIcons"]}) - add_header_edit('method', ValueType.COMPLEX_PICKER, {'left_text':'call', + add_header_edit('method', ValueType.DYNAMIC_OPTIONS, {'left_text':'call', 'empty_text':'Method', 'suggestions_func':get_method_suggestions, 'editor_icon':["Callable", "EditorIcons"]}, 'autoload_name') diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 8fb0c5438..0f8492159 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -335,8 +335,8 @@ func is_valid_event(string:String) -> bool: ################################################################################ func build_event_editor() -> void: - add_header_edit('action', ValueType.FIXED_OPTION_SELECTOR, { - 'selector_options': [ + add_header_edit('action', ValueType.FIXED_OPTIONS, { + 'options': [ { 'label': 'Join', 'value': Actions.JOIN, @@ -354,51 +354,52 @@ func build_event_editor() -> void: } ] }) - add_header_edit('character_identifier', ValueType.COMPLEX_PICKER, + add_header_edit('character_identifier', ValueType.DYNAMIC_OPTIONS, {'placeholder' : 'Character', 'file_extension' : '.dch', + 'mode' : 2, 'suggestions_func' : get_character_suggestions, 'icon' : load("res://addons/dialogic/Editor/Images/Resources/character.svg"), 'autofocus' : true}) # add_header_button('', _on_character_edit_pressed, 'Edit character', ["ExternalLink", "EditorIcons"], 'character != null and character_identifier != "--All--"') - add_header_edit('set_portrait', ValueType.BOOL, + add_header_edit('set_portrait', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Character/update_portrait.svg"), 'tooltip':'Change Portrait'}, "should_show_portrait_selector() and action == Actions.UPDATE") - add_header_edit('portrait', ValueType.COMPLEX_PICKER, + add_header_edit('portrait', ValueType.DYNAMIC_OPTIONS, {'placeholder' : 'Default', 'collapse_when_empty':true, 'suggestions_func' : get_portrait_suggestions, 'icon' : load("res://addons/dialogic/Editor/Images/Resources/portrait.svg")}, 'should_show_portrait_selector() and (action != Actions.UPDATE or set_portrait)') - add_header_edit('set_position', ValueType.BOOL, + add_header_edit('set_position', ValueType.BOOL_BUTTON, {'icon': load("res://addons/dialogic/Modules/Character/update_position.svg"), 'tooltip':'Change Position'}, "character != null and !has_no_portraits() and action == Actions.UPDATE") add_header_label('at position', 'character != null and !has_no_portraits() and action == Actions.JOIN') add_header_label('to position', 'character != null and !has_no_portraits() and action == Actions.UPDATE and set_position') - add_header_edit('position', ValueType.INTEGER, {}, + add_header_edit('position', ValueType.NUMBER, {'mode':1}, 'character != null and !has_no_portraits() and action != %s and (action != Actions.UPDATE or set_position)' %Actions.LEAVE) # Body - add_body_edit('animation_name', ValueType.COMPLEX_PICKER, + add_body_edit('animation_name', ValueType.DYNAMIC_OPTIONS, {'left_text' : 'Animation:', 'suggestions_func' : get_animation_suggestions, 'editor_icon' : ["Animation", "EditorIcons"], 'placeholder' : 'Default', 'enable_pretty_name' : true}, 'should_show_animation_options()') - add_body_edit('animation_length', ValueType.FLOAT, {'left_text':'Length:'}, + add_body_edit('animation_length', ValueType.NUMBER, {'left_text':'Length:'}, 'should_show_animation_options() and !animation_name.is_empty()') add_body_edit('animation_wait', ValueType.BOOL, {'left_text':'Await end:'}, 'should_show_animation_options() and !animation_name.is_empty()') - add_body_edit('animation_repeats', ValueType.INTEGER, {'left_text':'Repeat:'}, + add_body_edit('animation_repeats', ValueType.NUMBER, {'left_text':'Repeat:', 'mode':1}, 'should_show_animation_options() and !animation_name.is_empty() and action == %s)' %Actions.UPDATE) add_body_line_break() - add_body_edit('position_move_time', ValueType.FLOAT, {'left_text':'Movement duration:'}, + add_body_edit('position_move_time', ValueType.NUMBER, {'left_text':'Movement duration:'}, 'action == %s and set_position' %Actions.UPDATE) - add_body_edit('set_z_index', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Character/update_z_index.svg"), 'tooltip':'Change Z-Index'}, "character != null and action == Actions.UPDATE") - add_body_edit('z_index', ValueType.INTEGER, {'left_text':'Z-index:'}, + add_body_edit('set_z_index', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Character/update_z_index.svg"), 'tooltip':'Change Z-Index'}, "character != null and action == Actions.UPDATE") + add_body_edit('z_index', ValueType.NUMBER, {'left_text':'Z-index:', 'mode':1}, 'action != %s and (action != Actions.UPDATE or set_z_index)' %Actions.LEAVE) - add_body_edit('set_mirrored', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Character/update_mirror.svg"), 'tooltip':'Change Mirroring'}, "character != null and action == Actions.UPDATE") + add_body_edit('set_mirrored', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Character/update_mirror.svg"), 'tooltip':'Change Mirroring'}, "character != null and action == Actions.UPDATE") add_body_edit('mirrored', ValueType.BOOL, {'left_text':'Mirrored:'}, 'action != %s and (action != Actions.UPDATE or set_mirrored)' %Actions.LEAVE) diff --git a/addons/dialogic/Modules/Character/event_position.gd b/addons/dialogic/Modules/Character/event_position.gd index a0f3fcbdb..7f29d686b 100644 --- a/addons/dialogic/Modules/Character/event_position.gd +++ b/addons/dialogic/Modules/Character/event_position.gd @@ -81,8 +81,8 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('action', ValueType.FIXED_OPTION_SELECTOR, { - 'selector_options': [ + add_header_edit('action', ValueType.FIXED_OPTIONS, { + 'options': [ { 'label': 'Change', 'value': Actions.SET_RELATIVE, @@ -101,10 +101,10 @@ func build_event_editor(): } ] }) - add_header_edit("position", ValueType.INTEGER, {'left_text':"position"}, + add_header_edit("position", ValueType.NUMBER, {'left_text':"position", 'mode':1}, 'action != Actions.RESET_ALL') add_header_label('to (absolute)', 'action == Actions.SET_ABSOLUTE') add_header_label('by (relative)', 'action == Actions.SET_RELATIVE') add_header_edit("vector", ValueType.VECTOR2, {}, 'action != Actions.RESET and action != Actions.RESET_ALL') - add_body_edit("movement_time", ValueType.FLOAT, {'left_text':"AnimationTime:", "right_text":"(0 for instant)"}) + add_body_edit("movement_time", ValueType.NUMBER, {'left_text':"AnimationTime:", "right_text":"(0 for instant)"}) diff --git a/addons/dialogic/Modules/Character/settings_portraits.gd b/addons/dialogic/Modules/Character/settings_portraits.gd index 702319a1a..a637d9f45 100644 --- a/addons/dialogic/Modules/Character/settings_portraits.gd +++ b/addons/dialogic/Modules/Character/settings_portraits.gd @@ -4,9 +4,9 @@ extends DialogicSettingsPage func _ready(): %JoinDefault.get_suggestions_func = get_join_animation_suggestions - %JoinDefault.enable_pretty_name = true + %JoinDefault.mode = 1 %LeaveDefault.get_suggestions_func = get_leave_animation_suggestions - %LeaveDefault.enable_pretty_name = true + %LeaveDefault.mode = 1 func _refresh(): diff --git a/addons/dialogic/Modules/Character/settings_portraits.tscn b/addons/dialogic/Modules/Character/settings_portraits.tscn index d14aa10f1..ad39f9174 100644 --- a/addons/dialogic/Modules/Character/settings_portraits.tscn +++ b/addons/dialogic/Modules/Character/settings_portraits.tscn @@ -2,10 +2,10 @@ [ext_resource type="Script" path="res://addons/dialogic/Modules/Character/settings_portraits.gd" id="2"] [ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_dce78"] -[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn" id="3"] -[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="3_m06d8"] +[ext_resource type="PackedScene" uid="uid://dpwhshre1n4t6" path="res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn" id="3"] +[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/field_file.tscn" id="3_m06d8"] -[sub_resource type="Image" id="Image_yiygw"] +[sub_resource type="Image" id="Image_8p738"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0), "format": "RGBA8", @@ -14,8 +14,8 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_hx3oq"] -image = SubResource("Image_yiygw") +[sub_resource type="ImageTexture" id="ImageTexture_wre7v"] +image = SubResource("Image_8p738") [node name="Portraits" type="VBoxContainer"] anchors_preset = 15 @@ -37,7 +37,7 @@ text = "Default Portrait Scene [node name="HintTooltip" parent="Animations3" instance=ExtResource("2_dce78")] layout_mode = 2 tooltip_text = "If this is set, this scene will be what is used by default for any portrait that has no scene specified" -texture = SubResource("ImageTexture_hx3oq") +texture = SubResource("ImageTexture_wre7v") hint_text = "If this is set, this scene will be what is used by default for any portrait that has no scene specified" [node name="HBoxContainer" type="HBoxContainer" parent="."] @@ -67,7 +67,7 @@ text = "Default Animations [node name="HintTooltip" parent="Animations2" instance=ExtResource("2_dce78")] layout_mode = 2 tooltip_text = "These settings are used for Leave and Join events if no animation is selected." -texture = SubResource("ImageTexture_hx3oq") +texture = SubResource("ImageTexture_wre7v") hint_text = "These settings are used for Leave and Join events if no animation is selected." [node name="GridContainer" type="GridContainer" parent="."] @@ -84,7 +84,6 @@ layout_mode = 2 [node name="JoinDefault" parent="GridContainer/DefaultIn" instance=ExtResource("3")] unique_name_in_owner = true layout_mode = 2 -enable_pretty_name = true [node name="JoinDefaultLength" type="SpinBox" parent="GridContainer/DefaultIn"] unique_name_in_owner = true @@ -106,7 +105,6 @@ layout_mode = 2 [node name="LeaveDefault" parent="GridContainer/DefaultOut" instance=ExtResource("3")] unique_name_in_owner = true layout_mode = 2 -enable_pretty_name = true [node name="LeaveDefaultLength" type="SpinBox" parent="GridContainer/DefaultOut"] unique_name_in_owner = true diff --git a/addons/dialogic/Modules/Choice/event_choice.gd b/addons/dialogic/Modules/Choice/event_choice.gd index 7abc045a8..1e2937700 100644 --- a/addons/dialogic/Modules/Choice/event_choice.gd +++ b/addons/dialogic/Modules/Choice/event_choice.gd @@ -137,8 +137,8 @@ func _get_property_original_translation(property:String) -> String: func build_event_editor() -> void: add_header_edit("text", ValueType.SINGLELINE_TEXT, {'autofocus':true}) add_body_edit("condition", ValueType.CONDITION, {'left_text':'if '}) - add_body_edit("else_action", ValueType.FIXED_OPTION_SELECTOR, {'left_text':'else ', - 'selector_options': [ + add_body_edit("else_action", ValueType.FIXED_OPTIONS, {'left_text':'else ', + 'options': [ { 'label': 'Default', 'value': ElseActions.DEFAULT, diff --git a/addons/dialogic/Modules/Clear/event_clear.gd b/addons/dialogic/Modules/Clear/event_clear.gd index 567d48a00..8efdf8250 100644 --- a/addons/dialogic/Modules/Clear/event_clear.gd +++ b/addons/dialogic/Modules/Clear/event_clear.gd @@ -96,14 +96,14 @@ func get_shortcode_parameters() -> Dictionary: func build_event_editor(): add_header_label('Clear') - add_body_edit('time', ValueType.FLOAT, {'left_text':'Time:'}) + add_body_edit('time', ValueType.NUMBER, {'left_text':'Time:'}) add_body_edit('step_by_step', ValueType.BOOL, {'left_text':'Step by Step:'}, 'time > 0') add_body_line_break() - add_body_edit('clear_textbox', ValueType.BOOL, {'left_text':'Clear:', 'icon':load("res://addons/dialogic/Modules/Clear/clear_textbox.svg"), 'tooltip':'Clear Textbox'}) - add_body_edit('clear_portraits', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Clear/clear_characters.svg"), 'tooltip':'Clear Portraits'}) - add_body_edit('clear_background', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Clear/clear_background.svg"), 'tooltip':'Clear Background'}) - add_body_edit('clear_music', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Clear/clear_music.svg"), 'tooltip':'Clear Music'}) - add_body_edit('clear_style', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Clear/clear_style.svg"), 'tooltip':'Clear Style'}) - add_body_edit('clear_portrait_positions', ValueType.BOOL, {'icon':load("res://addons/dialogic/Modules/Clear/clear_positions.svg"), 'tooltip':'Clear Portrait Positions'}) + add_body_edit('clear_textbox', ValueType.BOOL_BUTTON, {'left_text':'Clear:', 'icon':load("res://addons/dialogic/Modules/Clear/clear_textbox.svg"), 'tooltip':'Clear Textbox'}) + add_body_edit('clear_portraits', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Clear/clear_characters.svg"), 'tooltip':'Clear Portraits'}) + add_body_edit('clear_background', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Clear/clear_background.svg"), 'tooltip':'Clear Background'}) + add_body_edit('clear_music', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Clear/clear_music.svg"), 'tooltip':'Clear Music'}) + add_body_edit('clear_style', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Clear/clear_style.svg"), 'tooltip':'Clear Style'}) + add_body_edit('clear_portrait_positions', ValueType.BOOL_BUTTON, {'icon':load("res://addons/dialogic/Modules/Clear/clear_positions.svg"), 'tooltip':'Clear Portrait Positions'}) diff --git a/addons/dialogic/Modules/Condition/event_condition.gd b/addons/dialogic/Modules/Condition/event_condition.gd index 2a0a59fa4..3445d8e15 100644 --- a/addons/dialogic/Modules/Condition/event_condition.gd +++ b/addons/dialogic/Modules/Condition/event_condition.gd @@ -21,9 +21,9 @@ func _execute() -> void: if condition_type == ConditionTypes.ELSE: finish() return - + if condition.is_empty(): condition = "true" - + var result :bool= dialogic.Expression.execute_condition(condition) if not result: var idx :int= dialogic.current_event_idx @@ -36,7 +36,7 @@ func _execute() -> void: ignore += 1 elif dialogic.current_timeline.get_event(idx) is DialogicEndBranchEvent: ignore -= 1 - + dialogic.current_event_idx = idx-1 finish() @@ -69,7 +69,7 @@ func get_end_branch_control() -> Control: func to_text() -> String: var result_string := "" - + match condition_type: ConditionTypes.IF: result_string = 'if '+condition+':' @@ -77,7 +77,7 @@ func to_text() -> String: result_string = 'elif '+condition+':' ConditionTypes.ELSE: result_string = 'else:' - + return result_string @@ -104,8 +104,8 @@ func is_valid_event(string:String) -> bool: ################################################################################ func build_event_editor(): - add_header_edit('condition_type', ValueType.FIXED_OPTION_SELECTOR, { - 'selector_options': [ + add_header_edit('condition_type', ValueType.FIXED_OPTIONS, { + 'options': [ { 'label': 'IF', 'value': ConditionTypes.IF, diff --git a/addons/dialogic/Modules/History/event_history.gd b/addons/dialogic/Modules/History/event_history.gd index b0b4e931e..3ff20f500 100644 --- a/addons/dialogic/Modules/History/event_history.gd +++ b/addons/dialogic/Modules/History/event_history.gd @@ -24,7 +24,7 @@ func _execute() -> void: dialogic.History.full_history_enabled = false Actions.RESUME: dialogic.History.full_history_enabled = true - + finish() @@ -49,7 +49,7 @@ func get_shortcode() -> String: func get_shortcode_parameters() -> Dictionary: return { #param_name : property_info - "action" : {"property": "action", "default": Actions.PAUSE, + "action" : {"property": "action", "default": Actions.PAUSE, "suggestions": func(): return {"Clear":{'value':0}, "Pause":{'value':1}, "Resume":{'value':2}}}, } @@ -58,8 +58,8 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('action', ValueType.FIXED_OPTION_SELECTOR, { - 'selector_options': [ + add_header_edit('action', ValueType.FIXED_OPTIONS, { + 'options': [ { 'label': 'Pause History', 'value': Actions.PAUSE, diff --git a/addons/dialogic/Modules/Jump/event_jump.gd b/addons/dialogic/Modules/Jump/event_jump.gd index 6b725a325..1760147b0 100644 --- a/addons/dialogic/Modules/Jump/event_jump.gd +++ b/addons/dialogic/Modules/Jump/event_jump.gd @@ -8,23 +8,24 @@ extends DialogicEvent ### Settings ## The timeline to jump to, if null then it's the current one. This setting should be a dialogic timeline resource. -var timeline :DialogicTimeline = null: - get: - if timeline == null: - if !_timeline_file.is_empty(): - if _timeline_file.contains("res://"): - return load(_timeline_file) - else: - return DialogicResourceUtil.get_timeline_resource(_timeline_file) - return timeline +var timeline : DialogicTimeline ## If not empty, the event will try to find a Label event with this set as name. Empty by default.. var label_name : String = "" ### Helpers -## Path to the timeline. Mainly used by the editor. -var _timeline_file: String = "" +## Used to set the timeline resource from the unique name identifier and vice versa +var timeline_identifier: String = "": + get: + if timeline: + var identifier := DialogicResourceUtil.get_unique_identifier(timeline.resource_path) + if not identifier.is_empty(): + return identifier + return timeline_identifier + set(value): + timeline_identifier = value + timeline = DialogicResourceUtil.get_timeline_resource(value) ################################################################################ @@ -64,8 +65,8 @@ func _get_icon() -> Resource: ################################################################################ func to_text() -> String: var result := "jump " - if _timeline_file: - result += _timeline_file+'/' + if timeline_identifier: + result += timeline_identifier+'/' if label_name: result += label_name elif label_name: @@ -76,7 +77,7 @@ func to_text() -> String: func from_text(string:String) -> void: var result := RegEx.create_from_string('jump (?.*\\/)?(?