First work on dialogic, resized guild, and started implementing portraits.
This commit is contained in:
113
addons/dialogic/Modules/StyleEditor/Components/style_browser.gd
Normal file
113
addons/dialogic/Modules/StyleEditor/Components/style_browser.gd
Normal file
@@ -0,0 +1,113 @@
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
var ListItem := load("res://addons/dialogic/Editor/Common/BrowserItem.tscn")
|
||||
enum Types {ALL, STYLES, LAYER, LAYOUT_BASE}
|
||||
|
||||
var current_type := Types.ALL
|
||||
var style_part_info := []
|
||||
var premade_scenes_reference := {}
|
||||
|
||||
signal activate_part(part_info:Dictionary)
|
||||
|
||||
var current_info := {}
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
%Search.right_icon = get_theme_icon("Search", "EditorIcons")
|
||||
%CloseButton.icon = get_theme_icon("Close", "EditorIcons")
|
||||
collect_style_parts()
|
||||
|
||||
|
||||
func collect_style_parts() -> void:
|
||||
for indexer in DialogicUtil.get_indexers():
|
||||
for layout_part in indexer._get_layout_parts():
|
||||
style_part_info.append(layout_part)
|
||||
if not layout_part.get('path', '').is_empty():
|
||||
premade_scenes_reference[layout_part['path']] = layout_part
|
||||
|
||||
|
||||
func is_premade_style_part(scene_path:String) -> bool:
|
||||
return scene_path in premade_scenes_reference
|
||||
|
||||
|
||||
func load_parts() -> void:
|
||||
for i in %PartGrid.get_children():
|
||||
i.queue_free()
|
||||
|
||||
%Search.placeholder_text = "Search for "
|
||||
%Search.text = ""
|
||||
match current_type:
|
||||
Types.STYLES:
|
||||
%Search.placeholder_text += "premade styles"
|
||||
Types.LAYER:
|
||||
%Search.placeholder_text += "layer scenes"
|
||||
Types.LAYOUT_BASE:
|
||||
%Search.placeholder_text += "layout base scenes"
|
||||
Types.ALL:
|
||||
%Search.placeholder_text += "styles or layout scenes"
|
||||
|
||||
for info in style_part_info:
|
||||
var type: String = info.get('type', '_')
|
||||
match current_type:
|
||||
Types.STYLES:
|
||||
if type != "Style":
|
||||
continue
|
||||
Types.LAYER:
|
||||
if type != "Layer":
|
||||
continue
|
||||
Types.LAYOUT_BASE:
|
||||
if type != "Layout Base":
|
||||
continue
|
||||
|
||||
var style_item: Node = ListItem.instantiate()
|
||||
style_item.load_info(info)
|
||||
%PartGrid.add_child(style_item)
|
||||
style_item.set_meta('info', info)
|
||||
style_item.clicked.connect(_on_style_item_clicked.bind(style_item, info))
|
||||
style_item.focused.connect(_on_style_item_clicked.bind(style_item, info))
|
||||
style_item.double_clicked.connect(emit_signal.bind('activate_part', info))
|
||||
|
||||
await get_tree().process_frame
|
||||
|
||||
if %PartGrid.get_child_count() > 0:
|
||||
%PartGrid.get_child(0).clicked.emit()
|
||||
%PartGrid.get_child(0).grab_focus()
|
||||
|
||||
|
||||
func _on_style_item_clicked(item:Node, info:Dictionary) -> void:
|
||||
load_part_info(info)
|
||||
|
||||
|
||||
func load_part_info(info:Dictionary) -> void:
|
||||
current_info = info
|
||||
%PartTitle.text = info.get('name', 'Unknown Part')
|
||||
%PartAuthor.text = "by "+info.get('author', 'Anonymus')
|
||||
%PartDescription.text = info.get('description', '')
|
||||
|
||||
if info.get('preview_image', null):
|
||||
%PreviewImage.texture = load(info.get('preview_image')[0])
|
||||
%PreviewImage.show()
|
||||
else:
|
||||
%PreviewImage.hide()
|
||||
|
||||
|
||||
func _on_activate_button_pressed() -> void:
|
||||
activate_part.emit(current_info)
|
||||
|
||||
|
||||
func _on_search_text_changed(new_text: String) -> void:
|
||||
for item in %PartGrid.get_children():
|
||||
if new_text.is_empty():
|
||||
item.show()
|
||||
continue
|
||||
|
||||
if new_text.to_lower() in item.get_meta('info').name.to_lower():
|
||||
item.show()
|
||||
continue
|
||||
|
||||
item.hide()
|
||||
|
||||
|
||||
func _on_close_button_pressed() -> void:
|
||||
get_parent().hide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://c8luq5u4kfml5
|
||||
@@ -0,0 +1,243 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://cs381i3h7sveq"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/dialogic/Modules/StyleEditor/Components/style_browser.gd" id="1_3sdb0"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_0o1u0"]
|
||||
colors = PackedColorArray(0.296448, 0.231485, 0.52887, 1, 0.100572, 0.303996, 0.476999, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_vd6co"]
|
||||
gradient = SubResource("Gradient_0o1u0")
|
||||
fill_from = Vector2(1, 1)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4e858"]
|
||||
content_margin_left = 6.0
|
||||
content_margin_top = 3.0
|
||||
content_margin_right = 6.0
|
||||
content_margin_bottom = 3.0
|
||||
draw_center = false
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(1, 1, 1, 0.615686)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_t3eoa"]
|
||||
content_margin_left = 6.0
|
||||
content_margin_top = 3.0
|
||||
content_margin_right = 6.0
|
||||
content_margin_bottom = 3.0
|
||||
draw_center = false
|
||||
border_width_left = 3
|
||||
border_width_top = 3
|
||||
border_width_right = 3
|
||||
border_width_bottom = 3
|
||||
border_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
expand_margin_left = 2.0
|
||||
expand_margin_top = 2.0
|
||||
expand_margin_right = 2.0
|
||||
expand_margin_bottom = 2.0
|
||||
|
||||
[sub_resource type="Image" id="Image_tg5pd"]
|
||||
data = {
|
||||
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 44, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 94, 94, 234, 255, 95, 95, 43, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
|
||||
"format": "RGBA8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_f5xt2"]
|
||||
image = SubResource("Image_tg5pd")
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mavtr"]
|
||||
bg_color = Color(0.0588235, 0.0313726, 0.0980392, 1)
|
||||
border_width_left = 5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dqdat"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
draw_center = false
|
||||
corner_radius_top_left = 10
|
||||
corner_radius_top_right = 10
|
||||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
shadow_color = Color(0.992157, 0.992157, 0.992157, 0.101961)
|
||||
shadow_size = 10
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_otau4"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
corner_radius_top_left = 10
|
||||
corner_radius_top_right = 10
|
||||
corner_radius_bottom_right = 10
|
||||
corner_radius_bottom_left = 10
|
||||
|
||||
[node name="StyleBrowser" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_3sdb0")
|
||||
|
||||
[node name="BGColor" type="TextureRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = SubResource("GradientTexture2D_vd6co")
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="."]
|
||||
clip_contents = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="HSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 1.5
|
||||
theme_override_constants/margin_left = 10
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="HSplitContainer/Margin"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="BrowserTitle" type="Label" parent="HSplitContainer/Margin/VBox"]
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"DialogicSubTitle"
|
||||
theme_override_font_sizes/font_size = 25
|
||||
text = "Dialogic Style Browser"
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="HSplitContainer/Margin/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Search" type="LineEdit" parent="HSplitContainer/Margin/VBox/HBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_4e858")
|
||||
theme_override_styles/focus = SubResource("StyleBoxFlat_t3eoa")
|
||||
placeholder_text = "Search"
|
||||
right_icon = SubResource("ImageTexture_f5xt2")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer/Margin/VBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PartGrid" type="HFlowContainer" parent="HSplitContainer/Margin/VBox/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="HSplitContainer/Margin/VBox"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="CloseButton" type="Button" parent="HSplitContainer/Margin/VBox/Buttons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Close"
|
||||
icon = SubResource("ImageTexture_f5xt2")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="HSplitContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mavtr")
|
||||
|
||||
[node name="Control" type="Control" parent="HSplitContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="HSplitContainer/PanelContainer/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -4.0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 71.0
|
||||
grow_vertical = 2
|
||||
rotation = 0.0349066
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_mavtr")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/PanelContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 5
|
||||
theme_override_constants/margin_top = 10
|
||||
theme_override_constants/margin_right = 10
|
||||
theme_override_constants/margin_bottom = 10
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="HSplitContainer/PanelContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBox"]
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_dqdat")
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBox/Panel"]
|
||||
clip_children = 1
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_otau4")
|
||||
|
||||
[node name="PreviewImage" type="TextureRect" parent="HSplitContainer/PanelContainer/MarginContainer/VBox/Panel/Panel"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
expand_mode = 5
|
||||
stretch_mode = 6
|
||||
|
||||
[node name="HFlowContainer" type="HFlowContainer" parent="HSplitContainer/PanelContainer/MarginContainer/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PartTitle" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBox/HFlowContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
theme_type_variation = &"DialogicTitle"
|
||||
text = "Cool Style Part"
|
||||
|
||||
[node name="PartAuthor" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBox/HFlowContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
theme_type_variation = &"DialogicHintText"
|
||||
text = "by Jowan"
|
||||
|
||||
[node name="PartType" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBox/HFlowContainer"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 8
|
||||
theme_type_variation = &"DialogicHintText"
|
||||
text = "a style"
|
||||
|
||||
[node name="PartDescription" type="Label" parent="HSplitContainer/PanelContainer/MarginContainer/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"DialogicHintText2"
|
||||
text = "A cool textbox layer"
|
||||
autowrap_mode = 3
|
||||
|
||||
[node name="ActivateButton" type="Button" parent="HSplitContainer/PanelContainer/MarginContainer/VBox"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Use"
|
||||
|
||||
[connection signal="text_changed" from="HSplitContainer/Margin/VBox/HBox/Search" to="." method="_on_search_text_changed"]
|
||||
[connection signal="pressed" from="HSplitContainer/Margin/VBox/Buttons/CloseButton" to="." method="_on_close_button_pressed"]
|
||||
[connection signal="pressed" from="HSplitContainer/PanelContainer/MarginContainer/VBox/ActivateButton" to="." method="_on_activate_button_pressed"]
|
||||
@@ -0,0 +1,22 @@
|
||||
@tool
|
||||
extends Window
|
||||
|
||||
var info := {}
|
||||
signal part_selected(info:Dictionary)
|
||||
|
||||
|
||||
func _on_close_requested() -> void:
|
||||
info = {}
|
||||
part_selected.emit({})
|
||||
hide()
|
||||
|
||||
|
||||
func get_picked_info() -> Dictionary:
|
||||
await part_selected
|
||||
return info
|
||||
|
||||
|
||||
func _on_style_browser_activate_part(part_info: Dictionary) -> void:
|
||||
info = part_info
|
||||
part_selected.emit(part_info)
|
||||
hide()
|
||||
@@ -0,0 +1 @@
|
||||
uid://0n4dj3rheg8b
|
||||
@@ -0,0 +1,53 @@
|
||||
@tool
|
||||
extends Tree
|
||||
|
||||
## Script that handles drag and drop on the layer tree.
|
||||
|
||||
|
||||
signal layer_moved(from:int, to:int)
|
||||
|
||||
#region DRAG AND DROP
|
||||
################################################################################
|
||||
|
||||
func _get_drag_data(position:Vector2) -> Variant:
|
||||
if get_selected() == null or get_selected() == get_root():
|
||||
return
|
||||
|
||||
if find_parent('StyleEditor').current_style.inherits != null:
|
||||
return
|
||||
|
||||
drop_mode_flags = DROP_MODE_INBETWEEN
|
||||
var preview := Label.new()
|
||||
preview.text = " "+get_selected().get_text(0)
|
||||
preview.add_theme_stylebox_override('normal', get_theme_stylebox("Background", "EditorStyles"))
|
||||
set_drag_preview(preview)
|
||||
|
||||
return get_selected()
|
||||
|
||||
|
||||
func _can_drop_data(position:Vector2, data:Variant) -> bool:
|
||||
return data is TreeItem
|
||||
|
||||
|
||||
func _drop_data(position:Vector2, item:Variant) -> void:
|
||||
var to_item := get_item_at_position(position)
|
||||
var drop_section := get_drop_section_at_position(position)
|
||||
|
||||
if to_item == get_root():
|
||||
if item.get_index() != 0:
|
||||
layer_moved.emit(item.get_index(), 0)
|
||||
return
|
||||
|
||||
if to_item == null:
|
||||
if item.get_index() != get_root().get_child_count()-1:
|
||||
layer_moved.emit(item.get_index(), get_root().get_child_count()-1)
|
||||
return
|
||||
|
||||
var to_idx: int = to_item.get_index()+max(0, drop_section)
|
||||
if to_idx > item.get_index():
|
||||
to_idx -= 1
|
||||
|
||||
if to_idx != item.get_index():
|
||||
layer_moved.emit(item.get_index(), to_idx)
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://5cka4hyqwgs4
|
||||
Reference in New Issue
Block a user