From 925887252e18408ad1fdf37c8b3ec3926a9158d5 Mon Sep 17 00:00:00 2001 From: Jowan-Spooner <42868150+Jowan-Spooner@users.noreply.github.com> Date: Tue, 2 Aug 2022 16:47:33 +0200 Subject: [PATCH] Event UI picker updates (#1070) * Event UI picker updates # File picker Adds a file picker. You can give it some placeholder text and a file filter (e.g. '*.png'). You can drag and drop files that fit that filter into the picker. # "Simple" Condition picker Pretty complex picker that allows to switch between "simple" editing and complex one. Simple editing provides three drop-downs. # Complex Picker doesn't use a popup anymore, instead it uses a ItemList node. * Update condition picker to use {Variable} style --- .../Editor/Events/EventNode/EventNode.gd | 20 +++- .../Editor/Events/Fields/ComplexPicker.gd | 72 +++++------- .../Editor/Events/Fields/ComplexPicker.tscn | 47 ++++++-- .../Editor/Events/Fields/ConditionPicker.gd | 109 ++++++++++++++++++ .../Editor/Events/Fields/ConditionPicker.tscn | 100 ++++++++++++++++ .../Editor/Events/Fields/FilePicker.gd | 61 ++++++++++ .../Editor/Events/Fields/FilePicker.tscn | 88 ++++++++++++++ .../dialogic/Editor/Events/Fields/Number.gd | 2 + .../dialogic/Editor/Events/Fields/Number.tscn | 27 +++-- addons/dialogic/Events/Background/event.gd | 2 +- addons/dialogic/Events/Condition/event.gd | 8 +- addons/dialogic/Events/Music/event.gd | 2 +- addons/dialogic/Events/Sound/event.gd | 2 +- addons/dialogic/Events/Variable/event.gd | 4 +- .../Events/Voice/SerialAudioregion.gd | 1 - addons/dialogic/Events/Voice/event.gd | 2 +- addons/dialogic/Other/DialogicGameHandler.gd | 1 - addons/dialogic/Resources/event.gd | 1 + 18 files changed, 475 insertions(+), 74 deletions(-) create mode 100644 addons/dialogic/Editor/Events/Fields/ConditionPicker.gd create mode 100644 addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn create mode 100644 addons/dialogic/Editor/Events/Fields/FilePicker.gd create mode 100644 addons/dialogic/Editor/Events/Fields/FilePicker.tscn diff --git a/addons/dialogic/Editor/Events/EventNode/EventNode.gd b/addons/dialogic/Editor/Events/EventNode/EventNode.gd index a0c7a7e1e..31c72d540 100644 --- a/addons/dialogic/Editor/Events/EventNode/EventNode.gd +++ b/addons/dialogic/Editor/Events/EventNode/EventNode.gd @@ -169,6 +169,7 @@ func build_editor(): if p.name == "linebreak": editor_node = Control.new() editor_node.theme_type_variation = "LineBreak" + ### STRINGS elif p.dialogic_type == resource.ValueType.MultilineText: editor_node = load("res://addons/dialogic/Editor/Events/Fields/MultilineText.tscn").instantiate() @@ -178,6 +179,17 @@ func build_editor(): elif p.dialogic_type == resource.ValueType.Bool: editor_node = load("res://addons/dialogic/Editor/Events/Fields/Bool.tscn").instantiate() + 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.ComplexPicker: editor_node = load("res://addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn").instantiate() @@ -235,10 +247,10 @@ func build_editor(): editor_node.set_value(resource.get(p.name)) if editor_node.has_signal('value_changed'): editor_node.value_changed.connect(set_property) - if editor_node.has_method('set_left_text') and p.has('left_text'): - editor_node.set_left_text(p.left_text) - if editor_node.has_method('set_right_text') and p.has('right_text'): - editor_node.set_right_text(p.right_text) + if editor_node.has_method('set_left_text'): + editor_node.set_left_text(p.get('left_text', '')) + if editor_node.has_method('set_right_text'): + editor_node.set_right_text(p.get('right_text', '')) if p.has('condition'): edit_conditions_list.append([editor_node, p.condition]) diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd index 8949b4660..a2204e537 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd +++ b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd @@ -7,7 +7,7 @@ extends Control var file_extension = "" var get_suggestions_func = [self, 'get_default_suggestions'] var empty_text = "" -var disable_pretty_name := false +@export var disable_pretty_name := false var resource_icon:Texture = null: get: @@ -21,10 +21,6 @@ var resource_icon:Texture = null: else: $Search.theme_type_variation = "LineEditWithIcon" -# I'm so sorry for this, but the popup_hide signal get's triggered if the popup is hidden by me, -# and I don't want it to change the resource, if one was just selected by clicking -var ignore_popup_hide_once = false - ## STORING VALUE AND REFERENCE TO RESOURCE var event_resource : DialogicEvent = null var property_name : String @@ -90,11 +86,9 @@ func _ready(): $Search/Icon.position.x = 10 $Search/SelectButton.icon = get_theme_icon("Collapse", "EditorIcons") $Search.placeholder_text = placeholder_text - $Search/Suggestions.hide() - $Search/Suggestions.index_pressed.connect(suggestion_selected) - $Search/Suggestions.popup_hide.connect(popup_hide) - #TODO: Invalid call. Nonexistent function 'add_theme_stylebox_override' in base 'PopupMenu'. - #$Search/Suggestions.add_theme_stylebox_override('panel', load("res://addons/dialogic/Editor/Events/styles/ResourceMenuPanelBackground.tres")) + %Suggestions.add_theme_stylebox_override('bg', load("res://addons/dialogic/Editor/Events/styles/ResourceMenuPanelBackground.tres")) + %Suggestions.hide() + %Suggestions.item_selected.connect(suggestion_selected) if resource_icon == null: self.resource_icon = null @@ -103,44 +97,45 @@ func _ready(): ## SEARCH & SUGGESTION POPUP ################################################################################ func _on_Search_text_entered(new_text = ""): - if $Search/Suggestions.get_item_count() and not $Search.text.is_empty(): + if %Suggestions.get_item_count() and not $Search.text.is_empty(): suggestion_selected(0) else: changed_to_empty() func _on_Search_text_changed(new_text, just_update = false): - $Search/Suggestions.clear() + %Suggestions.clear() if new_text == "" and !just_update: changed_to_empty() - - ignore_popup_hide_once = just_update - + var suggestions = get_suggestions_func[0].call(get_suggestions_func[1], new_text) + var line_length = 0 var more_hidden = false var idx = 0 for element in suggestions: if new_text != "" or idx < 12: + line_length = max(get_theme_font('font', 'Label').get_string_size(element, HORIZONTAL_ALIGNMENT_LEFT, -1, get_theme_font_size("font_size", 'Label')).x+80, line_length) + %Suggestions.add_item(element) if suggestions[element].has('icon'): - $Search/Suggestions.add_icon_item(suggestions[element].icon, element) + %Suggestions.set_item_icon(idx, suggestions[element].icon) elif suggestions[element].has('editor_icon'): - $Search/Suggestions.add_icon_item(get_theme_icon(suggestions[element].editor_icon[0],suggestions[element].editor_icon[1]), element) - else: - $Search/Suggestions.add_item(element) - $Search/Suggestions.set_item_tooltip(idx, suggestions[element].get('tooltip', '')) - $Search/Suggestions.set_item_metadata(idx, suggestions[element].value) + %Suggestions.set_item_icon(idx, get_theme_icon(suggestions[element].editor_icon[0],suggestions[element].editor_icon[1])) + + %Suggestions.set_item_tooltip(idx, suggestions[element].get('tooltip', '')) + %Suggestions.set_item_metadata(idx, suggestions[element].value) else: more_hidden = true break idx += 1 if more_hidden: - $Search/Suggestions.add_item('...') - $Search/Suggestions.set_item_disabled(idx, true) + %Suggestions.add_item('...', null, false) - if not $Search/Suggestions.visible: - $Search/Suggestions.popup_on_parent(Rect2i($Search.get_global_rect().position+Vector2(0,$Search.size.y), Vector2($Search.size.x, 50))) + if not %Suggestions.visible: + %Suggestions.show() + %Suggestions.global_position = $Search.global_position+Vector2(0,1)*$Search.size.y + %Suggestions.custom_minimum_size.x = max($Search.size.x, line_length) $Search.grab_focus() @@ -155,30 +150,27 @@ func get_default_suggestions(search_text): return suggestions func suggestion_selected(index): - $Search.text = $Search/Suggestions.get_item_text(index) + $Search.text = %Suggestions.get_item_text(index) # if this is a resource: if file_extension: - var file = load($Search/Suggestions.get_item_metadata(index)) + var file = load(%Suggestions.get_item_metadata(index)) current_value = file else: - current_value = $Search/Suggestions.get_item_metadata(index) + current_value = %Suggestions.get_item_metadata(index) - ignore_popup_hide_once = true - $Search/Suggestions.hide() + hide_suggestions() emit_signal("value_changed", property_name, current_value) - -func popup_hide(): + +func _input(event): + if event is InputEventMouseButton and event.pressed: + if !%Suggestions.get_global_rect().has_point(get_global_mouse_position()): + if %Suggestions.visible: hide_suggestions() + +func hide_suggestions(): $Search/SelectButton.button_pressed = false - if ignore_popup_hide_once: - ignore_popup_hide_once = false - return - if $Search/Suggestions.get_item_count() and not $Search.text.is_empty(): - suggestion_selected(0) - else: - set_value(null) - changed_to_empty() + %Suggestions.hide() func _on_Search_focus_entered(): if $Search.text == "" or current_value == null or (typeof(current_value) == TYPE_STRING and current_value.is_empty()): diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn b/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn index bfe7c2446..06c3e467d 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn +++ b/addons/dialogic/Editor/Events/Fields/ComplexPicker.tscn @@ -1,9 +1,26 @@ -[gd_scene load_steps=5 format=3 uid="uid://dpwhshre1n4t6"] +[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="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="2_lcu5c"] +[ext_resource type="StyleBox" uid="uid://c8k6tbipodsg" path="res://addons/dialogic/Editor/Events/styles/ResourceMenuPanelBackground.tres" id="3_66uah"] -[sub_resource type="Image" id="Image_by40g"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vnmqh"] +content_margin_left = 25.0 +content_margin_top = 5.0 +content_margin_right = 25.0 +content_margin_bottom = 5.0 +bg_color = Color(0.113725, 0.121569, 0.145098, 1) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.0784314, 0.0862745, 0.101961, 1) +corner_radius_top_left = 3 +corner_radius_top_right = 3 +corner_radius_bottom_right = 3 +corner_radius_bottom_left = 3 + +[sub_resource type="Image" id="Image_g62mn"] data = { "data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 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, 93, 93, 255, 255, 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, 131, 255, 255, 255, 0, 255, 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, 131, 255, 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, 93, 93, 131, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 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, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 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, 93, 93, 55, 255, 97, 97, 58, 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, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 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, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 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,8 +29,8 @@ data = { "width": 16 } -[sub_resource type="ImageTexture" id="ImageTexture_2kfue"] -image = SubResource("Image_by40g") +[sub_resource type="ImageTexture" id="ImageTexture_2yvt7"] +image = SubResource("Image_g62mn") [node name="ComplexPicker" type="HBoxContainer"] custom_minimum_size = Vector2(200, 0) @@ -35,9 +52,11 @@ offset_right = 195.0 offset_bottom = 33.0 size_flags_horizontal = 3 size_flags_vertical = 4 -focus_next = NodePath("Suggestions") mouse_filter = 1 theme = ExtResource("2_lcu5c") +theme_override_styles/normal = SubResource("StyleBoxFlat_vnmqh") +theme_override_styles/focus = SubResource("StyleBoxFlat_vnmqh") +theme_override_styles/read_only = SubResource("StyleBoxFlat_vnmqh") placeholder_text = "Select Resource" expand_to_text_length = true caret_blink = true @@ -51,10 +70,24 @@ offset_right = 33.0 ignore_texture_size = true stretch_mode = 3 -[node name="Suggestions" type="PopupMenu" parent="Search"] +[node name="Suggestions3" type="PopupMenu" parent="Search"] handle_input_locally = false allow_search = false +[node name="Suggestions" type="ItemList" parent="Search"] +unique_name_in_owner = true +visible = false +top_level = true +custom_minimum_size = Vector2(100, 0) +offset_left = -5.0 +offset_right = 95.0 +offset_bottom = 104.0 +theme_override_styles/bg = ExtResource("3_66uah") +max_text_lines = 3 +auto_height = true +item_count = 1 +item_0/text = "" + [node name="SelectButton" type="Button" parent="Search"] anchor_left = 1.0 anchor_right = 1.0 @@ -62,7 +95,7 @@ anchor_bottom = 1.0 grow_horizontal = 0 toggle_mode = true shortcut_in_tooltip = false -icon = SubResource("ImageTexture_2kfue") +icon = SubResource("ImageTexture_2yvt7") flat = true [node name="RightText" type="Label" parent="."] diff --git a/addons/dialogic/Editor/Events/Fields/ConditionPicker.gd b/addons/dialogic/Editor/Events/Fields/ConditionPicker.gd new file mode 100644 index 000000000..ca4eb3c14 --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/ConditionPicker.gd @@ -0,0 +1,109 @@ +@tool +extends Control + +var property_name : String +signal value_changed + +var operators = {'==':0, '<':1, '>':2, '<=':3, '>=':4, '!=':5} + +func _ready(): + %ToggleComplex.icon = get_theme_icon("Enum", "EditorIcons") + + %Value1.resource_icon = get_theme_icon("ClassList", "EditorIcons") + %Value1.get_suggestions_func = [self, 'get_value1_suggestions'] + %Value1.value_changed.connect(something_changed) + + %Operator.item_selected.connect(something_changed) + + %Value2.resource_icon = get_theme_icon("Variant", "EditorIcons") + %Value2.get_suggestions_func = [self, 'get_value2_suggestions'] + %Value2.value_changed.connect(something_changed) + +func set_right_text(value:String): + $RightText.text = str(value) + $RightText.visible = !value.is_empty() + +func set_left_text(value:String): + $LeftText.text = str(value) + $LeftText.visible = !value.is_empty() + +func set_value(value:String): + 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: + var data = complex2simple(value) + %Value1.set_value(data[0]) + %Operator.select(operators[data[1]]) + %Value2.set_value(data[2]) + +func something_changed(fake_arg1=null, fake_arg2 = null): + if %ComplexEditor.visible: + value_changed.emit(property_name, %ComplexEditor.text) + elif %SimpleEditor.visible: + value_changed.emit(property_name, simple2complex(%Value1.current_value, %Operator.get_item_text(%Operator.selected), %Value2.current_value)) + +func is_too_complex(condition:String) -> bool: + return !condition.is_empty() and len(condition.split(' ', false)) != 3 + +func complex2simple(condition:String) -> Array: + if is_too_complex(condition): + return ['', '==',''] + return Array(condition.split(' ', false)) + +func simple2complex(value1, operator, value2) -> String: + if value1 == null: value1 = '' + if value1.is_empty(): + return '' + if value2 == null: value2 = '' + return value1 +" "+ operator +" "+ value2 + +func _on_toggle_complex_toggled(button_pressed) -> void: + if button_pressed: + %ComplexEditor.show() + %SimpleEditor.hide() + %ComplexEditor.text = simple2complex(%Value1.current_value, %Operator.get_item_text(%Operator.selected), %Value2.current_value) + else: + if !is_too_complex(%ComplexEditor.text): + %ComplexEditor.hide() + %SimpleEditor.show() + var data = complex2simple(%ComplexEditor.text) + %Value1.set_value(data[0]) + %Operator.select(operators[data[1]]) + %Value2.set_value(data[2]) + +func _on_complex_editor_text_changed(new_text): + %ToggleComplex.disabled = is_too_complex(%ComplexEditor.text) + something_changed() + +func get_value1_suggestions(filter:String) -> Dictionary: + var suggestions = {} + if filter: + suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]} + var vars = DialogicUtil.get_project_setting('dialogic/variables', {}) + for var_path in list_variables(vars): + if filter.is_empty() or filter.to_lower() in var_path.to_lower(): + suggestions[var_path] = {'value':'{'+var_path+"}", 'editor_icon':["ClassList", "EditorIcons"]} + return suggestions + +func list_variables(dict, path = "") -> Array: + var array = [] + for key in dict.keys(): + if typeof(dict[key]) == TYPE_DICTIONARY: + array.append_array(list_variables(dict[key], path+key+".")) + else: + array.append(path+key) + return array + +func get_value2_suggestions(filter:String) -> Dictionary: + var suggestions = {} + if filter: + suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]} + var vars = DialogicUtil.get_project_setting('dialogic/variables', {}) + for var_path in list_variables(vars): + if filter.is_empty() or filter.to_lower() in var_path.to_lower(): + suggestions[var_path] = {'value':'{'+var_path+"}", 'editor_icon':["ClassList", "EditorIcons"]} + return suggestions diff --git a/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn b/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn new file mode 100644 index 000000000..90b847e17 --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/ConditionPicker.tscn @@ -0,0 +1,100 @@ +[gd_scene load_steps=6 format=3 uid="uid://ir6334lqtuwt"] + +[ext_resource type="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="1_l2tpu"] +[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"] + +[sub_resource type="Image" id="Image_gctj2"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 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, 93, 93, 255, 255, 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, 131, 255, 255, 255, 0, 255, 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, 131, 255, 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, 93, 93, 131, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 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, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 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, 93, 93, 55, 255, 97, 97, 58, 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, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 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, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 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_2d0xq"] +image = SubResource("Image_gctj2") + +[node name="ConditionPicker" type="HBoxContainer"] +offset_right = 77.0 +offset_bottom = 31.0 +theme = ExtResource("1_l2tpu") +script = ExtResource("1_q5p62") + +[node name="LeftText" type="Label" parent="."] +offset_top = 5.0 +offset_right = 1.0 +offset_bottom = 28.0 + +[node name="SimpleEditor" type="HBoxContainer" parent="."] +unique_name_in_owner = true +offset_left = 5.0 +offset_right = 477.0 +offset_bottom = 33.0 + +[node name="Value1" parent="SimpleEditor" instance=ExtResource("1_rr7mq")] +unique_name_in_owner = true +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_right = 200.0 +offset_bottom = 33.0 +disable_pretty_name = true + +[node name="Operator" type="OptionButton" parent="SimpleEditor"] +unique_name_in_owner = true +offset_left = 204.0 +offset_right = 268.0 +offset_bottom = 33.0 +item_count = 6 +selected = 0 +popup/item_0/text = "==" +popup/item_0/id = 0 +popup/item_1/text = ">" +popup/item_1/id = 1 +popup/item_2/text = "<" +popup/item_2/id = 2 +popup/item_3/text = "<=" +popup/item_3/id = 3 +popup/item_4/text = ">=" +popup/item_4/id = 4 +popup/item_5/text = "not ==" +popup/item_5/id = 5 + +[node name="Value2" parent="SimpleEditor" instance=ExtResource("1_rr7mq")] +unique_name_in_owner = true +anchor_right = 0.0 +anchor_bottom = 0.0 +offset_left = 272.0 +offset_right = 472.0 +offset_bottom = 33.0 +disable_pretty_name = true + +[node name="ComplexEditor" type="LineEdit" parent="."] +unique_name_in_owner = true +visible = false +custom_minimum_size = Vector2(150, 0) +offset_left = 479.0 +offset_right = 986.0 +offset_bottom = 33.0 +mouse_filter = 1 +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 +offset_left = 481.0 +offset_right = 505.0 +offset_bottom = 33.0 +toggle_mode = true +icon = SubResource("ImageTexture_2d0xq") + +[node name="RightText" type="Label" parent="."] +offset_left = 509.0 +offset_top = 5.0 +offset_right = 510.0 +offset_bottom = 28.0 + +[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/FilePicker.gd b/addons/dialogic/Editor/Events/Fields/FilePicker.gd new file mode 100644 index 000000000..2b49faae7 --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/FilePicker.gd @@ -0,0 +1,61 @@ +@tool +extends Control + +var file_filter := "" +var placeholder := "" +var resource_icon:Texture = null: + get: + return resource_icon + set(new_icon): + resource_icon = new_icon + %Icon.texture = new_icon + if new_icon == null: + %Field.theme_type_variation = "" + else: + %Field.theme_type_variation = "LineEditWithIcon" + +var property_name : String +signal value_changed + +func _ready(): + %OpenButton.icon = get_theme_icon("Folder", "EditorIcons") + %ClearButton.icon = get_theme_icon("Reload", "EditorIcons") + %OpenButton.button_down.connect(_on_OpenButton_pressed) + %ClearButton.button_up.connect(clear_path) + %Field.set_drag_forwarding(self) + %Field.placeholder_text = placeholder + +func set_right_text(value:String): + $RightText.text = str(value) + $RightText.visible = !value.is_empty() + +func set_left_text(value:String): + $LeftText.text = str(value) + $LeftText.visible = !value.is_empty() + +func set_value(value): + %Field.text = value.get_file() + %Field.hint_tooltip = value + %ClearButton.visible = !value.is_empty() + +func _on_OpenButton_pressed() -> void: + find_parent('EditorView').godot_file_dialog(_on_file_dialog_selected, file_filter, EditorFileDialog.FILE_MODE_OPEN_FILE, "Open "+DialogicUtil.pretty_name(property_name)) + +func _on_file_dialog_selected(path:String) -> void: + emit_signal("value_changed", property_name, path) + set_value(path) + +func clear_path(): + emit_signal("value_changed", property_name, "") + set_value("") + +func _can_drop_data_fw(position, data, from_control): + if typeof(data) == TYPE_DICTIONARY and data.has('files') and len(data.files) == 1: + if file_filter: + if '*.'+data.files[0].get_extension() in file_filter: + return true + else: return true + return false + +func _drop_data_fw(position, data, from_control): + _on_file_dialog_selected(data.files[0]) diff --git a/addons/dialogic/Editor/Events/Fields/FilePicker.tscn b/addons/dialogic/Editor/Events/Fields/FilePicker.tscn new file mode 100644 index 000000000..67f86782c --- /dev/null +++ b/addons/dialogic/Editor/Events/Fields/FilePicker.tscn @@ -0,0 +1,88 @@ +[gd_scene load_steps=5 format=3 uid="uid://7mvxuaulctcq"] + +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.gd" id="1_838yp"] +[ext_resource type="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="2_514jv"] + +[sub_resource type="Image" id="Image_6itop"] +data = { +"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 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, 93, 93, 255, 255, 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, 131, 255, 255, 255, 0, 255, 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, 131, 255, 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, 93, 93, 131, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 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, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 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, 93, 93, 55, 255, 97, 97, 58, 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, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 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, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 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, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 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_2d0xq"] +image = SubResource("Image_6itop") + +[node name="FilePicker" type="HBoxContainer"] +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_838yp") + +[node name="LeftText" type="Label" parent="."] +offset_top = 8.0 +offset_right = 1.0 +offset_bottom = 31.0 + +[node name="Field" type="LineEdit" parent="."] +unique_name_in_owner = true +custom_minimum_size = Vector2(200, 0) +offset_left = 5.0 +offset_right = 205.0 +offset_bottom = 40.0 +mouse_filter = 1 +theme = ExtResource("2_514jv") +theme_type_variation = &"LineEditWithIcon" +text = "asdad" +expand_to_text_length = true + +[node name="HBox" type="HBoxContainer" parent="Field"] +anchor_right = 1.0 +anchor_bottom = 1.0 +theme_override_constants/separation = 0 +alignment = 2 + +[node name="Margin" type="Control" parent="Field/HBox"] +custom_minimum_size = Vector2(5, 0) +offset_right = 5.0 +offset_bottom = 40.0 +size_flags_horizontal = 0 + +[node name="Icon" type="TextureRect" parent="Field/HBox"] +unique_name_in_owner = true +offset_left = 5.0 +offset_top = 20.0 +offset_right = 5.0 +offset_bottom = 20.0 +size_flags_vertical = 4 +mouse_filter = 2 + +[node name="Control" type="Control" parent="Field/HBox"] +offset_left = 5.0 +offset_right = 152.0 +offset_bottom = 40.0 +size_flags_horizontal = 3 +mouse_filter = 2 + +[node name="OpenButton" type="Button" parent="Field/HBox"] +unique_name_in_owner = true +offset_left = 152.0 +offset_right = 176.0 +offset_bottom = 40.0 +icon = SubResource("ImageTexture_2d0xq") +flat = true + +[node name="ClearButton" type="Button" parent="Field/HBox"] +unique_name_in_owner = true +offset_left = 176.0 +offset_right = 200.0 +offset_bottom = 40.0 +icon = SubResource("ImageTexture_2d0xq") +flat = true + +[node name="RightText" type="Label" parent="."] +offset_left = 209.0 +offset_top = 8.0 +offset_right = 210.0 +offset_bottom = 31.0 diff --git a/addons/dialogic/Editor/Events/Fields/Number.gd b/addons/dialogic/Editor/Events/Fields/Number.gd index 3d9ac6d74..ef53320a4 100644 --- a/addons/dialogic/Editor/Events/Fields/Number.gd +++ b/addons/dialogic/Editor/Events/Fields/Number.gd @@ -14,9 +14,11 @@ func _on_value_changed(value): func set_right_text(value): $RightText.text = str(value) + $RightText.visible = !value.is_empty() func set_left_text(value): $LeftText.text = str(value) + $LeftText.visible = !value.is_empty() func set_value(value): $Value.value = value diff --git a/addons/dialogic/Editor/Events/Fields/Number.tscn b/addons/dialogic/Editor/Events/Fields/Number.tscn index de9d1f05d..1aea8ef7f 100644 --- a/addons/dialogic/Editor/Events/Fields/Number.tscn +++ b/addons/dialogic/Editor/Events/Fields/Number.tscn @@ -1,25 +1,28 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=3 format=3 uid="uid://kdpp3mibml33"] -[ext_resource path="res://addons/dialogic/Editor/Events/Fields/Number.gd" type="Script" id=1] +[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/Fields/Number.gd" id="1"] +[ext_resource type="Theme" uid="uid://d3g4i4dshtdpu" path="res://addons/dialogic/Editor/Events/styles/InputFieldsStyle.tres" id="2_u2kma"] [node name="NumberValue" type="HBoxContainer"] anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 1 ) +script = ExtResource("1") [node name="LeftText" type="Label" parent="."] -margin_top = 293.0 -margin_bottom = 307.0 +offset_top = 288.0 +offset_right = 1.0 +offset_bottom = 311.0 [node name="Value" type="SpinBox" parent="."] -margin_left = 4.0 -margin_right = 78.0 -margin_bottom = 600.0 +offset_left = 5.0 +offset_right = 111.0 +offset_bottom = 600.0 +theme = ExtResource("2_u2kma") [node name="RightText" type="Label" parent="."] -margin_left = 82.0 -margin_top = 293.0 -margin_right = 82.0 -margin_bottom = 307.0 +offset_left = 115.0 +offset_top = 288.0 +offset_right = 116.0 +offset_bottom = 311.0 [connection signal="value_changed" from="Value" to="." method="_on_Value_value_changed"] diff --git a/addons/dialogic/Events/Background/event.gd b/addons/dialogic/Events/Background/event.gd index bcde9553c..752d771fd 100644 --- a/addons/dialogic/Events/Background/event.gd +++ b/addons/dialogic/Events/Background/event.gd @@ -47,4 +47,4 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('Path', ValueType.SinglelineText, 'Path:') + add_header_edit('Path', ValueType.File, 'Path:', '', {'file_filter':'*.tscn, *.scn, *.jpg, *.jpeg, *.png, *.webp, *.tga, *svg, *.bmp, *.dds, *.exr, *.hdr', 'placeholder': "No background", 'editor_icon':["Image", "EditorIcons"]}) diff --git a/addons/dialogic/Events/Condition/event.gd b/addons/dialogic/Events/Condition/event.gd index 943daf554..0727682a9 100644 --- a/addons/dialogic/Events/Condition/event.gd +++ b/addons/dialogic/Events/Condition/event.gd @@ -6,13 +6,15 @@ enum ConditionTypes {IF, ELIF, ELSE} # DEFINE ALL PROPERTIES OF THE EVENT var ConditionType = ConditionTypes.IF -var Condition :String = "true" +var Condition :String = "" func _execute() -> void: if ConditionType == ConditionTypes.ELSE: finish() return + if Condition.is_empty(): Condition = "true" + var result = dialogic.execute_condition(Condition) if not result: var idx = dialogic.current_event_idx @@ -102,5 +104,5 @@ func is_valid_event_string(string:String): ################################################################################ func build_event_editor(): - add_header_edit('ConditionType', ValueType.FixedOptionSelector, '', '', {'selector_options':{"IF":ConditionTypes.IF, "ELIF":ConditionTypes.ELIF, "ELSE":ConditionTypes.ELSE}, 'disabled':true}) - add_header_edit('Condition', ValueType.SinglelineText, '', '', {}, 'ConditionType != %s'%ConditionTypes.ELSE) + add_header_edit('ConditionType', ValueType.FixedOptionSelector, 'Cond:', '', {'selector_options':{"IF":ConditionTypes.IF, "ELIF":ConditionTypes.ELIF, "ELSE":ConditionTypes.ELSE}, 'disabled':true}) + add_header_edit('Condition', ValueType.Condition, '', '', {}, 'ConditionType != %s'%ConditionTypes.ELSE) diff --git a/addons/dialogic/Events/Music/event.gd b/addons/dialogic/Events/Music/event.gd index 3fe611315..cf3c94dea 100644 --- a/addons/dialogic/Events/Music/event.gd +++ b/addons/dialogic/Events/Music/event.gd @@ -57,7 +57,7 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('FilePath', ValueType.SinglelineText, 'Path:') + add_header_edit('FilePath', ValueType.File, 'Path:', '', {'file_filter':'*.mp3, *.ogg, *.wav', 'placeholder': "No music", 'editor_icon':["AudioStreamPlayer", "EditorIcons"]}) add_header_edit('FadeLength', ValueType.Float, 'Fade:') add_body_edit('Volume', ValueType.Decibel, 'Volume:', '', {}, '!FilePath.is_empty()') add_body_edit('AudioBus', ValueType.SinglelineText, 'AudioBus:', '', {}, '!FilePath.is_empty()') diff --git a/addons/dialogic/Events/Sound/event.gd b/addons/dialogic/Events/Sound/event.gd index c5dfad874..37fd68223 100644 --- a/addons/dialogic/Events/Sound/event.gd +++ b/addons/dialogic/Events/Sound/event.gd @@ -48,7 +48,7 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('FilePath', ValueType.SinglelineText, 'Path:') + add_header_edit('FilePath', ValueType.File, 'Path:', '', {'file_filter':'*.mp3, *.ogg, *.wav', 'placeholder': "Select file", 'editor_icon':["AudioStreamPlayer", "EditorIcons"]}) add_body_edit('Volume', ValueType.Decibel, 'Volume:', '', {}, '!FilePath.is_empty()') add_body_edit('AudioBus', ValueType.SinglelineText, 'AudioBus:', '', {}, '!FilePath.is_empty()') #add_body_edit('Loop', ValueType.Bool, 'Loop:') diff --git a/addons/dialogic/Events/Variable/event.gd b/addons/dialogic/Events/Variable/event.gd index a32c2e04a..d1f79c3bd 100644 --- a/addons/dialogic/Events/Variable/event.gd +++ b/addons/dialogic/Events/Variable/event.gd @@ -138,7 +138,7 @@ func get_var_suggestions(filter:String) -> Dictionary: suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]} var vars = DialogicUtil.get_project_setting('dialogic/variables', {}) for var_path in list_variables(vars): - if !filter.is_empty() or filter.to_lower() in var_path.to_lower(): # Added the .is_empty here. Not sure if it was the right thing + if filter.is_empty() or filter.to_lower() in var_path.to_lower(): suggestions[var_path] = {'value':var_path, 'editor_icon':["ClassList", "EditorIcons"]} return suggestions @@ -159,6 +159,6 @@ func get_value_suggestions(filter:String) -> Dictionary: suggestions[filter] = {'value':filter, 'editor_icon':["GuiScrollArrowRight", "EditorIcons"]} var vars = DialogicUtil.get_project_setting('dialogic/variables', {}) for var_path in list_variables(vars): - if filter.to_lower() in var_path.to_lower(): + if filter.is_empty() or filter.to_lower() in var_path.to_lower(): suggestions[var_path] = {'value':var_path, 'editor_icon':["ClassList", "EditorIcons"]} return suggestions diff --git a/addons/dialogic/Events/Voice/SerialAudioregion.gd b/addons/dialogic/Events/Voice/SerialAudioregion.gd index 57795fe6a..facbab13f 100644 --- a/addons/dialogic/Events/Voice/SerialAudioregion.gd +++ b/addons/dialogic/Events/Voice/SerialAudioregion.gd @@ -22,7 +22,6 @@ func _ready(): func set_value(value): if value == null: return - print("SerialAudioRegion set_value(" + value + ")") if not value is String: printerr("Invalid data - %s (SerialAudioRegion): data incoming is not string." % property_name) var data:PackedStringArray = value.split("region", false) diff --git a/addons/dialogic/Events/Voice/event.gd b/addons/dialogic/Events/Voice/event.gd index 67a17f7f5..40d793231 100644 --- a/addons/dialogic/Events/Voice/event.gd +++ b/addons/dialogic/Events/Voice/event.gd @@ -61,7 +61,7 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('FilePath', ValueType.SinglelineText, 'Path:') + add_header_edit('FilePath', ValueType.File, 'Path:', '', {'file_filter':'*.mp3, *.ogg, *.wav', 'placeholder': "Select file", 'editor_icon':["AudioStreamPlayer", "EditorIcons"]}) add_body_edit('Volume', ValueType.Decibel, 'Volume:', '', {}, '!FilePath.is_empty()') add_body_edit('AudioBus', ValueType.SinglelineText, 'AudioBus:', '', {}, '!FilePath.is_empty()') add_body_edit('regions', ValueType.Custom, '', '', {'path' : 'res://addons/dialogic/Events/Voice/SerialAudioregion.tscn'}, '!FilePath.is_empty()') diff --git a/addons/dialogic/Other/DialogicGameHandler.gd b/addons/dialogic/Other/DialogicGameHandler.gd index 857567b99..5fafad6ff 100644 --- a/addons/dialogic/Other/DialogicGameHandler.gd +++ b/addons/dialogic/Other/DialogicGameHandler.gd @@ -121,7 +121,6 @@ func execute_condition(condition:String) -> bool: var replacement = "VAR." + r_string.substr(1,r_string.length()-2) condition = condition.replace(r_string, replacement) - var expr = Expression.new() var autoload_names = [] var autoloads = [] diff --git a/addons/dialogic/Resources/event.gd b/addons/dialogic/Resources/event.gd index fa0b66aca..594a00a25 100644 --- a/addons/dialogic/Resources/event.gd +++ b/addons/dialogic/Resources/event.gd @@ -45,6 +45,7 @@ enum ValueType { Label, MultilineText, SinglelineText, + Condition, Bool,