Skip to content

Commit

Permalink
Character Editor UI improvement suggestion (#1565)
Browse files Browse the repository at this point in the history
* Big character editor update

* Allow custom portrait settings + communication between sections

Also re-adds the mood per portrait functionality.

* Respect export range for integers

This will help both for custom portrait exports and also in the theme editor.

* Fix broken signal
  • Loading branch information
Jowan-Spooner authored May 21, 2023
1 parent 53ca34c commit ae6ed99
Show file tree
Hide file tree
Showing 38 changed files with 849 additions and 720 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
@tool
extends DialogicCharacterEditorPortraitSettingsTab
extends DialogicCharacterEditorPortraitSection

## Tab that allows setting values of exported scene variables
## for custom portrait scenes

var current_portrait_data := {}

func _ready() -> void:
get_parent().set_tab_icon(get_index(), get_theme_icon("EditInternal", "EditorIcons"))
add_theme_stylebox_override('panel', get_theme_stylebox("Background", "EditorStyles"))

$Label.add_theme_color_override("font_color", get_theme_color("readonly_color", "Editor"))


func _load_portrait_data(data:Dictionary) -> void:
_recheck(data)

func _recheck(data:Dictionary):
if data.get('scene', '').is_empty():
get_parent().set_tab_hidden(get_index(), true)
hide()
get_parent().get_child(get_index()-1).hide()
get_parent().get_child(get_index()+1).hide()
else:
get_parent().set_tab_hidden(get_index(), false)
get_parent().get_child(get_index()-1).show()

current_portrait_data = data
load_portrait_scene_export_variables()


func load_portrait_scene_export_variables():
var scene = null
if !current_portrait_data.get('scene', '').is_empty():
Expand Down Expand Up @@ -56,6 +64,9 @@ func load_portrait_scene_export_variables():
title.add_theme_stylebox_override('normal', get_theme_stylebox("ContextualToolbar", "EditorStyles"))
$Grid.add_child(title)
$Grid.add_child(Control.new())

$Label.visible = $Grid.get_child_count() == 0


func set_export_override(property_name:String, value:String = "") -> void:
var data:Dictionary = selected_item.get_metadata(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[gd_scene load_steps=2 format=3]

[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_p_section_exports.gd" id="1_isys8"]

[node name="Exports" type="VBoxContainer"]
custom_minimum_size = Vector2(0, 35)
offset_right = 367.0
offset_bottom = 82.0
script = ExtResource("1_isys8")

[node name="Label" type="Label" parent="."]
layout_mode = 2
text = "There are no exported variables to override. Add @export properties to the root script of your scene and make sure it's in @tool mode."
autowrap_mode = 3

[node name="Grid" type="GridContainer" parent="."]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/h_separation = 10
columns = 2
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
@tool
extends DialogicCharacterEditorPortraitSettingsTab
extends DialogicCharacterEditorPortraitSection

## Tab that allows setting size, offset and mirror of a portrait.


func _ready():
get_parent().set_tab_icon(get_index(), get_theme_icon('EditorPivot', 'EditorIcons'))


func _load_portrait_data(data:Dictionary) -> void:
%IgnoreScale.button_pressed = data.get('ignore_char_scale', false)

%PortraitScale.value = data.get('scale', 1.0)*100
%PortraitOffsetX.value = data.get('offset', Vector2()).x
%PortraitOffsetY.value = data.get('offset', Vector2()).y
%PortraitOffset.set_value(data.get('offset', Vector2()))
%PortraitMirror.button_pressed = data.get('mirror', false)


Expand All @@ -22,22 +19,22 @@ func _on_portrait_scale_value_changed(value) -> void:
changed.emit()


func _on_portrait_offset_x_value_changed(value) -> void:
func _on_portrait_mirror_toggled(button_pressed:bool)-> void:
var data:Dictionary = selected_item.get_metadata(0)
data['offset'] = data.get('offset', Vector2())
data['offset'].x = value
data['mirror'] = button_pressed
update_preview.emit()
changed.emit()

func _on_portrait_offset_y_value_changed(value)-> void:

func _on_ignore_scale_toggled(button_pressed:bool) -> void:
var data:Dictionary = selected_item.get_metadata(0)
data['offset'] = data.get('offset', Vector2())
data['offset'].y = value
data['ignore_char_scale'] = button_pressed
update_preview.emit()
changed.emit()

func _on_portrait_mirror_toggled(button_pressed:bool)-> void:

func _on_portrait_offset_value_changed(property:String, value:Vector2) -> void:
var data:Dictionary = selected_item.get_metadata(0)
data['mirror'] = button_pressed
data['offset'] = value
update_preview.emit()
changed.emit()
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[gd_scene load_steps=3 format=3 uid="uid://crke8suvv52c6"]

[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_p_section_layout.gd" id="1_76vf2"]
[ext_resource type="PackedScene" uid="uid://dtimnsj014cu" path="res://addons/dialogic/Editor/Events/Fields/Vector2.tscn" id="2_c8kyi"]

[node name="Layout" type="HFlowContainer"]
offset_right = 428.0
offset_bottom = 128.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_76vf2")

[node name="Label3" type="Label" parent="."]
layout_mode = 2
text = "Ignore Main Scale: "

[node name="IgnoreScale" type="CheckBox" parent="."]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "This portrait will ignore the main scale."

[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Label" type="Label" parent="HBoxContainer"]
layout_mode = 2
text = "Scale:"

[node name="PortraitScale" type="SpinBox" parent="HBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "A scale to be applied on top of the main scale
(unless ignore main scale is pressed)."
value = 100.0
allow_greater = true
suffix = "%"

[node name="HBoxContainer2" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Label2" type="Label" parent="HBoxContainer2"]
layout_mode = 2
text = "Offset:"

[node name="PortraitOffset" parent="HBoxContainer2" instance=ExtResource("2_c8kyi")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Offset that is applied on top of the main portrait offset."

[node name="MirrorOption" type="HBoxContainer" parent="."]
layout_mode = 2

[node name="Label" type="Label" parent="MirrorOption"]
layout_mode = 2
text = "Mirror:"

[node name="PortraitMirror" type="CheckBox" parent="MirrorOption"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "Mirroring that is applied on top of the main portrait mirror."

[connection signal="toggled" from="IgnoreScale" to="." method="_on_ignore_scale_toggled"]
[connection signal="value_changed" from="HBoxContainer/PortraitScale" to="." method="_on_portrait_scale_value_changed"]
[connection signal="value_changed" from="HBoxContainer2/PortraitOffset" to="." method="_on_portrait_offset_value_changed"]
[connection signal="toggled" from="MirrorOption/PortraitMirror" to="." method="_on_portrait_mirror_toggled"]
39 changes: 39 additions & 0 deletions addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@tool
extends DialogicCharacterEditorPortraitSection

## Tab that allows setting an image file on a portrait.


func _ready() -> void:
%ImagePicker.file_filter = "*.png, *.svg"
%ImagePicker.resource_icon = get_theme_icon('Image', 'EditorIcons')

%ScenePicker.file_filter = "*.tscn, *.scn; Scenes"
%ScenePicker.resource_icon = get_theme_icon('PackedScene', 'EditorIcons')
%ScenePicker.placeholder = 'Default scene'


func _load_portrait_data(data:Dictionary) -> void:
%ScenePicker.set_value(data.get('scene', ''))
%ImagePicker.set_value(data.get('image', ''))
update_image_picker_visibility(data['scene'].is_empty())


func _on_image_picker_value_changed(prop_name:String, value:String):
var data:Dictionary = selected_item.get_metadata(0)
data['image'] = value
changed.emit()
update_preview.emit()


func _on_scene_picker_value_changed(prop_name:String, value:String) -> void:
var data:Dictionary = selected_item.get_metadata(0)
data['scene'] = value
update_image_picker_visibility(data['scene'].is_empty())
update_preview.emit()
changed.emit()


func update_image_picker_visibility(show= true) -> void:
%ImagePicker.visible = show
%ImageLabel.visible = show
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[gd_scene load_steps=7 format=3 uid="uid://djq4aasoihexj"]

[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_p_section_main.gd" id="1_ht8lu"]
[ext_resource type="PackedScene" uid="uid://7mvxuaulctcq" path="res://addons/dialogic/Editor/Events/Fields/FilePicker.tscn" id="2_k8xs0"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rimrq"]
content_margin_left = 4.0
content_margin_top = 0.0
content_margin_right = 4.0
content_margin_bottom = 0.0
bg_color = Color(0.1, 0.1, 0.1, 0.6)
border_width_bottom = 2
border_color = Color(0, 0, 0, 0.6)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5

[sub_resource type="Image" id="Image_4x7i8"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 0, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 131, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 94, 94, 127, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 128, 128, 4, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 231, 255, 93, 93, 55, 255, 97, 97, 58, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 231, 255, 94, 94, 54, 255, 94, 94, 57, 255, 93, 93, 233, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 93, 93, 41, 255, 255, 255, 0, 255, 255, 255, 0, 255, 97, 97, 42, 255, 93, 93, 233, 255, 93, 93, 232, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 98, 98, 47, 255, 97, 97, 42, 255, 255, 255, 0, 255, 97, 97, 42, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 96, 96, 45, 255, 93, 93, 235, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 94, 94, 46, 255, 93, 93, 236, 255, 93, 93, 233, 255, 97, 97, 42, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 93, 93, 235, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 233, 255, 95, 95, 59, 255, 96, 96, 61, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 93, 93, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 93, 93, 252, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0),
"format": "RGBA8",
"height": 16,
"mipmaps": false,
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_y34ar"]
image = SubResource("Image_4x7i8")

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bvmrg"]
content_margin_left = 4.0
content_margin_top = 0.0
content_margin_right = 4.0
content_margin_bottom = 0.0
bg_color = Color(0.1, 0.1, 0.1, 0.6)
border_width_bottom = 2
border_color = Color(0, 0, 0, 0.6)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 5

[node name="General" type="GridContainer"]
offset_right = 298.0
offset_bottom = 86.0
size_flags_horizontal = 3
columns = 2
script = ExtResource("1_ht8lu")

[node name="Label2" type="Label" parent="."]
layout_mode = 2
text = "Scene: "

[node name="ScenePicker" parent="." instance=ExtResource("2_k8xs0")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_rimrq")
file_filter = "*.tscn, *.scn; Scenes"
placeholder = "Default scene"
resource_icon = SubResource("ImageTexture_y34ar")

[node name="ImageLabel" type="Label" parent="."]
unique_name_in_owner = true
layout_mode = 2
text = "Image: "

[node name="ImagePicker" parent="." instance=ExtResource("2_k8xs0")]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 3
theme_override_styles/panel = SubResource("StyleBoxFlat_bvmrg")
file_filter = "*.png, *.svg"
resource_icon = SubResource("ImageTexture_y34ar")

[connection signal="value_changed" from="ScenePicker" to="." method="_on_scene_picker_value_changed"]
[connection signal="value_changed" from="ImagePicker" to="." method="_on_image_picker_value_changed"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@tool
extends DialogicCharacterEditorMainTab
extends DialogicCharacterEditorMainSection

## The general character settings tab

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://de5kj4vd0we1w"]
[gd_scene load_steps=2 format=3]

[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/character_editor_tab_general.gd" id="1_3e1i1"]
[ext_resource type="Script" path="res://addons/dialogic/Editor/CharacterEditor/char_edit_section_general.gd" id="1_3e1i1"]

[node name="General" type="GridContainer"]
anchors_preset = 15
Expand All @@ -19,6 +19,7 @@ script = ExtResource("1_3e1i1")

[node name="Label2" type="Label" parent="."]
layout_mode = 2
size_flags_vertical = 0
text = "Display Name: "

[node name="DisplayName" type="HBoxContainer" parent="."]
Expand All @@ -43,6 +44,7 @@ edit_alpha = false

[node name="Label3" type="Label" parent="."]
layout_mode = 2
size_flags_vertical = 0
text = "Nicknames:"

[node name="NicknameLineEdit" type="LineEdit" parent="."]
Expand Down
Loading

0 comments on commit ae6ed99

Please sign in to comment.