Arnaud Vergnet 8 months ago
parent
commit
49c84f10d1
26 changed files with 2278 additions and 0 deletions
  1. 76
    0
      addons/EXP-System-Dialog/Dialog Editor/Dialog_Editor.tscn
  2. 52
    0
      addons/EXP-System-Dialog/Dialog Editor/Editor/Editor.tscn
  3. 21
    0
      addons/EXP-System-Dialog/Dialog Editor/Editor/editor.gd
  4. 111
    0
      addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn
  5. 1
    0
      addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg
  6. 34
    0
      addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg.import
  7. 114
    0
      addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd
  8. 224
    0
      addons/EXP-System-Dialog/Dialog Editor/dialog_editor.gd
  9. BIN
      addons/EXP-System-Dialog/Images/de.png
  10. 34
    0
      addons/EXP-System-Dialog/Images/de.png.import
  11. BIN
      addons/EXP-System-Dialog/Images/icon.png
  12. 34
    0
      addons/EXP-System-Dialog/Images/icon.png.import
  13. BIN
      addons/EXP-System-Dialog/Images/se.png
  14. 34
    0
      addons/EXP-System-Dialog/Images/se.png.import
  15. 83
    0
      addons/EXP-System-Dialog/Reference_StoryReader/EXP_StoryReader.gd
  16. 6
    0
      addons/EXP-System-Dialog/Resource_BakedStory/EXP_BakedStory.gd
  17. 9
    0
      addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd
  18. 6
    0
      addons/EXP-System-Dialog/Resource_NodeTemplate/EXP_NodeTemplate.gd
  19. 109
    0
      addons/EXP-System-Dialog/Story Editor/Dialog Record/Dialog_Record.tscn
  20. 91
    0
      addons/EXP-System-Dialog/Story Editor/Dialog Record/dialog_record.gd
  21. 92
    0
      addons/EXP-System-Dialog/Story Editor/Rename Record Box/Rename_Record_Box.tscn
  22. 32
    0
      addons/EXP-System-Dialog/Story Editor/Rename Record Box/rename_record_box.gd
  23. 268
    0
      addons/EXP-System-Dialog/Story Editor/Story_Editor.tscn
  24. 753
    0
      addons/EXP-System-Dialog/Story Editor/story_editor.gd
  25. 7
    0
      addons/EXP-System-Dialog/plugin.cfg
  26. 87
    0
      addons/EXP-System-Dialog/plugin.gd

+ 76
- 0
addons/EXP-System-Dialog/Dialog Editor/Dialog_Editor.tscn View File

@@ -0,0 +1,76 @@
1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/dialog_editor.gd" type="Script" id=1]
4
+
5
+[node name="Dialog_Editor" type="Control"]
6
+anchor_right = 1.0
7
+anchor_bottom = 1.0
8
+rect_min_size = Vector2( 0, 256 )
9
+script = ExtResource( 1 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}
13
+
14
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
15
+anchor_right = 1.0
16
+anchor_bottom = 1.0
17
+__meta__ = {
18
+"_edit_use_anchors_": false
19
+}
20
+
21
+[node name="VBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
22
+margin_right = 1024.0
23
+margin_bottom = 20.0
24
+
25
+[node name="Close_BTN" type="Button" parent="VBoxContainer/VBoxContainer"]
26
+margin_right = 47.0
27
+margin_bottom = 20.0
28
+hint_tooltip = "Close the Dialog Editor."
29
+text = "Close"
30
+
31
+[node name="Back_BTN" type="Button" parent="VBoxContainer/VBoxContainer"]
32
+margin_left = 51.0
33
+margin_right = 93.0
34
+margin_bottom = 20.0
35
+hint_tooltip = "Return to the Story Editor."
36
+text = "Back"
37
+
38
+[node name="VSeparator" type="VSeparator" parent="VBoxContainer/VBoxContainer"]
39
+margin_left = 97.0
40
+margin_right = 101.0
41
+margin_bottom = 20.0
42
+
43
+[node name="Add_Node_BTN" type="Button" parent="VBoxContainer/VBoxContainer"]
44
+margin_left = 105.0
45
+margin_right = 180.0
46
+margin_bottom = 20.0
47
+hint_tooltip = "Add a new node to the graph."
48
+text = "Add Node"
49
+
50
+[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/VBoxContainer"]
51
+margin_left = 184.0
52
+margin_right = 188.0
53
+margin_bottom = 20.0
54
+
55
+[node name="Human_Readable_LBL" type="Label" parent="VBoxContainer/VBoxContainer"]
56
+margin_left = 192.0
57
+margin_top = 3.0
58
+margin_right = 378.0
59
+margin_bottom = 17.0
60
+text = "Human Readable Description"
61
+
62
+[node name="GraphEdit" type="GraphEdit" parent="VBoxContainer"]
63
+margin_top = 24.0
64
+margin_right = 1024.0
65
+margin_bottom = 600.0
66
+size_flags_horizontal = 3
67
+size_flags_vertical = 3
68
+right_disconnects = true
69
+__meta__ = {
70
+"_edit_use_anchors_": false
71
+}
72
+[connection signal="pressed" from="VBoxContainer/VBoxContainer/Close_BTN" to="." method="_on_Close_BTN_pressed"]
73
+[connection signal="pressed" from="VBoxContainer/VBoxContainer/Back_BTN" to="." method="_on_Back_BTN_pressed"]
74
+[connection signal="pressed" from="VBoxContainer/VBoxContainer/Add_Node_BTN" to="." method="_on_Add_Node_BTN_pressed"]
75
+[connection signal="connection_request" from="VBoxContainer/GraphEdit" to="." method="_on_GraphEdit_connection_request"]
76
+[connection signal="disconnection_request" from="VBoxContainer/GraphEdit" to="." method="_on_GraphEdit_disconnection_request"]

+ 52
- 0
addons/EXP-System-Dialog/Dialog Editor/Editor/Editor.tscn View File

@@ -0,0 +1,52 @@
1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Editor/editor.gd" type="Script" id=1]
4
+
5
+[node name="WindowDialog" type="WindowDialog"]
6
+anchor_left = 0.5
7
+anchor_top = 0.5
8
+anchor_right = 0.5
9
+anchor_bottom = 0.5
10
+margin_left = -540.0
11
+margin_top = -384.0
12
+margin_right = 540.0
13
+margin_bottom = 384.0
14
+window_title = "Node Editor"
15
+resizable = true
16
+script = ExtResource( 1 )
17
+__meta__ = {
18
+"_edit_use_anchors_": false
19
+}
20
+
21
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
22
+anchor_right = 1.0
23
+anchor_bottom = 1.0
24
+margin_left = 13.0
25
+margin_top = 13.0
26
+margin_right = -13.0
27
+margin_bottom = -13.0
28
+__meta__ = {
29
+"_edit_use_anchors_": false
30
+}
31
+
32
+[node name="TextEdit" type="TextEdit" parent="VBoxContainer"]
33
+margin_right = 1054.0
34
+margin_bottom = 718.0
35
+size_flags_horizontal = 3
36
+size_flags_vertical = 3
37
+smooth_scrolling = true
38
+__meta__ = {
39
+"_edit_use_anchors_": false
40
+}
41
+
42
+[node name="OK_BTN" type="Button" parent="VBoxContainer"]
43
+margin_left = 503.0
44
+margin_top = 722.0
45
+margin_right = 550.0
46
+margin_bottom = 742.0
47
+hint_tooltip = "Close the node editor."
48
+size_flags_horizontal = 4
49
+size_flags_vertical = 0
50
+text = "Close"
51
+[connection signal="text_changed" from="VBoxContainer/TextEdit" to="." method="_on_TextEdit_text_changed"]
52
+[connection signal="pressed" from="VBoxContainer/OK_BTN" to="." method="_on_OK_BTN_pressed"]

+ 21
- 0
addons/EXP-System-Dialog/Dialog Editor/Editor/editor.gd View File

@@ -0,0 +1,21 @@
1
+tool
2
+extends WindowDialog
3
+
4
+onready var _Text_Editor = self.get_node("VBoxContainer/TextEdit")
5
+
6
+var _Target_Node
7
+
8
+#Public Methods
9
+
10
+func set_target_node(node):
11
+	self._Target_Node = node
12
+	self._Text_Editor.text = node.get_text()
13
+
14
+#Callback Methods
15
+
16
+func _on_OK_BTN_pressed():
17
+	self.visible = false
18
+
19
+
20
+func _on_TextEdit_text_changed():
21
+	self._Target_Node.set_text(self._Text_Editor.text)

+ 111
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn View File

@@ -0,0 +1,111 @@
1
+[gd_scene load_steps=3 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd" type="Script" id=1]
4
+[ext_resource path="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg" type="Texture" id=2]
5
+
6
+
7
+[node name="Line" type="GraphNode"]
8
+margin_right = 324.0
9
+margin_bottom = 137.0
10
+rect_min_size = Vector2( 324, 137 )
11
+title = "Line"
12
+offset = Vector2( 40, 40 )
13
+show_close = true
14
+resizable = true
15
+slot/0/left_enabled = true
16
+slot/0/left_type = 0
17
+slot/0/left_color = Color( 1, 1, 1, 1 )
18
+slot/0/right_enabled = true
19
+slot/0/right_type = 0
20
+slot/0/right_color = Color( 1, 1, 1, 1 )
21
+slot/1/left_enabled = false
22
+slot/1/left_type = 0
23
+slot/1/left_color = Color( 1, 1, 1, 1 )
24
+slot/1/right_enabled = false
25
+slot/1/right_type = 0
26
+slot/1/right_color = Color( 1, 1, 1, 1 )
27
+script = ExtResource( 1 )
28
+__meta__ = {
29
+"_edit_use_anchors_": false
30
+}
31
+
32
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
33
+margin_left = 16.0
34
+margin_top = 39.0
35
+margin_right = 380.0
36
+margin_bottom = 131.0
37
+size_flags_horizontal = 3
38
+size_flags_vertical = 3
39
+__meta__ = {
40
+"_edit_use_anchors_": false
41
+}
42
+
43
+[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
44
+margin_right = 364.0
45
+margin_bottom = 64.0
46
+
47
+[node name="TextEdit" type="TextEdit" parent="VBoxContainer/HBoxContainer2"]
48
+margin_right = 328.0
49
+margin_bottom = 64.0
50
+rect_min_size = Vector2( 256, 64 )
51
+size_flags_horizontal = 3
52
+size_flags_vertical = 3
53
+smooth_scrolling = true
54
+
55
+[node name="Editor_BTN" type="Button" parent="VBoxContainer/HBoxContainer2"]
56
+margin_left = 332.0
57
+margin_right = 364.0
58
+margin_bottom = 64.0
59
+rect_min_size = Vector2( 32, 0 )
60
+hint_tooltip = "Expand this node's text editor."
61
+icon = ExtResource( 2 )
62
+expand_icon = true
63
+
64
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
65
+margin_top = 68.0
66
+margin_right = 364.0
67
+margin_bottom = 92.0
68
+alignment = 1
69
+
70
+[node name="Save_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
71
+margin_right = 125.0
72
+margin_bottom = 24.0
73
+hint_tooltip = "Save the current text as a template that can quickly loaded into new nodes."
74
+text = "Save Template As"
75
+
76
+[node name="Load_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
77
+margin_left = 129.0
78
+margin_right = 235.0
79
+margin_bottom = 24.0
80
+hint_tooltip = "Load a template from file."
81
+text = "Load Template"
82
+
83
+[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
84
+margin_left = 239.0
85
+margin_right = 243.0
86
+margin_bottom = 24.0
87
+
88
+[node name="Link_LBL" type="Label" parent="VBoxContainer/HBoxContainer"]
89
+margin_left = 247.0
90
+margin_top = 5.0
91
+margin_right = 286.0
92
+margin_bottom = 19.0
93
+text = "Slots: "
94
+
95
+[node name="Link_SpinBox" type="SpinBox" parent="VBoxContainer/HBoxContainer"]
96
+margin_left = 290.0
97
+margin_right = 364.0
98
+margin_bottom = 24.0
99
+hint_tooltip = "Change the number of output slots on this node."
100
+min_value = 1.0
101
+value = 1.0
102
+rounded = true
103
+allow_greater = true
104
+[connection signal="close_request" from="." to="." method="_on_Line_close_request"]
105
+[connection signal="offset_changed" from="." to="." method="_on_Line_offset_changed"]
106
+[connection signal="resize_request" from="." to="." method="_on_Line_resize_request"]
107
+[connection signal="text_changed" from="VBoxContainer/HBoxContainer2/TextEdit" to="." method="_on_TextEdit_text_changed"]
108
+[connection signal="pressed" from="VBoxContainer/HBoxContainer2/Editor_BTN" to="." method="_on_Editor_BTN_pressed"]
109
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Save_BTN" to="." method="_on_Save_BTN_pressed"]
110
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Load_BTN" to="." method="_on_Load_BTN_pressed"]
111
+[connection signal="value_changed" from="VBoxContainer/HBoxContainer/Link_SpinBox" to="." method="_on_Link_SpinBox_value_changed"]

+ 1
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg View File

@@ -0,0 +1 @@
1
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1v5l1.793-1.793 2.5 2.5 1.4141-1.4141-2.5-2.5 1.793-1.793h-5zm9 0 1.793 1.793-2.5 2.5 1.4141 1.4141 2.5-2.5 1.793 1.793v-5h-5zm-4.707 8.293-2.5 2.5-1.793-1.793v5h5l-1.793-1.793 2.5-2.5-1.4141-1.4141zm5.4141 0-1.4141 1.4141 2.5 2.5-1.793 1.793h5v-5l-1.793 1.793-2.5-2.5z" fill="#e0e0e0"/></svg>

+ 34
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg.import View File

@@ -0,0 +1,34 @@
1
+[remap]
2
+
3
+importer="texture"
4
+type="StreamTexture"
5
+path="res://.import/icon_distraction_free.svg-5120bf5545890a3868c1108c903f7cd9.stex"
6
+metadata={
7
+"vram_texture": false
8
+}
9
+
10
+[deps]
11
+
12
+source_file="res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/icon_distraction_free.svg"
13
+dest_files=[ "res://.import/icon_distraction_free.svg-5120bf5545890a3868c1108c903f7cd9.stex" ]
14
+
15
+[params]
16
+
17
+compress/mode=0
18
+compress/lossy_quality=0.7
19
+compress/hdr_mode=0
20
+compress/bptc_ldr=0
21
+compress/normal_map=0
22
+flags/repeat=0
23
+flags/filter=true
24
+flags/mipmaps=false
25
+flags/anisotropic=false
26
+flags/srgb=2
27
+process/fix_alpha_border=true
28
+process/premult_alpha=false
29
+process/HDR_as_SRGB=false
30
+process/invert_color=false
31
+stream=false
32
+size_limit=0
33
+detect_3d=true
34
+svg/scale=1.0

+ 114
- 0
addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/line_node.gd View File

@@ -0,0 +1,114 @@
1
+tool
2
+extends GraphNode
3
+
4
+signal changed_offset(nid, vec2)
5
+signal changed_size(this)
6
+signal changed_slots(this)
7
+signal erased(this)
8
+signal pressed_editor(this)
9
+signal pressed_load(this)
10
+signal pressed_save(this)
11
+signal text_changed(nid, new_text)
12
+
13
+onready var _Link_SpinBox = self.get_node("VBoxContainer/HBoxContainer/Link_SpinBox")
14
+onready var _Text_Editor = self.get_node("VBoxContainer/HBoxContainer2/TextEdit")
15
+
16
+var _nid : int = 0
17
+var _slot_amount : int = 1
18
+
19
+#Virtual Methods
20
+
21
+func _ready():
22
+	self._update_slots()
23
+
24
+#Callback Methods
25
+
26
+func _on_Editor_BTN_pressed():
27
+	self.emit_signal("pressed_editor", self)
28
+
29
+
30
+func _on_Line_close_request():
31
+	self.emit_signal("erased", self)
32
+
33
+
34
+func _on_Line_offset_changed():
35
+	self.emit_signal("changed_offset", self._nid, self.offset)
36
+
37
+
38
+func _on_Line_resize_request(new_minsize):
39
+	self.rect_size = new_minsize
40
+	self.emit_signal("changed_size", self)
41
+
42
+
43
+func _on_Link_SpinBox_value_changed(value):
44
+	self._slot_amount = int(self._Link_SpinBox.value)
45
+	self._update_slots()
46
+	self.emit_signal("changed_slots", self)
47
+
48
+
49
+func _on_Load_BTN_pressed():
50
+	self.emit_signal("pressed_load", self)
51
+
52
+
53
+func _on_Save_BTN_pressed():
54
+	self.emit_signal("pressed_save", self)
55
+
56
+
57
+func _on_TextEdit_text_changed():
58
+	self.emit_signal("text_changed", self._nid, self._Text_Editor.text)
59
+
60
+#Public Methods
61
+
62
+func get_nid() -> int:
63
+	return self._nid
64
+
65
+
66
+func get_slot_amount() -> int:
67
+	return self._slot_amount
68
+
69
+
70
+func get_text() -> String:
71
+	return self._Text_Editor.text
72
+
73
+
74
+func set_nid(new_nid):
75
+	self._nid = new_nid
76
+	var new_name = "NID " + str(new_nid)
77
+	self.title = new_name
78
+	self.name = new_name
79
+
80
+
81
+func set_slot_amount(new_amount : int):
82
+	self._slot_amount = new_amount
83
+
84
+
85
+func set_text(new_text : String):
86
+	self._Text_Editor.text = new_text
87
+	self.emit_signal("text_changed", self._nid, new_text)
88
+
89
+#Private Methods
90
+
91
+func _clear_link_labels():
92
+	var children = self.get_children()
93
+	for child in children:
94
+		if child is Label:
95
+			child.free()
96
+
97
+
98
+func _update_slots():
99
+	self.clear_all_slots()
100
+	self._clear_link_labels()
101
+	self.set_slot(0, true, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
102
+	var base_link_label = Label.new()
103
+	base_link_label.text = "0"
104
+	base_link_label.align = Label.ALIGN_RIGHT
105
+	self.add_child(base_link_label)
106
+	self.move_child(base_link_label, 0)
107
+	var last_output_link_label = base_link_label
108
+	for slot in range(1, self._slot_amount):
109
+		self.set_slot(slot, false, 0, Color(1.0, 1.0, 1.0, 1.0), true, 0, Color(1.0, 1.0, 1.0, 1.0), null, null)
110
+		var output_link_label = Label.new()
111
+		output_link_label.text = str(slot)
112
+		output_link_label.align = Label.ALIGN_RIGHT
113
+		self.add_child_below_node(last_output_link_label, output_link_label)
114
+		last_output_link_label = output_link_label

+ 224
- 0
addons/EXP-System-Dialog/Dialog Editor/dialog_editor.gd View File

@@ -0,0 +1,224 @@
1
+tool
2
+extends Control
3
+
4
+signal back_BTN_pressed
5
+signal close_BTN_pressed
6
+
7
+onready var _Graph = self.get_node("VBoxContainer/GraphEdit")
8
+onready var _Human_Readable_LBL = self.get_node("VBoxContainer/VBoxContainer/Human_Readable_LBL")
9
+
10
+var _Editor_TSCN = preload("res://addons/EXP-System-Dialog/Dialog Editor/Editor/Editor.tscn")
11
+var _LineNode = preload("res://addons/EXP-System-Dialog/Dialog Editor/Nodes/Line/Line_Node.tscn")
12
+var _NodeTemplate= preload("res://addons/EXP-System-Dialog/Resource_NodeTemplate/EXP_NodeTemplate.gd")
13
+
14
+var _did : int = -1
15
+var _Editor
16
+var _Load_Template : EditorFileDialog
17
+var _Save_Template_As : EditorFileDialog
18
+var _Story_Editor
19
+var _Target_Node
20
+
21
+#Virtual Methods
22
+
23
+func _ready():
24
+	self._setup_dialogs()
25
+	self._Editor = _Editor_TSCN.instance()
26
+	self.add_child(self._Editor)
27
+
28
+#Callback Methods
29
+
30
+func _on_Add_Node_BTN_pressed():
31
+	var new_nid = self._Story_Editor.create_node(self._did, "line")
32
+	var new_line_node = self._LineNode.instance()
33
+	new_line_node.offset += self._Graph.scroll_offset
34
+	new_line_node.set_nid(new_nid)
35
+	new_line_node.connect("erased", self, "_on_Node_erased")
36
+	new_line_node.connect("changed_offset", self, "_on_Node_changed_offset")
37
+	new_line_node.connect("text_changed", self, "_on_Node_text_changed")
38
+	new_line_node.connect("pressed_save", self, "_on_Node_pressed_save")
39
+	new_line_node.connect("pressed_load", self, "_on_Node_pressed_load")
40
+	new_line_node.connect("pressed_editor", self, "_on_Node_pressed_editor")
41
+	new_line_node.connect("changed_slots", self, "_on_Node_changed_slots")
42
+	new_line_node.connect("changed_size", self, "_on_Node_changed_size")
43
+	var slot_count = self._Story_Editor.get_node_property(self._did, new_nid, "slot_amount")
44
+	self._Story_Editor.set_node_property(self._did, new_nid, "rect_size", new_line_node.rect_size)
45
+	new_line_node.set_slot_amount(slot_count)
46
+	self._Graph.add_child(new_line_node)
47
+
48
+
49
+func _on_Back_BTN_pressed():
50
+	self.emit_signal("back_BTN_pressed")
51
+
52
+
53
+func _on_Close_BTN_pressed():
54
+	self.emit_signal("close_BTN_pressed")
55
+
56
+
57
+func _on_GraphEdit_connection_request(from, from_slot, to, to_slot):
58
+	self._Graph.connect_node(from, from_slot, to, to_slot)
59
+	var from_node = self._Graph.get_node(from)
60
+	var to_node = self._Graph.get_node(to)
61
+	var from_node_nid = from_node.get_nid()
62
+	var to_node_nid = to_node.get_nid()
63
+	self._Story_Editor.set_link(self._did, from_node_nid, from_slot, to_node_nid)
64
+
65
+
66
+func _on_GraphEdit_disconnection_request(from, from_slot, to, to_slot):
67
+	self._Graph.disconnect_node(from, from_slot, to, to_slot)
68
+	var from_node = self._Graph.get_node(from)
69
+	var from_node_nid = from_node.get_nid()
70
+	self._Story_Editor.erase_link(self._did, from_node_nid, from_slot)
71
+
72
+
73
+func _on_Load_Template_file_selected(filename):
74
+	var file_data = load(filename)
75
+	if not file_data.TYPE == "EXP_Dialog_Node_Template_editor":
76
+		return
77
+	
78
+	self._Target_Node.set_text(file_data.template)
79
+
80
+
81
+func _on_Node_changed_offset(nid, new_offset):
82
+	self._Story_Editor.set_node_property(self._did, nid, "graph_offset", new_offset)
83
+
84
+
85
+func _on_Node_changed_size(changed_node):
86
+	var changed_node_nid = changed_node.get_nid()
87
+	self._Story_Editor.set_node_property(self._did, changed_node_nid, "rect_size", changed_node.rect_size)
88
+
89
+
90
+func _on_Node_changed_slots(changed_node):
91
+	var changed_node_nid = changed_node.get_nid()
92
+	self._unlink_nid_from_story(changed_node_nid)
93
+	self._disconnect_all_from(changed_node)
94
+	self._Story_Editor.set_node_property(self._did, changed_node_nid, "slot_amount",
95
+		changed_node.get_slot_amount())
96
+
97
+
98
+func _on_Node_erased(deleted_node):
99
+	var deleted_nid = deleted_node.get_nid()
100
+	self._unlink_nid_from_story(deleted_nid)
101
+	self._Story_Editor.erase_node(self._did, deleted_nid)
102
+	self._disconnect_all_from(deleted_node)
103
+	deleted_node.queue_free()
104
+
105
+
106
+func _on_Node_pressed_editor(node):
107
+	self._Editor.set_target_node(node)
108
+	self._Editor.visible = true
109
+
110
+
111
+func _on_Node_pressed_load(node):
112
+	self._Target_Node = node
113
+	self._Load_Template.popup_centered_ratio(0.7)
114
+
115
+
116
+func _on_Node_pressed_save(node):
117
+	self._Target_Node = node
118
+	self._Save_Template_As.popup_centered_ratio(0.7)
119
+
120
+
121
+func _on_Node_text_changed(nid, new_text):
122
+	self._Story_Editor.set_node_property(self._did, nid, "text", new_text)
123
+
124
+
125
+func _on_Save_Template_As_file_selected(filename):
126
+	var save_file = _NodeTemplate.new()
127
+	save_file.template = self._Target_Node.get_text()
128
+	ResourceSaver.save(filename, save_file)
129
+
130
+
131
+func _on_Story_Editor_dialog_edit_pressed(story_editor, did : int):
132
+	self._Story_Editor = story_editor
133
+	self._did = did
134
+	self._Human_Readable_LBL.text = self._Story_Editor.get_dialog_property(self._did, "human_readable_description")
135
+	self._clear_nodes()
136
+	self._populate_graph()
137
+	self._link_node_connections()
138
+
139
+#Private Methods
140
+
141
+func _clear_nodes():
142
+	self._Graph.clear_connections()
143
+	var children = self._Graph.get_children()
144
+	for child in children:
145
+		if child is GraphNode:
146
+			child.free()
147
+
148
+
149
+func _disconnect_all_from(node):
150
+	var node_name = node.name
151
+	var connection_list = self._Graph.get_connection_list()
152
+	for connection in connection_list:
153
+		if connection["from"] == node.name or connection["to"] == node.name:
154
+			self._Graph.disconnect_node(connection["from"], connection["from_port"],
155
+				connection["to"], connection["to_port"])
156
+
157
+
158
+func _link_node_connections():
159
+	var node_IDs = self._Story_Editor.get_nids(self._did)
160
+	for nID in node_IDs:
161
+		var slots = self._Story_Editor.get_link_slots(self._did, nID)
162
+		for slot in slots:
163
+			var to_node_nid = self._Story_Editor.get_nid_link_from(self._did, nID, slot)
164
+			var to = "NID " + str(to_node_nid)
165
+			var from = "NID " + str(nID)
166
+			self._Graph.connect_node(from, slot, to, 0)
167
+
168
+
169
+func _populate_graph():
170
+	var node_IDs = self._Story_Editor.get_nids(self._did)
171
+	for nID in node_IDs:
172
+		var new_node : GraphNode
173
+		match self._Story_Editor.get_node_property(self._did, nID, "type"):
174
+			"line":
175
+				new_node = _LineNode.instance()
176
+				var slot_count = self._Story_Editor.get_node_property(self._did, nID, "slot_amount")
177
+				new_node.set_slot_amount(slot_count)
178
+				self._Graph.add_child(new_node)
179
+				new_node.connect("erased", self, "_on_Node_erased")
180
+				var new_text = self._Story_Editor.get_node_property(self._did, nID, "text")
181
+				var new_rect_size = self._Story_Editor.get_node_property(self._did, nID, "rect_size")
182
+				new_node.rect_size = new_rect_size
183
+				new_node.set_text(new_text)
184
+				new_node.connect("text_changed", self, "_on_Node_text_changed")
185
+				new_node.connect("pressed_save", self, "_on_Node_pressed_save")
186
+				new_node.connect("pressed_load", self, "_on_Node_pressed_load")
187
+				new_node.connect("pressed_editor", self, "_on_Node_pressed_editor")
188
+				new_node.connect("changed_slots", self, "_on_Node_changed_slots")
189
+				new_node.connect("changed_size", self, "_on_Node_changed_size")
190
+		
191
+		new_node.set_nid(nID)
192
+		new_node.offset = self._Story_Editor.get_node_property(self._did, nID, "graph_offset")
193
+		new_node.connect("changed_offset", self, "_on_Node_changed_offset")
194
+
195
+
196
+func _setup_dialogs():
197
+	self._Load_Template = EditorFileDialog.new()
198
+	self._Load_Template.mode = EditorFileDialog.MODE_OPEN_FILE
199
+	self._Load_Template.add_filter("*.res ; Template files")
200
+	self._Load_Template.resizable = true
201
+	self._Load_Template.access = EditorFileDialog.ACCESS_RESOURCES
202
+	self._Load_Template.current_dir = "res://"
203
+	self._Load_Template.connect("file_selected", self, "_on_Load_Template_file_selected")
204
+	self.add_child(self._Load_Template)
205
+	
206
+	self._Save_Template_As = EditorFileDialog.new()
207
+	self._Save_Template_As.mode = EditorFileDialog.MODE_SAVE_FILE
208
+	self._Save_Template_As.add_filter("*.res ; Template files")
209
+	self._Save_Template_As.resizable = true
210
+	self._Save_Template_As.access = EditorFileDialog.ACCESS_RESOURCES
211
+	self._Save_Template_As.current_dir = "res://"
212
+	self._Save_Template_As.connect("file_selected", self, "_on_Save_Template_As_file_selected")
213
+	self.add_child(self._Save_Template_As)
214
+
215
+
216
+func _unlink_nid_from_story(removed_nid):
217
+	self._Story_Editor.erase_all_links(self._did, removed_nid)
218
+	var nIDs = self._Story_Editor.get_nids(self._did)
219
+	for nID in nIDs:
220
+		var node_slots = self._Story_Editor.get_link_slots(self._did, nID)
221
+		for slot in node_slots:
222
+			var to_node_nid = self._Story_Editor.get_nid_link_from(self._did, nID, slot)
223
+			if to_node_nid == removed_nid:
224
+				self._Story_Editor.erase_link(self._did, nID, slot)

BIN
addons/EXP-System-Dialog/Images/de.png View File


+ 34
- 0
addons/EXP-System-Dialog/Images/de.png.import View File

@@ -0,0 +1,34 @@
1
+[remap]
2
+
3
+importer="texture"
4
+type="StreamTexture"
5
+path="res://.import/de.png-fbe4565917c56d102e03dea598024725.stex"
6
+metadata={
7
+"vram_texture": false
8
+}
9
+
10
+[deps]
11
+
12
+source_file="res://addons/EXP-System-Dialog/Images/de.png"
13
+dest_files=[ "res://.import/de.png-fbe4565917c56d102e03dea598024725.stex" ]
14
+
15
+[params]
16
+
17
+compress/mode=0
18
+compress/lossy_quality=0.7
19
+compress/hdr_mode=0
20
+compress/bptc_ldr=0
21
+compress/normal_map=0
22
+flags/repeat=0
23
+flags/filter=true
24
+flags/mipmaps=false
25
+flags/anisotropic=false
26
+flags/srgb=2
27
+process/fix_alpha_border=true
28
+process/premult_alpha=false
29
+process/HDR_as_SRGB=false
30
+process/invert_color=false
31
+stream=false
32
+size_limit=0
33
+detect_3d=true
34
+svg/scale=1.0

BIN
addons/EXP-System-Dialog/Images/icon.png View File


+ 34
- 0
addons/EXP-System-Dialog/Images/icon.png.import View File

@@ -0,0 +1,34 @@
1
+[remap]
2
+
3
+importer="texture"
4
+type="StreamTexture"
5
+path="res://.import/icon.png-47dc6e8cad94817cb2e2b72e131ff5fa.stex"
6
+metadata={
7
+"vram_texture": false
8
+}
9
+
10
+[deps]
11
+
12
+source_file="res://addons/EXP-System-Dialog/Images/icon.png"
13
+dest_files=[ "res://.import/icon.png-47dc6e8cad94817cb2e2b72e131ff5fa.stex" ]
14
+
15
+[params]
16
+
17
+compress/mode=0
18
+compress/lossy_quality=0.7
19
+compress/hdr_mode=0
20
+compress/bptc_ldr=0
21
+compress/normal_map=0
22
+flags/repeat=0
23
+flags/filter=true
24
+flags/mipmaps=false
25
+flags/anisotropic=false
26
+flags/srgb=2
27
+process/fix_alpha_border=true
28
+process/premult_alpha=false
29
+process/HDR_as_SRGB=false
30
+process/invert_color=false
31
+stream=false
32
+size_limit=0
33
+detect_3d=true
34
+svg/scale=1.0

BIN
addons/EXP-System-Dialog/Images/se.png View File


+ 34
- 0
addons/EXP-System-Dialog/Images/se.png.import View File

@@ -0,0 +1,34 @@
1
+[remap]
2
+
3
+importer="texture"
4
+type="StreamTexture"
5
+path="res://.import/se.png-e2b4f76b280be2edfdda792d18e61fd1.stex"
6
+metadata={
7
+"vram_texture": false
8
+}
9
+
10
+[deps]
11
+
12
+source_file="res://addons/EXP-System-Dialog/Images/se.png"
13
+dest_files=[ "res://.import/se.png-e2b4f76b280be2edfdda792d18e61fd1.stex" ]
14
+
15
+[params]
16
+
17
+compress/mode=0
18
+compress/lossy_quality=0.7
19
+compress/hdr_mode=0
20
+compress/bptc_ldr=0
21
+compress/normal_map=0
22
+flags/repeat=0
23
+flags/filter=true
24
+flags/mipmaps=false
25
+flags/anisotropic=false
26
+flags/srgb=2
27
+process/fix_alpha_border=true
28
+process/premult_alpha=false
29
+process/HDR_as_SRGB=false
30
+process/invert_color=false
31
+stream=false
32
+size_limit=0
33
+detect_3d=true
34
+svg/scale=1.0

+ 83
- 0
addons/EXP-System-Dialog/Reference_StoryReader/EXP_StoryReader.gd View File

@@ -0,0 +1,83 @@
1
+extends Reference
2
+
3
+var _story : Dictionary = {}
4
+var _names : Dictionary = {}
5
+
6
+
7
+func get_dids() -> Array:
8
+	return self._story.keys()
9
+
10
+
11
+func get_did_via_record_name(name : String) -> int:
12
+	assert(self._names.has(name))
13
+	return self._names[name]
14
+
15
+
16
+func get_nid_from_slot(did : int, nid : int, slot : int) -> int:
17
+	assert(self.has_did(did))
18
+	assert(self.has_nid(did, nid))
19
+	assert(self.has_slot(did, nid, slot))
20
+	return self._story[did]["nodes"][nid]["links"][slot]
21
+
22
+
23
+func get_nid_via_exact_text(did : int, query : String) -> int:
24
+	assert(self.has_did(did))
25
+	
26
+	for nid in self._story[did]["nodes"].keys():
27
+		if self._story[did]["nodes"][nid]["text"] == query:
28
+			return nid
29
+	return -1
30
+
31
+
32
+func get_nids(did : int) -> Array:
33
+	assert(self.has_did(did))
34
+	return self._story[did]["nodes"].keys()
35
+
36
+
37
+func get_slot_count(did : int, nid : int) -> int:
38
+	assert(self.has_did(did))
39
+	assert(self.has_nid(did, nid))
40
+	return self._story[did]["nodes"][nid]["links"].size()
41
+
42
+
43
+func get_slots(did : int, nid : int) -> Array:
44
+	assert(self.has_did(did))
45
+	assert(self.has_nid(did, nid))
46
+	return self._story[did]["nodes"][nid]["links"].keys()
47
+
48
+
49
+func get_text(did : int, nid : int) -> String:
50
+	assert(self.has_did(did))
51
+	assert(self.has_nid(did, nid))
52
+	return self._story[did]["nodes"][nid]["text"]
53
+
54
+
55
+func has_did(did : int) -> bool:
56
+	return self._story.has(did)
57
+
58
+
59
+func has_nid(did : int, nid : int) -> bool:
60
+	assert(self.has_did(did))
61
+	return self._story[did]["nodes"].has(nid)
62
+
63
+
64
+func has_record_name(name : String) -> bool:
65
+	return self._names.has(name)
66
+
67
+
68
+func has_slot(did: int, nid : int, slot : int) -> bool:
69
+	assert(self.has_did(did))
70
+	assert(self.has_nid(did, nid))
71
+	return self._story[did]["nodes"][nid]["links"].has(slot)
72
+
73
+
74
+func read(file):
75
+	if not "TYPE" in file:
76
+		print_debug("Story reader failed to open file: ", str(file.filename))
77
+		return
78
+	if not file.TYPE == "EXP_Baked_Story" or file.TYPE == "EXP_Story_editor":
79
+		print_debug("Story reader failed to open file: ", str(file.filename))
80
+		return
81
+	
82
+	self._story = file.story
83
+	self._names = file.names

+ 6
- 0
addons/EXP-System-Dialog/Resource_BakedStory/EXP_BakedStory.gd View File

@@ -0,0 +1,6 @@
1
+tool
2
+extends Resource
3
+
4
+export(String) var TYPE = "EXP_Baked_Story"
5
+export(Dictionary) var story : Dictionary
6
+export(Dictionary) var names : Dictionary

+ 9
- 0
addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd View File

@@ -0,0 +1,9 @@
1
+tool
2
+extends Resource
3
+
4
+export(String) var TYPE = "EXP_Story_editor"
5
+
6
+export(Dictionary) var names : Dictionary
7
+export(Dictionary) var story : Dictionary
8
+export(Array) var available_dids : Array
9
+export(Array) var groups : Array

+ 6
- 0
addons/EXP-System-Dialog/Resource_NodeTemplate/EXP_NodeTemplate.gd View File

@@ -0,0 +1,6 @@
1
+tool
2
+extends Resource
3
+
4
+var TYPE = "EXP_Dialog_Node_Template_editor"
5
+
6
+export(String) var template

+ 109
- 0
addons/EXP-System-Dialog/Story Editor/Dialog Record/Dialog_Record.tscn View File

@@ -0,0 +1,109 @@
1
+[gd_scene load_steps=4 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/Dialog Record/dialog_record.gd" type="Script" id=1]
4
+
5
+[sub_resource type="StyleBoxFlat" id=1]
6
+bg_color = Color( 0.6, 0.6, 0.6, 0 )
7
+border_color = Color( 0.8, 0.8, 0.8, 0 )
8
+shadow_color = Color( 0, 0, 0, 0 )
9
+
10
+[sub_resource type="StyleBoxFlat" id=2]
11
+bg_color = Color( 0.6, 0.6, 0.6, 0 )
12
+border_color = Color( 0.8, 0.8, 0.8, 0 )
13
+shadow_color = Color( 0, 0, 0, 0 )
14
+
15
+[node name="Dialog_Record" type="Control"]
16
+anchor_right = 1.0
17
+rect_min_size = Vector2( 0, 28 )
18
+script = ExtResource( 1 )
19
+__meta__ = {
20
+"_edit_use_anchors_": false
21
+}
22
+
23
+[node name="ColorRect" type="ColorRect" parent="."]
24
+anchor_right = 1.0
25
+anchor_bottom = 1.0
26
+rect_min_size = Vector2( 0, 24 )
27
+size_flags_horizontal = 3
28
+color = Color( 1, 1, 1, 0.12549 )
29
+__meta__ = {
30
+"_edit_use_anchors_": false
31
+}
32
+
33
+[node name="HBoxContainer" type="HBoxContainer" parent="ColorRect"]
34
+anchor_right = 1.0
35
+anchor_bottom = 1.0
36
+__meta__ = {
37
+"_edit_use_anchors_": false
38
+}
39
+
40
+[node name="CheckBox" type="CheckBox" parent="ColorRect/HBoxContainer"]
41
+margin_right = 24.0
42
+margin_bottom = 28.0
43
+
44
+[node name="DID_LBL" type="Label" parent="ColorRect/HBoxContainer"]
45
+margin_left = 28.0
46
+margin_top = 7.0
47
+margin_right = 85.0
48
+margin_bottom = 21.0
49
+text = "DID: 101"
50
+
51
+[node name="VSeparator" type="VSeparator" parent="ColorRect/HBoxContainer"]
52
+margin_left = 89.0
53
+margin_right = 93.0
54
+margin_bottom = 28.0
55
+
56
+[node name="Edit_BTN" type="Button" parent="ColorRect/HBoxContainer"]
57
+margin_left = 97.0
58
+margin_right = 138.0
59
+margin_bottom = 28.0
60
+hint_tooltip = "Edit this dialog record in the Dialog Editor."
61
+text = "EDIT"
62
+flat = true
63
+
64
+[node name="VSeparator4" type="VSeparator" parent="ColorRect/HBoxContainer"]
65
+margin_left = 142.0
66
+margin_right = 146.0
67
+margin_bottom = 28.0
68
+
69
+[node name="Name_BTN" type="Button" parent="ColorRect/HBoxContainer"]
70
+margin_left = 150.0
71
+margin_right = 200.0
72
+margin_bottom = 28.0
73
+hint_tooltip = "Edit this dialog record in the Dialog Editor."
74
+text = "NAME"
75
+flat = true
76
+
77
+[node name="VSeparator2" type="VSeparator" parent="ColorRect/HBoxContainer"]
78
+margin_left = 204.0
79
+margin_right = 208.0
80
+margin_bottom = 28.0
81
+
82
+[node name="Group_BTN" type="OptionButton" parent="ColorRect/HBoxContainer"]
83
+margin_left = 212.0
84
+margin_right = 274.0
85
+margin_bottom = 28.0
86
+hint_tooltip = "View groups applied to this dialog record."
87
+text = "TAGS"
88
+flat = true
89
+
90
+[node name="VSeparator3" type="VSeparator" parent="ColorRect/HBoxContainer"]
91
+margin_left = 278.0
92
+margin_right = 282.0
93
+margin_bottom = 28.0
94
+
95
+[node name="Human_Readable_LineEdit" type="LineEdit" parent="ColorRect/HBoxContainer"]
96
+margin_left = 286.0
97
+margin_right = 476.0
98
+margin_bottom = 28.0
99
+custom_styles/focus = SubResource( 1 )
100
+custom_styles/normal = SubResource( 2 )
101
+text = "Human Readable Description"
102
+expand_to_text_length = true
103
+context_menu_enabled = false
104
+[connection signal="toggled" from="ColorRect/HBoxContainer/CheckBox" to="." method="_on_CheckBox_toggled"]
105
+[connection signal="pressed" from="ColorRect/HBoxContainer/Edit_BTN" to="." method="_on_Edit_BTN_pressed"]
106
+[connection signal="pressed" from="ColorRect/HBoxContainer/Name_BTN" to="." method="_on_Name_BTN_pressed"]
107
+[connection signal="pressed" from="ColorRect/HBoxContainer/Group_BTN" to="." method="_on_Group_BTN_pressed"]
108
+[connection signal="focus_exited" from="ColorRect/HBoxContainer/Human_Readable_LineEdit" to="." method="_on_Human_Readable_LineEdit_focus_exited"]
109
+[connection signal="text_changed" from="ColorRect/HBoxContainer/Human_Readable_LineEdit" to="." method="_on_Human_Readable_LineEdit_text_changed"]

+ 91
- 0
addons/EXP-System-Dialog/Story Editor/Dialog Record/dialog_record.gd View File

@@ -0,0 +1,91 @@
1
+tool
2
+extends Control
3
+
4
+signal changed_human_readable_text(did, text)
5
+signal checked(this)
6
+signal edit_pressed(did)
7
+signal rename_pressed(this)
8
+signal unchecked(this)
9
+
10
+onready var _DID_LBL = self.get_node("ColorRect/HBoxContainer/DID_LBL")
11
+onready var _Human_Readable_LineEdit = self.get_node("ColorRect/HBoxContainer/Human_Readable_LineEdit")
12
+onready var _Group_List = self.get_node("ColorRect/HBoxContainer/Group_BTN")
13
+onready var _Name_BTN = self.get_node("ColorRect/HBoxContainer/Name_BTN")
14
+onready var _Select_CheckBox = self.get_node("ColorRect/HBoxContainer/CheckBox")
15
+
16
+var _did : int = -1
17
+var _Story_Editor
18
+
19
+#Virtual Methods
20
+
21
+func _ready():
22
+	self.update_human_readable_description("Human Readable Description")
23
+
24
+#Callback Methods
25
+
26
+func _on_CheckBox_toggled(button_pressed):
27
+	if button_pressed:
28
+		self.emit_signal("checked", self)
29
+	else:
30
+		self.emit_signal("unchecked", self)
31
+
32
+
33
+func _on_Edit_BTN_pressed():
34
+	self.emit_signal("edit_pressed", self._did)
35
+
36
+
37
+func _on_Group_BTN_pressed():
38
+	var groups = self._Story_Editor.dialog_get_groups(self._did)
39
+	self._Group_List.clear()
40
+	self._Group_List.text = "TAGS"
41
+	for group in groups:
42
+		self._Group_List.get_popup().add_item(group)
43
+	for idx in range(self._Group_List.get_item_count()):
44
+		self._Group_List.set_item_disabled(idx, true)
45
+
46
+
47
+func _on_Human_Readable_LineEdit_focus_exited():
48
+	self._Human_Readable_LineEdit.deselect()
49
+
50
+
51
+func _on_Human_Readable_LineEdit_text_changed(new_text):
52
+	self.emit_signal("changed_human_readable_text", self._did, new_text)
53
+
54
+
55
+func _on_Name_BTN_pressed():
56
+	emit_signal("rename_pressed", self)
57
+
58
+#Public Methods
59
+
60
+func check():
61
+	self._Select_CheckBox.pressed = true
62
+
63
+
64
+func get_did():
65
+	return self._did
66
+
67
+
68
+func get_record_name():
69
+	return self._Name_BTN.text
70
+
71
+
72
+func set_did(new_did : int):
73
+	self._did = new_did
74
+	self._DID_LBL.text = "DID: " + str(new_did)
75
+
76
+
77
+func set_record_name(rename : String):
78
+	self._Name_BTN.text = rename
79
+
80
+
81
+func set_story_editor(editor):
82
+	self._Story_Editor = editor
83
+
84
+
85
+func uncheck():
86
+	self._Select_CheckBox.pressed = false
87
+
88
+
89
+func update_human_readable_description(new_text):
90
+	self._Human_Readable_LineEdit.text = new_text
91
+	self.emit_signal("changed_human_readable_text", self._did, new_text)

+ 92
- 0
addons/EXP-System-Dialog/Story Editor/Rename Record Box/Rename_Record_Box.tscn View File

@@ -0,0 +1,92 @@
1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/Rename Record Box/rename_record_box.gd" type="Script" id=1]
4
+
5
+[node name="Record_Rename_Box" type="WindowDialog"]
6
+anchor_left = 0.5
7
+anchor_top = 0.5
8
+anchor_right = 0.5
9
+anchor_bottom = 0.5
10
+margin_left = -193.0
11
+margin_top = -64.0
12
+margin_right = 193.0
13
+margin_bottom = 52.0
14
+rect_min_size = Vector2( 386, 116 )
15
+size_flags_horizontal = 3
16
+size_flags_vertical = 3
17
+window_title = "Rename Dialog Record"
18
+script = ExtResource( 1 )
19
+__meta__ = {
20
+"_edit_use_anchors_": false
21
+}
22
+
23
+[node name="MarginContainer" type="MarginContainer" parent="."]
24
+anchor_right = 1.0
25
+anchor_bottom = 1.0
26
+margin_left = 8.0
27
+margin_top = 8.0
28
+margin_right = -8.0
29
+margin_bottom = -8.0
30
+size_flags_horizontal = 3
31
+size_flags_vertical = 3
32
+__meta__ = {
33
+"_edit_use_anchors_": false
34
+}
35
+
36
+[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
37
+margin_right = 370.0
38
+margin_bottom = 100.0
39
+size_flags_horizontal = 3
40
+size_flags_vertical = 3
41
+__meta__ = {
42
+"_edit_use_anchors_": false
43
+}
44
+
45
+[node name="Name_LBL" type="Label" parent="MarginContainer/VBoxContainer"]
46
+margin_right = 370.0
47
+margin_bottom = 14.0
48
+text = "Name:"
49
+
50
+[node name="Spacer2" type="Control" parent="MarginContainer/VBoxContainer"]
51
+margin_top = 18.0
52
+margin_right = 370.0
53
+margin_bottom = 22.0
54
+rect_min_size = Vector2( 0, 4 )
55
+
56
+[node name="Name_LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
57
+margin_top = 26.0
58
+margin_right = 370.0
59
+margin_bottom = 50.0
60
+
61
+[node name="Spacer3" type="Control" parent="MarginContainer/VBoxContainer"]
62
+margin_top = 54.0
63
+margin_right = 370.0
64
+margin_bottom = 58.0
65
+rect_min_size = Vector2( 0, 4 )
66
+
67
+[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
68
+margin_top = 62.0
69
+margin_right = 370.0
70
+margin_bottom = 82.0
71
+alignment = 1
72
+
73
+[node name="Cancel_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
74
+margin_left = 106.0
75
+margin_right = 160.0
76
+margin_bottom = 20.0
77
+text = "Cancel"
78
+
79
+[node name="Spacer" type="Control" parent="MarginContainer/VBoxContainer/HBoxContainer"]
80
+margin_left = 164.0
81
+margin_right = 196.0
82
+margin_bottom = 20.0
83
+rect_min_size = Vector2( 32, 0 )
84
+
85
+[node name="Rename_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
86
+margin_left = 200.0
87
+margin_right = 264.0
88
+margin_bottom = 20.0
89
+text = "Rename"
90
+[connection signal="text_entered" from="MarginContainer/VBoxContainer/Name_LineEdit" to="." method="_on_Name_LineEdit_text_entered"]
91
+[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Cancel_BTN" to="." method="_on_Cancel_BTN_pressed"]
92
+[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Rename_BTN" to="." method="_on_Rename_BTN_pressed"]

+ 32
- 0
addons/EXP-System-Dialog/Story Editor/Rename Record Box/rename_record_box.gd View File

@@ -0,0 +1,32 @@
1
+tool
2
+extends WindowDialog
3
+
4
+signal rename_BTN_pressed(text)
5
+
6
+onready var _Name_LineEdit = self.get_node("MarginContainer/VBoxContainer/Name_LineEdit")
7
+
8
+var _Target_Record = null
9
+
10
+#Public Methods
11
+
12
+func get_target_record():
13
+	return self._Target_Record
14
+
15
+
16
+func set_target_record(record):
17
+	self._Target_Record = record
18
+	self._Name_LineEdit.text = record.get_record_name()
19
+
20
+#Callback Methods
21
+
22
+func _on_Cancel_BTN_pressed():
23
+	self.visible = false
24
+
25
+
26
+func _on_Rename_BTN_pressed():
27
+	self.visible = false
28
+	self.emit_signal("rename_BTN_pressed", self._Name_LineEdit.text)
29
+
30
+
31
+func _on_Name_LineEdit_text_entered(new_text):
32
+	self._on_Rename_BTN_pressed()

+ 268
- 0
addons/EXP-System-Dialog/Story Editor/Story_Editor.tscn View File

@@ -0,0 +1,268 @@
1
+[gd_scene load_steps=2 format=2]
2
+
3
+[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/story_editor.gd" type="Script" id=1]
4
+
5
+[node name="Story_Editor" type="Control"]
6
+anchor_right = 1.0
7
+anchor_bottom = 1.0
8
+rect_min_size = Vector2( 0, 256 )
9
+script = ExtResource( 1 )
10
+__meta__ = {
11
+"_edit_use_anchors_": false
12
+}
13
+
14
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
15
+anchor_right = 1.0
16
+anchor_bottom = 1.0
17
+__meta__ = {
18
+"_edit_use_anchors_": false
19
+}
20
+
21
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
22
+margin_right = 1024.0
23
+margin_bottom = 20.0
24
+
25
+[node name="Close_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
26
+margin_right = 47.0
27
+margin_bottom = 20.0
28
+text = "Close"
29
+
30
+[node name="VSeparator5" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
31
+margin_left = 51.0
32
+margin_right = 55.0
33
+margin_bottom = 20.0
34
+
35
+[node name="Story" type="MenuButton" parent="VBoxContainer/HBoxContainer"]
36
+margin_left = 59.0
37
+margin_right = 103.0
38
+margin_bottom = 20.0
39
+text = "Story"
40
+items = [ "New Story", null, 0, false, false, 0, 0, null, "", false, "Load Story", null, 0, false, false, 1, 0, null, "", false, "Save Story As", null, 0, false, false, 2, 0, null, "", false, "Bake Story As", null, 0, false, false, 3, 0, null, "", false, "Save CSV As", null, 0, false, false, 4, 0, null, "", false, "Load CSV", null, 0, false, false, 5, 0, null, "", false ]
41
+
42
+[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
43
+margin_left = 107.0
44
+margin_right = 111.0
45
+margin_bottom = 20.0
46
+
47
+[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer"]
48
+margin_left = 115.0
49
+margin_top = 3.0
50
+margin_right = 163.0
51
+margin_bottom = 17.0
52
+text = "Dialog: "
53
+
54
+[node name="Create_Dialog_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
55
+margin_left = 167.0
56
+margin_right = 220.0
57
+margin_bottom = 20.0
58
+hint_tooltip = "Create a new dialog record."
59
+text = "Create"
60
+
61
+[node name="Delete_Dialog_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
62
+margin_left = 224.0
63
+margin_right = 279.0
64
+margin_bottom = 20.0
65
+hint_tooltip = "Delete all checked dialog records."
66
+text = "Delete"
67
+
68
+[node name="Check_All_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
69
+margin_left = 283.0
70
+margin_right = 354.0
71
+margin_bottom = 20.0
72
+hint_tooltip = "Check all currently visible dialog records."
73
+text = "Check All"
74
+
75
+[node name="UnCheck_All_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
76
+margin_left = 358.0
77
+margin_right = 447.0
78
+margin_bottom = 20.0
79
+hint_tooltip = "Uncheck all currently visible dialog records."
80
+text = "UnCheck All"
81
+
82
+[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
83
+margin_left = 451.0
84
+margin_right = 455.0
85
+margin_bottom = 20.0
86
+
87
+[node name="Label3" type="Label" parent="VBoxContainer/HBoxContainer"]
88
+margin_left = 459.0
89
+margin_top = 3.0
90
+margin_right = 495.0
91
+margin_bottom = 17.0
92
+text = "Tags: "
93
+
94
+[node name="Group_Manager_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
95
+margin_left = 499.0
96
+margin_right = 590.0
97
+margin_bottom = 20.0
98
+hint_tooltip = "Toggles the Group Manager open and closed. Use the Group Manager to add and delete groups that can be applied to dialog records in this story project."
99
+toggle_mode = true
100
+text = "Tag Manager"
101
+
102
+[node name="VSeparator3" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
103
+margin_left = 594.0
104
+margin_right = 598.0
105
+margin_bottom = 20.0
106
+
107
+[node name="Apply_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
108
+margin_left = 602.0
109
+margin_right = 650.0
110
+margin_bottom = 20.0
111
+hint_tooltip = "Apply the group selected in the Group selector menu to all checked dialog records."
112
+text = "Apply"
113
+
114
+[node name="Remove_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
115
+margin_left = 654.0
116
+margin_right = 718.0
117
+margin_bottom = 20.0
118
+hint_tooltip = "Remove the group selected in the Group selector menu from all checked dialog records if the group is applied to them."
119
+text = "Remove"
120
+
121
+[node name="Group_Selector_BTN" type="OptionButton" parent="VBoxContainer/HBoxContainer"]
122
+margin_left = 722.0
123
+margin_right = 779.0
124
+margin_bottom = 20.0
125
+hint_tooltip = "Select a group to apply or remove from dialog records."
126
+text = "Tags"
127
+
128
+[node name="VSeparator4" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
129
+margin_left = 783.0
130
+margin_right = 787.0
131
+margin_bottom = 20.0
132
+
133
+[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
134
+margin_top = 24.0
135
+margin_right = 1024.0
136
+margin_bottom = 572.0
137
+size_flags_horizontal = 3
138
+size_flags_vertical = 3
139
+
140
+[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer3"]
141
+margin_right = 1024.0
142
+margin_bottom = 548.0
143
+size_flags_horizontal = 3
144
+size_flags_vertical = 3
145
+
146
+[node name="VScrollBar" type="ScrollContainer" parent="VBoxContainer/HBoxContainer3/Panel"]
147
+anchor_right = 1.0
148
+anchor_bottom = 1.0
149
+rect_min_size = Vector2( 0, 128 )
150
+size_flags_vertical = 3
151
+__meta__ = {
152
+"_edit_use_anchors_": false
153
+}
154
+
155
+[node name="Dialog_Record_Root" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3/Panel/VScrollBar"]
156
+margin_right = 1024.0
157
+margin_bottom = 548.0
158
+rect_min_size = Vector2( 0, 128 )
159
+size_flags_horizontal = 3
160
+size_flags_vertical = 3
161
+__meta__ = {
162
+"_edit_use_anchors_": false
163
+}
164
+
165
+[node name="Group_Manager" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3"]
166
+visible = false
167
+margin_left = 824.0
168
+margin_right = 1080.0
169
+margin_bottom = 716.0
170
+rect_min_size = Vector2( 256, 0 )
171
+__meta__ = {
172
+"_edit_use_anchors_": false
173
+}
174
+
175
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer3/Group_Manager"]
176
+margin_right = 256.0
177
+margin_bottom = 24.0
178
+
179
+[node name="Add_Group_LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
180
+margin_right = 156.0
181
+margin_bottom = 24.0
182
+rect_min_size = Vector2( 128, 0 )
183
+size_flags_horizontal = 3
184
+
185
+[node name="Add_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
186
+margin_left = 160.0
187
+margin_right = 197.0
188
+margin_bottom = 24.0
189
+hint_tooltip = "Add a group to this story project."
190
+text = "Add"
191
+__meta__ = {
192
+"_edit_use_anchors_": false
193
+}
194
+
195
+[node name="Delete_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
196
+margin_left = 201.0
197
+margin_right = 256.0
198
+margin_bottom = 24.0
199
+hint_tooltip = "Remove the selected group from this story project."
200
+text = "Delete"
201
+
202
+[node name="Group_ItemList" type="ItemList" parent="VBoxContainer/HBoxContainer3/Group_Manager"]
203
+margin_top = 28.0
204
+margin_right = 256.0
205
+margin_bottom = 716.0
206
+size_flags_vertical = 3
207
+
208
+[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
209
+margin_top = 576.0
210
+margin_right = 1024.0
211
+margin_bottom = 600.0
212
+rect_min_size = Vector2( 0, 24 )
213
+
214
+[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2"]
215
+margin_top = 5.0
216
+margin_right = 65.0
217
+margin_bottom = 19.0
218
+text = "Search by "
219
+
220
+[node name="Search_OptionButton" type="OptionButton" parent="VBoxContainer/HBoxContainer2"]
221
+margin_left = 69.0
222
+margin_right = 233.0
223
+margin_bottom = 24.0
224
+text = "Human Readable LBL"
225
+items = [ "Human Readable LBL", null, false, 0, null, "DID", null, false, 1, null ]
226
+selected = 0
227
+
228
+[node name="Search_LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"]
229
+margin_left = 237.0
230
+margin_right = 493.0
231
+margin_bottom = 24.0
232
+rect_min_size = Vector2( 256, 0 )
233
+
234
+[node name="Filter_MenuButton" type="MenuButton" parent="VBoxContainer/HBoxContainer2"]
235
+margin_left = 497.0
236
+margin_right = 537.0
237
+margin_bottom = 24.0
238
+hint_tooltip = "Select the groups that appear listed in the story editor."
239
+keep_pressed_outside = true
240
+text = "Tags"
241
+flat = false
242
+items = [ "-No Tags-", null, 1, true, false, 0, 0, null, "", false ]
243
+
244
+[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer2"]
245
+margin_left = 541.0
246
+margin_right = 545.0
247
+margin_bottom = 24.0
248
+
249
+[node name="Filename_LBL" type="Label" parent="VBoxContainer/HBoxContainer2"]
250
+margin_left = 549.0
251
+margin_top = 5.0
252
+margin_right = 640.0
253
+margin_bottom = 19.0
254
+text = "Unsaved Story"
255
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Close_BTN" to="." method="_on_Close_BTN_pressed"]
256
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Create_Dialog_BTN" to="." method="_on_Create_Dialog_BTN_pressed"]
257
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Delete_Dialog_BTN" to="." method="_on_Delete_Dialog_BTN_pressed"]
258
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Check_All_BTN" to="." method="_on_Check_All_BTN_pressed"]
259
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/UnCheck_All_BTN" to="." method="_on_Uncheck_All_BTN_pressed"]
260
+[connection signal="toggled" from="VBoxContainer/HBoxContainer/Group_Manager_BTN" to="." method="_on_Group_Manager_BTN_toggled"]
261
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Apply_Group_BTN" to="." method="_on_Apply_Group_BTN_pressed"]
262
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Remove_Group_BTN" to="." method="_on_Remove_Group_BTN_pressed"]
263
+[connection signal="pressed" from="VBoxContainer/HBoxContainer/Group_Selector_BTN" to="." method="_on_Group_Selector_BTN_pressed"]
264
+[connection signal="text_entered" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_LineEdit" to="." method="_on_Add_Group_LineEdit_text_entered"]
265
+[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_BTN" to="." method="_on_Add_Group_BTN_pressed"]
266
+[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Delete_Group_BTN" to="." method="_on_Delete_Group_BTN_pressed"]
267
+[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/Search_OptionButton" to="." method="_on_Search_OptionButton_item_selected"]
268
+[connection signal="text_changed" from="VBoxContainer/HBoxContainer2/Search_LineEdit" to="." method="_on_Search_LineEdit_text_changed"]

+ 753
- 0
addons/EXP-System-Dialog/Story Editor/story_editor.gd View File

@@ -0,0 +1,753 @@
1
+tool
2
+extends Control
3
+
4
+signal changed_story
5
+signal close_pressed
6
+signal dialog_edit_pressed(story, did)
7
+
8
+onready var _Dialog_Record_Root = self.get_node("VBoxContainer/HBoxContainer3/Panel/VScrollBar/Dialog_Record_Root")
9
+onready var _Dir = Directory.new()
10
+onready var _Filename_LBL = self.get_node("VBoxContainer/HBoxContainer2/Filename_LBL")
11
+onready var _Filter_Menu = self.get_node("VBoxContainer/HBoxContainer2/Filter_MenuButton")
12
+onready var _Group_List = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager/Group_ItemList")
13
+onready var _Group_Manager_Panel = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager")
14
+onready var _Group_Selector = self.get_node("VBoxContainer/HBoxContainer/Group_Selector_BTN")
15
+onready var _New_Group_LineEdit = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_LineEdit")
16
+onready var _Search_LineEdit = self.get_node("VBoxContainer/HBoxContainer2/Search_LineEdit")
17
+onready var _Search_Option_BTN = self.get_node("VBoxContainer/HBoxContainer2/Search_OptionButton")
18
+onready var _Story_Menu = self.get_node("VBoxContainer/HBoxContainer/Story")
19
+
20
+var _Dialog_Record = preload("res://addons/EXP-System-Dialog/Story Editor/Dialog Record/Dialog_Record.tscn")
21
+var _EXP_Baked_Story = preload("res://addons/EXP-System-Dialog/Resource_BakedStory/EXP_BakedStory.gd")
22
+var _EXP_Story = preload("res://addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd")
23
+var _Record_Rename_Box_TSCN = preload("res://addons/EXP-System-Dialog/Story Editor/Rename Record Box/Rename_Record_Box.tscn")
24
+
25
+var _available_dids : Array
26
+var _Bake_Story_As : EditorFileDialog
27
+var _checked_dialogs : Array = []
28
+var _groups : Array
29
+var _Load_CSV : EditorFileDialog
30
+var _Load_Story : EditorFileDialog
31
+var _record_names : Dictionary
32
+var _Record_Rename_Box
33
+var _Save_CSV_As : EditorFileDialog
34
+var _Save_Story_As : EditorFileDialog
35
+var _story : Dictionary
36
+
37
+#Virtual Methods
38
+
39
+func _ready():
40
+	self._create_rename_box()
41
+	self._populate_story_menu()
42
+	self._setup_dialogs()
43
+	self._Filter_Menu.get_popup().connect("index_pressed", self, "_on_Filter_Menu_index_pressed")
44
+	self._Filter_Menu.get_popup().hide_on_checkable_item_selection = false
45
+	self._populate_filter_menu()
46
+	self._populate_searchby_menu()
47
+
48
+#Callback Methods
49
+
50
+func _on_Add_Group_BTN_pressed():
51
+	self._add_group()
52
+
53
+
54
+func _on_Add_Group_LineEdit_text_entered(new_text):
55
+	self._add_group()
56
+
57
+
58
+func _on_Apply_Group_BTN_pressed():
59
+	var id = self._Group_Selector.get_selected_id()
60
+	if id == -1:
61
+		return
62
+	
63
+	var idx = self._Group_Selector.get_item_index(id)
64
+	var group = self._Group_Selector.get_popup().get_item_text(idx)
65
+	for record in self._checked_dialogs.duplicate():
66
+		var did = record.get_did()
67
+		self._dialog_apply_group(did, group)
68
+		record.uncheck()
69
+	self.emit_signal("changed_story")
70
+
71
+
72
+func _on_Bake_Story_As_file_selected(filename : String):
73
+	self._bake_data_to(filename)
74
+
75
+
76
+func _on_Bake_Story_BTN_pressed():
77
+	self._Bake_Story_As.popup_centered_ratio(0.7)
78
+
79
+
80
+func _on_Check_All_BTN_pressed():
81
+	var records = self._Dialog_Record_Root.get_children()
82
+	for record in records:
83
+		if record.visible:
84
+			record.check()
85
+
86
+
87
+func _on_Close_BTN_pressed():
88
+	self.emit_signal("close_pressed")
89
+
90
+
91
+func _on_Create_Dialog_BTN_pressed():
92
+	self._create_dialog_record()
93
+
94
+
95
+func _on_Delete_Dialog_BTN_pressed():
96
+	self._delete_checked_dialogs()
97
+
98
+
99
+func _on_Delete_Group_BTN_pressed():
100
+	var idxs = self._Group_List.get_selected_items()
101
+	var group
102
+	for idx in idxs:
103
+		group = self._Group_List.get_item_text(idx)
104
+		self._Group_List.remove_item(idx)
105
+		self._delete_group(group)
106
+	self._populate_group_selector()
107
+	self._populate_filter_menu()
108
+	
109
+
110
+func _on_Dialog_changed_human_readable_text(did : int, new_text : String):
111
+	self.set_dialog_property(did, "human_readable_description", new_text)
112
+	self.emit_signal("changed_story")
113
+
114
+
115
+func _on_Dialog_checked(dialog):
116
+	self._checked_dialogs.push_front(dialog)
117
+
118
+
119
+func _on_Dialog_edit_pressed(did : int):
120
+	self.emit_signal("dialog_edit_pressed", self, did)
121
+
122
+
123
+func _on_Dialog_unchecked(dialog):
124
+	self._checked_dialogs.erase(dialog)
125
+
126
+
127
+func _on_Filter_Menu_index_pressed(idx):
128
+	var checked = self._Filter_Menu.get_popup().is_item_checked(idx)
129
+	if not checked:
130
+		self._Filter_Menu.get_popup().set_item_checked(idx, true)
131
+	else:
132
+		self._Filter_Menu.get_popup().set_item_checked(idx, false)
133
+	self._update_filter()
134
+
135
+
136
+func _on_Group_Manager_BTN_toggled(button_pressed : bool):
137
+	if button_pressed:
138
+		self._Group_Manager_Panel.visible = true
139
+	else:
140
+		self._Group_Manager_Panel.visible = false
141
+
142
+
143
+func _on_Group_Selector_BTN_pressed():
144
+	self._populate_group_selector()
145
+
146
+
147
+func _on_Load_CSV_BTN_pressed():
148
+	self._Load_CSV.popup_centered_ratio(0.7)
149
+
150
+
151
+func _on_Load_CSV_file_selected(filepath : String):
152
+	var csv_file = File.new()
153
+	var status = csv_file.open(filepath, File.READ)
154
+	
155
+	if not status == OK:
156
+		print_debug("EXP_Story_Editor: Error loading file \"" + filepath + "\".")
157
+		return
158
+	
159
+	csv_file.get_csv_line()
160
+	
161
+	while not csv_file.eof_reached():
162
+		var line = csv_file.get_csv_line()
163
+		
164
+		if line.empty():
165
+			continue
166
+		
167
+		var did = int(line[0])
168
+		var nid = int(line[1])
169
+		var dialog = String(line[2])
170
+		
171
+		if not self._story.has(did):
172
+			continue
173
+		if not self._story[did]["nodes"].has(nid):
174
+			continue
175
+		
176
+		self._story[did]["nodes"][nid]["text"] = dialog
177
+	
178
+	csv_file.close()
179
+
180
+
181
+func _on_Load_Story_BTN_pressed():
182
+	self._Load_Story.popup_centered_ratio(0.7)
183
+
184
+
185
+func _on_Load_Story_file_selected(filename : String):
186
+	var file_data = load(filename)
187
+	if not file_data.TYPE == "EXP_Story_editor":
188
+		return
189
+	
190
+	self._clear_story()
191
+	self._load_data_from(file_data)
192
+	self._Filename_LBL.text = filename.get_file()
193
+	
194
+	for group in self._groups:
195
+		self._Group_List.add_item(group)
196
+	self._populate_filter_menu()
197
+	
198
+	for did in self.get_dids():
199
+		var new_dialog_record = _Dialog_Record.instance()
200
+		self._Dialog_Record_Root.add_child(new_dialog_record)
201
+		new_dialog_record.set_story_editor(self)
202
+		new_dialog_record.connect("checked", self, "_on_Dialog_checked")
203
+		new_dialog_record.connect("unchecked", self, "_on_Dialog_unchecked")
204
+		new_dialog_record.connect("changed_human_readable_text", self,
205
+			"_on_Dialog_changed_human_readable_text")
206
+		new_dialog_record.connect("edit_pressed", self, "_on_Dialog_edit_pressed")
207
+		new_dialog_record.connect("rename_pressed", self, "_on_Record_Rename_pressed")
208
+		
209
+		new_dialog_record.set_did(did)
210
+		var human_readable_description = self.get_dialog_property(did, "human_readable_description")
211
+		new_dialog_record.update_human_readable_description(human_readable_description)
212
+		
213
+		if self._story[did].has("name"):
214
+			var record_name = self._story[did]["name"]
215
+			new_dialog_record.set_record_name(record_name)
216
+
217
+
218
+func _on_New_Story_BTN_pressed():
219
+	self._clear_story()
220
+
221
+
222
+func _on_Record_Rename_pressed(record):
223
+	self._Record_Rename_Box.set_target_record(record)
224
+	self._Record_Rename_Box.visible = true
225
+
226
+
227
+func _on_Remove_Group_BTN_pressed():
228
+	var id = self._Group_Selector.get_selected_id()
229
+	if id == -1:
230
+		return
231
+		
232
+	var idx = self._Group_Selector.get_item_index(id)
233
+	var group = self._Group_Selector.get_popup().get_item_text(idx)
234
+	for record in self._checked_dialogs.duplicate():
235
+		var did = record.get_did()
236
+		self._dialog_remove_group(did, group)
237
+		record.uncheck()
238
+	self.emit_signal("changed_story")
239
+
240
+
241
+func _on_Rename_Box_Rename(rename : String):
242
+	var record = self._Record_Rename_Box.get_target_record()
243
+	var old_name = record.get_record_name()
244
+	var record_did = record.get_did()
245
+	
246
+	if rename.empty() or rename == "NAME":
247
+		record.set_record_name("NAME")
248
+		self._story[record_did].erase("name")
249
+		self._record_names.erase(old_name)
250
+		return
251
+	
252
+	if self._record_names.has(rename):
253
+		return
254
+	
255
+	self._record_names.erase(old_name)
256
+	
257
+	self._record_names[rename] = record_did
258
+	self._story[record_did]["name"] = rename
259
+	record.set_record_name(rename)
260
+
261
+
262
+func _on_Save_CSV_BTN_pressed():
263
+	self._Save_CSV_As.popup_centered_ratio(0.7)
264
+
265
+
266
+func _on_Save_CVS_As_file_selected(filepath : String):
267
+	var csv_file = File.new()
268
+	var status = csv_file.open(filepath, File.WRITE)
269
+	
270
+	if not status == OK:
271
+		print_debug("EXP_Story_Editor: Error saving csv file \"" + filepath + "\".")
272
+		return
273
+	
274
+	csv_file.store_csv_line(["DID", "NID", "Dialog"], ",")
275
+	
276
+	for did in self._story.keys():
277
+		for nid in self._story[did]["nodes"].keys():
278
+			var dialog = self._story[did]["nodes"][nid]["text"]
279
+			csv_file.store_csv_line([did, nid, dialog], ",")
280
+	
281
+	csv_file.close()
282
+
283
+
284
+func _on_Save_Story_As_file_selected(filename : String):
285
+	self._save_data_to(filename)
286
+	self._Filename_LBL.text = filename.get_file()
287
+
288
+
289
+func _on_Save_Story_BTN_pressed():
290
+	self._Save_Story_As.popup_centered_ratio(0.7)
291
+
292
+
293
+func _on_Search_LineEdit_text_changed(new_text : String):
294
+	self._update_filter()
295
+
296
+
297
+func _on_Search_OptionButton_item_selected(id):
298
+	self._update_filter()
299
+
300
+
301
+func _on_story_menu_option_pressed(id):
302
+	match id:
303
+		0:
304
+			self._on_New_Story_BTN_pressed()
305
+		1:
306
+			self._on_Load_Story_BTN_pressed()
307
+		2:
308
+			self._on_Save_Story_BTN_pressed()
309
+		3:
310
+			self._on_Bake_Story_BTN_pressed()
311
+		4:
312
+			self._on_Save_CSV_BTN_pressed()
313
+		5:
314
+			self._on_Load_CSV_BTN_pressed()
315
+
316
+
317
+func _on_Uncheck_All_BTN_pressed():
318
+	var records = self._Dialog_Record_Root.get_children()
319
+	for record in records:
320
+		if record.visible:
321
+			record.uncheck()
322
+
323
+#Public Methods
324
+
325
+func create_node(did : int, type : String) -> int:
326
+	var new_nid = self._generate_nid(did)
327
+	var node_data = {"type": type, "text": "", "graph_offset": Vector2(40, 40),
328
+	"rect_size": Vector2(0,0) ,"links": {}, "slot_amount": 1}
329
+	self._story[did]["nodes"][new_nid] = node_data
330
+	return new_nid
331
+
332
+func dialog_get_groups(did : int):
333
+	return self._story[did]["groups"]
334
+
335
+
336
+func erase_all_links(did: int, nid : int):
337
+	self._story[did]["nodes"][nid]["links"].clear()
338
+
339
+
340
+func erase_dialog(did : int):
341
+	self._story.erase(did)
342
+	self._make_did_available(did)
343
+
344
+
345
+func erase_link(did : int, nid : int, slot : int):
346
+	self._story[did]["nodes"][nid]["links"].erase(slot)
347
+
348
+
349
+func erase_node(did :int, nid :int):
350
+	self._story[did]["nodes"].erase(nid)
351
+	self._make_nid_available(did, nid)
352
+
353
+
354
+func get_dialog_property(did : int, property: String):
355
+	return self._story[did][property]
356
+
357
+
358
+func get_dids():
359
+	return self._story.keys()
360
+
361
+
362
+func get_link_slots(did : int, nid : int):
363
+	return self._story[did]["nodes"][nid]["links"].keys()
364
+
365
+
366
+func get_nid_link_from(did : int, nid: int, slot : int):
367
+	return self._story[did]["nodes"][nid]["links"][slot]
368
+
369
+
370
+func get_nids(did : int):
371
+	return self._story[did]["nodes"].keys()
372
+
373
+
374
+func get_node_property(did : int, nid : int, property: String):
375
+	return self._story[did]["nodes"][nid][property]
376
+
377
+
378
+func set_dialog_property(did : int, property : String , data):
379
+	self._story[did][property] = data
380
+
381
+
382
+func set_link(did : int, this_nid : int, slot : int, that_nid : int):
383
+	self._story[did]["nodes"][this_nid]["links"][slot] = that_nid
384
+
385
+
386
+func set_node_property(did : int, nid : int, property : String , data):
387
+	self._story[did]["nodes"][nid][property] = data
388
+
389
+
390
+func set_node_slot_count(did : int, nid : int, amount : int):
391
+	self._story[did]["nodes"][nid]["slot_amount"] = amount
392
+
393
+#Private Methods
394
+
395
+func _add_group():
396
+	var new_group_name = self._New_Group_LineEdit.text
397
+	if new_group_name == "" or self._groups.has(new_group_name):
398
+		return
399
+	
400
+	self._groups.push_back(new_group_name)
401
+	self._New_Group_LineEdit.text = ""
402
+	self._Group_List.add_item(new_group_name)
403
+	self._populate_filter_menu()
404
+	
405
+	var sort_list : Array
406
+	for idx in range(self._Group_List.get_item_count()):
407
+		var group = self._Group_List.get_item_text(idx)
408
+		sort_list.push_back(group)
409
+	sort_list.sort()
410
+	self._Group_List.clear()
411
+	for group in sort_list:
412
+		self._Group_List.add_item(group)
413
+
414
+
415
+func _bake_data() :
416
+	var baked_story = self._story.duplicate(true)
417
+	for did in baked_story.keys():
418
+		baked_story[did].erase("name")
419
+		baked_story[did].erase("groups")
420
+		baked_story[did].erase("available_nid")
421
+		baked_story[did].erase("human_readable_description")
422
+		for nid in baked_story[did]["nodes"].keys():
423
+			baked_story[did]["nodes"][nid].erase("type")
424
+			baked_story[did]["nodes"][nid].erase("graph_offset")
425
+			baked_story[did]["nodes"][nid].erase("rect_size")
426
+			baked_story[did]["nodes"][nid].erase("slot_amount")
427
+	return baked_story.duplicate(true)
428
+
429
+
430
+func _bake_data_to(filename):
431
+	var file_data
432
+	if self._Dir.file_exists(filename):
433
+		file_data = load(filename)
434
+		if file_data.TYPE == "EXP_Baked_Story":
435
+			file_data.story = self._bake_data()
436
+			file_data.names = self._record_names.duplicate(true)
437
+			ResourceSaver.save(filename, file_data)
438
+	else:
439
+		file_data = _EXP_Baked_Story.new()
440
+		file_data.story = self._bake_data()
441
+		file_data.names = self._record_names.duplicate(true)
442
+		ResourceSaver.save(filename, file_data)
443
+
444
+
445
+func _clear_group_manager():
446
+	self._groups.clear()
447
+	for idx in range(self._Group_List.get_item_count()):
448
+		self._Group_List.remove_item(0)
449
+		self._populate_group_selector()
450
+		self._Filter_Menu.get_popup().clear()
451
+
452
+
453
+func _clear_story():
454
+	self._remove_all_records()
455
+	self._clear_group_manager()
456
+	self._populate_filter_menu()
457
+	self._story.clear()
458
+	self._available_dids.clear()
459
+	self._checked_dialogs.clear()
460
+	self._record_names.clear()
461
+	self._Filename_LBL.text = "Unsaved Story"
462
+	self.emit_signal("changed_story")
463
+
464
+
465
+func _create_dialog() -> int:
466
+	var new_did = self._generate_did()
467
+	var dialog_data = {"human_readable_description":
468
+		"New Dialog - Enter Human Readable Description",
469
+		"groups": [],
470
+		"available_nid": [],
471
+		"nodes": {}}
472
+	self._story[new_did] = dialog_data
473
+	return new_did
474
+
475
+
476
+func _create_dialog_record():
477
+	var new_did = self._create_dialog()
478
+	
479
+	var new_dialog_record = _Dialog_Record.instance()
480
+	self._Dialog_Record_Root.add_child(new_dialog_record)
481
+	new_dialog_record.set_story_editor(self)
482
+	
483
+	new_dialog_record.connect("checked", self, "_on_Dialog_checked")
484
+	new_dialog_record.connect("unchecked", self, "_on_Dialog_unchecked")
485
+	new_dialog_record.connect("changed_human_readable_text", self,
486
+		"_on_Dialog_changed_human_readable_text")
487
+	new_dialog_record.connect("edit_pressed", self, "_on_Dialog_edit_pressed")
488
+	new_dialog_record.connect("rename_pressed", self, "_on_Record_Rename_pressed")
489
+	
490
+	new_dialog_record.set_did(new_did)
491
+	new_dialog_record.update_human_readable_description(
492
+		"New Dialog - Enter Human Readable Description.")
493
+
494
+
495
+func _create_rename_box():
496
+	self._Record_Rename_Box = _Record_Rename_Box_TSCN.instance()
497
+	self._Record_Rename_Box.connect("rename_BTN_pressed", self, "_on_Rename_Box_Rename")
498
+	self.add_child(self._Record_Rename_Box)
499
+
500
+
501
+func _delete_checked_dialogs():
502
+	for dialog in self._checked_dialogs:
503
+		self._delete_dialog(dialog)
504
+	self._checked_dialogs.clear()
505
+	self.emit_signal("changed_story")
506
+
507
+
508
+func _delete_dialog(dialog):
509
+	var did = dialog.get_did()
510
+	self.erase_dialog(did)
511
+	self._remove_record(dialog)
512
+
513
+
514
+func _delete_group(group):
515
+	self._groups.erase(group)
516
+	self._remove_group_from_story(group)
517
+
518
+
519
+func _dialog_apply_group(did : int, group : String):
520
+	if not self._story[did]["groups"].has(group):
521
+		self._story[did]["groups"].push_back(group)
522
+
523
+
524
+func _dialog_remove_group(did : int, group : String):
525
+	if self._story[did]["groups"].has(group):
526
+		self._story[did]["groups"].erase(group)
527
+
528
+
529
+func _generate_did() -> int:
530
+	if not self._available_dids.empty():
531
+		return self._available_dids.pop_front()
532
+	else:
533
+		return self._story.size() + 1
534
+
535
+
536
+func _generate_nid(did : int) -> int:
537
+	if not self._story[did]["available_nid"].empty():
538
+		return self._story[did]["available_nid"].pop_front()
539
+	else:
540
+		return self._story[did]["nodes"].size() + 1
541
+
542
+
543
+func _load_data_from(new_story):
544
+	self._story = new_story.story.duplicate(true)
545
+	self._available_dids = new_story.available_dids.duplicate(true)
546
+	self._groups = new_story.groups.duplicate(true)
547
+	self._record_names = new_story.names.duplicate(true)
548
+	
549
+
550
+
551
+func _make_did_available(did : int):
552
+	self._available_dids.push_front(did)
553
+	self._available_dids.sort()
554
+
555
+
556
+func _make_nid_available(did : int, nid : int):
557
+	self._story[did]["available_nid"].push_front(nid)
558
+	self._story[did]["available_nid"].sort()
559
+
560
+
561
+func _make_records_visible():
562
+	var children = self._Dialog_Record_Root.get_children()
563
+	for child in children:
564
+		child.visible = true
565
+
566
+
567
+func _populate_filter_menu():
568
+	self._Filter_Menu.get_popup().clear()
569
+	self._Filter_Menu.get_popup().add_check_item("-No Tags-")
570
+	for group in self._groups:
571
+		self._Filter_Menu.get_popup().add_check_item(group)
572
+	for idx in range(self._Filter_Menu.get_popup().get_item_count()):
573
+		self._Filter_Menu.get_popup().set_item_checked(idx, true)
574
+
575
+
576
+func _populate_group_selector():
577
+	self._Group_Selector.clear()
578
+	self._Group_Selector.text = "Tags"
579
+	for group in self._groups:
580
+		self._Group_Selector.get_popup().add_item(group)
581
+
582
+
583
+func _populate_searchby_menu():
584
+	self._Search_Option_BTN.clear()
585
+	self._Search_Option_BTN.get_popup().add_item("Human Readable LBL", 0)
586
+	self._Search_Option_BTN.get_popup().add_item("DID", 1)
587
+	self._Search_Option_BTN.get_popup().add_item("Record Name", 2)
588
+	self._Search_Option_BTN.select(0)
589
+
590
+func _populate_story_menu():
591
+	self._Story_Menu.get_popup().clear()
592
+	self._Story_Menu.get_popup().add_item("New Story", 0)
593
+	self._Story_Menu.get_popup().add_item("Load Story", 1)
594
+	self._Story_Menu.get_popup().add_item("Save Story As", 2)
595
+	self._Story_Menu.get_popup().add_item("Bake Story As", 3)
596
+	self._Story_Menu.get_popup().add_item("Save CSV As", 4)
597
+	self._Story_Menu.get_popup().add_item("Load CSV", 5)
598
+	self._Story_Menu.get_popup().connect("id_pressed", self, "_on_story_menu_option_pressed")
599
+
600
+
601
+func _remove_all_records():
602
+	var dialog_records = self._Dialog_Record_Root.get_children()
603
+	for record in dialog_records:
604
+		self._remove_record(record)
605
+
606
+
607
+func _remove_group_from_story(group : String):
608
+	for did in self._story:
609
+		if self._story[did]["groups"].has(group):
610
+			self._story[did]["groups"].erase(group)
611
+
612
+
613
+func _remove_record(dialog_record):
614
+	dialog_record.disconnect("checked", self, "_on_Dialog_checked")
615
+	dialog_record.disconnect("unchecked", self, "_on_Dialog_unchecked")
616
+	dialog_record.disconnect("changed_human_readable_text", self,
617
+		"_on_Dialog_changed_human_readable_text")
618
+	dialog_record.disconnect("rename_pressed", self, "_on_Record_Rename_pressed")
619
+	var record_name = dialog_record.get_record_name()
620
+	if not record_name == "NAME":
621
+		self._record_names.erase(record_name)
622
+	
623
+	dialog_record.free()
624
+
625
+
626
+func _save_data_to(filename):
627
+	var file_data
628
+	if self._Dir.file_exists(filename):
629
+		file_data = load(filename)
630
+		if file_data.TYPE == "EXP_Story_editor":
631
+			file_data.names = self._record_names.duplicate(true)
632
+			file_data.story = self._story.duplicate(true)
633
+			file_data.available_dids = self._available_dids.duplicate(true)
634
+			file_data.groups = self._groups.duplicate(true)
635
+			ResourceSaver.save(filename, file_data)
636
+	else:
637
+		file_data = _EXP_Story.new()
638
+		file_data.names = self._record_names.duplicate(true)
639
+		file_data.story = self._story.duplicate(true)
640
+		file_data.available_dids = self._available_dids.duplicate(true)
641
+		file_data.groups = self._groups.duplicate(true)
642
+		ResourceSaver.save(filename, file_data)
643
+
644
+
645
+func _setup_dialogs():
646
+	self._Load_Story = EditorFileDialog.new()
647
+	self._Load_Story.mode = EditorFileDialog.MODE_OPEN_FILE
648
+	self._Load_Story.add_filter("*.tres ; Story files")
649
+	self._Load_Story.resizable = true
650
+	self._Load_Story.access = EditorFileDialog.ACCESS_RESOURCES
651
+	self._Load_Story.current_dir = "res://"
652
+	self._Load_Story.connect("file_selected", self, "_on_Load_Story_file_selected")
653
+	self.add_child(self._Load_Story)
654
+	
655
+	self._Save_Story_As = EditorFileDialog.new()
656
+	self._Save_Story_As.mode = EditorFileDialog.MODE_SAVE_FILE
657
+	self._Save_Story_As.add_filter("*.tres ; Story files")
658
+	self._Save_Story_As.resizable = true
659
+	self._Save_Story_As.access = EditorFileDialog.ACCESS_RESOURCES
660
+	self._Save_Story_As.current_dir = "res://"
661
+	self._Save_Story_As.connect("file_selected", self, "_on_Save_Story_As_file_selected")
662
+	self.add_child(self._Save_Story_As)
663
+	
664
+	self._Bake_Story_As = EditorFileDialog.new()
665
+	self._Bake_Story_As.mode = EditorFileDialog.MODE_SAVE_FILE
666
+	self._Bake_Story_As.add_filter("*.tres ; Baked Story files")
667
+	self._Bake_Story_As.resizable = true
668
+	self._Bake_Story_As.access = EditorFileDialog.ACCESS_RESOURCES
669
+	self._Bake_Story_As.current_dir = "res://"
670
+	self._Bake_Story_As.connect("file_selected", self, "_on_Bake_Story_As_file_selected")
671
+	self.add_child(self._Bake_Story_As)
672
+	
673
+	self._Save_CSV_As = EditorFileDialog.new()
674
+	self._Save_CSV_As.mode = EditorFileDialog.MODE_SAVE_FILE
675
+	self._Save_CSV_As.add_filter("*.csv ; CSV files")
676
+	self._Save_CSV_As.resizable = true
677
+	self._Save_CSV_As.access = EditorFileDialog.ACCESS_FILESYSTEM
678
+	self._Save_CSV_As.current_dir = "res://"
679
+	self._Save_CSV_As.connect("file_selected", self, "_on_Save_CVS_As_file_selected")
680
+	self.add_child(self._Save_CSV_As)
681
+	
682
+	self._Load_CSV  = EditorFileDialog.new()
683
+	self._Load_CSV .mode = EditorFileDialog.MODE_OPEN_FILE
684
+	self._Load_CSV .add_filter("*.csv ; CSV files")
685
+	self._Load_CSV .resizable = true
686
+	self._Load_CSV .access = EditorFileDialog.ACCESS_FILESYSTEM
687
+	self._Load_CSV .current_dir = "res://"
688
+	self._Load_CSV .connect("file_selected", self, "_on_Load_CSV_file_selected")
689
+	self.add_child(self._Load_CSV)
690
+
691
+
692
+func _update_filter():
693
+	var new_text = self._Search_LineEdit.text
694
+	self._make_records_visible()
695
+	
696
+	var filter_groups : Array
697
+	for idx in range(self._Filter_Menu.get_popup().get_item_count()):
698
+		if self._Filter_Menu.get_popup().is_item_checked(idx):
699
+			var group = self._Filter_Menu.get_popup().get_item_text(idx)
700
+			filter_groups.push_back(group)
701
+	
702
+	var children = self._Dialog_Record_Root.get_children()
703
+	
704
+	var search_option = self._Search_Option_BTN.selected
705
+	
706
+	match search_option:
707
+		0: #Human Readable Search
708
+			for child in children:
709
+				var did = child.get_did()
710
+				var human_readable_description = self.get_dialog_property(did, "human_readable_description")
711
+				if human_readable_description.find(new_text) == -1 and not new_text.empty():
712
+					child.visible = false
713
+				else:
714
+					child.visible = false
715
+					if self._Filter_Menu.get_popup().get_item_count() == 0:
716
+						child.visible = true
717
+					var dialog_groups = self.dialog_get_groups(did)
718
+					if dialog_groups.empty() and filter_groups.has("-No Tags-"):
719
+						child.visible = true
720
+					for group in dialog_groups:
721
+						if filter_groups.has(group):
722
+							child.visible = true
723
+		1: #DID Search
724
+			for child in children:
725
+				var did = child.get_did()
726
+				if not new_text == str(did) and not new_text.empty():
727
+					child.visible = false
728
+				else:
729
+					child.visible = false
730
+					if self._Filter_Menu.get_popup().get_item_count() == 0:
731
+						child.visible = true
732
+					var dialog_groups = self.dialog_get_groups(did)
733
+					if dialog_groups.empty() and filter_groups.has("-No Tags-"):
734
+						child.visible = true
735
+					for group in dialog_groups:
736
+						if filter_groups.has(group):
737
+							child.visible = true
738
+		2: #Record Name Search 
739
+			for child in children:
740
+				var did = child.get_did()
741
+				var record_name = child.get_record_name()
742
+				if record_name.find(new_text) == -1 and not new_text.empty():
743
+					child.visible = false
744
+				else:
745
+					child.visible = false
746
+					if self._Filter_Menu.get_popup().get_item_count() == 0:
747
+						child.visible = true
748
+					var dialog_groups = self.dialog_get_groups(did)
749
+					if dialog_groups.empty() and filter_groups.has("-No Tags-"):
750
+						child.visible = true
751
+					for group in dialog_groups:
752
+						if filter_groups.has(group):
753
+							child.visible = true

+ 7
- 0
addons/EXP-System-Dialog/plugin.cfg View File

@@ -0,0 +1,7 @@
1
+[plugin]
2
+
3
+name="EXP_Dialog"
4
+description="EXPWorld's dialog technology."
5
+author="David Lipps @ EXPWorlds"
6
+version="1.1.0"
7
+script="plugin.gd"

+ 87
- 0
addons/EXP-System-Dialog/plugin.gd View File

@@ -0,0 +1,87 @@
1
+tool
2
+extends EditorPlugin
3
+
4
+var _Story_Editor = preload("res://addons/EXP-System-Dialog/Story Editor/Story_Editor.tscn")
5
+var _Story_Editor_Instance
6
+var _Story_Editor_BTN : ToolButton
7
+var _Dialog_Editor = preload("res://addons/EXP-System-Dialog/Dialog Editor/Dialog_Editor.tscn")
8
+var _Dialog_Editor_Instance
9
+var _Dialog_Editor_BTN : ToolButton
10
+
11
+
12
+func _enter_tree():
13
+	
14
+	self._Story_Editor_Instance = self._Story_Editor.instance()
15
+	self._Story_Editor_Instance.connect("close_pressed", self, "_on_StoryFile_Editor_close_pressed")
16
+	self._Story_Editor_BTN = self.add_control_to_bottom_panel(self._Story_Editor_Instance, "EXP StoryFile Editor")
17
+	self._Story_Editor_Instance.visible = false
18
+	self._Story_Editor_BTN.visible = false
19
+	self.add_tool_menu_item("EXP StoryFile Editor", self, "_on_StoryFile_Editor_opened")
20
+	
21
+	self._Dialog_Editor_Instance = self._Dialog_Editor.instance()
22
+	self._Dialog_Editor_BTN = self.add_control_to_bottom_panel(self._Dialog_Editor_Instance, "EXP Dialog Editor")
23
+	self._Dialog_Editor_BTN.visible = false
24
+	
25
+	self._Story_Editor_Instance.connect("dialog_edit_pressed",
26
+		self, "_on_Story_Editor_dialog_edit_pressed")
27
+	self._Story_Editor_Instance.connect("dialog_edit_pressed",
28
+		self._Dialog_Editor_Instance, "_on_Story_Editor_dialog_edit_pressed")
29
+	self._Dialog_Editor_Instance.connect("close_BTN_pressed", self,
30
+		"_on_Dialog_Editor_close_BTN_pressed")
31
+	self._Dialog_Editor_Instance.connect("back_BTN_pressed", self,
32
+		"_on_Dialog_Editor_back_BTN_pressed")
33
+	self._Story_Editor_Instance.connect("changed_story", self,
34
+		"_on_Story_Editor_changed_story")
35
+	
36
+	
37
+func _exit_tree():
38
+	
39
+	self._Story_Editor_Instance.disconnect("dialog_edit_pressed",
40
+		self, "_on_Story_Editor_dialog_edit_pressed")
41
+	self._Story_Editor_Instance.disconnect("dialog_edit_pressed",
42
+		self._Dialog_Editor_Instance, "_on_Story_Editor_dialog_edit_pressed")
43
+	self._Dialog_Editor_Instance.disconnect("close_BTN_pressed", self,
44
+		"_on_Dialog_Editor_close_BTN_pressed")
45
+	self._Dialog_Editor_Instance.disconnect("back_BTN_pressed", self,
46
+		"_on_Dialog_Editor_back_BTN_pressed")
47
+	self._Story_Editor_Instance.disconnect("changed_story", self,
48
+		"_on_Story_Editor_changed_story")
49
+		
50
+	self.remove_control_from_bottom_panel(self._Story_Editor_Instance)
51
+	self._Story_Editor_Instance.queue_free()
52
+	self.remove_control_from_bottom_panel(self._Dialog_Editor_Instance)
53
+	self._Dialog_Editor_Instance.queue_free()
54
+	self.remove_tool_menu_item("EXP StoryFile Editor")
55
+
56
+
57
+func _on_Story_Editor_dialog_edit_pressed(story, did):
58
+	self._Dialog_Editor_BTN.visible = true
59
+	self._Story_Editor_BTN.pressed = false
60
+	self._Dialog_Editor_BTN.pressed = true
61
+	self._Dialog_Editor_BTN.emit_signal("pressed")
62
+
63
+
64
+func _on_Dialog_Editor_close_BTN_pressed():
65
+	self._Dialog_Editor_BTN.pressed = false
66
+	self._Dialog_Editor_BTN.visible = false
67
+
68
+
69
+func _on_Story_Editor_changed_story():
70
+	self._Dialog_Editor_BTN.visible = false
71
+
72
+
73
+func _on_Dialog_Editor_back_BTN_pressed():
74
+	self._Story_Editor_BTN.pressed = true
75
+	self._Dialog_Editor_BTN.pressed = false
76
+	self._Story_Editor_BTN.emit_signal("pressed")
77
+
78
+
79
+func _on_StoryFile_Editor_opened(trash_parameter):
80
+	self._Story_Editor_BTN.visible = true
81
+
82
+
83
+func _on_StoryFile_Editor_close_pressed():
84
+	self._Story_Editor_Instance.visible = false
85
+	self._Story_Editor_BTN.visible = false
86
+	self._Dialog_Editor_Instance.visible = false
87
+	self._Dialog_Editor_BTN.visible = false

Loading…
Cancel
Save