diff --git a/addons/dialogic/Core/DialogicResourceUtil.gd b/addons/dialogic/Core/DialogicResourceUtil.gd index f9114d9d7..cf00f2d33 100644 --- a/addons/dialogic/Core/DialogicResourceUtil.gd +++ b/addons/dialogic/Core/DialogicResourceUtil.gd @@ -46,6 +46,8 @@ static func update_directory(extension:String) -> void: var keys_to_remove := [] for key in directory: + if not typeof(directory[key]) == TYPE_STRING: + continue if not ResourceLoader.exists(directory[key]): keys_to_remove.append(key) for key in keys_to_remove: @@ -54,6 +56,10 @@ static func update_directory(extension:String) -> void: set_directory(extension, directory) +static func is_resource_in_directory(file_path:String) -> bool: + var directory := get_directory(file_path.get_extension()) + return file_path in directory.values() + static func add_resource_to_directory(file_path:String, directory:Dictionary) -> Dictionary: var suggested_name := file_path.get_file().trim_suffix("."+file_path.get_extension()) var temp := suggested_name diff --git a/addons/dialogic/Core/DialogicUtil.gd b/addons/dialogic/Core/DialogicUtil.gd index 37329db6c..d8c0c5ad5 100644 --- a/addons/dialogic/Core/DialogicUtil.gd +++ b/addons/dialogic/Core/DialogicUtil.gd @@ -4,6 +4,9 @@ class_name DialogicUtil ## Script that container helper methods for both editor and game execution. ## Used whenever the same thing is needed in different parts of the plugin. + +static var editor_settings_cache := {} + #region EDITOR ## This method should be used instead of EditorInterface.get_editor_scale(), because if you use that @@ -148,6 +151,9 @@ static func set_editor_setting(setting:String, value:Variant) -> void: static func get_editor_setting(setting:String, default:Variant=null) -> Variant: + if setting in editor_settings_cache: + return editor_settings_cache[setting] + var cfg := ConfigFile.new() if !FileAccess.file_exists('user://dialogic/editor_settings.cfg'): return default @@ -155,9 +161,15 @@ static func get_editor_setting(setting:String, default:Variant=null) -> Variant: if !cfg.load('user://dialogic/editor_settings.cfg') == OK: return default + if cfg.has_section_key('DES', setting): + editor_settings_cache[setting] = cfg.get_value('DES', setting, default) return cfg.get_value('DES', setting, default) +static func clear_editor_settings_cache() -> void: + editor_settings_cache.clear() + + static func get_color_palette(default:bool = false) -> Dictionary: var defaults := { 'Color1': Color('#3b8bf2'), # Blue @@ -612,7 +624,11 @@ static func get_character_suggestions(_search_text:String, current_value:Dialogi var character_directory := DialogicResourceUtil.get_character_directory() for resource in character_directory.keys(): - suggestions[resource] = {'value': resource, 'tooltip': character_directory[resource], 'icon': icon} + suggestions[resource] = { + 'value': resource, + 'tooltip': character_directory[resource], + 'icon': icon, + } return suggestions diff --git a/addons/dialogic/Editor/CharacterEditor/character_editor.gd b/addons/dialogic/Editor/CharacterEditor/character_editor.gd index 67835d3ea..4e4eeed78 100644 --- a/addons/dialogic/Editor/CharacterEditor/character_editor.gd +++ b/addons/dialogic/Editor/CharacterEditor/character_editor.gd @@ -143,9 +143,8 @@ func _ready() -> void: if get_parent() is SubViewport: return - DialogicUtil.get_dialogic_plugin().resource_saved.connect(_on_some_resource_saved) - # NOTE: This check is required because up to 4.2 this signal is not exposed. - if DialogicUtil.get_dialogic_plugin().has_signal("scene_saved"): + if Engine.is_editor_hint(): + DialogicUtil.get_dialogic_plugin().resource_saved.connect(_on_some_resource_saved) DialogicUtil.get_dialogic_plugin().scene_saved.connect(_on_some_resource_saved) $NoCharacterScreen.color = get_theme_color("dark_color_2", "Editor") diff --git a/addons/dialogic/Editor/Common/reference_manager_window.gd b/addons/dialogic/Editor/Common/reference_manager_window.gd index 04bd610da..e13a20249 100644 --- a/addons/dialogic/Editor/Common/reference_manager_window.gd +++ b/addons/dialogic/Editor/Common/reference_manager_window.gd @@ -39,8 +39,9 @@ func _ready() -> void: hide() - get_parent().plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved) - get_parent().plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed) + if get_parent().plugin_reference: + get_parent().plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved) + get_parent().plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed) get_parent().get_node('ResourceRenameWarning').confirmed.connect(open) diff --git a/addons/dialogic/Editor/Common/update_install_window.gd b/addons/dialogic/Editor/Common/update_install_window.gd index f1c659d19..7661ce689 100644 --- a/addons/dialogic/Editor/Common/update_install_window.gd +++ b/addons/dialogic/Editor/Common/update_install_window.gd @@ -13,7 +13,8 @@ func _ready() -> void: %LoadingIcon.texture = editor_view.get_theme_icon("KeyTrackScale", "EditorIcons") %InstallWarning.modulate = editor_view.get_theme_color("warning_color", "Editor") %CloseButton.icon = editor_view.get_theme_icon("Close", "EditorIcons") - DialogicUtil.get_dialogic_plugin().get_editor_interface().get_resource_filesystem().resources_reimported.connect(_on_resources_reimported) + if DialogicUtil.get_dialogic_plugin(): + DialogicUtil.get_dialogic_plugin().get_editor_interface().get_resource_filesystem().resources_reimported.connect(_on_resources_reimported) func open() -> void: diff --git a/addons/dialogic/Editor/Events/EventBlock/event_block.gd b/addons/dialogic/Editor/Events/EventBlock/event_block.gd index 944757e64..e71459769 100644 --- a/addons/dialogic/Editor/Events/EventBlock/event_block.gd +++ b/addons/dialogic/Editor/Events/EventBlock/event_block.gd @@ -19,8 +19,6 @@ var end_node: Node = null: ## 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 @@ -33,7 +31,7 @@ const indent_size := 22 ## STATE # List that stores visibility conditions -var field_list := [] +var field_list: Array[Dictionary] = [] var current_indent_level := 1 @@ -66,11 +64,13 @@ func initialize_ui() -> void: # Expand Button %ToggleBodyVisibilityButton.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons") + %ToggleBodyVisibilityButton.begin_bulk_theme_override() %ToggleBodyVisibilityButton.set("theme_override_colors/icon_normal_color", get_theme_color("contrast_color_2", "Editor")) %ToggleBodyVisibilityButton.set("theme_override_colors/icon_hover_color", get_theme_color("accent_color", "Editor")) %ToggleBodyVisibilityButton.set("theme_override_colors/icon_pressed_color", get_theme_color("contrast_color_2", "Editor")) %ToggleBodyVisibilityButton.set("theme_override_colors/icon_hover_pressed_color", get_theme_color("accent_color", "Editor")) %ToggleBodyVisibilityButton.add_theme_stylebox_override('hover_pressed', StyleBoxEmpty.new()) + %ToggleBodyVisibilityButton.end_bulk_theme_override() # Icon Panel %IconPanel.tooltip_text = resource.event_name @@ -83,10 +83,10 @@ func initialize_ui() -> void: %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) + custom_style.set_corner_radius_all(int(5 * _scale)) # Focus Mode - set_focus_mode(1) # Allowing this node to grab focus + set_focus_mode(FOCUS_CLICK) # Allowing this node to grab focus # Separation on the header %Header.add_theme_constant_override("custom_constants/separation", 5 * _scale) @@ -109,7 +109,7 @@ func initialize_logic() -> void: content_changed.connect(recalculate_field_visibility) - _on_ToggleBodyVisibility_toggled(resource.expand_by_default or resource.created_by_button) + set_expanded(resource.expand_by_default or resource.created_by_button) #endregion @@ -125,6 +125,8 @@ func visual_select() -> void: func visual_deselect() -> void: + if not selected: + return $PanelContainer.add_theme_stylebox_override('panel', load("res://addons/dialogic/Editor/Events/styles/unselected_stylebox.tres")) selected = false %IconPanel.self_modulate = resource.event_color.lerp(Color.DARK_SLATE_GRAY, 0.1) @@ -144,7 +146,7 @@ func set_warning(text:String= "") -> void: func set_indent(indent: int) -> void: - add_theme_constant_override("margin_left", indent_size * indent * DialogicUtil.get_editor_scale()) + add_theme_constant_override("margin_left", int(indent_size * indent * DialogicUtil.get_editor_scale())) current_indent_level = indent #endregion @@ -153,26 +155,27 @@ func set_indent(indent: int) -> void: #region EVENT FIELDS ################################################################################ -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", - DialogicEvent.ValueType.VECTOR3: "res://addons/dialogic/Editor/Events/Fields/field_vector3.tscn", - DialogicEvent.ValueType.VECTOR4: "res://addons/dialogic/Editor/Events/Fields/field_vector4.tscn", - DialogicEvent.ValueType.COLOR: "res://addons/dialogic/Editor/Events/Fields/field_color.tscn", - DialogicEvent.ValueType.AUDIO_PREVIEW: "res://addons/dialogic/Editor/Events/Fields/field_audio_preview.tscn", - DialogicEvent.ValueType.IMAGE_PREVIEW: "res://addons/dialogic/Editor/Events/Fields/field_image_preview.tscn", +static var FIELD_SCENES := { + DialogicEvent.ValueType.MULTILINE_TEXT: preload("res://addons/dialogic/Editor/Events/Fields/field_text_multiline.tscn"), + DialogicEvent.ValueType.SINGLELINE_TEXT: preload("res://addons/dialogic/Editor/Events/Fields/field_text_singleline.tscn"), + DialogicEvent.ValueType.FILE: preload("res://addons/dialogic/Editor/Events/Fields/field_file.tscn"), + DialogicEvent.ValueType.BOOL: preload("res://addons/dialogic/Editor/Events/Fields/field_bool_check.tscn"), + DialogicEvent.ValueType.BOOL_BUTTON: preload("res://addons/dialogic/Editor/Events/Fields/field_bool_button.tscn"), + DialogicEvent.ValueType.CONDITION: preload("res://addons/dialogic/Editor/Events/Fields/field_condition.tscn"), + DialogicEvent.ValueType.ARRAY: preload("res://addons/dialogic/Editor/Events/Fields/field_array.tscn"), + DialogicEvent.ValueType.DICTIONARY: preload("res://addons/dialogic/Editor/Events/Fields/field_dictionary.tscn"), + DialogicEvent.ValueType.DYNAMIC_OPTIONS: preload("res://addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn"), + DialogicEvent.ValueType.FIXED_OPTIONS: preload("res://addons/dialogic/Editor/Events/Fields/field_options_fixed.tscn"), + DialogicEvent.ValueType.NUMBER: preload("res://addons/dialogic/Editor/Events/Fields/field_number.tscn"), + DialogicEvent.ValueType.VECTOR2: preload("res://addons/dialogic/Editor/Events/Fields/field_vector2.tscn"), + DialogicEvent.ValueType.VECTOR3: preload("res://addons/dialogic/Editor/Events/Fields/field_vector3.tscn"), + DialogicEvent.ValueType.VECTOR4: preload("res://addons/dialogic/Editor/Events/Fields/field_vector4.tscn"), + DialogicEvent.ValueType.COLOR: preload("res://addons/dialogic/Editor/Events/Fields/field_color.tscn"), + DialogicEvent.ValueType.AUDIO_PREVIEW: preload("res://addons/dialogic/Editor/Events/Fields/field_audio_preview.tscn"), + DialogicEvent.ValueType.IMAGE_PREVIEW: preload("res://addons/dialogic/Editor/Events/Fields/field_image_preview.tscn"), } + func build_editor(build_header:bool = true, build_body:bool = false) -> void: var current_body_container: HFlowContainer = null @@ -191,9 +194,9 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: if p.has('condition'): field_list[-1]['condition'] = p.condition - if !build_body and p.location == 1: + if not build_body and p.location == 1: continue - elif !build_header and p.location == 0: + elif not build_header and p.location == 0: continue ### -------------------------------------------------------------------- @@ -203,14 +206,14 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: ### LINEBREAK if p.name == "linebreak": field_list.remove_at(field_list.size()-1) - if !current_body_container.get_child_count(): + if not current_body_container.get_child_count(): current_body_container.queue_free() current_body_container = HFlowContainer.new() %BodyContent.add_child(current_body_container) continue elif p.field_type in FIELD_SCENES: - editor_node = load(FIELD_SCENES[p.field_type]).instantiate() + editor_node = FIELD_SCENES[p.field_type].instantiate() elif p.field_type == resource.ValueType.LABEL: editor_node = Label.new() @@ -229,7 +232,12 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: editor_node.icon = p.display_info.icon editor_node.flat = true editor_node.custom_minimum_size.x = 30 * DialogicUtil.get_editor_scale() - editor_node.pressed.connect(p.display_info.callable) + if not p.display_info.callable.is_valid(): + if resource.has_method(p.display_info.callable.get_method()): + editor_node.pressed.connect(Callable(resource, p.display_info.callable.get_method())) + + else: + editor_node.pressed.connect(p.display_info.callable) ## CUSTOM elif p.field_type == resource.ValueType.CUSTOM: @@ -242,14 +250,15 @@ 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 + editor_node.name = p.name.to_pascal_case() ### -------------------------------------------------------------------- # 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) @@ -261,14 +270,15 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: # Some things need to be called AFTER the field is added to the tree if editor_node is DialogicVisualEditorField: - # Only set the value if the field is visible - # - # This prevents events with varied value types (event_setting, event_variable) - # from injecting incorrect types into hidden fields, which then throw errors - # in the console. + ## Only set the value if the field is visible + ## + ## This prevents events with varied value types (event_setting, event_variable) + ## from injecting incorrect types into hidden fields, which then throw errors + ## in the console. if p.has('condition') and not p.condition.is_empty(): - if _evaluate_visibility_condition(p): - editor_node._set_value(resource.get(p.name)) + editor_node.hide() + #if _evaluate_visibility_condition(p): + #editor_node._set_value(resource.get(p.name)) else: editor_node._set_value(resource.get(p.name)) @@ -284,14 +294,14 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: ### 4. ADD LEFT AND RIGHT TEXT var left_label: Label = null var right_label: Label = null - if !p.get('left_text', '').is_empty(): + if not p.get('left_text', '').is_empty(): left_label = Label.new() left_label.text = p.get('left_text') left_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER left_label.add_theme_color_override('font_color', resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.8)) location.add_child(left_label) location.move_child(left_label, editor_node.get_index()) - if !p.get('right_text', '').is_empty(): + if not p.get('right_text', '').is_empty(): right_label = Label.new() right_label.text = p.get('right_text') right_label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER @@ -311,7 +321,6 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: if build_body: if current_body_container.get_child_count() == 0: - expanded = false %Body.visible = false recalculate_field_visibility() @@ -319,23 +328,23 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: func recalculate_field_visibility() -> void: has_any_enabled_body_content = false - for p in field_list: - if !p.has('condition') or p.condition.is_empty(): - if p.node != null: - p.node.show() - if p.location == 1: + for field in field_list: + if not field.node and has_any_enabled_body_content: + continue + if _evaluate_visibility_condition(field): + if field.node: + if field.has("condition") and (not field.node.visible) and field.has("property"): + field.node._set_value(resource.get(field.property)) + + field.node.show() + + if field.location == 1: has_any_enabled_body_content = true + else: - if _evaluate_visibility_condition(p): - if p.node != null: - if p.node.visible == false and p.has("property"): - p.node._set_value(resource.get(p.property)) - p.node.show() - if p.location == 1: - has_any_enabled_body_content = true - else: - if p.node != null: - p.node.hide() + if field.node != null: + field.node.hide() + %ToggleBodyVisibilityButton.visible = has_any_enabled_body_content @@ -346,16 +355,27 @@ func set_property(property_name:String, value:Variant) -> void: end_node.parent_node_changed() -func _evaluate_visibility_condition(p: Dictionary) -> bool: - var expr := Expression.new() - expr.parse(p.condition) +func _evaluate_visibility_condition(field: Dictionary) -> bool: + if field.get("condition", "").is_empty(): + return true + + var expr: Expression + var cache: Dictionary = Engine.get_meta("dialogic_visibility_condition_cache", {}) + if field.condition in cache: + expr = cache[field.condition] + else: + expr = Expression.new() + expr.parse(field.condition) + cache[field.condition] = expr + Engine.set_meta("dialogic_visibility_condition_cache", cache) + var result: bool if expr.execute([], resource): result = true else: result = false if expr.has_execute_failed(): - printerr("[Dialogic] Failed executing visibility condition for '",p.get('property', 'unnamed'),"': " + expr.get_error_text()) + printerr("[Dialogic] Failed executing visibility condition for '", field.get('property', 'unnamed'),"': " + expr.get_error_text()) return result @@ -374,11 +394,9 @@ func _on_resource_ui_update_needed() -> void: # This prevents events with varied value types (event_setting, event_variable) # from injecting incorrect types into hidden fields, which then throw errors # in the console. - if node_info.has('condition') and not node_info.condition.is_empty(): - if _evaluate_visibility_condition(node_info): - node_info.node.set_value(resource.get(node_info.property)) - else: + if _evaluate_visibility_condition(node_info): node_info.node.set_value(resource.get(node_info.property)) + recalculate_field_visibility() @@ -396,20 +414,27 @@ func _on_collapse_toggled(toggled:bool) -> void: func _on_ToggleBodyVisibility_toggled(button_pressed:bool) -> void: - if button_pressed and !body_was_build: + set_expanded(button_pressed) + + if find_parent('VisualEditor') != null: + find_parent('VisualEditor').indent_events() + + +func set_expanded(expanded:=true) -> void: + if expanded and not body_was_build: build_editor(false, true) - %ToggleBodyVisibilityButton.set_pressed_no_signal(button_pressed) - if button_pressed: + %ToggleBodyVisibilityButton.set_pressed_no_signal(expanded) + if expanded: %ToggleBodyVisibilityButton.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons") else: %ToggleBodyVisibilityButton.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons") - expanded = button_pressed - %Body.visible = button_pressed + %Body.visible = expanded - if find_parent('VisualEditor') != null: - find_parent('VisualEditor').indent_events() + +func is_expanded() -> bool: + return %Body.visible func _on_EventNode_gui_input(event:InputEvent) -> void: @@ -417,13 +442,13 @@ func _on_EventNode_gui_input(event:InputEvent) -> void: grab_focus() # Grab focus to avoid copy pasting text or events if event.double_click: if has_any_enabled_body_content: - _on_ToggleBodyVisibility_toggled(!expanded) + _on_ToggleBodyVisibility_toggled(not is_expanded()) # For opening the context menu if event is InputEventMouseButton: if event.button_index == MOUSE_BUTTON_RIGHT and event.pressed: var popup: PopupMenu = get_parent().get_parent().get_node('EventPopupMenu') popup.current_event = self - popup.popup_on_parent(Rect2(get_global_mouse_position(),Vector2())) + popup.popup_on_parent(Rect2(get_global_mouse_position(), Vector2())) if resource.help_page_path == "": popup.set_item_disabled(2, true) else: diff --git a/addons/dialogic/Editor/Events/Fields/field_bool_button.gd b/addons/dialogic/Editor/Events/Fields/field_bool_button.gd index 1593be3d8..ae556926e 100644 --- a/addons/dialogic/Editor/Events/Fields/field_bool_button.gd +++ b/addons/dialogic/Editor/Events/Fields/field_bool_button.gd @@ -7,14 +7,22 @@ extends DialogicVisualEditorField ################################################################################ func _ready() -> void: - add_theme_color_override("icon_normal_color", get_theme_color("disabled_font_color", "Editor")) - add_theme_color_override("icon_hover_color", get_theme_color("warning_color", "Editor")) - 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")) self.toggled.connect(_on_value_changed) +# We do this because theme changes are costly and many of these nodes are never becoming visible at all +func _on_visibility_changed() -> void: + if visible and not has_meta("did_theming"): + begin_bulk_theme_override() + add_theme_color_override("icon_normal_color", get_theme_color("disabled_font_color", "Editor")) + add_theme_color_override("icon_hover_color", get_theme_color("warning_color", "Editor")) + 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")) + end_bulk_theme_override() + set_meta("did_theming", true) + + func _load_display_info(info:Dictionary) -> void: if info.has('editor_icon'): if not is_inside_tree(): diff --git a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd index 8e1ee7aa0..22769b702 100644 --- a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd +++ b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.gd @@ -56,14 +56,29 @@ func _set_value(value:Variant) -> void: _: %Search.text = str(value) + %Search.visible = not collapse_when_empty or value current_value = str(value) + ## TODO FIGURE OUT A WAY TO MAKE COLORED ICONS EFFICIANT. + ## This works, but slows down timeline opening to much. + #%Icon.modulate = Color.WHITE + #if suggestions_func: + #var suggestions: Dictionary = suggestions_func.call(current_value) + #for i in suggestions.values(): + #if i.value == current_value: + #if i.has("icon_color"): + #%Icon.modulate = i.get("icon_color") + #break + func _load_display_info(info:Dictionary) -> void: valid_file_drop_extension = info.get('file_extension', '') collapse_when_empty = info.get('collapse_when_empty', false) suggestions_func = info.get('suggestions_func', suggestions_func) + if not suggestions_func.is_valid(): + if event_resource.has_method(suggestions_func.get_method()): + suggestions_func = Callable(event_resource, suggestions_func.get_method()) validation_func = info.get('validation_func', validation_func) empty_text = info.get('empty_text', '') placeholder_text = info.get('placeholder', 'Select Resource') @@ -85,6 +100,8 @@ func _autofocus() -> void: ################################################################################ func _ready() -> void: + if not is_visible_in_tree(): + return var focus := get_theme_stylebox("focus", "LineEdit") if has_theme_stylebox("focus", "DialogicEventEdit"): focus = get_theme_stylebox('focus', 'DialogicEventEdit') @@ -198,7 +215,7 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void: if new_text and mode == Modes.ANY_VALID_STRING and not new_text in suggestions.keys(): %Suggestions.add_item(new_text, get_theme_icon('GuiScrollArrowRight', 'EditorIcons')) - %Suggestions.set_item_metadata(idx, new_text) + %Suggestions.set_item_metadata(idx, {"value":new_text}) line_length = get_theme_font('font', 'Label').get_string_size( new_text, HORIZONTAL_ALIGNMENT_LEFT, -1, get_theme_font_size("font_size", 'Label') ).x + %Suggestions.fixed_icon_size.x * %Suggestions.get_icon_scale() + _icon_margin * 2 + _h_separation @@ -219,10 +236,13 @@ func _on_Search_text_changed(new_text:String, just_update:bool = false) -> void: %Suggestions.set_item_icon(idx, get_theme_icon(suggestions[element].editor_icon[0],suggestions[element].editor_icon[1])) curr_line_length += %Suggestions.fixed_icon_size.x * %Suggestions.get_icon_scale() + _icon_margin * 2 + _h_separation + #if suggestions[element].has("icon_color"): + #%Suggestions.set_item_icon_modulate(idx, suggestions[element].get("icon_color")) + line_length = max(line_length, curr_line_length) %Suggestions.set_item_tooltip(idx, suggestions[element].get('tooltip', '')) - %Suggestions.set_item_metadata(idx, suggestions[element].value) + %Suggestions.set_item_metadata(idx, {"value":suggestions[element].value, "color": suggestions[element].get("icon_color", Color.WHITE)}) idx += 1 if not %Suggestions.visible: @@ -262,11 +282,12 @@ func suggestion_selected(index: int, _position := Vector2(), button_index := MOU %Search.text = %Suggestions.get_item_text(index) - if %Suggestions.get_item_metadata(index) == null: + if not %Suggestions.get_item_metadata(index): current_value = "" else: - current_value = %Suggestions.get_item_metadata(index) + current_value = %Suggestions.get_item_metadata(index).value + #%Icon.modulate = %Suggestions.get_item_metadata(index).get("color", Color.WHITE) update_error_tooltip('') hide_suggestions() @@ -277,11 +298,12 @@ func suggestion_selected(index: int, _position := Vector2(), button_index := MOU 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 \ - !%SelectButton.get_global_rect().has_point(get_global_mouse_position()): - hide_suggestions() + if not visible: + return + if %Suggestions.visible and event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT: + if not %Suggestions.get_global_rect().has_point(get_global_mouse_position()) and \ + not %SelectButton.get_global_rect().has_point(get_global_mouse_position()): + hide_suggestions() func hide_suggestions() -> void: diff --git a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn index c2c898e6b..692a85941 100644 --- a/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn +++ b/addons/dialogic/Editor/Events/Fields/field_options_dynamic.tscn @@ -1,35 +1,59 @@ -[gd_scene load_steps=7 format=3 uid="uid://dpwhshre1n4t6"] +[gd_scene load_steps=8 format=3 uid="uid://dpwhshre1n4t6"] [ext_resource type="Script" uid="uid://cowk63wwk126v" 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_qw5e6"] +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tmt5n"] + +[sub_resource type="Image" id="Image_1bhct"] 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), +"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0), "format": "RGBA8", "height": 16, "mipmaps": false, "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_g63da"] -image = SubResource("Image_qw5e6") +[sub_resource type="ImageTexture" id="ImageTexture_6orff"] +image = SubResource("Image_1bhct") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_g74jb"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qw5e6"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 content_margin_bottom = 4.0 -bg_color = Color(1, 0.365, 0.365, 1) +bg_color = Color(1, 1, 1, 0.75) draw_center = false border_width_left = 2 border_width_top = 2 border_width_right = 2 border_width_bottom = 2 -corner_detail = 1 +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 +corner_detail = 5 +expand_margin_left = 2.0 +expand_margin_top = 2.0 +expand_margin_right = 2.0 +expand_margin_bottom = 2.0 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qatmg"] +content_margin_left = 6.0 +content_margin_top = 6.0 +content_margin_right = 6.0 +content_margin_bottom = 6.0 +bg_color = Color(0, 0, 0, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0, 0, 0, 1) +corner_radius_top_left = 4 +corner_radius_top_right = 4 +corner_radius_bottom_right = 4 +corner_radius_bottom_left = 4 [node name="Field_DynamicStringOptions" type="HBoxContainer"] anchors_preset = 15 @@ -86,14 +110,15 @@ size_flags_vertical = 4 focus_neighbor_bottom = NodePath("Suggestions") focus_mode = 1 mouse_filter = 1 -theme_override_styles/normal = SubResource("StyleBoxEmpty_tmt5n") theme_override_styles/focus = SubResource("StyleBoxEmpty_vennf") +theme_override_styles/normal = SubResource("StyleBoxEmpty_tmt5n") expand_to_text_length = true flat = true caret_blink = true [node name="Suggestions" type="ItemList" parent="PanelContainer/MarginContainer/HBoxContainer/Search"] unique_name_in_owner = true +auto_translate_mode = 2 visible = false top_level = true custom_minimum_size = Vector2(-1086, 0) @@ -103,7 +128,6 @@ offset_top = 36.0 offset_right = 195.0 offset_bottom = 71.0 size_flags_vertical = 0 -auto_translate = false focus_neighbor_top = NodePath("..") max_text_lines = 3 item_count = 1 @@ -116,7 +140,7 @@ layout_mode = 2 focus_mode = 0 toggle_mode = true shortcut_in_tooltip = false -icon = SubResource("ImageTexture_g63da") +icon = SubResource("ImageTexture_6orff") flat = true [node name="Focus" type="Panel" parent="PanelContainer"] @@ -124,7 +148,7 @@ unique_name_in_owner = true visible = false layout_mode = 2 mouse_filter = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_g74jb") +theme_override_styles/panel = SubResource("StyleBoxFlat_qw5e6") metadata/_edit_use_anchors_ = true [node name="ErrorTooltip" type="Label" parent="PanelContainer/Focus"] @@ -136,6 +160,7 @@ offset_left = -2.0 offset_top = -44.5 offset_right = 11.0 offset_bottom = -9.5 +theme_override_styles/normal = SubResource("StyleBoxFlat_qatmg") [connection signal="focus_entered" from="." to="." method="_on_focus_entered"] [connection signal="focus_entered" from="PanelContainer/MarginContainer/HBoxContainer/Search" to="." method="_on_search_focus_entered"] diff --git a/addons/dialogic/Editor/Settings/settings_editor.gd b/addons/dialogic/Editor/Settings/settings_editor.gd index 0e01464e8..727ad0141 100644 --- a/addons/dialogic/Editor/Settings/settings_editor.gd +++ b/addons/dialogic/Editor/Settings/settings_editor.gd @@ -161,6 +161,7 @@ func _close() -> void: for child in %SettingsContent.get_children(): if child.get_meta('section').has_method('_about_to_close'): child.get_meta('section')._about_to_close() + DialogicUtil.clear_editor_settings_cache() func refresh() -> void: diff --git a/addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd b/addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd index 2e9ee90df..64696c4a0 100644 --- a/addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd +++ b/addons/dialogic/Editor/TimelineEditor/TextEditor/syntax_highlighter.gd @@ -32,7 +32,8 @@ var text_event: DialogicTextEvent = null func _init() -> void: update_colors() - DialogicUtil.get_dialogic_plugin().get_editor_interface().get_base_control().theme_changed.connect(update_colors) + if DialogicUtil.get_dialogic_plugin(): + DialogicUtil.get_dialogic_plugin().get_editor_interface().get_base_control().theme_changed.connect(update_colors) func update_colors() -> void: diff --git a/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd b/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd index 81ea68ef3..1dc8fc4ae 100644 --- a/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd +++ b/addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd @@ -53,20 +53,20 @@ func save_timeline() -> void: timeline_editor.current_resource.set_meta("timeline_not_saved", false) timeline_editor.current_resource_state = DialogicEditor.ResourceStates.SAVED - DialogicResourceUtil.update_directory('dtl') + if not DialogicResourceUtil.is_resource_in_directory(timeline_editor.current_resource.resource_path): + DialogicResourceUtil.update_directory('dtl') -func text_timeline_to_array(text:String) -> Array: +func text_timeline_to_array(timeline_text:String) -> Array: # Parse the lines down into an array var events := [] - var lines := text.split('\n', true) + var lines := timeline_text.split('\n', true) var idx := -1 while idx < len(lines)-1: idx += 1 var line: String = lines[idx] - var line_stripped: String = line.strip_edges(true, true) events.append(line) return events @@ -161,7 +161,7 @@ func toggle_comment() -> void: ## Allows dragging files into the editor -func _can_drop_data(at_position:Vector2, data:Variant) -> bool: +func _can_drop_data(_at_position:Vector2, data:Variant) -> bool: if typeof(data) == TYPE_DICTIONARY and 'files' in data.keys() and len(data.files) == 1: return true return false @@ -311,7 +311,6 @@ func replace(replace_text:String) -> void: func replace_all(replace_text:String) -> void: begin_complex_operation() var next_pos := get_next_search_position() - var counter := 0 while next_pos.y != -1: insert_text("@@", next_pos.y, next_pos.x) if get_meta("current_search_flags") & SEARCH_MATCH_CASE: @@ -343,8 +342,8 @@ func _filter_code_completion_candidates(candidates:Array) -> Array: ## Called when code completion was activated ## Inserts the selected item -func _confirm_code_completion(replace:bool) -> void: - code_completion_helper.confirm_code_completion(replace, self) +func _confirm_code_completion(do_replace:bool) -> void: + code_completion_helper.confirm_code_completion(do_replace, self) ################################################################################ diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd b/addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd index d95062a1c..a03fafc0e 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd @@ -22,9 +22,6 @@ signal drag_canceled() func _ready() -> void: - resized.connect(add_extra_scroll_area_to_timeline) - %Timeline.child_entered_tree.connect(add_extra_scroll_area_to_timeline) - # This prevents the view to turn black if you are editing this scene in Godot if find_parent('EditorView'): %TimelineArea.get_theme_color("background_color", "CodeEdit") @@ -48,7 +45,7 @@ func _input(event:InputEvent) -> void: finish_dragging() -func _process(delta:float) -> void: +func _process(_delta:float) -> void: if !dragging: return @@ -86,8 +83,8 @@ func _draw() -> void: ## Draw Event Lines - for idx in range($Timeline.get_child_count()): - var block: Control = $Timeline.get_child(idx) + for idx in range(%Timeline.get_child_count()): + var block: Control = %Timeline.get_child(idx) if not "resource" in block: continue @@ -110,11 +107,11 @@ func _draw() -> void: else: color *= color_multiplier - if block.expanded and not block.resource.can_contain_events: + if block.is_expanded() and not block.resource.can_contain_events: draw_rect(Rect2(rect_position-global_position+Vector2(line_width, 0), Vector2(line_width, block.size.y-block.get_node('%IconPanel').size.y)), color) ## If the indentation has not changed, nothing else happens - if idx >= $Timeline.get_child_count()-1 or block.current_indent_level >= $Timeline.get_child(idx+1).current_indent_level: + if idx >= %Timeline.get_child_count()-1 or block.current_indent_level >= %Timeline.get_child(idx+1).current_indent_level: continue ## Draw connection between opening and end branch events @@ -140,7 +137,7 @@ func _draw() -> void: var group_color: Color = block.resource.event_color*color_multiplier var group_starter := true if idx != 0: - var block_above := $Timeline.get_child(idx-1) + var block_above := %Timeline.get_child(idx-1) if block_above.resource.event_name == block.resource.event_name: group_starter = false if block_above.resource is DialogicEndBranchEvent and block_above.parent_node.resource.event_name == block.resource.event_name: @@ -158,13 +155,13 @@ func _draw() -> void: ## Find the last event in the group (or that events END BRANCH) var sub_idx := idx var group_end_idx := idx - while sub_idx < $Timeline.get_child_count()-1: + while sub_idx < %Timeline.get_child_count()-1: sub_idx += 1 - if $Timeline.get_child(sub_idx).current_indent_level == block.current_indent_level-1: + if %Timeline.get_child(sub_idx).current_indent_level == block.current_indent_level-1: group_end_idx = sub_idx-1 break - var end_node := $Timeline.get_child(group_end_idx) + var end_node := %Timeline.get_child(group_end_idx) var offset := Vector2(-2*line_width, -icon_panel_height/2) var v_length: float = end_node.global_position.y - rect_position.y + icon_panel_height @@ -189,16 +186,3 @@ func _draw() -> void: draw_line(Vector2(0, height), Vector2(size.x*0.9, height), get_theme_color("accent_color", "Editor"), line_width*.3) #endregion - - -#region SPACE BELOW -################################################################################ - -func add_extra_scroll_area_to_timeline(fake_arg:Variant=null) -> void: - if %Timeline.get_children().size() > 4: - %Timeline.custom_minimum_size.y = 0 - %Timeline.size.y = 0 - if %Timeline.size.y + 200 > %TimelineArea.size.y: - %Timeline.custom_minimum_size = Vector2(0, %Timeline.size.y + 200) - -#endregion diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd index 9c71fb0e3..6018c5340 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd @@ -48,13 +48,12 @@ func save_timeline() -> void: # create a list of text versions of all the events with the right indent var new_events := [] - var indent := 0 for event in %Timeline.get_children(): if 'event_name' in event.resource: event.resource.update_text_version() new_events.append(event.resource) - if !timeline_editor.current_resource: + if not timeline_editor.current_resource: return timeline_editor.current_resource.events = new_events @@ -78,6 +77,8 @@ func load_timeline(resource:DialogicTimeline) -> void: # In case another timeline is still loading cancel_loading() + set_meta("loading_start", Time.get_unix_time_from_system()) + clear_timeline_nodes() if timeline_editor.current_resource.events.size() == 0: @@ -90,7 +91,7 @@ func load_timeline(resource:DialogicTimeline) -> void: var data := resource.events var page := 1 - var batch_size := 10 + var batch_size := 100 _batches = [] _building_timeline = true while batch_events(data, batch_size, page).size() != 0: @@ -102,6 +103,12 @@ func load_timeline(resource:DialogicTimeline) -> void: %TimelineArea.scroll_vertical = 0 +func get_time_since_loading_started(text:="Loading") -> float: + if has_meta("loading_start"): + return Time.get_unix_time_from_system() - get_meta("loading_start") + return -1 + + func is_loading_timeline() -> bool: return _building_timeline @@ -114,14 +121,14 @@ func cancel_loading() -> void: _building_timeline = false -func batch_events(array: Array, size: int, batch_number: int) -> Array: - return array.slice((batch_number - 1) * size, batch_number * size) +func batch_events(array: Array, batch_size: int, batch_number: int) -> Array: + return array.slice((batch_number - 1) * batch_size, batch_number * batch_size) # a list of all events like choice and condition events (so they get connected to their end events) var opener_events_stack := [] -func load_batch(data:Array) -> void: +func load_next_batch() -> void: # Don't try to cast it to Array immedietly, as the item may have become null and will throw a useless error var current_batch = _batches.pop_front() if current_batch: @@ -145,7 +152,7 @@ func _on_batch_loaded() -> void: var progress: float = 1-(1.0/get_meta("batch_count")*len(_batches)) timeline_editor.set_progress(progress) await get_tree().process_frame - load_batch(_batches) + load_next_batch() return # This hides the progress bar again @@ -158,6 +165,9 @@ func _on_batch_loaded() -> void: timeline_loaded.emit() + if has_meta("loading_start"): + print("[Dialogic] Loading %s events took %s seconds."%[len(timeline_editor.current_resource.events), get_time_since_loading_started()]) + opener_events_stack = [] indent_events() update_content_list() @@ -298,6 +308,8 @@ func _on_content_item_clicked(label:String) -> void: func update_content_list() -> void: + if has_meta("updated_content_list"): + return if not is_inside_tree(): return @@ -316,6 +328,10 @@ func update_content_list() -> void: timeline_editor.editors_manager.sidebar.update_content_list(labels) timeline_editor.update_audio_channel_cache(channels) + set_meta("updated_content_list", true) + await get_tree().process_frame + remove_meta("updated_content_list") + #endregion diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.tscn b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.tscn index 34f9b5c59..2ecc3944b 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.tscn +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.tscn @@ -3,15 +3,15 @@ [ext_resource type="Script" uid="uid://cvgok7bxva5e2" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd" id="1_8smxc"] [ext_resource type="Theme" uid="uid://cqst728xxipcw" path="res://addons/dialogic/Editor/Theme/MainTheme.tres" id="2_x0fhp"] [ext_resource type="Script" uid="uid://b6ka2avnh1u55" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd" id="3_sap1x"] -[ext_resource type="Script" uid="uid://n1knm2ohcehu" path="res://addons/dialogic/Editor/Events/EventBlock/event_right_click_menu.gd" id="4_ugiq6"] +[ext_resource type="Script" uid="uid://dixbl4axc8idr" path="res://addons/dialogic/Editor/Events/EventBlock/event_right_click_menu.gd" id="4_ugiq6"] [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_phyjj"] content_margin_top = 10.0 -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6gqu8"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3temo"] bg_color = Color(0, 0, 0, 1) -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jujwh"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s3c81"] content_margin_left = 4.0 content_margin_top = 4.0 content_margin_right = 4.0 @@ -24,17 +24,17 @@ border_width_right = 2 border_width_bottom = 2 corner_detail = 1 -[sub_resource type="Image" id="Image_3temo"] +[sub_resource type="Image" id="Image_njhke"] 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), +"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0), "format": "RGBA8", "height": 16, "mipmaps": false, "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_xe7d2"] -image = SubResource("Image_3temo") +[sub_resource type="ImageTexture" id="ImageTexture_5thxx"] +image = SubResource("Image_njhke") [node name="TimelineVisualEditor" type="MarginContainer"] anchors_preset = 15 @@ -61,41 +61,56 @@ size_flags_vertical = 3 theme_override_styles/panel = SubResource("StyleBoxEmpty_phyjj") script = ExtResource("3_sap1x") -[node name="Timeline" type="VBoxContainer" parent="View/TimelineArea"] +[node name="VBox" type="VBoxContainer" parent="View/TimelineArea"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="Timeline" type="VBoxContainer" parent="View/TimelineArea/VBox"] unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 3 +[node name="Spacer" type="Control" parent="View/TimelineArea/VBox"] +custom_minimum_size = Vector2(0, 200) +layout_mode = 2 + [node name="EventPopupMenu" type="PopupMenu" parent="View/TimelineArea"] unique_name_in_owner = true size = Vector2i(165, 124) -theme_override_styles/panel = SubResource("StyleBoxFlat_6gqu8") -theme_override_styles/hover = SubResource("StyleBoxFlat_jujwh") -item_count = 9 +theme_override_styles/panel = SubResource("StyleBoxFlat_3temo") +theme_override_styles/hover = SubResource("StyleBoxFlat_s3c81") +item_count = 11 item_0/text = "Duplicate" -item_0/icon = SubResource("ImageTexture_xe7d2") +item_0/icon = SubResource("ImageTexture_5thxx") +item_0/id = 0 item_1/id = -1 item_1/separator = true -item_2/text = "Documentation" -item_2/icon = SubResource("ImageTexture_xe7d2") -item_2/id = 2 -item_3/text = "Open Code" -item_3/icon = SubResource("ImageTexture_xe7d2") -item_3/id = 3 -item_4/id = -1 -item_4/separator = true -item_5/text = "Move up" -item_5/icon = SubResource("ImageTexture_xe7d2") -item_5/id = 5 -item_6/text = "Move down" -item_6/icon = SubResource("ImageTexture_xe7d2") -item_6/id = 6 -item_7/id = -1 -item_7/separator = true -item_8/text = "Delete" -item_8/icon = SubResource("ImageTexture_xe7d2") -item_8/id = 8 +item_2/text = "Play from here" +item_2/icon = SubResource("ImageTexture_5thxx") +item_2/id = 1 +item_3/id = -1 +item_3/separator = true +item_4/text = "Documentation" +item_4/icon = SubResource("ImageTexture_5thxx") +item_4/id = 2 +item_5/text = "Open Code" +item_5/icon = SubResource("ImageTexture_5thxx") +item_5/id = 3 +item_6/id = -1 +item_6/separator = true +item_7/text = "Move up" +item_7/icon = SubResource("ImageTexture_5thxx") +item_7/id = 4 +item_8/text = "Move down" +item_8/icon = SubResource("ImageTexture_5thxx") +item_8/id = 5 +item_9/id = -1 +item_9/separator = true +item_10/text = "Delete" +item_10/icon = SubResource("ImageTexture_5thxx") +item_10/id = 6 script = ExtResource("4_ugiq6") [node name="RightSidebar" type="ScrollContainer" parent="View"] diff --git a/addons/dialogic/Editor/editor_main.gd b/addons/dialogic/Editor/editor_main.gd index adc5f0b0c..a625f6158 100644 --- a/addons/dialogic/Editor/editor_main.gd +++ b/addons/dialogic/Editor/editor_main.gd @@ -6,7 +6,7 @@ extends Control var plugin_reference: EditorPlugin = null var editors_manager: Control = null -var editor_file_dialog: EditorFileDialog +var editor_file_dialog: ConfirmationDialog @onready var sidebar := %Sidebar as DialogicSidebar @@ -25,7 +25,10 @@ func _ready() -> void: button.pressed.connect(toggle_floating_window) # File dialog - editor_file_dialog = EditorFileDialog.new() + if Engine.is_editor_hint(): + editor_file_dialog = EditorFileDialog.new() + else: + editor_file_dialog = FileDialog.new() add_child(editor_file_dialog) var info_message := Label.new() @@ -37,7 +40,9 @@ func _ready() -> void: $SaveConfirmationDialog.add_button("No Saving Please!", true, "nosave") $SaveConfirmationDialog.hide() update_theme_additions() - EditorInterface.get_base_control().theme_changed.connect(update_theme_additions) + + if Engine.is_editor_hint(): + EditorInterface.get_base_control().theme_changed.connect(update_theme_additions) func _on_sidebar_toggled(sidebar_shown: bool) -> void: @@ -200,13 +205,13 @@ func update_theme_additions() -> void: new_theme.set_constant("separation", "DialogicMegaSeparator", 50) new_theme.set_type_variation("DialogicTextEventTextEdit", "CodeEdit") - var editor_settings := plugin_reference.get_editor_interface().get_editor_settings() + var editor_settings := plugin_reference.get_editor_interface().get_editor_settings() if Engine.is_editor_hint() else null var text_panel := DCSS.inline({ "border-radius": 8, "background": editor_settings.get_setting("text_editor/theme/highlighting/background_color").lerp( editor_settings.get_setting("text_editor/theme/highlighting/text_color"), 0.05 - ), + ) if editor_settings else Color.DIM_GRAY, "padding": [8, 8], }) text_panel.content_margin_bottom = 5 diff --git a/addons/dialogic/Editor/editors_manager.gd b/addons/dialogic/Editor/editors_manager.gd index 029a9199f..72abd5af8 100644 --- a/addons/dialogic/Editor/editors_manager.gd +++ b/addons/dialogic/Editor/editors_manager.gd @@ -63,8 +63,9 @@ func _ready() -> void: used_resources_cache = DialogicUtil.get_editor_setting('last_resources', []) sidebar.update_resource_list(used_resources_cache) - find_parent('EditorView').plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved) - find_parent('EditorView').plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed) + if find_parent('EditorView').plugin_reference: + find_parent('EditorView').plugin_reference.get_editor_interface().get_file_system_dock().files_moved.connect(_on_file_moved) + find_parent('EditorView').plugin_reference.get_editor_interface().get_file_system_dock().file_removed.connect(_on_file_removed) hsplit.set("theme_override_constants/separation", get_theme_constant("base_margin", "Editor") * DialogicUtil.get_editor_scale()) diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 81df6ad5d..089b25acb 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -256,7 +256,8 @@ func to_text() -> String: func from_text(string:String) -> void: # Load default character - character = DialogicResourceUtil.get_character_resource(character_identifier) + if character_identifier: + character = DialogicResourceUtil.get_character_resource(character_identifier) var result := regex.search(string) diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index a1e4bdd31..0061dc5bc 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -32,7 +32,7 @@ var character_identifier: String: set(value): character_identifier = value character = DialogicResourceUtil.get_character_resource(value) - if (not character) or (character and not character.portraits.has(portrait)): + if (not character and character_identifier.is_empty()) or (character and not character.portraits.has(portrait)): portrait = "" ui_update_needed.emit() @@ -325,12 +325,15 @@ func from_text(string:String) -> void: else: character = DialogicResourceUtil.get_character_resource(name) - if character == null and Engine.is_editor_hint() == false: - character = DialogicCharacter.new() - character.display_name = name - character.set_identifier(name) - if portrait: - character.color = Color(portrait) + if character == null: + if Engine.is_editor_hint() == false: + character = DialogicCharacter.new() + character.display_name = name + character.set_identifier(name) + if portrait: + character.color = Color(portrait) + else: + character_identifier = name if not result: return @@ -353,8 +356,8 @@ func is_string_full_event(string:String) -> bool: func get_shortcode_parameters() -> Dictionary: return { #param_name : property_info - "character" : {"property": "character_identifier", "default": ""}, - "portrait" : {"property": "portrait", "default": ""}, + "character" : {"property": "character_identifier", "default": ""}, + "portrait" : {"property": "portrait", "default": ""}, } #endregion @@ -400,7 +403,7 @@ func build_event_editor() -> void: func should_show_portrait_selector() -> bool: - return character and not character.portraits.is_empty() and not character.portraits.size() == 1 + return (character and not character.portraits.is_empty() and not character.portraits.size() == 1) or (character_identifier and not character) func do_any_characters_exist() -> bool: @@ -408,7 +411,13 @@ func do_any_characters_exist() -> bool: func get_character_suggestions(search_text:String) -> Dictionary: - var suggestions := DialogicUtil.get_character_suggestions(search_text, character, true, false, editor_node) + var suggestions := {} + if not search_text and character_identifier and not character: + suggestions[character_identifier] = { + "value":character_identifier, + "tooltip": "A temporary character, created on the spot.", + "editor_icon":["GuiEllipsis", "EditorIcons"]} + suggestions.merge(DialogicUtil.get_character_suggestions(search_text, character, true, false, editor_node)) if search_text and not search_text in suggestions: suggestions[search_text] = { "value":search_text, @@ -416,7 +425,10 @@ func get_character_suggestions(search_text:String) -> Dictionary: "editor_icon":["GuiEllipsis", "EditorIcons"]} return suggestions + func get_portrait_suggestions(search_text:String) -> Dictionary: + if not character and search_text: + return {search_text: {"value":search_text, "tooltip":"Portrait will be interpreted as color on temporary character.", "editor_icon":["PickerShapeCircle", "EditorIcons"]}} return DialogicUtil.get_portrait_suggestions(search_text, character, true, "Don't change") #endregion diff --git a/addons/dialogic/Modules/Variable/variables_editor/variables_editor.tscn b/addons/dialogic/Modules/Variable/variables_editor/variables_editor.tscn index f4315621b..673645aec 100644 --- a/addons/dialogic/Modules/Variable/variables_editor/variables_editor.tscn +++ b/addons/dialogic/Modules/Variable/variables_editor/variables_editor.tscn @@ -5,33 +5,28 @@ [sub_resource type="Image" id="Image_1bhct"] 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), +"data": PackedByteArray(255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 92, 92, 127, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 90, 90, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 0, 255, 93, 93, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 42, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 93, 93, 41, 255, 90, 90, 0, 255, 94, 94, 0, 255, 91, 91, 42, 255, 93, 93, 233, 255, 92, 92, 232, 255, 92, 92, 0, 255, 92, 92, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 93, 93, 0, 255, 91, 91, 45, 255, 93, 93, 44, 255, 91, 91, 0, 255, 91, 91, 42, 255, 91, 91, 42, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 45, 255, 92, 92, 235, 255, 92, 92, 234, 255, 89, 89, 43, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 91, 91, 0, 255, 92, 92, 0, 255, 92, 92, 0, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 91, 91, 59, 255, 92, 92, 61, 255, 92, 92, 0, 255, 92, 92, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 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, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0, 255, 93, 93, 0), "format": "RGBA8", "height": 16, "mipmaps": false, "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_sr7s6"] +[sub_resource type="ImageTexture" id="ImageTexture_6orff"] image = SubResource("Image_1bhct") -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7aodm"] -content_margin_left = 2.0 -content_margin_top = 0.0 -content_margin_right = 2.0 -content_margin_bottom = 0.0 -bg_color = Color(0.44, 0.73, 0.98, 0.1) +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_on3ut"] +content_margin_left = 4.0 +content_margin_top = 4.0 +content_margin_right = 4.0 +content_margin_bottom = 4.0 +bg_color = Color(1, 0.365, 0.365, 1) +draw_center = false border_width_left = 2 border_width_top = 2 border_width_right = 2 border_width_bottom = 2 -border_color = Color(0.44, 0.73, 0.98, 1) -corner_radius_top_left = 3 -corner_radius_top_right = 3 -corner_radius_bottom_right = 3 -corner_radius_bottom_left = 3 -corner_detail = 3 -anti_aliasing = false +corner_detail = 1 [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_vn21i"] @@ -47,9 +42,9 @@ expand_margin_bottom = 4.0 anti_aliasing = false [sub_resource type="Theme" id="Theme_17j6i"] -Button/styles/hover = SubResource("StyleBoxFlat_7aodm") +Button/styles/hover = SubResource("StyleBoxFlat_on3ut") Button/styles/normal = SubResource("StyleBoxEmpty_vn21i") -Button/styles/pressed = SubResource("StyleBoxFlat_7aodm") +Button/styles/pressed = SubResource("StyleBoxFlat_on3ut") pressed/styles/Button = SubResource("StyleBoxFlat_ffuxp") [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ncgqs"] @@ -84,7 +79,7 @@ unique_name_in_owner = true layout_mode = 2 size_flags_horizontal = 3 placeholder_text = "Search" -right_icon = SubResource("ImageTexture_sr7s6") +right_icon = SubResource("ImageTexture_6orff") [node name="Tree" type="Tree" parent="Editor"] unique_name_in_owner = true @@ -117,7 +112,7 @@ custom_minimum_size = Vector2(30, 30) layout_mode = 2 tooltip_text = "String (Any text)" toggle_mode = true -icon = SubResource("ImageTexture_sr7s6") +icon = SubResource("ImageTexture_6orff") icon_alignment = 1 [node name="Float" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"] @@ -125,7 +120,7 @@ custom_minimum_size = Vector2(30, 30) layout_mode = 2 tooltip_text = "Float (Number with Decimals)" toggle_mode = true -icon = SubResource("ImageTexture_sr7s6") +icon = SubResource("ImageTexture_6orff") icon_alignment = 1 [node name="Int" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"] @@ -133,7 +128,7 @@ custom_minimum_size = Vector2(30, 30) layout_mode = 2 tooltip_text = "Int (Integer)" toggle_mode = true -icon = SubResource("ImageTexture_sr7s6") +icon = SubResource("ImageTexture_6orff") icon_alignment = 1 [node name="Bool" type="Button" parent="Editor/Tree/ChangeTypePopup/HBox"] @@ -141,7 +136,7 @@ custom_minimum_size = Vector2(30, 30) layout_mode = 2 tooltip_text = "Bool (True/False flag)" toggle_mode = true -icon = SubResource("ImageTexture_sr7s6") +icon = SubResource("ImageTexture_6orff") icon_alignment = 1 [node name="RightClickMenu" type="PopupMenu" parent="Editor/Tree"] @@ -149,6 +144,7 @@ unique_name_in_owner = true size = Vector2i(67, 35) item_count = 1 item_0/text = "Copy" +item_0/icon = SubResource("ImageTexture_6orff") item_0/id = 0 [node name="ReferenceInfo" type="HBoxContainer" parent="Editor"] diff --git a/addons/dialogic/Resources/event.gd b/addons/dialogic/Resources/event.gd index 571e4721e..a6f0a1e93 100644 --- a/addons/dialogic/Resources/event.gd +++ b/addons/dialogic/Resources/event.gd @@ -70,6 +70,8 @@ var help_page_path := "" ## Is the event block created by a button? var created_by_button := false +var _editor_icon_cache: Dictionary = {} + ## Reference to the node, that represents this event. Only works while in visual editor mode. ## Use with care. var editor_node: Control = null @@ -100,7 +102,8 @@ enum ValueType { CUSTOM, BUTTON, LABEL, COLOR, AUDIO_PREVIEW, IMAGE_PREVIEW } ## List that stores the fields for the editor -var editor_list: Array = [] +var editor_list: Array[Dictionary] = [] +static var _editor_list_cache := {} var this_folder: String = get_script().resource_path.get_base_dir() @@ -199,7 +202,7 @@ func _get_property_original_translation(_property_name:String) -> String: ## Returns true if there is any translatable properties on this event. ## Overwrite [_get_translatable_properties()] to change this. func can_be_translated() -> bool: - return !_get_translatable_properties().is_empty() + return not _get_translatable_properties().is_empty() ## This is automatically called, no need to use this. @@ -433,13 +436,15 @@ func parse_shortcode_parameters(shortcode: String) -> Dictionary: ################################################################################ func _get_icon() -> Resource: - var _icon_file_name := "res://addons/dialogic/Editor/Images/Pieces/closed-icon.svg" # Default - # Check for both svg and png, but prefer svg if available - if ResourceLoader.exists(self.get_script().get_path().get_base_dir() + "/icon.svg"): - _icon_file_name = self.get_script().get_path().get_base_dir() + "/icon.svg" - elif ResourceLoader.exists(self.get_script().get_path().get_base_dir() + "/icon.png"): - _icon_file_name = self.get_script().get_path().get_base_dir() + "/icon.png" - return load(_icon_file_name) + if not event_name in _editor_icon_cache: + var _icon_file_name := "res://addons/dialogic/Editor/Images/Pieces/closed-icon.svg" # Default + # Check for both svg and png, but prefer svg if available + if ResourceLoader.exists(self.get_script().get_path().get_base_dir() + "/icon.svg"): + _icon_file_name = self.get_script().get_path().get_base_dir() + "/icon.svg" + elif ResourceLoader.exists(self.get_script().get_path().get_base_dir() + "/icon.png"): + _icon_file_name = self.get_script().get_path().get_base_dir() + "/icon.png" + _editor_icon_cache[event_name] = load(_icon_file_name) + return _editor_icon_cache[event_name] func set_default_color(value:Variant) -> void: @@ -484,18 +489,17 @@ func _get_syntax_highlighting(_Highlighter:SyntaxHighlighter, dict:Dictionary, _ ################################################################################ func get_event_editor_info() -> Array: - if Engine.is_editor_hint(): - if editor_list != null: - editor_list.clear() - else: - editor_list = [] + if not event_name in _editor_list_cache: + editor_list.clear() if DialogicUtil.get_editor_setting('show_event_names', false): add_header_label(event_name) build_event_editor() - return editor_list - else: - return [] + + _editor_list_cache[event_name] = editor_list + + return _editor_list_cache[event_name] + ## to be overwritten by the sub_classes @@ -514,10 +518,10 @@ func build_event_editor() -> void: func add_header_label(text:String, condition:= "") -> void: editor_list.append({ "name" : "something", - "type" :+ TYPE_STRING, + "type" : TYPE_STRING, "location" : Location.HEADER, "usage" : PROPERTY_USAGE_EDITOR, - "field_type" : ValueType.LABEL, + "field_type" : ValueType.LABEL, "display_info" : {"text":text}, "condition" : condition }) @@ -529,7 +533,7 @@ func add_header_edit(variable:String, editor_type := ValueType.LABEL, extra_info "type" : typeof(get(variable)), "location" : Location.HEADER, "usage" : PROPERTY_USAGE_DEFAULT, - "field_type" : editor_type, + "field_type" : editor_type, "display_info" : extra_info, "left_text" : extra_info.get('left_text', ''), "right_text" : extra_info.get('right_text', ''), @@ -543,7 +547,7 @@ func add_header_button(text:String, callable:Callable, tooltip:String, icon: Var "type" : TYPE_STRING, "location" : Location.HEADER, "usage" : PROPERTY_USAGE_DEFAULT, - "field_type" : ValueType.BUTTON, + "field_type" : ValueType.BUTTON, "display_info" : {'text':text, 'tooltip':tooltip, 'callable':callable, 'icon':icon}, "condition" : condition, }) @@ -555,7 +559,7 @@ func add_body_edit(variable:String, editor_type := ValueType.LABEL, extra_info:= "type" : typeof(get(variable)), "location" : Location.BODY, "usage" : PROPERTY_USAGE_DEFAULT, - "field_type" : editor_type, + "field_type" : editor_type, "display_info" : extra_info, "left_text" : extra_info.get('left_text', ''), "right_text" : extra_info.get('right_text', ''),