]> Untitled Git - wolf-seeking-sheep.git/blob - addons/dialogic/Editor/Events/BranchEnd.gd
Initial Godot project with Dialogic 2.0-Alpha-17
[wolf-seeking-sheep.git] / addons / dialogic / Editor / Events / BranchEnd.gd
1 @tool
2 extends Control
3 ## A scene shown at the end of events that contain other events
4
5 var resource: DialogicEndBranchEvent
6
7 # References
8 var parent_node: Control = null
9 var end_control: Control = null
10
11 # Indent
12 var indent_size := 22
13 var current_indent_level := 1
14
15 var selected := false
16
17 func _ready() -> void:
18         $Icon.icon = get_theme_icon("GuiSpinboxUpdown", "EditorIcons")
19         $Spacer.custom_minimum_size.x = 90 * DialogicUtil.get_editor_scale()
20         visual_deselect()
21         parent_node_changed()
22
23
24 ## Called by the visual timeline editor
25 func visual_select() -> void:
26         modulate = get_theme_color("highlighted_font_color", "Editor")
27         selected = true
28
29
30 ## Called by the visual timeline editor
31 func visual_deselect() -> void:
32         if !parent_node:return
33         selected = false
34         modulate = parent_node.resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.3)
35
36
37 func is_selected() -> bool:
38         return selected
39
40
41 ## Called by the visual timeline editor
42 func highlight() -> void:
43         if !parent_node:return
44         modulate = parent_node.resource.event_color.lerp(get_theme_color("font_color", "Editor"), 0.6)
45
46
47 ## Called by the visual timeline editor
48 func unhighlight() -> void:
49         modulate = parent_node.resource.event_color
50
51
52 func update_hidden_events_indicator(hidden_events_count:int = 0) -> void:
53         $HiddenEventsLabel.visible = hidden_events_count > 0
54         if hidden_events_count == 1:
55                 $HiddenEventsLabel.text = "[1 event hidden]"
56         else:
57                 $HiddenEventsLabel.text = "["+str(hidden_events_count)+ " events hidden]"
58
59
60 ## Called by the visual timeline editor
61 func set_indent(indent: int) -> void:
62         $Indent.custom_minimum_size = Vector2(indent_size * indent * DialogicUtil.get_editor_scale(), 0)
63         $Indent.visible = indent != 0
64         current_indent_level = indent
65         queue_redraw()
66
67
68 ## Called by the visual timeline editor if something was edited on the parent event block
69 func parent_node_changed() -> void:
70         if parent_node and end_control and end_control.has_method('refresh'):
71                 end_control.refresh()
72
73
74 ## Called on creation if the parent event provides an end control
75 func add_end_control(control:Control) -> void:
76         if !control:
77                 return
78         add_child(control)
79         control.size_flags_vertical = SIZE_SHRINK_CENTER
80         if "parent_resource" in control:
81                 control.parent_resource = parent_node.resource
82         if control.has_method('refresh'):
83                 control.refresh()
84         end_control = control
85