Add addons
This commit is contained in:
parent
2c862b2235
commit
3367bad24f
527 changed files with 36197 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
func refresh():
|
||||
%MainVariableGroup.update()
|
||||
%MainVariableGroup.load_data('Variables', DialogicUtil.get_project_setting('dialogic/variables', {}))
|
||||
|
||||
func _about_to_close():
|
||||
ProjectSettings.set_setting('dialogic/variables', %MainVariableGroup.get_data())
|
||||
ProjectSettings.save()
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,11 @@
|
|||
@tool
|
||||
extends Control
|
||||
|
||||
# This preview is used in the variables editor (Settings)
|
||||
|
||||
func set_text(text):
|
||||
$Panel/HBox/Label.text = text
|
||||
|
||||
func _ready():
|
||||
$Panel/HBox/TextureRect.texture = get_theme_icon("TripleBar", "EditorIcons")
|
||||
$Panel.self_modulate = get_theme_color("prop_subGroup", "Editor")
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c6clf8lgj5ta0"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Variable/variables_editor/variable_drag_preview.gd" id="1_uphub"]
|
||||
|
||||
[sub_resource type="Image" id="Image_uxwa0"]
|
||||
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_iae3h"]
|
||||
image = SubResource("Image_uxwa0")
|
||||
|
||||
[node name="Preview" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
script = ExtResource("1_uphub")
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="."]
|
||||
self_modulate = Color(0, 0, 0, 1)
|
||||
layout_mode = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Panel"]
|
||||
layout_mode = 2
|
||||
offset_right = 54.0
|
||||
offset_bottom = 26.0
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="Panel/HBox"]
|
||||
layout_mode = 2
|
||||
offset_right = 16.0
|
||||
offset_bottom = 26.0
|
||||
texture = SubResource("ImageTexture_iae3h")
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/HBox"]
|
||||
layout_mode = 2
|
||||
offset_left = 20.0
|
||||
offset_right = 54.0
|
||||
offset_bottom = 26.0
|
||||
text = "Text"
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
@tool
|
||||
extends PanelContainer
|
||||
|
||||
var parent_Group = null
|
||||
var preview_scene = get_script().resource_path.get_base_dir().path_join("variable_drag_preview.tscn")
|
||||
|
||||
################################################################################
|
||||
## FUNCTIONALITY
|
||||
################################################################################
|
||||
|
||||
func get_item_name():
|
||||
return %NameEdit.text.strip_edges()
|
||||
|
||||
func get_data() -> String:
|
||||
return %ValueEdit.text
|
||||
|
||||
func load_data(var_name:String, var_value:String, _Group:Control) -> void:
|
||||
parent_Group = _Group
|
||||
%NameEdit.text = var_name
|
||||
%ValueEdit.text = var_value
|
||||
|
||||
################################################################################
|
||||
## DRAGGING
|
||||
################################################################################
|
||||
|
||||
func _get_drag_data(position):
|
||||
var data = {
|
||||
'data':{},
|
||||
'node':self
|
||||
}
|
||||
data.data[get_item_name()] = get_data()
|
||||
|
||||
var prev = load(preview_scene).instantiate()
|
||||
prev.set_text(get_item_name())
|
||||
set_drag_preview(prev)
|
||||
|
||||
return data
|
||||
|
||||
func is_variable():
|
||||
return true
|
||||
|
||||
|
||||
func _can_drop_data(position, data):
|
||||
if typeof(data) == TYPE_DICTIONARY and data.has('data') and data.has('node'):
|
||||
return true
|
||||
return false
|
||||
|
||||
func _drop_data(position, data):
|
||||
parent_Group.add_data(data.data)
|
||||
data.node.queue_free()
|
||||
|
||||
################################################################################
|
||||
## UI
|
||||
################################################################################
|
||||
|
||||
func _ready():
|
||||
%DeleteButton.icon = get_theme_icon("Remove", "EditorIcons")
|
||||
%Dragger.texture = get_theme_icon("TripleBar", "EditorIcons")
|
||||
|
||||
|
||||
func _on_DeleteButton_pressed():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_NameEdit_gui_input(event):
|
||||
if event is InputEventMouseButton and event.pressed and event.double_click:
|
||||
%NameEdit.editable = true
|
||||
if event is InputEventKey and event.pressed and event.keycode == KEY_ENTER and !%NameEdit.editable:
|
||||
print('hey')
|
||||
%NameEdit.editable = true
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _on_NameEdit_focus_exited():
|
||||
disable_name_edit()
|
||||
|
||||
|
||||
func _on_name_edit_text_submitted(new_text:String) -> void:
|
||||
%NameEdit.text = new_text.replace(' ', '_')
|
||||
disable_name_edit()
|
||||
|
||||
|
||||
func disable_name_edit():
|
||||
%NameEdit.editable = false
|
||||
parent_Group.check_data()
|
||||
|
||||
|
||||
func warning():
|
||||
modulate = get_theme_color("warning_color", "Editor")
|
||||
|
||||
|
||||
func no_warning():
|
||||
modulate = Color(1,1,1,1)
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dbo8jol41ed83"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Variable/variables_editor/variable_field.gd" id="1"]
|
||||
|
||||
[sub_resource type="Image" id="Image_yxhfa"]
|
||||
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_3qnqh"]
|
||||
image = SubResource("Image_yxhfa")
|
||||
|
||||
[node name="VariableField" type="PanelContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_bottom = -569.0
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="Dragger" type="TextureRect" parent="HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_default_cursor_shape = 13
|
||||
texture = SubResource("ImageTexture_3qnqh")
|
||||
|
||||
[node name="NameEdit" type="LineEdit" parent="HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "NewVariable"
|
||||
editable = false
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="ValueEdit" type="LineEdit" parent="HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
select_all_on_focus = true
|
||||
|
||||
[node name="DeleteButton" type="Button" parent="HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
icon = SubResource("ImageTexture_3qnqh")
|
||||
flat = true
|
||||
|
||||
[connection signal="focus_exited" from="HBox/NameEdit" to="." method="_on_NameEdit_focus_exited"]
|
||||
[connection signal="gui_input" from="HBox/NameEdit" to="." method="_on_NameEdit_gui_input"]
|
||||
[connection signal="text_submitted" from="HBox/NameEdit" to="." method="_on_name_edit_text_submitted"]
|
||||
[connection signal="pressed" from="HBox/DeleteButton" to="." method="_on_DeleteButton_pressed"]
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
@tool
|
||||
extends PanelContainer
|
||||
|
||||
@export var MainGroup: bool = false
|
||||
var Group_scene = get_script().resource_path.get_base_dir().path_join("variable_group.tscn")
|
||||
var field_scene = get_script().resource_path.get_base_dir().path_join("variable_field.tscn")
|
||||
var preview_scene = get_script().resource_path.get_base_dir().path_join("variable_drag_preview.tscn")
|
||||
|
||||
var drag_preview = null
|
||||
|
||||
var parent_Group = null
|
||||
################################################################################
|
||||
## FUNCTIONALITY
|
||||
################################################################################
|
||||
func get_item_name():
|
||||
return %NameEdit.text
|
||||
|
||||
func get_data() -> Dictionary:
|
||||
var data = {}
|
||||
for child in %Content.get_children():
|
||||
data[child.get_item_name()] = child.get_data()
|
||||
return data
|
||||
|
||||
func load_data(Group_name, data:Dictionary, _parent_Group:Control = null) -> void:
|
||||
if not MainGroup:
|
||||
%NameEdit.text = Group_name
|
||||
parent_Group = _parent_Group
|
||||
else:
|
||||
clear()
|
||||
|
||||
add_data(data)
|
||||
|
||||
func add_data(data) -> void:
|
||||
for key in data.keys():
|
||||
if typeof(data[key]) == TYPE_DICTIONARY:
|
||||
var Group = load(Group_scene).instantiate()
|
||||
%Content.add_child(Group)
|
||||
Group.update()
|
||||
Group.load_data(key, data[key], self)
|
||||
else:
|
||||
var field = load(field_scene).instantiate()
|
||||
%Content.add_child(field)
|
||||
field.load_data(key, data[key], self)
|
||||
|
||||
func check_data():
|
||||
var names = []
|
||||
for child in %Content.get_children():
|
||||
if child.has_method('warning') and not child.is_queued_for_deletion():
|
||||
if child.get_item_name() in names:
|
||||
child.warning()
|
||||
else:
|
||||
child.no_warning()
|
||||
names.append(child.get_item_name())
|
||||
|
||||
func search(term:String) -> bool:
|
||||
var found_anything = false
|
||||
for child in %Content.get_children():
|
||||
if child.has_method('search'):
|
||||
var res = child.search(term)
|
||||
if not found_anything:
|
||||
found_anything = res
|
||||
|
||||
elif term.is_empty():
|
||||
child.show()
|
||||
elif child.has_method('get_item_name'):
|
||||
child.visible = term in str(child.get_item_name()).to_lower() or term in child.get_data().to_lower()
|
||||
if not found_anything:
|
||||
found_anything = child.visible
|
||||
|
||||
if not term.is_empty() and not found_anything and not MainGroup:
|
||||
hide()
|
||||
else:
|
||||
show()
|
||||
|
||||
return found_anything
|
||||
|
||||
func _get_drag_data(position):
|
||||
if MainGroup:
|
||||
return null
|
||||
|
||||
var data = {
|
||||
'data':{},
|
||||
'node':self
|
||||
}
|
||||
data.data[get_item_name()] = get_data()
|
||||
|
||||
var prev = load(preview_scene).instantiate()
|
||||
prev.set_text(get_item_name())
|
||||
set_drag_preview(prev)
|
||||
|
||||
return data
|
||||
|
||||
func _can_drop_data(position, data):
|
||||
if typeof(data) == TYPE_DICTIONARY and data.has('data') and data.has('node'):
|
||||
return true
|
||||
return false
|
||||
|
||||
func _drop_data(position, data):
|
||||
# safety that should prevent dragging a Group into itself
|
||||
var fold = self
|
||||
while fold != null:
|
||||
if fold == data.node:
|
||||
return
|
||||
fold = fold.parent_Group
|
||||
|
||||
# if everything is good, then add new data and delete old one
|
||||
add_data(data.data)
|
||||
data.node.queue_free()
|
||||
check_data()
|
||||
|
||||
func _on_VariableGroup_gui_input(event):
|
||||
if get_viewport().gui_is_dragging():
|
||||
if get_global_rect().has_point(get_global_mouse_position()):
|
||||
if not drag_preview:
|
||||
drag_preview = Control.new()
|
||||
drag_preview.custom_minimum_size.y = 30
|
||||
%Content.add_child(drag_preview)
|
||||
%Content.move_child(drag_preview, %Content.get_child_count())
|
||||
self_modulate = get_theme_color("accent_color", "Editor")
|
||||
else:
|
||||
undrag()
|
||||
|
||||
func _on_VariableGroup_mouse_exited():
|
||||
undrag()
|
||||
|
||||
|
||||
func undrag():
|
||||
if drag_preview != null:
|
||||
drag_preview.queue_free()
|
||||
drag_preview = null
|
||||
self_modulate = Color(1,1,1,1)
|
||||
|
||||
################################################################################
|
||||
## UI
|
||||
################################################################################
|
||||
func _ready():
|
||||
update()
|
||||
|
||||
func update():
|
||||
if MainGroup:
|
||||
%DeleteButton.hide()
|
||||
%DuplicateButton.hide()
|
||||
%FoldButton.hide()
|
||||
%NameEdit.text = "VAR"
|
||||
%NameEdit.editable = false
|
||||
%SearchBar.show()
|
||||
%Dragger.hide()
|
||||
%SearchBar.right_icon = get_theme_icon("Search", "EditorIcons")
|
||||
|
||||
%Dragger.texture = get_theme_icon("TripleBar", "EditorIcons")
|
||||
%NameEdit.add_theme_color_override("font_color_uneditable", get_theme_color('font_color', 'Label'))
|
||||
%DeleteButton.icon = get_theme_icon("Remove", "EditorIcons")
|
||||
%DeleteButton.tooltip_text = "Delete Group"
|
||||
%DuplicateButton.icon = get_theme_icon("Duplicate", "EditorIcons")
|
||||
%DuplicateButton.tooltip_text = "Duplicate Group"
|
||||
%NewGroup.icon = get_theme_icon("Folder", "EditorIcons")
|
||||
%NewGroup.tooltip_text = "Add new Group"
|
||||
%NewVariable.icon = get_theme_icon("Add", "EditorIcons")
|
||||
%NewVariable.tooltip_text = "Add new variable"
|
||||
%FoldButton.icon = get_theme_icon("GuiVisibilityVisible", "EditorIcons")
|
||||
%FoldButton.tooltip_text = "Hide/Show content"
|
||||
|
||||
|
||||
func clear():
|
||||
for child in %Content.get_children():
|
||||
child.queue_free()
|
||||
|
||||
func warning():
|
||||
modulate = get_theme_color("warning_color", "Editor")
|
||||
|
||||
func no_warning():
|
||||
modulate = Color(1,1,1,1)
|
||||
|
||||
func _on_DeleteButton_pressed():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_DuplicateButton_pressed():
|
||||
parent_Group.add_data({get_item_name()+'_duplicate':get_data()})
|
||||
|
||||
|
||||
func _on_NewGroup_pressed():
|
||||
add_data({'New Group':{}})
|
||||
|
||||
|
||||
func _on_NewVariable_pressed():
|
||||
add_data({'New Variable':""})
|
||||
|
||||
|
||||
func _on_FoldButton_toggled(button_pressed):
|
||||
%Content.visible = button_pressed
|
||||
|
||||
if button_pressed:
|
||||
%FoldButton.icon = get_theme_icon("GuiVisibilityVisible", "EditorIcons")
|
||||
else:
|
||||
%FoldButton.icon = get_theme_icon("GuiVisibilityHidden", "EditorIcons")
|
||||
|
||||
|
||||
func _on_NameEdit_gui_input(event):
|
||||
if event is InputEventMouseButton and event.pressed and event.double_click:
|
||||
if not MainGroup:
|
||||
%NameEdit.editable = true
|
||||
|
||||
func _on_name_edit_text_submitted(new_text):
|
||||
disable_name_edit()
|
||||
|
||||
func _on_NameEdit_focus_exited():
|
||||
disable_name_edit()
|
||||
|
||||
func disable_name_edit():
|
||||
%NameEdit.editable = false
|
||||
check_data()
|
||||
|
||||
|
||||
func _on_SearchBar_text_changed(new_text):
|
||||
search(new_text.to_lower())
|
||||
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
[gd_scene load_steps=8 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Events/Variable/variables_editor/variable_group.gd" id="1"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7k4ja"]
|
||||
content_margin_left = 5.0
|
||||
content_margin_top = 5.0
|
||||
content_margin_right = 5.0
|
||||
content_margin_bottom = 5.0
|
||||
bg_color = Color(0.466667, 0.466667, 0.466667, 0.137255)
|
||||
border_width_left = 2
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="Image" id="Image_t2vcq"]
|
||||
data = {
|
||||
"data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
"format": "LumAlpha8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id="6"]
|
||||
image = SubResource("Image_t2vcq")
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_rhdj5"]
|
||||
|
||||
[sub_resource type="Image" id="Image_wxcgx"]
|
||||
data = {
|
||||
"data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
"format": "LumAlpha8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id="9"]
|
||||
image = SubResource("Image_wxcgx")
|
||||
|
||||
[node name="VariableGroup" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_7k4ja")
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
offset_left = 5.0
|
||||
offset_top = 5.0
|
||||
offset_right = 1019.0
|
||||
offset_bottom = 595.0
|
||||
|
||||
[node name="MainBar" type="HBoxContainer" parent="VBox"]
|
||||
offset_right = 1014.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Dragger" type="TextureRect" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_right = 16.0
|
||||
offset_bottom = 31.0
|
||||
mouse_default_cursor_shape = 13
|
||||
texture = SubResource("6")
|
||||
|
||||
[node name="NameEdit" type="LineEdit" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 20.0
|
||||
offset_right = 874.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/read_only = SubResource("StyleBoxEmpty_rhdj5")
|
||||
text = "NewFolder"
|
||||
editable = false
|
||||
|
||||
[node name="SearchBar" type="LineEdit" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.5
|
||||
placeholder_text = "search"
|
||||
|
||||
[node name="NewVariable" type="Button" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 878.0
|
||||
offset_right = 902.0
|
||||
offset_bottom = 31.0
|
||||
hint_tooltip = "Add new variable"
|
||||
icon = SubResource("9")
|
||||
flat = true
|
||||
|
||||
[node name="NewGroup" type="Button" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 906.0
|
||||
offset_right = 930.0
|
||||
offset_bottom = 31.0
|
||||
hint_tooltip = "Add new folder"
|
||||
icon = SubResource("9")
|
||||
flat = true
|
||||
|
||||
[node name="DuplicateButton" type="Button" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 934.0
|
||||
offset_right = 958.0
|
||||
offset_bottom = 31.0
|
||||
hint_tooltip = "Duplicate Group"
|
||||
icon = SubResource("6")
|
||||
flat = true
|
||||
|
||||
[node name="DeleteButton" type="Button" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 962.0
|
||||
offset_right = 986.0
|
||||
offset_bottom = 31.0
|
||||
hint_tooltip = "Delete Group"
|
||||
icon = SubResource("6")
|
||||
flat = true
|
||||
|
||||
[node name="FoldButton" type="Button" parent="VBox/MainBar"]
|
||||
unique_name_in_owner = true
|
||||
offset_left = 990.0
|
||||
offset_right = 1014.0
|
||||
offset_bottom = 31.0
|
||||
hint_tooltip = "Hide/Show content"
|
||||
toggle_mode = true
|
||||
icon = SubResource("9")
|
||||
flat = true
|
||||
|
||||
[node name="ContentKeeper" type="HBoxContainer" parent="VBox"]
|
||||
offset_top = 35.0
|
||||
offset_right = 1014.0
|
||||
offset_bottom = 35.0
|
||||
|
||||
[node name="Space" type="Control" parent="VBox/ContentKeeper"]
|
||||
custom_minimum_size = Vector2(20, 0)
|
||||
offset_right = 20.0
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBox/ContentKeeper"]
|
||||
offset_left = 24.0
|
||||
offset_right = 1014.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Labels" type="HBoxContainer" parent="VBox/ContentKeeper/VBoxContainer"]
|
||||
visible = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBox/ContentKeeper/VBoxContainer/Labels"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 5
|
||||
text = "Name"
|
||||
|
||||
[node name="Label2" type="Label" parent="VBox/ContentKeeper/VBoxContainer/Labels"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 5
|
||||
text = "Default value"
|
||||
|
||||
[node name="Space2" type="Control" parent="VBox/ContentKeeper/VBoxContainer/Labels"]
|
||||
|
||||
[node name="Content" type="VBoxContainer" parent="VBox/ContentKeeper/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
offset_right = 990.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[connection signal="gui_input" from="." to="." method="_on_VariableGroup_gui_input"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_VariableGroup_mouse_exited"]
|
||||
[connection signal="focus_exited" from="VBox/MainBar/NameEdit" to="." method="_on_NameEdit_focus_exited"]
|
||||
[connection signal="gui_input" from="VBox/MainBar/NameEdit" to="." method="_on_NameEdit_gui_input"]
|
||||
[connection signal="text_submitted" from="VBox/MainBar/NameEdit" to="." method="_on_name_edit_text_submitted"]
|
||||
[connection signal="text_changed" from="VBox/MainBar/SearchBar" to="." method="_on_SearchBar_text_changed"]
|
||||
[connection signal="pressed" from="VBox/MainBar/NewVariable" to="." method="_on_NewVariable_pressed"]
|
||||
[connection signal="pressed" from="VBox/MainBar/NewGroup" to="." method="_on_NewGroup_pressed"]
|
||||
[connection signal="pressed" from="VBox/MainBar/DuplicateButton" to="." method="_on_DuplicateButton_pressed"]
|
||||
[connection signal="pressed" from="VBox/MainBar/DeleteButton" to="." method="_on_DeleteButton_pressed"]
|
||||
[connection signal="toggled" from="VBox/MainBar/FoldButton" to="." method="_on_FoldButton_toggled"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue