bcp de characters
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
@tool
|
||||
extends ScrollContainer
|
||||
|
||||
# Script of the TimelineArea (that contains the event blocks).
|
||||
# Manages the drawing of the event lines and event dragging.
|
||||
|
||||
|
||||
enum DragTypes {NOTHING, NEW_EVENT, EXISTING_EVENTS, GENERATED_EVENT}
|
||||
|
||||
var drag_type: DragTypes = DragTypes.NOTHING
|
||||
var drag_data: Variant
|
||||
var drag_to_position := 0:
|
||||
set(value):
|
||||
drag_to_position = value
|
||||
drag_to_position_updated = true
|
||||
var dragging := false
|
||||
var drag_to_position_updated := false
|
||||
|
||||
|
||||
signal drag_completed(type, index, data)
|
||||
signal drag_canceled()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if owner.get_parent() is SubViewport:
|
||||
return
|
||||
|
||||
resized.connect(add_extra_scroll_area_to_timeline)
|
||||
%Timeline.child_entered_tree.connect(add_extra_scroll_area_to_timeline)
|
||||
|
||||
# This prevents the view to turn black if you are editing this scene in Godot
|
||||
if find_parent("EditorView"):
|
||||
%TimelineArea.get_theme_color("background_color", "CodeEdit")
|
||||
|
||||
|
||||
#region EVENT DRAGGING
|
||||
################################################################################
|
||||
|
||||
func start_dragging(type:DragTypes, data:Variant) -> void:
|
||||
dragging = true
|
||||
drag_type = type
|
||||
drag_data = data
|
||||
drag_to_position_updated = false
|
||||
|
||||
|
||||
func _input(event:InputEvent) -> void:
|
||||
if !dragging:
|
||||
return
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
if !event.is_pressed():
|
||||
finish_dragging()
|
||||
|
||||
|
||||
func _process(_delta:float) -> void:
|
||||
if !dragging:
|
||||
return
|
||||
|
||||
for child in %Timeline.get_children():
|
||||
if (child.global_position.y < get_global_mouse_position().y) and \
|
||||
(child.global_position.y+child.size.y > get_global_mouse_position().y):
|
||||
|
||||
if get_global_mouse_position().y > child.global_position.y+(child.size.y/2.0):
|
||||
drag_to_position = child.get_index()+1
|
||||
queue_redraw()
|
||||
return
|
||||
else:
|
||||
drag_to_position = child.get_index()
|
||||
queue_redraw()
|
||||
return
|
||||
|
||||
if get_global_rect().has_point(get_global_mouse_position()):
|
||||
if %Timeline.get_child_count():
|
||||
var last_child := %Timeline.get_child(-1)
|
||||
if get_global_mouse_position().y > last_child.global_position.y + last_child.size.y:
|
||||
drag_to_position = %Timeline.get_child_count()
|
||||
queue_redraw()
|
||||
return
|
||||
else:
|
||||
drag_to_position = 0
|
||||
queue_redraw()
|
||||
return
|
||||
|
||||
|
||||
|
||||
func finish_dragging() -> void:
|
||||
dragging = false
|
||||
if drag_to_position_updated and get_global_rect().has_point(get_global_mouse_position()):
|
||||
drag_completed.emit(drag_type, drag_to_position, drag_data)
|
||||
else:
|
||||
drag_canceled.emit()
|
||||
queue_redraw()
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region LINE DRAWING
|
||||
################################################################################
|
||||
|
||||
func _draw() -> void:
|
||||
var line_width := 5 * DialogicUtil.get_editor_scale()
|
||||
var horizontal_line_length := 100 * DialogicUtil.get_editor_scale()
|
||||
var color_multiplier := Color(1,1,1,0.25)
|
||||
var selected_color_multiplier := Color(1,1,1,1)
|
||||
|
||||
## Draw Event Lines
|
||||
for idx in range($Timeline.get_child_count()):
|
||||
var block: Control = $Timeline.get_child(idx)
|
||||
|
||||
if not "resource" in block:
|
||||
continue
|
||||
|
||||
if not block.visible:
|
||||
continue
|
||||
|
||||
if block.resource is DialogicEndBranchEvent:
|
||||
continue
|
||||
|
||||
if not (block.has_any_enabled_body_content or block.resource.can_contain_events):
|
||||
continue
|
||||
|
||||
var icon_panel_height: int = block.get_node("%IconPanel").size.y
|
||||
var rect_position: Vector2 = block.get_node("%IconPanel").global_position+Vector2(0,1)*block.get_node("%IconPanel").size+Vector2(0,-4)
|
||||
var color: Color = block.resource.event_color
|
||||
|
||||
if block.is_selected() or block.end_node and block.end_node.is_selected():
|
||||
color *= selected_color_multiplier
|
||||
else:
|
||||
color *= color_multiplier
|
||||
|
||||
if block.expanded and not block.resource.can_contain_events:
|
||||
draw_rect(Rect2(rect_position-global_position+Vector2(line_width, 0), Vector2(line_width, block.size.y-block.get_node('%IconPanel').size.y)), color)
|
||||
|
||||
## If the indentation has not changed, nothing else happens
|
||||
if idx >= $Timeline.get_child_count()-1 or block.current_indent_level >= $Timeline.get_child(idx+1).current_indent_level:
|
||||
continue
|
||||
|
||||
## Draw connection between opening and end branch events
|
||||
if block.resource.can_contain_events:
|
||||
var end_node: Node = block.end_node
|
||||
|
||||
if end_node != null:
|
||||
var v_length: float = end_node.global_position.y+end_node.size.y/2-rect_position.y
|
||||
#var rect_size := Vector2(line_width, )
|
||||
var offset := Vector2(line_width, 0)
|
||||
|
||||
# Draw vertical line
|
||||
draw_rect(Rect2(rect_position-global_position+offset, Vector2(line_width, v_length)), color)
|
||||
# Draw horizonal line (on END BRANCH event)
|
||||
draw_rect(Rect2(
|
||||
rect_position.x+line_width-global_position.x+offset.x,
|
||||
rect_position.y+v_length-line_width-global_position.y,
|
||||
horizontal_line_length-offset.x,
|
||||
line_width),
|
||||
color)
|
||||
|
||||
if block.resource.wants_to_group:
|
||||
var group_color: Color = block.resource.event_color*color_multiplier*0.7
|
||||
var group_starter := true
|
||||
if idx != 0:
|
||||
var block_above := $Timeline.get_child(idx-1)
|
||||
if block_above.resource.event_name == block.resource.event_name and block_above.current_indent_level == block.current_indent_level:
|
||||
group_starter = false
|
||||
if block_above.resource is DialogicEndBranchEvent and block_above.parent_node.resource.event_name == block.resource.event_name:
|
||||
group_starter = false
|
||||
|
||||
## Draw small horizontal line on any event in group
|
||||
draw_rect(Rect2(
|
||||
rect_position.x-global_position.x-line_width,
|
||||
rect_position.y-global_position.y-icon_panel_height/2.0,
|
||||
line_width,
|
||||
line_width),
|
||||
group_color)
|
||||
|
||||
if group_starter:
|
||||
## Find the last event in the group (or that events END BRANCH)
|
||||
var target_indent: int = block.current_indent_level-1
|
||||
var sub_idx := idx
|
||||
var group_end_idx := idx
|
||||
while sub_idx < $Timeline.get_child_count()-1:
|
||||
sub_idx += 1
|
||||
if $Timeline.get_child(sub_idx).current_indent_level == target_indent:
|
||||
group_end_idx = sub_idx-1
|
||||
break
|
||||
if sub_idx + 1 == $Timeline.get_child_count():
|
||||
group_end_idx = sub_idx
|
||||
break
|
||||
|
||||
var end_node := $Timeline.get_child(group_end_idx)
|
||||
|
||||
var offset := Vector2(-2*line_width, -icon_panel_height/2.0)
|
||||
var v_length: float = end_node.global_position.y - rect_position.y + icon_panel_height
|
||||
|
||||
## Draw vertical line
|
||||
draw_rect(Rect2(
|
||||
rect_position.x - global_position.x + offset.x,
|
||||
rect_position.y - global_position.y + offset.y,
|
||||
line_width,
|
||||
v_length),
|
||||
group_color)
|
||||
|
||||
|
||||
## Draw line that indicates the dragging position
|
||||
if dragging and get_global_rect().has_point(get_global_mouse_position()):
|
||||
var height: int = 0
|
||||
if drag_to_position == %Timeline.get_child_count():
|
||||
if drag_to_position == 0:
|
||||
height = 0
|
||||
else:
|
||||
height = %Timeline.get_child(-1).global_position.y+%Timeline.get_child(-1).size.y-global_position.y-(line_width/2.0)
|
||||
else:
|
||||
height = %Timeline.get_child(drag_to_position).global_position.y-global_position.y-(line_width/2.0)
|
||||
|
||||
draw_line(Vector2(0, height), Vector2(size.x*0.9, height), get_theme_color("accent_color", "Editor"), line_width*.3)
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region SPACE BELOW
|
||||
################################################################################
|
||||
|
||||
func add_extra_scroll_area_to_timeline(_fake_arg:Variant=null) -> void:
|
||||
if %Timeline.get_children().size() > 4:
|
||||
%Timeline.custom_minimum_size.y = 0
|
||||
%Timeline.size.y = 0
|
||||
if %Timeline.size.y + 200 > %TimelineArea.size.y:
|
||||
%Timeline.custom_minimum_size = Vector2(0, %Timeline.size.y + 200)
|
||||
|
||||
#endregion
|
||||
@@ -0,0 +1 @@
|
||||
uid://b6ka2avnh1u55
|
||||
@@ -0,0 +1,85 @@
|
||||
@tool
|
||||
extends Button
|
||||
|
||||
@export var visible_name := ""
|
||||
@export var event_id := ""
|
||||
@export var event_icon: Texture:
|
||||
get:
|
||||
return event_icon
|
||||
set(texture):
|
||||
event_icon = texture
|
||||
icon = event_icon
|
||||
@export var event_sorting_index: int = 0
|
||||
@export var resource: DialogicEvent
|
||||
@export var dialogic_color_name := ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
if get_parent() is SubViewport:
|
||||
return
|
||||
|
||||
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"))
|
||||
|
||||
|
||||
var tooltip_box := StyleBoxFlat.new()
|
||||
tooltip_box.bg_color = get_theme_color("background", "Editor")
|
||||
tooltip_box.set_border_width_all(1)
|
||||
tooltip_box.border_width_left = 5 * int(DialogicUtil.get_editor_scale())
|
||||
theme.set_stylebox("panel", "TooltipPanel", tooltip_box)
|
||||
|
||||
apply_base_button_style()
|
||||
|
||||
|
||||
func apply_base_button_style() -> void:
|
||||
var nstyle: StyleBoxFlat = get_parent().get_theme_stylebox("normal", "Button").duplicate()
|
||||
nstyle.border_width_left = 5 * int(DialogicUtil.get_editor_scale())
|
||||
add_theme_stylebox_override("normal", nstyle)
|
||||
var hstyle: StyleBoxFlat = get_parent().get_theme_stylebox("hover", "Button").duplicate()
|
||||
hstyle.border_width_left = 5 * int(DialogicUtil.get_editor_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)
|
||||
|
||||
var tooltip_box : StyleBoxFlat = theme.get_stylebox("panel", "TooltipPanel")
|
||||
tooltip_box.border_color = color
|
||||
theme.set_stylebox("panel", "TooltipPanel", tooltip_box)
|
||||
|
||||
|
||||
func toggle_name(on:= false) -> void:
|
||||
if not on:
|
||||
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()
|
||||
|
||||
|
||||
func _on_button_down() -> void:
|
||||
find_parent("VisualEditor").get_node("%TimelineArea").start_dragging(1, resource)
|
||||
|
||||
|
||||
func _make_custom_tooltip(for_text: String) -> Object:
|
||||
var rtl := RichTextLabel.new()
|
||||
rtl.bbcode_enabled = true
|
||||
rtl.text = "[b]{0}[/b]\n{1}".format(Array(for_text.split("\n", false, 2)))
|
||||
rtl.fit_content = true
|
||||
rtl.custom_minimum_size.x = 300*DialogicUtil.get_editor_scale()
|
||||
return rtl
|
||||
@@ -0,0 +1 @@
|
||||
uid://dofrrscd4c61l
|
||||
@@ -0,0 +1,50 @@
|
||||
[gd_scene format=3 uid="uid://depcrpeh3f4rv"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dofrrscd4c61l" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/add_event_button.gd" id="1_s43sc"]
|
||||
|
||||
[sub_resource type="Theme" id="Theme_7ohuy"]
|
||||
resource_local_to_scene = true
|
||||
|
||||
[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" unique_id=1564302678]
|
||||
custom_minimum_size = Vector2(35, 30)
|
||||
offset_right = 97.0
|
||||
offset_bottom = 42.0
|
||||
tooltip_text = "S"
|
||||
theme = SubResource("Theme_7ohuy")
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 0.75)
|
||||
theme_override_styles/normal = SubResource("StyleBoxFlat_qx31r")
|
||||
theme_override_styles/hover = SubResource("StyleBoxFlat_n1o16")
|
||||
alignment = 0
|
||||
expand_icon = true
|
||||
script = ExtResource("1_s43sc")
|
||||
visible_name = "S"
|
||||
|
||||
[connection signal="button_down" from="." to="." method="_on_button_down"]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
uid://cvgok7bxva5e2
|
||||
@@ -0,0 +1,62 @@
|
||||
[gd_scene format=3 uid="uid://ysqbusmy0qma"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cvgok7bxva5e2" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd" id="1_8smxc"]
|
||||
[ext_resource type="Theme" uid="uid://cqst728xxipcw" path="res://addons/dialogic/Editor/Theme/MainTheme.tres" id="2_x0fhp"]
|
||||
[ext_resource type="Script" uid="uid://b6ka2avnh1u55" path="res://addons/dialogic/Editor/TimelineEditor/VisualEditor/TimelineArea.gd" id="3_sap1x"]
|
||||
[ext_resource type="Script" uid="uid://n1knm2ohcehu" path="res://addons/dialogic/Editor/Events/EventBlock/event_right_click_menu.gd" id="4_ugiq6"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_phyjj"]
|
||||
content_margin_top = 10.0
|
||||
|
||||
[node name="TimelineVisualEditor" type="MarginContainer" unique_id=1827236598]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 5
|
||||
theme_override_constants/margin_right = 5
|
||||
theme_override_constants/margin_bottom = 5
|
||||
script = ExtResource("1_8smxc")
|
||||
|
||||
[node name="View" type="HSplitContainer" parent="." unique_id=1893392013]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource("2_x0fhp")
|
||||
|
||||
[node name="TimelineArea" type="ScrollContainer" parent="View" unique_id=1257416940]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxEmpty_phyjj")
|
||||
script = ExtResource("3_sap1x")
|
||||
|
||||
[node name="Timeline" type="VBoxContainer" parent="View/TimelineArea" unique_id=1887371894]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="EventPopupMenu" type="PopupMenu" parent="View/TimelineArea" unique_id=1937370098]
|
||||
unique_name_in_owner = true
|
||||
size = Vector2i(165, 124)
|
||||
script = ExtResource("4_ugiq6")
|
||||
|
||||
[node name="RightSidebar" type="ScrollContainer" parent="View" unique_id=269152096]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
layout_mode = 2
|
||||
size_flags_stretch_ratio = 0.2
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="EventContainer" type="VBoxContainer" parent="View/RightSidebar" unique_id=151696986]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.2
|
||||
|
||||
[connection signal="drag_completed" from="View/TimelineArea" to="." method="_on_timeline_area_drag_completed"]
|
||||
[connection signal="id_pressed" from="View/TimelineArea/EventPopupMenu" to="." method="_on_event_popup_menu_id_pressed"]
|
||||
[connection signal="resized" from="View/RightSidebar" to="." method="_on_right_sidebar_resized"]
|
||||
Reference in New Issue
Block a user