Skip to content

Commit

Permalink
A lot of stuff (#1441)
Browse files Browse the repository at this point in the history
- fix event collapsing (hiding contained events)
- improve look of collapsed events
- simplify add-event button
- add small mode for event button sidebar when to thin
- save and restore event button sidebar size
- modulate text input box
- fix text input event name not being capitalized
- fix bug when saving timelines in visual timeline editor
- fix variable event "Variable Editor" button not working
  • Loading branch information
Jowan-Spooner authored Feb 26, 2023
1 parent 85c4036 commit 183b4f4
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 215 deletions.
68 changes: 42 additions & 26 deletions addons/dialogic/Editor/Events/BranchEnd.gd
Original file line number Diff line number Diff line change
@@ -1,50 +1,66 @@
@tool
extends Control
var resource
var parent_node
## A scene shown at the end of events that contain other events

var end_control :Control
var resource : DialogicEndBranchEvent

### the indent size
var indent_size = 15
var current_indent_level = 1
# References
var parent_node : Control = null
var end_control :Control = null

func _ready():
# Indent
var indent_size := 15
var current_indent_level := 1

func _ready() -> void:
$Icon.icon = get_theme_icon("GuiSpinboxUpdown", "EditorIcons")
parent_node_changed()
$Spacer.custom_minimum_size.x = 100*DialogicUtil.get_editor_scale()

visual_deselect()
parent_node_changed()


func visual_select():
modulate = get_theme_color("warning_color", "Editor")
## Called by the visual timeline editor
func visual_select() -> void:
modulate = get_theme_color("highlighted_font_color", "Editor")


func visual_deselect():
modulate = Color(1,1,1,1)
## Called by the visual timeline editor
func visual_deselect() -> void:
modulate = parent_node.resource.event_color


func highlight():
## Called by the visual timeline editor
func highlight() -> void:
modulate = parent_node.resource.event_color.lightened(0.5)


func unhighlight():
modulate = Color(1,1,1,1)
## Called by the visual timeline editor
func unhighlight() -> void:
modulate = parent_node.resource.event_color

func set_indent(indent: int):
var indent_node = $Indent
indent_node.custom_minimum_size = Vector2(indent_size * indent, 0)
indent_node.visible = indent != 0

func update_hidden_events_indicator(hidden_events_count:int = 0) -> void:
$HiddenEventsLabel.visible = hidden_events_count > 0
$HiddenEventsLabel.text = "["+str(hidden_events_count)+ " events hidden]"

## Called by the visual timeline editor
func set_indent(indent: int) -> void:
$Indent.custom_minimum_size = Vector2(indent_size * indent, 0)
$Indent.visible = indent != 0
current_indent_level = indent
queue_redraw()

func parent_node_changed():
if parent_node:
if end_control and end_control.has_method('refresh'):
end_control.refresh()

func add_end_control(control:Control):
## Called by the visual timeline editor if something was edited on the parent event block
func parent_node_changed() -> void:
if parent_node and end_control and end_control.has_method('refresh'):
end_control.refresh()


## Called on creation of the parent event provides an end control
func add_end_control(control:Control) -> void:
add_child(control)
control.size_flags_vertical = SIZE_SHRINK_BEGIN
control.size_flags_vertical = SIZE_SHRINK_CENTER
if "parent_resource" in control:
control.parent_resource = parent_node.resource
if control.has_method('refresh'):
Expand Down
22 changes: 15 additions & 7 deletions addons/dialogic/Editor/Events/BranchEnd.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ext_resource type="Script" path="res://addons/dialogic/Editor/Events/BranchEnd.gd" id="1"]

[sub_resource type="Image" id="Image_ov00m"]
[sub_resource type="Image" id="Image_8tlok"]
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",
Expand All @@ -11,14 +11,15 @@ data = {
"width": 16
}

[sub_resource type="ImageTexture" id="ImageTexture_oe0il"]
image = SubResource("Image_ov00m")
[sub_resource type="ImageTexture" id="ImageTexture_vm1jl"]
image = SubResource("Image_8tlok")

[node name="EndBranch" type="HBoxContainer"]
custom_minimum_size = Vector2(0, 40)
anchors_preset = 10
anchor_right = 1.0
offset_bottom = 24.0
offset_bottom = 40.0
grow_horizontal = 2
mouse_filter = 0
script = ExtResource("1")

Expand All @@ -33,9 +34,16 @@ size_flags_vertical = 0

[node name="Icon" type="Button" parent="."]
unique_name_in_owner = true
custom_minimum_size = Vector2(31, 0)
custom_minimum_size = Vector2(20, 0)
layout_mode = 2
size_flags_vertical = 0
size_flags_vertical = 4
tooltip_text = "Click and drag"
focus_mode = 0
mouse_filter = 1
icon = SubResource("ImageTexture_oe0il")
icon = SubResource("ImageTexture_vm1jl")
flat = true

[node name="HiddenEventsLabel" type="Label" parent="."]
visible = false
layout_mode = 2
text = "XX Events hidden"
25 changes: 1 addition & 24 deletions addons/dialogic/Editor/Events/EventBlock/event_block.gd
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,14 @@ func _set_event_icon(icon: Texture) -> void:
custom_style.corner_radius_bottom_right = 5 * _scale


func _request_selection() -> void:
# TODO doesn't work. I'm sure - JS
var timeline_editor = editor_reference.get_node_or_null('MainPanel/TimelineEditor')
if (timeline_editor != null):
# @todo select item and clear selection is marked as "private" in TimelineEditor.gd
# consider to make it "public" or add a public helper function
timeline_editor.select_item(self)


# called to inform event parts, that a focus is wanted
func focus():
pass


func toggle_collapse(toggled:bool) -> void:
collapsed = toggled
$PanelContainer/VBoxContainer/CollapsedBody.visible = toggled
var timeline_editor = find_parent('TimelineVisualEditor')
var timeline_editor = find_parent('VisualEditor')
if (timeline_editor != null):
# @todo select item and clear selection is marked as "private" in TimelineEditor.gd
# consider to make it "public" or add a public helper function
Expand Down Expand Up @@ -356,26 +346,13 @@ func _ready():

if resource:
if resource.event_name:
#title_label.text = DTS.translate(resource.event_name)
title_label.text = resource.event_name
if resource._get_icon() != null:
_set_event_icon(resource._get_icon())

%IconPanel.self_modulate = resource.event_color

_on_ExpandButton_toggled(resource.expand_by_default)

# Only create this if it can collapse children events
if resource.can_contain_events:
var cb:HBoxContainer = HBoxContainer.new()
cb.name = 'CollapsedBody'
cb.visible = false
var cb_label:Label = Label.new()
cb_label.text = 'Contains Events (currently hidden)'
cb_label.size_flags_horizontal = 3
cb_label.horizontal_alignment = 1
cb.add_child(cb_label)
$PanelContainer/VBoxContainer.add_child(cb)

set_focus_mode(1) # Allowing this node to grab focus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,71 @@ extends Button
return event_icon
set(texture):
event_icon = texture
%Icon.texture = texture
icon = event_icon
@export var event_category:int = 0
@export var event_sorting_index:int = 0
@export var resource:Resource
@export var resource:DialogicEvent
@export var dialogic_color_name:String = ''

func _ready():
self_modulate = Color(1,1,1)
if visible_name != '':
text = ' ' + visible_name
#tooltip_text = DTS.translate(tooltip_text)

var _scale = DialogicUtil.get_editor_scale()
custom_minimum_size = Vector2(30,30)* _scale
icon = null

%ColorBorder.custom_minimum_size.x = 5 * _scale
%IconContainer.custom_minimum_size = custom_minimum_size

func _ready() -> void:
toggle_name()
tooltip_text = visible_name

custom_minimum_size = Vector2(get_theme_font("font", 'Label').get_string_size(text).x+35,30)* DialogicUtil.get_editor_scale()

add_theme_color_override("font_color", get_theme_color("font_color", "Editor"))
add_theme_color_override("font_color_hover", get_theme_color("accent_color", "Editor"))
%Icon.modulate = get_theme_color("font_color", "Button")

# TODO godot4 signal was removed. find a way to react to color changes
# ProjectSettings.project_settings_changed.connect(_update_color)
apply_base_button_style()

func set_color(color):
%ColorBorder.self_modulate = color
func apply_base_button_style() -> void:
var scale := DialogicUtil.get_editor_scale()
var nstyle :StyleBoxFlat= get_parent().get_theme_stylebox('normal', 'Button').duplicate()
nstyle.border_width_left = 5 *scale
add_theme_stylebox_override('normal', nstyle)
var hstyle :StyleBoxFlat= get_parent().get_theme_stylebox('hover', 'Button').duplicate()
hstyle.border_width_left = 5 *scale
add_theme_stylebox_override('hover', hstyle)
set_color(resource.event_color)


func set_color(color:Color) -> void:
var style := get_theme_stylebox('normal', 'Button')
style.border_color = color
add_theme_stylebox_override('normal', style)
style = get_theme_stylebox('hover', 'Button')
style.border_color = color
add_theme_stylebox_override('hover', style)

#func _update_color():
# if dialogic_color_name != '':
# var new_color = DialogicUtil.get_color(dialogic_color_name)
# resource.event_color = new_color
# %ColorBorder.self_modulate = DialogicUtil.get_color(dialogic_color_name)

func _get_drag_data(position):
var preview_label = Label.new()
func _get_drag_data(position:Vector2) -> Variant:
var preview_label := Label.new()

preview_label.text = 'Add Event %s' % [ tooltip_text ]
if self.text != '':
preview_label.text = text

set_drag_preview(preview_label)

return { "source": "EventButton", "resource": resource }

func toggle_name():
if text != "":
text = ""
custom_minimum_size = Vector2(40, 40)*DialogicUtil.get_editor_scale()
var style := get_theme_stylebox('normal', 'Button')
style.bg_color = style.border_color.darkened(0.2)
add_theme_stylebox_override('normal', style)
style = get_theme_stylebox('hover', 'Button')
style.bg_color = style.border_color
add_theme_stylebox_override('hover', style)
else:
text = visible_name
custom_minimum_size = Vector2(get_theme_font("font", 'Label').get_string_size(text).x+35,30)* DialogicUtil.get_editor_scale()
apply_base_button_style()
103 changes: 39 additions & 64 deletions addons/dialogic/Editor/TimelineEditor/VisualEditor/AddEventButton.tscn
Original file line number Diff line number Diff line change
@@ -1,71 +1,46 @@
[gd_scene load_steps=3 format=3]
[gd_scene load_steps=5 format=3 uid="uid://depcrpeh3f4rv"]

[ext_resource type="Script" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/AddEventButton.gd" id="1_s43sc"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ba8bn"]
bg_color = Color(1, 1, 1, 1)
corner_radius_top_left = 5
corner_radius_bottom_left = 5
[ext_resource type="Texture2D" uid="uid://bbqfq3s7qrduv" path="res://icon.svg" id="2_mncsv"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qx31r"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0.1, 0.1, 0.1, 0.6)
border_width_left = 3
border_color = Color(0.231373, 0.545098, 0.94902, 1)
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="StyleBoxFlat" id="StyleBoxFlat_n1o16"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0.225, 0.225, 0.225, 0.6)
border_width_left = 3
border_color = Color(0.231373, 0.545098, 0.94902, 1)
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="AddEventButton" type="Button"]
custom_minimum_size = Vector2(60, 60)
offset_right = 103.0
offset_bottom = 31.0
custom_minimum_size = Vector2(29.25, 22.5)
offset_right = 97.0
offset_bottom = 42.0
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = " S"
flat = true
theme_override_styles/normal = SubResource("StyleBoxFlat_qx31r")
theme_override_styles/hover = SubResource("StyleBoxFlat_n1o16")
text = "S"
icon = ExtResource("2_mncsv")
alignment = 0
expand_icon = true
script = ExtResource("1_s43sc")
visible_name = "S"

[node name="Border" type="Panel" parent="."]
show_behind_parent = true
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2

[node name="Hbox" type="HBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
metadata/_edit_layout_mode = 1

[node name="ColorBorder" type="Panel" parent="Hbox"]
unique_name_in_owner = true
self_modulate = Color(0.635294, 0.635294, 0.635294, 0.282353)
show_behind_parent = true
custom_minimum_size = Vector2(10, 0)
layout_mode = 2
offset_right = 10.0
offset_bottom = 60.0
mouse_filter = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_ba8bn")

[node name="IconContainer" type="MarginContainer" parent="Hbox"]
unique_name_in_owner = true
custom_minimum_size = Vector2(60, 60)
layout_mode = 2
offset_left = 10.0
offset_right = 70.0
offset_bottom = 60.0
theme_override_constants/margin_left = 0
theme_override_constants/margin_top = 0
theme_override_constants/margin_right = 0
theme_override_constants/margin_bottom = 0

[node name="Icon" type="TextureRect" parent="Hbox/IconContainer"]
unique_name_in_owner = true
modulate = Color(0, 0, 0, 1)
layout_mode = 2
offset_right = 60.0
offset_bottom = 60.0
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
ignore_texture_size = true
metadata/_edit_layout_mode = 1
Loading

0 comments on commit 183b4f4

Please sign in to comment.