First work on dialogic, resized guild, and started implementing portraits.

This commit is contained in:
2025-08-14 10:26:24 -04:00
parent 95a7db036b
commit 3aeb3d44e6
959 changed files with 47688 additions and 46 deletions

View 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()

View File

@@ -0,0 +1 @@
uid://c8luq5u4kfml5

View File

@@ -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"]

View File

@@ -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()

View File

@@ -0,0 +1 @@
uid://0n4dj3rheg8b

View File

@@ -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

View File

@@ -0,0 +1 @@
uid://5cka4hyqwgs4

View File

@@ -0,0 +1,4 @@
extends DialogicIndexer
func _get_editors() -> Array:
return [this_folder.path_join('style_editor.tscn')]

View File

@@ -0,0 +1 @@
uid://7suimrdaehf6

View File

@@ -0,0 +1,401 @@
@tool
extends DialogicEditor
## Editor that handles the editing of styles and their layers.
var styles: Array[DialogicStyle] = []
var current_style : DialogicStyle = null
var default_style := ""
var premade_style_parts := {}
@onready var StyleList: ItemList = %StyleList
#region EDITOR MANAGEMENT
################################################################################
func _get_title() -> String:
return "Styles"
func _get_icon() -> Texture:
return load(DialogicUtil.get_module_path('StyleEditor').path_join("styles_icon.svg"))
func _register() -> void:
editors_manager.register_simple_editor(self)
alternative_text = "Change the look of the dialog in your game"
func _open(_extra_info:Variant = null) -> void:
load_style_list()
func _close() -> void:
save_style_list()
save_style()
#endregion
func _ready() -> void:
collect_styles()
setup_ui()
#region STYLE MANAGEMENT
################################################################################
func collect_styles() -> void:
for indexer in DialogicUtil.get_indexers():
for layout in indexer._get_layout_parts():
premade_style_parts[layout['path']] = layout
var style_list: Array = ProjectSettings.get_setting('dialogic/layout/style_list', [])
for style in style_list:
if ResourceLoader.exists(style):
if style != null:
styles.append(ResourceLoader.load(style, "DialogicStyle"))
else:
print("[Dialogic] Failed to open style '", style, "'. Some dependency might be broken.")
else:
print("[Dialogic] Failed to open style '", style, "'. Might have been moved or deleted.")
default_style = ProjectSettings.get_setting('dialogic/layout/default_style', 'Default')
func save_style_list() -> void:
ProjectSettings.set_setting('dialogic/layout/style_list', styles.map(func(style:DialogicStyle): return style.resource_path))
ProjectSettings.set_setting('dialogic/layout/default_style', default_style)
ProjectSettings.save()
func save_style() -> void:
if current_style == null:
return
ResourceSaver.save(current_style)
func add_style(file_path:String, style:DialogicStyle, inherits:DialogicStyle= null) -> void:
style.resource_path = file_path
style.inherits = inherits
if style.layer_list.is_empty() and style.inherits_anything():
for id in style.get_layer_inherited_list():
style.add_layer('', {}, id)
ResourceSaver.save(style, file_path)
styles.append(style)
if len(styles) == 1:
default_style = style.resource_path
save_style_list()
load_style_list()
select_style(style)
func delete_style(style:DialogicStyle) -> void:
for other_style in styles:
if other_style.inherits == style:
other_style.realize_inheritance()
push_warning('[Dialogic] Style "',other_style.name,'" had to be realized because it inherited "', style.name,'" which was deleted!')
if style.resource_path == default_style:
default_style = ""
styles.erase(style)
save_style_list()
func delete_style_by_name(style_name:String) -> void:
for style in styles:
if style.name == style_name:
delete_style(style)
return
func realize_style() -> void:
current_style.realize_inheritance()
select_style(current_style)
#endregion
#region USER INTERFACE
################################################################################
func setup_ui() -> void:
%AddButton.icon = get_theme_icon("Add", "EditorIcons")
%DuplicateButton.icon = get_theme_icon("Duplicate", "EditorIcons")
%InheritanceButton.icon = get_theme_icon("GuiDropdown", "EditorIcons")
%RemoveButton.icon = get_theme_icon("Remove", "EditorIcons")
%EditNameButton.icon = get_theme_icon("Edit", "EditorIcons")
%TestStyleButton.icon = get_theme_icon("PlayCustom", "EditorIcons")
%MakeDefaultButton.icon = get_theme_icon("Favorites", "EditorIcons")
StyleList.item_selected.connect(_on_stylelist_selected)
%AddButton.get_popup().index_pressed.connect(_on_AddStyleMenu_selected)
%AddButton.about_to_popup.connect(_on_AddStyleMenu_about_to_popup)
%InheritanceButton.get_popup().index_pressed.connect(_on_inheritance_index_pressed)
StyleList.set_drag_forwarding(_on_stylelist_drag, _on_stylelist_can_drop, _on_style_list_drop)
%StyleView.hide()
%NoStyleView.show()
func load_style_list() -> void:
var latest: String = DialogicUtil.get_editor_setting('latest_layout_style', 'Default')
StyleList.clear()
var idx := 0
for style in styles:
# TODO remove when going Beta
style.update_from_pre_alpha16()
StyleList.add_item(style.name, get_theme_icon("PopupMenu", "EditorIcons"))
StyleList.set_item_tooltip(idx, style.resource_path)
StyleList.set_item_metadata(idx, style)
if style.resource_path == default_style:
StyleList.set_item_icon_modulate(idx, get_theme_color("warning_color", "Editor"))
if style.resource_path.begins_with("res://addons/dialogic"):
StyleList.set_item_icon_modulate(idx, get_theme_color("property_color_z", "Editor"))
StyleList.set_item_tooltip(idx, "This is a default style. Only edit it if you know what you are doing!")
StyleList.set_item_custom_bg_color(idx, get_theme_color("property_color_z", "Editor").lerp(get_theme_color("dark_color_3", "Editor"), 0.8))
if style.name == latest:
StyleList.select(idx)
load_style(style)
idx += 1
if len(styles) == 0:
%StyleView.hide()
%NoStyleView.show()
elif !StyleList.is_anything_selected():
StyleList.select(0)
load_style(StyleList.get_item_metadata(0))
func _on_stylelist_selected(index:int) -> void:
load_style(StyleList.get_item_metadata(index))
func select_style(style:DialogicStyle) -> void:
DialogicUtil.set_editor_setting('latest_layout_style', style.name)
for idx in range(StyleList.item_count):
if StyleList.get_item_metadata(idx) == style:
StyleList.select(idx)
return
func load_style(style:DialogicStyle) -> void:
if current_style != null:
current_style.changed.disconnect(save_style)
save_style()
current_style = style
if current_style == null:
return
current_style.changed.connect(save_style)
%LayoutStyleName.text = style.name
if style.resource_path == default_style:
%MakeDefaultButton.tooltip_text = "Is Default"
%MakeDefaultButton.disabled = true
else:
%MakeDefaultButton.tooltip_text = "Make Default"
%MakeDefaultButton.disabled = false
%StyleEditor.load_style(style)
%InheritanceButton.visible = style.inherits_anything()
if %InheritanceButton.visible:
%InheritanceButton.text = "Inherits " + style.inherits.name
DialogicUtil.set_editor_setting('latest_layout_style', style.name)
%StyleView.show()
%NoStyleView.hide()
func _on_AddStyleMenu_about_to_popup() -> void:
%AddButton.get_popup().set_item_disabled(3, not StyleList.is_anything_selected())
func _on_AddStyleMenu_selected(index:int) -> void:
# add preset style
if index == 2:
%StyleBrowserWindow.popup_centered_ratio(0.6)
%StyleBrowser.current_type = 1
%StyleBrowser.load_parts()
var picked_info: Dictionary = await %StyleBrowserWindow.get_picked_info()
if not picked_info.has('style_path'):
return
if not ResourceLoader.exists(picked_info.style_path):
return
var new_style: DialogicStyle = load(picked_info.style_path).clone()
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(new_style),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")
if index == 3:
if StyleList.get_selected_items().is_empty():
return
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(DialogicStyle.new(), current_style),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")
if index == 4:
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(DialogicStyle.new()),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")
func add_style_undoable(file_path:String, style:DialogicStyle, inherits:DialogicStyle = null) -> void:
style.name = _get_new_name(file_path.get_file().trim_suffix('.'+file_path.get_extension()))
var undo_redo: EditorUndoRedoManager = DialogicUtil.get_dialogic_plugin().get_undo_redo()
undo_redo.create_action('Add Style', UndoRedo.MERGE_ALL)
undo_redo.add_do_method(self, "add_style", file_path, style, inherits)
undo_redo.add_do_method(self, "load_style_list")
undo_redo.add_undo_method(self, "delete_style", style)
undo_redo.add_undo_method(self, "load_style_list")
undo_redo.commit_action()
DialogicUtil.set_editor_setting('latest_layout_style', style.name)
func _on_duplicate_button_pressed() -> void:
if !StyleList.is_anything_selected():
return
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(current_style.clone(), null),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")
func _on_remove_button_pressed() -> void:
if !StyleList.is_anything_selected():
return
if current_style.name == default_style:
push_warning("[Dialogic] You cannot delete the default style!")
return
delete_style(current_style)
load_style_list()
func _on_edit_name_button_pressed() -> void:
%LayoutStyleName.grab_focus()
%LayoutStyleName.select_all()
func _on_layout_style_name_text_submitted(_new_text:String) -> void:
_on_layout_style_name_focus_exited()
func _on_layout_style_name_focus_exited() -> void:
var new_name: String = %LayoutStyleName.text.strip_edges()
if new_name == current_style.name:
return
for style in styles:
if style.name == new_name:
%LayoutStyleName.text = current_style.name
return
current_style.name = new_name
DialogicUtil.set_editor_setting('latest_layout_style', new_name)
load_style_list()
func _on_make_default_button_pressed() -> void:
default_style = current_style.resource_path
save_style_list()
load_style_list()
func _on_test_style_button_pressed() -> void:
var dialogic_plugin := DialogicUtil.get_dialogic_plugin()
# Save the current opened timeline
DialogicUtil.set_editor_setting('current_test_style', current_style.name)
DialogicUtil.get_dialogic_plugin().get_editor_interface().play_custom_scene("res://addons/dialogic/Editor/TimelineEditor/test_timeline_scene.tscn")
await get_tree().create_timer(3).timeout
DialogicUtil.set_editor_setting('current_test_style', '')
func _on_inheritance_index_pressed(index:int) -> void:
if index == 0:
realize_style()
func _on_start_styling_button_pressed() -> void:
var new_style := DialogicUtil.get_fallback_style().clone()
find_parent('EditorView').godot_file_dialog(
add_style_undoable.bind(new_style),
'*.tres',
EditorFileDialog.FILE_MODE_SAVE_FILE,
"Select folder for new style")
#endregion
func _on_stylelist_drag(vector:Vector2) -> Variant:
return null
func _on_stylelist_can_drop(at_position: Vector2, data: Variant) -> bool:
if not data is Dictionary:
return false
if not data.get('type', 's') == 'files':
return false
for f in data.files:
var style := load(f)
if style is DialogicStyle:
if not style in styles:
return true
return false
func _on_style_list_drop(at_position: Vector2, data: Variant) -> void:
for file in data.files:
var style := load(file)
if style is DialogicStyle:
if not style in styles:
styles.append(style)
save_style_list()
load_style_list()
#region Helpers
func _get_new_name(base_name:String) -> String:
var new_name_idx := 1
var found_unique_name := false
var new_name := base_name
while not found_unique_name:
found_unique_name = true
for style in styles:
if style.name == new_name:
new_name_idx += 1
new_name = base_name+" "+str(new_name_idx)
found_unique_name = false
return new_name
#endregion

View File

@@ -0,0 +1 @@
uid://cfej0uty5k5di

View File

@@ -0,0 +1,446 @@
[gd_scene load_steps=16 format=3 uid="uid://cx6h3tck10s1g"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/StyleEditor/style_editor.gd" id="1_gy14f"]
[ext_resource type="PackedScene" uid="uid://dbpkta2tjsqim" path="res://addons/dialogic/Editor/Common/hint_tooltip_icon.tscn" id="2_g4mnt"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/StyleEditor/style_layer_editor.gd" id="3_iih7c"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/StyleEditor/Components/style_layer_tree.gd" id="4_kpoqn"]
[ext_resource type="Script" path="res://addons/dialogic/Modules/StyleEditor/Components/style_browser_window.gd" id="5_qbwx0"]
[ext_resource type="PackedScene" uid="uid://cs381i3h7sveq" path="res://addons/dialogic/Modules/StyleEditor/Components/style_browser.tscn" id="6_p6lia"]
[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="Image" id="Image_ns66m"]
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_xtj53"]
image = SubResource("Image_ns66m")
[sub_resource type="Theme" id="Theme_l6tyr"]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_tixgs"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0nh8y"]
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
[sub_resource type="Image" id="Image_op8ly"]
data = {
"data": PackedByteArray(0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 255),
"format": "RGBA8",
"height": 2,
"mipmaps": false,
"width": 2
}
[sub_resource type="ImageTexture" id="ImageTexture_yr3tj"]
image = SubResource("Image_op8ly")
[node name="StyleEditor" type="HSplitContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -3.0
offset_bottom = 3.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_gy14f")
[node name="Panel" type="PanelContainer" parent="."]
custom_minimum_size = Vector2(150, 0)
layout_mode = 2
size_flags_stretch_ratio = 0.2
theme_type_variation = &"DialogicPanelA"
[node name="VBox" type="VBoxContainer" parent="Panel"]
layout_mode = 2
[node name="Title" type="HBoxContainer" parent="Panel/VBox"]
layout_mode = 2
[node name="StyleListTitle" type="Label" parent="Panel/VBox/Title"]
layout_mode = 2
theme_type_variation = &"DialogicSubTitle"
text = "Styles"
[node name="HintTooltip" parent="Panel/VBox/Title" instance=ExtResource("2_g4mnt")]
layout_mode = 2
tooltip_text = "Each style consist of a list of layers and settings for each layer.
A style can inherit from another style (inherited styles can only overwrite settings of their layers).
When one style is selected as default dialogic will use that style when calling Dialogic.start() otherwise a fallback is used.
You can change the style with the Change Style event, by setting a style on a character or by calling
Dialogic.Styles.load_style(\"Style Name\") before calling Dialogic.start()."
texture = null
hint_text = "Each style consist of a list of layers and settings for each layer.
A style can inherit from another style (inherited styles can only overwrite settings of their layers).
When one style is selected as default dialogic will use that style when calling Dialogic.start() otherwise a fallback is used.
You can change the style with the Change Style event, by setting a style on a character or by calling
Dialogic.Styles.load_style(\"Style Name\") before calling Dialogic.start()."
[node name="StyleButtons" type="HBoxContainer" parent="Panel/VBox"]
layout_mode = 2
alignment = 2
[node name="AddButton" type="MenuButton" parent="Panel/VBox/StyleButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Add layout-style"
icon = SubResource("ImageTexture_f5xt2")
switch_on_hover = true
item_count = 5
popup/item_0/text = "ADD STYLE"
popup/item_0/id = 0
popup/item_0/disabled = true
popup/item_1/text = ""
popup/item_1/id = 0
popup/item_1/separator = true
popup/item_2/text = "Premade Style"
popup/item_2/id = 0
popup/item_3/text = "Inherited Style"
popup/item_3/id = 1
popup/item_4/text = "Custom Style"
popup/item_4/id = 2
[node name="DuplicateButton" type="Button" parent="Panel/VBox/StyleButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Duplicate style"
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="RemoveButton" type="Button" parent="Panel/VBox/StyleButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Remove style from list"
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="MakeDefaultButton" type="Button" parent="Panel/VBox/StyleButtons"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
tooltip_text = "Make Default"
toggle_mode = true
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="StyleList" type="ItemList" parent="Panel/VBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
item_count = 1
item_0/text = "Style"
item_0/icon = SubResource("ImageTexture_xtj53")
[node name="StyleView" type="VBoxContainer" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_horizontal = 3
[node name="HBox" type="HBoxContainer" parent="StyleView"]
layout_mode = 2
theme = SubResource("Theme_l6tyr")
theme_override_constants/separation = 0
[node name="LayoutStyleName" type="LineEdit" parent="StyleView/HBox"]
unique_name_in_owner = true
layout_mode = 2
theme_type_variation = &"DialogicTitle"
theme_override_styles/normal = SubResource("StyleBoxEmpty_tixgs")
theme_override_styles/focus = SubResource("StyleBoxEmpty_tixgs")
theme_override_styles/read_only = SubResource("StyleBoxEmpty_tixgs")
text = "Style"
expand_to_text_length = true
[node name="EditNameButton" type="Button" parent="StyleView/HBox"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Edit Name"
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="InheritanceButton" type="MenuButton" parent="StyleView/HBox"]
unique_name_in_owner = true
visible = false
layout_mode = 2
text = "Inherits VN Style"
icon = SubResource("ImageTexture_f5xt2")
icon_alignment = 2
item_count = 1
popup/item_0/text = "Clear Inheritance"
popup/item_0/id = 0
[node name="TestStyleButton" type="Button" parent="StyleView/HBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 10
tooltip_text = "Play current timeline with this style"
text = "Test Style"
icon = SubResource("ImageTexture_f5xt2")
[node name="PanelContainer" type="PanelContainer" parent="StyleView"]
layout_mode = 2
size_flags_vertical = 3
theme_type_variation = &"DialogicPanelB"
[node name="StyleEditor" type="HSplitContainer" parent="StyleView/PanelContainer"]
unique_name_in_owner = true
layout_mode = 2
script = ExtResource("3_iih7c")
[node name="LayerPanel" type="PanelContainer" parent="StyleView/PanelContainer/StyleEditor"]
layout_mode = 2
theme_type_variation = &"DialogicPanelA"
[node name="VBox" type="VBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerPanel"]
layout_mode = 2
[node name="Title" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox"]
layout_mode = 2
[node name="LayerListTitle" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/Title"]
layout_mode = 2
theme_type_variation = &"DialogicSubTitle"
text = "Layers"
[node name="HintTooltip" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/Title" instance=ExtResource("2_g4mnt")]
layout_mode = 2
tooltip_text = "Each layer is a scene and settings that will be applied to that scene.
A layer can either be a premade scene or a scene you've made yourself."
texture = null
hint_text = "Each layer is a scene and settings that will be applied to that scene.
A layer can either be a premade scene or a scene you've made yourself."
[node name="LayerButtons" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox"]
layout_mode = 2
alignment = 2
[node name="AddLayerButton" type="MenuButton" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Add Layer"
icon = SubResource("ImageTexture_f5xt2")
switch_on_hover = true
item_count = 4
popup/item_0/text = "ADD LAYER"
popup/item_0/id = 1
popup/item_0/disabled = true
popup/item_1/text = ""
popup/item_1/id = 1
popup/item_1/separator = true
popup/item_2/text = "Premade Layer"
popup/item_2/id = 1
popup/item_3/text = "Custom Layer"
popup/item_3/id = 0
[node name="ReplaceLayerButton" type="MenuButton" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Replace Layer"
icon = SubResource("ImageTexture_f5xt2")
switch_on_hover = true
item_count = 4
popup/item_0/text = "REPLACE LAYER"
popup/item_0/id = 0
popup/item_0/disabled = true
popup/item_1/text = ""
popup/item_1/id = 0
popup/item_1/separator = true
popup/item_2/text = "Premade Layer"
popup/item_2/id = 0
popup/item_3/text = "Custom Layer"
popup/item_3/id = 1
[node name="MakeCustomButton" type="MenuButton" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Make Custom"
icon = SubResource("ImageTexture_f5xt2")
switch_on_hover = true
item_count = 4
popup/item_0/text = "MAKE CUSTOM"
popup/item_0/id = 3
popup/item_0/disabled = true
popup/item_1/text = ""
popup/item_1/id = 0
popup/item_1/separator = true
popup/item_2/text = "Current Layer"
popup/item_2/id = 0
popup/item_3/text = "Full Layout"
popup/item_3/id = 2
[node name="DeleteLayerButton" type="Button" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Delete Layer (no undo!)"
disabled = true
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="LayerTree" type="Tree" parent="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/icon_max_width = 32
allow_rmb_select = true
hide_folding = true
enable_recursive_folding = false
drop_mode_flags = 2
script = ExtResource("4_kpoqn")
[node name="LayerSettings" type="VBoxContainer" parent="StyleView/PanelContainer/StyleEditor"]
layout_mode = 2
size_flags_horizontal = 3
[node name="LayerInfoHeader" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings"]
layout_mode = 2
[node name="LayerName" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoHeader"]
unique_name_in_owner = true
layout_mode = 2
theme_type_variation = &"DialogicTitle"
text = "Default Layout Base"
[node name="ExpandLayerInfo" type="Button" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoHeader"]
unique_name_in_owner = true
layout_mode = 2
icon = SubResource("ImageTexture_f5xt2")
flat = true
[node name="LayerInfoBody" type="VBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings"]
unique_name_in_owner = true
layout_mode = 2
[node name="HBox" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody"]
layout_mode = 2
[node name="Panel" type="PanelContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox"]
show_behind_parent = true
clip_children = 2
layout_mode = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_0nh8y")
[node name="SmallLayerPreview" type="TextureRect" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Panel"]
unique_name_in_owner = true
layout_mode = 2
texture = SubResource("ImageTexture_yr3tj")
expand_mode = 3
stretch_mode = 6
[node name="Info" type="VBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 0
[node name="HBoxContainer" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="SmallLayerScene" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info/HBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
tooltip_text = "res://addons/dialogic/Modules/LayoutStuff/Base_Default/default_layout_base.tscn"
text = "default_layout_base.tscn"
[node name="SmallLayerAuthor" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info/HBoxContainer"]
unique_name_in_owner = true
self_modulate = Color(1, 1, 1, 0.603922)
layout_mode = 2
theme_type_variation = &"DialogicHintText"
text = "Dialogic"
[node name="Description" type="HBoxContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info"]
layout_mode = 2
theme_override_constants/separation = 0
[node name="Label" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info/Description"]
layout_mode = 2
theme_type_variation = &"DialogicHintText2"
text = "Info:"
[node name="SmallLayerDescription" type="Label" parent="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoBody/HBox/Info/Description"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
theme_type_variation = &"DialogicHintText2"
text = "A very simple base for layouts."
autowrap_mode = 3
text_overrun_behavior = 4
[node name="LayerSettingsTabs" type="TabContainer" parent="StyleView/PanelContainer/StyleEditor/LayerSettings"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
[node name="Margin" type="Control" parent="StyleView"]
custom_minimum_size = Vector2(0, 10)
layout_mode = 2
[node name="NoStyleView" type="VBoxContainer" parent="."]
unique_name_in_owner = true
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="NoStyleView"]
layout_mode = 2
text = "You have not set up any styles yet. Dialogic will use a fallback style."
horizontal_alignment = 1
autowrap_mode = 3
[node name="StartStylingButton" type="Button" parent="NoStyleView"]
layout_mode = 2
size_flags_horizontal = 4
tooltip_text = "Make a custom style from a variation of the fallback."
text = "Make my own!"
[node name="StyleBrowserWindow" type="Window" parent="."]
unique_name_in_owner = true
title = "Style Browser"
position = Vector2i(0, 36)
size = Vector2i(500, 400)
visible = false
wrap_controls = true
transient = true
popup_window = true
script = ExtResource("5_qbwx0")
[node name="StyleBrowser" parent="StyleBrowserWindow" instance=ExtResource("6_p6lia")]
unique_name_in_owner = true
[connection signal="pressed" from="Panel/VBox/StyleButtons/DuplicateButton" to="." method="_on_duplicate_button_pressed"]
[connection signal="pressed" from="Panel/VBox/StyleButtons/RemoveButton" to="." method="_on_remove_button_pressed"]
[connection signal="pressed" from="Panel/VBox/StyleButtons/MakeDefaultButton" to="." method="_on_make_default_button_pressed"]
[connection signal="focus_exited" from="StyleView/HBox/LayoutStyleName" to="." method="_on_layout_style_name_focus_exited"]
[connection signal="text_submitted" from="StyleView/HBox/LayoutStyleName" to="." method="_on_layout_style_name_text_submitted"]
[connection signal="pressed" from="StyleView/HBox/EditNameButton" to="." method="_on_edit_name_button_pressed"]
[connection signal="pressed" from="StyleView/HBox/TestStyleButton" to="." method="_on_test_style_button_pressed"]
[connection signal="about_to_popup" from="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons/MakeCustomButton" to="StyleView/PanelContainer/StyleEditor" method="_on_make_custom_button_about_to_popup"]
[connection signal="pressed" from="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerButtons/DeleteLayerButton" to="StyleView/PanelContainer/StyleEditor" method="_on_delete_layer_button_pressed"]
[connection signal="button_clicked" from="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerTree" to="StyleView/PanelContainer/StyleEditor" method="_on_layer_tree_button_clicked"]
[connection signal="layer_moved" from="StyleView/PanelContainer/StyleEditor/LayerPanel/VBox/LayerTree" to="StyleView/PanelContainer/StyleEditor" method="_on_layer_tree_layer_moved"]
[connection signal="pressed" from="StyleView/PanelContainer/StyleEditor/LayerSettings/LayerInfoHeader/ExpandLayerInfo" to="StyleView/PanelContainer/StyleEditor" method="_on_expand_layer_info_pressed"]
[connection signal="pressed" from="NoStyleView/StartStylingButton" to="." method="_on_start_styling_button_pressed"]
[connection signal="close_requested" from="StyleBrowserWindow" to="StyleBrowserWindow" method="_on_close_requested"]
[connection signal="activate_part" from="StyleBrowserWindow/StyleBrowser" to="StyleBrowserWindow" method="_on_style_browser_activate_part"]

View File

@@ -0,0 +1,542 @@
@tool
extends HSplitContainer
## Script that handles the style editor.
var current_style: DialogicStyle = null
var customization_editor_info := {}
## The id of the currently selected layer.
## "" is the base scene.
var current_layer_id := ""
var _minimum_tree_item_height: int
@onready var tree: Tree = %LayerTree
func _ready() -> void:
# Styling
%AddLayerButton.icon = get_theme_icon("Add", "EditorIcons")
%DeleteLayerButton.icon = get_theme_icon("Remove", "EditorIcons")
%ReplaceLayerButton.icon = get_theme_icon("Loop", "EditorIcons")
%MakeCustomButton.icon = get_theme_icon("FileAccess", "EditorIcons")
%ExpandLayerInfo.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons")
%AddLayerButton.get_popup().index_pressed.connect(_on_add_layer_menu_pressed)
%ReplaceLayerButton.get_popup().index_pressed.connect(_on_replace_layer_menu_pressed)
%MakeCustomButton.get_popup().index_pressed.connect(_on_make_custom_menu_pressed)
%LayerTree.item_selected.connect(_on_layer_selected)
_minimum_tree_item_height = int(DialogicUtil.get_editor_scale() * 32)
%LayerTree.add_theme_constant_override("icon_max_width", _minimum_tree_item_height)
func load_style(style:DialogicStyle) -> void:
current_style = style
if current_style.has_meta("_latest_layer"):
current_layer_id = str(current_style.get_meta("_latest_layer", ""))
else:
current_layer_id = ""
%AddLayerButton.disabled = style.inherits_anything()
%ReplaceLayerButton.disabled = style.inherits_anything()
%MakeCustomButton.disabled = style.inherits_anything()
%DeleteLayerButton.disabled = style.inherits_anything()
load_style_layer_list()
func load_style_layer_list() -> void:
tree.clear()
var root := tree.create_item()
var base_layer_info := current_style.get_layer_inherited_info("")
setup_layer_tree_item(base_layer_info, root)
for layer_id in current_style.get_layer_inherited_list():
var layer_info := current_style.get_layer_inherited_info(layer_id)
var layer_item := tree.create_item(root)
setup_layer_tree_item(layer_info, layer_item)
select_layer(current_layer_id)
func select_layer(id:String) -> void:
if id == "":
tree.get_root().select(0)
else:
for child in tree.get_root().get_children():
if child.get_meta("id", "") == id:
child.select(0)
return
func setup_layer_tree_item(info:Dictionary, item:TreeItem) -> void:
item.custom_minimum_height = _minimum_tree_item_height
if %StyleBrowser.is_premade_style_part(info.path):
if ResourceLoader.exists(%StyleBrowser.premade_scenes_reference[info.path].get('icon', '')):
item.set_icon(0, load(%StyleBrowser.premade_scenes_reference[info.path].get("icon")))
item.set_text(0, %StyleBrowser.premade_scenes_reference[info.path].get("name", "Layer"))
else:
item.set_text(0, clean_scene_name(info.path))
item.add_button(0, get_theme_icon("PackedScene", "EditorIcons"))
item.set_button_tooltip_text(0, 0, "Open Scene")
item.set_meta("scene", info.path)
item.set_meta("id", info.id)
func _on_layer_selected() -> void:
var item: TreeItem = %LayerTree.get_selected()
load_layer(item.get_meta("id", ""))
func load_layer(layer_id:=""):
current_layer_id = layer_id
current_style.set_meta('_latest_layer', current_layer_id)
var layer_info := current_style.get_layer_inherited_info(layer_id)
%SmallLayerPreview.hide()
if %StyleBrowser.is_premade_style_part(layer_info.get('path', 'Unkown Layer')):
var premade_infos = %StyleBrowser.premade_scenes_reference[layer_info.get('path')]
%LayerName.text = premade_infos.get('name', 'Unknown Layer')
%SmallLayerAuthor.text = "by "+premade_infos.get('author', '')
%SmallLayerDescription.text = premade_infos.get('description', '')
if premade_infos.get('preview_image', null) and ResourceLoader.exists(premade_infos.get('preview_image')[0]):
%SmallLayerPreview.texture = load(premade_infos.get('preview_image')[0])
%SmallLayerPreview.show()
else:
%LayerName.text = clean_scene_name(layer_info.get('path', 'Unkown Layer'))
%SmallLayerAuthor.text = "Custom Layer"
%SmallLayerDescription.text = layer_info.get('path', 'Unkown Layer')
%DeleteLayerButton.disabled = layer_id == "" or current_style.inherits_anything()
%SmallLayerScene.text = layer_info.get('path', 'Unkown Layer').get_file()
%SmallLayerScene.tooltip_text = layer_info.get('path', '')
var inherited_layer_info := current_style.get_layer_inherited_info(layer_id, true)
load_layout_scene_customization(
layer_info.path,
layer_info.overrides,
inherited_layer_info.overrides)
func add_layer(scene_path:="", overrides:= {}):
current_style.add_layer(scene_path, overrides)
load_style_layer_list()
await get_tree().process_frame
%LayerTree.get_root().get_child(-1).select(0)
func delete_layer() -> void:
if current_layer_id == "":
return
current_style.delete_layer(current_layer_id)
load_style_layer_list()
%LayerTree.get_root().select(0)
func move_layer(from_idx:int, to_idx:int) -> void:
current_style.move_layer(from_idx, to_idx)
load_style_layer_list()
select_layer(current_style.get_layer_id_at_index(to_idx))
func replace_layer(layer_id:String, scene_path:String) -> void:
current_style.set_layer_scene(layer_id, scene_path)
load_style_layer_list()
select_layer(layer_id)
func _on_add_layer_menu_pressed(index:int) -> void:
# Adding a premade layer
if index == 2:
%StyleBrowserWindow.popup_centered_ratio(0.6)
%StyleBrowser.current_type = 2
%StyleBrowser.load_parts()
var picked_info: Dictionary = await %StyleBrowserWindow.get_picked_info()
if not picked_info.is_empty():
add_layer(picked_info.get('path', ''))
# Adding a custom scene as a layer
else:
find_parent('EditorView').godot_file_dialog(
_on_add_custom_layer_file_selected,
'*.tscn, Scenes',
EditorFileDialog.FILE_MODE_OPEN_FILE,
"Open custom layer scene")
func _on_replace_layer_menu_pressed(index:int) -> void:
# Adding a premade layer
if index == 2:
%StyleBrowserWindow.popup_centered_ratio(0.6)
if %LayerTree.get_selected() == %LayerTree.get_root():
%StyleBrowser.current_type = 3
else:
%StyleBrowser.current_type = 2
%StyleBrowser.load_parts()
var picked_info: Dictionary = await %StyleBrowserWindow.get_picked_info()
if not picked_info.is_empty():
replace_layer(%LayerTree.get_selected().get_meta("id", ""), picked_info.get('path', ''))
# Adding a custom scene as a layer
else:
find_parent('EditorView').godot_file_dialog(
_on_replace_custom_layer_file_selected,
'*.tscn, Scenes',
EditorFileDialog.FILE_MODE_OPEN_FILE,
"Open custom layer scene")
func _on_add_custom_layer_file_selected(file_path:String) -> void:
add_layer(file_path)
func _on_replace_custom_layer_file_selected(file_path:String) -> void:
replace_layer(%LayerTree.get_selected().get_meta("id", ""), file_path)
func _on_make_custom_button_about_to_popup() -> void:
%MakeCustomButton.get_popup().set_item_disabled(2, false)
%MakeCustomButton.get_popup().set_item_disabled(3, false)
if not %StyleBrowser.is_premade_style_part(current_style.get_layer_info(current_layer_id).path):
%MakeCustomButton.get_popup().set_item_disabled(2, true)
func _on_make_custom_menu_pressed(index:int) -> void:
# This layer only
if index == 2:
find_parent('EditorView').godot_file_dialog(
_on_make_custom_layer_file_selected,
'',
EditorFileDialog.FILE_MODE_OPEN_DIR,
"Select folder for new copy of layer")
# The full layout
if index == 3:
find_parent('EditorView').godot_file_dialog(
_on_make_custom_layout_file_selected,
'',
EditorFileDialog.FILE_MODE_OPEN_DIR,
"Select folder for new layout scene")
func _on_make_custom_layer_file_selected(file:String) -> void:
make_layer_custom(file)
func _on_make_custom_layout_file_selected(file:String) -> void:
make_layout_custom(file)
func make_layer_custom(target_folder:String, custom_name := "") -> void:
var original_file: String = current_style.get_layer_info(current_layer_id).path
var custom_new_folder := ""
if custom_name.is_empty():
custom_name = "custom_"+%StyleBrowser.premade_scenes_reference[original_file].name.to_snake_case()
custom_new_folder = %StyleBrowser.premade_scenes_reference[original_file].name.to_pascal_case()
var result_path := DialogicUtil.make_file_custom(
original_file,
target_folder,
custom_name,
custom_new_folder,
)
current_style.set_layer_scene(current_layer_id, result_path)
load_style_layer_list()
if %LayerTree.get_selected() == %LayerTree.get_root():
%LayerTree.get_root().select(0)
else:
%LayerTree.get_root().get_child(%LayerTree.get_selected().get_index()).select(0)
func make_layout_custom(target_folder:String) -> void:
target_folder = target_folder.path_join("Custom" + current_style.name.to_pascal_case())
DirAccess.make_dir_absolute(target_folder)
%LayerTree.get_root().select(0)
make_layer_custom(target_folder, "custom_" + current_style.name.to_snake_case())
var base_layer_info := current_style.get_layer_info("")
var target_path: String = base_layer_info.path
# Load base scene
var base_scene_pck: PackedScene = load(base_layer_info.path).duplicate()
var base_scene := base_scene_pck.instantiate()
base_scene.name = "Custom" + clean_scene_name(base_scene_pck.resource_path).to_pascal_case()
# Load layers
for layer_id in current_style.get_layer_inherited_list():
var layer_info := current_style.get_layer_inherited_info(layer_id)
if not ResourceLoader.exists(layer_info.path):
continue
var layer_scene: DialogicLayoutLayer = load(layer_info.path).instantiate()
base_scene.add_layer(layer_scene)
layer_scene.owner = base_scene
layer_scene.apply_overrides_on_ready = true
# Apply layer overrides
DialogicUtil.apply_scene_export_overrides(layer_scene, layer_info.overrides, false)
var pckd_scn := PackedScene.new()
pckd_scn.pack(base_scene)
pckd_scn.take_over_path(target_path)
ResourceSaver.save(pckd_scn, target_path)
current_style.base_scene = load(target_path)
current_style.inherits = null
current_style.layers = []
current_style.changed.emit()
load_style_layer_list()
%LayerTree.get_root().select(0)
find_parent('EditorView').plugin_reference.get_editor_interface().get_resource_filesystem().scan_sources()
func _on_delete_layer_button_pressed() -> void:
delete_layer()
#region Layer Settings
####### LAYER SETTINGS #########################################################
func load_layout_scene_customization(custom_scene_path:String, overrides:Dictionary = {}, inherited_overrides:Dictionary = {}) -> void:
for child in %LayerSettingsTabs.get_children():
child.get_parent().remove_child(child)
child.queue_free()
var scene: Node = null
if !custom_scene_path.is_empty() and ResourceLoader.exists(custom_scene_path):
var pck_scn := load(custom_scene_path)
if pck_scn:
scene = pck_scn.instantiate()
var settings := []
if scene and scene.script:
settings = collect_settings(scene.script.get_script_property_list())
if settings.is_empty():
var note := Label.new()
note.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
note.text = "This layer has no exposed settings."
if not %StyleBrowser.is_premade_style_part(custom_scene_path):
note.text += "\n\nIf you want to add settings, make sure to have a root script in @tool mode and expose some @exported variables to show up here."
note.theme_type_variation = 'DialogicHintText2'
%LayerSettingsTabs.add_child(note)
note.name = "General"
return
var current_grid: GridContainer = null
var label_bg_style := get_theme_stylebox("CanvasItemInfoOverlay", "EditorStyles").duplicate()
label_bg_style.content_margin_left = 5
label_bg_style.content_margin_right = 5
label_bg_style.content_margin_top = 5
var current_group_name := ""
var current_subgroup_name := ""
customization_editor_info = {}
for i in settings:
match i['id']:
&"GROUP":
var main_scroll := ScrollContainer.new()
main_scroll.size_flags_vertical = Control.SIZE_EXPAND_FILL
main_scroll.size_flags_horizontal = Control.SIZE_EXPAND_FILL
main_scroll.name = i['name']
%LayerSettingsTabs.add_child(main_scroll, true)
current_grid = GridContainer.new()
current_grid.columns = 3
current_grid.size_flags_horizontal = Control.SIZE_EXPAND_FILL
main_scroll.add_child(current_grid)
current_group_name = i['name'].to_snake_case()
current_subgroup_name = ""
&"SUBGROUP":
# add separator
if current_subgroup_name:
current_grid.add_child(HSeparator.new())
current_grid.get_child(-1).add_theme_constant_override('separation', 20)
current_grid.add_child(current_grid.get_child(-1).duplicate())
current_grid.add_child(current_grid.get_child(-1).duplicate())
var title_label := Label.new()
title_label.text = i['name']
title_label.theme_type_variation = "DialogicSection"
title_label.size_flags_horizontal = SIZE_EXPAND_FILL
current_grid.add_child(title_label, true)
# add spaced to the grid
current_grid.add_child(Control.new())
current_grid.add_child(Control.new())
current_subgroup_name = i['name'].to_snake_case()
&"SETTING":
var label := Label.new()
label.text = str(i['name'].trim_prefix(current_group_name+'_').trim_prefix(current_subgroup_name+'_')).capitalize()
current_grid.add_child(label, true)
var scene_value: Variant = scene.get(i['name'])
customization_editor_info[i['name']] = {}
if i['name'] in inherited_overrides:
customization_editor_info[i['name']]['orig'] = str_to_var(inherited_overrides.get(i['name']))
else:
customization_editor_info[i['name']]['orig'] = scene_value
var current_value: Variant
if i['name'] in overrides:
current_value = str_to_var(overrides.get(i['name']))
else:
current_value = customization_editor_info[i['name']]['orig']
var input: Node = DialogicUtil.setup_script_property_edit_node(i, current_value, set_export_override)
input.size_flags_horizontal = SIZE_EXPAND_FILL
customization_editor_info[i['name']]['node'] = input
var reset := Button.new()
reset.flat = true
reset.icon = get_theme_icon("Reload", "EditorIcons")
reset.tooltip_text = "Remove customization"
customization_editor_info[i['name']]['reset'] = reset
reset.disabled = current_value == customization_editor_info[i['name']]['orig']
current_grid.add_child(reset)
reset.pressed.connect(_on_export_override_reset.bind(i['name']))
current_grid.add_child(input)
if scene:
scene.queue_free()
func collect_settings(properties:Array[Dictionary]) -> Array[Dictionary]:
var settings: Array[Dictionary] = []
var current_group := {}
var current_subgroup := {}
for i in properties:
if i['usage'] & PROPERTY_USAGE_CATEGORY:
continue
if (i['usage'] & PROPERTY_USAGE_GROUP):
current_group = i
current_group['added'] = false
current_group['id'] = &'GROUP'
current_subgroup = {}
elif i['usage'] & PROPERTY_USAGE_SUBGROUP:
current_subgroup = i
current_subgroup['added'] = false
current_subgroup['id'] = &'SUBGROUP'
elif i['usage'] & PROPERTY_USAGE_EDITOR:
if current_group.get('name', '') == 'Private':
continue
if current_group.is_empty():
current_group = {'name':'General', 'added':false, 'id':&"GROUP"}
if current_group.get('added', true) == false:
settings.append(current_group)
current_group['added'] = true
if current_subgroup.is_empty():
current_subgroup = {'name':current_group['name'], 'added':false, 'id':&"SUBGROUP"}
if current_subgroup.get('added', true) == false:
settings.append(current_subgroup)
current_subgroup['added'] = true
i['id'] = &'SETTING'
settings.append(i)
return settings
func set_export_override(property_name:String, value:String = "") -> void:
if str_to_var(value) != customization_editor_info[property_name]['orig']:
current_style.set_layer_setting(current_layer_id, property_name, value)
customization_editor_info[property_name]['reset'].disabled = false
else:
current_style.remove_layer_setting(current_layer_id, property_name)
customization_editor_info[property_name]['reset'].disabled = true
func _on_export_override_reset(property_name:String) -> void:
current_style.remove_layer_setting(current_layer_id, property_name)
customization_editor_info[property_name]['reset'].disabled = true
set_customization_value(property_name, customization_editor_info[property_name]['orig'])
func set_customization_value(property_name:String, value:Variant) -> void:
var node: Node = customization_editor_info[property_name]['node']
if node is CheckBox:
node.button_pressed = value
elif node is LineEdit:
node.text = value
elif node.has_method('set_value'):
node.set_value(value)
elif node is ColorPickerButton:
node.color = value
elif node is OptionButton:
node.select(value)
elif node is SpinBox:
node.value = value
#endregion
func _on_expand_layer_info_pressed() -> void:
if %LayerInfoBody.visible:
%LayerInfoBody.hide()
%ExpandLayerInfo.icon = get_theme_icon("CodeFoldedRightArrow", "EditorIcons")
else:
%LayerInfoBody.show()
%ExpandLayerInfo.icon = get_theme_icon("CodeFoldDownArrow", "EditorIcons")
func _on_layer_tree_layer_moved(from: int, to: int) -> void:
move_layer(from, to)
func _on_layer_tree_button_clicked(item: TreeItem, column: int, id: int, mouse_button_index: int) -> void:
if ResourceLoader.exists(item.get_meta('scene')):
find_parent('EditorView').plugin_reference.get_editor_interface().open_scene_from_path(item.get_meta('scene'))
find_parent('EditorView').plugin_reference.get_editor_interface().set_main_screen_editor("2D")
#region Helpers
####### HELPERS ################################################################
func clean_scene_name(file_path:String) -> String:
return file_path.get_file().trim_suffix('.tscn').capitalize()
#endregion

View File

@@ -0,0 +1 @@
uid://5ia3xcfuitje

View File

@@ -0,0 +1 @@
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="16" xmlns="http://www.w3.org/2000/svg" height="16" id="screenshot-dd20a063-b517-80d9-8002-55556598bb7d" viewBox="0 0 16 16" style="-webkit-print-color-adjust: exact;" fill="none" version="1.1"><g id="shape-dd20a063-b517-80d9-8002-55556598bb7d"><defs><clipPath class="frame-clip-def frame-clip" id="frame-clip-dd20a063-b517-80d9-8002-55556598bb7d-rumext-id-1"><rect rx="0" ry="0" x="0" y="0" width="16" height="16" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)"/></clipPath></defs><g clip-path="url(#frame-clip-dd20a063-b517-80d9-8002-55556598bb7d-rumext-id-1)"><clipPath class="frame-clip-def frame-clip" id="frame-clip-dd20a063-b517-80d9-8002-55556598bb7d-rumext-id-1"><rect rx="0" ry="0" x="0" y="0" width="16" height="16" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)"/></clipPath><g class="fills" id="fills-dd20a063-b517-80d9-8002-55556598bb7d"><rect rx="0" ry="0" x="0" y="0" transform="matrix(1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000)" width="16" height="16" class="frame-background"/></g><g class="frame-children"><g id="shape-dd20a063-b517-80d9-8002-555549440d01" rx="0" ry="0"><g id="shape-dd20a063-b517-80d9-8002-555549440d02"><g class="fills" id="fills-dd20a063-b517-80d9-8002-555549440d02"><path rx="0" ry="0" d="M7.549,13.909L8.078,10.224L9.132,9.405L11.492,9.520L12.839,8.702L13.346,7.337L3.044,5.307L2.771,6.673L3.746,7.922L6.244,8.820L6.283,9.834L4.644,12.917L4.630,14.274L5.502,14.985L6.751,15.024" style="fill: rgb(255, 255, 255); fill-opacity: 1;"/></g></g><g id="shape-dd20a063-b517-80d9-8002-555549440d03"><g class="fills" id="fills-dd20a063-b517-80d9-8002-555549440d03"><path rx="0" ry="0" d="M3.161,4.605L13.541,6.634L15.024,1.678L11.239,2.459L8.657,1.644L5.843,2.006L4.956,1.327L3.941,1.522L3.161,4.605ZL3.161,4.605Z" style="fill: rgb(255, 255, 255); fill-opacity: 1;"/></g></g></g></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,44 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://1mccycya6eua"
path="res://.godot/imported/styles_icon.svg-c55f9f7d15c3512c8b20dbf30eed7047.ctex"
metadata={
"has_editor_variant": true,
"vram_texture": false
}
[deps]
source_file="res://addons/dialogic/Modules/StyleEditor/styles_icon.svg"
dest_files=["res://.godot/imported/styles_icon.svg-c55f9f7d15c3512c8b20dbf30eed7047.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=true
editor/convert_colors_with_editor_theme=true