Intial commit

This commit is contained in:
2020-05-15 20:02:56 -04:00
commit ad966789c5
284 changed files with 6546 additions and 0 deletions

View File

@ -0,0 +1,109 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/Dialog Record/dialog_record.gd" type="Script" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0.6, 0.6, 0.6, 0 )
border_color = Color( 0.8, 0.8, 0.8, 0 )
shadow_color = Color( 0, 0, 0, 0 )
[sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.6, 0.6, 0.6, 0 )
border_color = Color( 0.8, 0.8, 0.8, 0 )
shadow_color = Color( 0, 0, 0, 0 )
[node name="Dialog_Record" type="Control"]
anchor_right = 1.0
rect_min_size = Vector2( 0, 28 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ColorRect" type="ColorRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 24 )
size_flags_horizontal = 3
color = Color( 1, 1, 1, 0.12549 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="ColorRect"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CheckBox" type="CheckBox" parent="ColorRect/HBoxContainer"]
margin_right = 24.0
margin_bottom = 28.0
[node name="DID_LBL" type="Label" parent="ColorRect/HBoxContainer"]
margin_left = 28.0
margin_top = 7.0
margin_right = 85.0
margin_bottom = 21.0
text = "DID: 101"
[node name="VSeparator" type="VSeparator" parent="ColorRect/HBoxContainer"]
margin_left = 89.0
margin_right = 93.0
margin_bottom = 28.0
[node name="Edit_BTN" type="Button" parent="ColorRect/HBoxContainer"]
margin_left = 97.0
margin_right = 138.0
margin_bottom = 28.0
hint_tooltip = "Edit this dialog record in the Dialog Editor."
text = "EDIT"
flat = true
[node name="VSeparator4" type="VSeparator" parent="ColorRect/HBoxContainer"]
margin_left = 142.0
margin_right = 146.0
margin_bottom = 28.0
[node name="Name_BTN" type="Button" parent="ColorRect/HBoxContainer"]
margin_left = 150.0
margin_right = 200.0
margin_bottom = 28.0
hint_tooltip = "Edit this dialog record in the Dialog Editor."
text = "NAME"
flat = true
[node name="VSeparator2" type="VSeparator" parent="ColorRect/HBoxContainer"]
margin_left = 204.0
margin_right = 208.0
margin_bottom = 28.0
[node name="Group_BTN" type="OptionButton" parent="ColorRect/HBoxContainer"]
margin_left = 212.0
margin_right = 274.0
margin_bottom = 28.0
hint_tooltip = "View groups applied to this dialog record."
text = "TAGS"
flat = true
[node name="VSeparator3" type="VSeparator" parent="ColorRect/HBoxContainer"]
margin_left = 278.0
margin_right = 282.0
margin_bottom = 28.0
[node name="Human_Readable_LineEdit" type="LineEdit" parent="ColorRect/HBoxContainer"]
margin_left = 286.0
margin_right = 476.0
margin_bottom = 28.0
custom_styles/focus = SubResource( 1 )
custom_styles/normal = SubResource( 2 )
text = "Human Readable Description"
expand_to_text_length = true
context_menu_enabled = false
[connection signal="toggled" from="ColorRect/HBoxContainer/CheckBox" to="." method="_on_CheckBox_toggled"]
[connection signal="pressed" from="ColorRect/HBoxContainer/Edit_BTN" to="." method="_on_Edit_BTN_pressed"]
[connection signal="pressed" from="ColorRect/HBoxContainer/Name_BTN" to="." method="_on_Name_BTN_pressed"]
[connection signal="pressed" from="ColorRect/HBoxContainer/Group_BTN" to="." method="_on_Group_BTN_pressed"]
[connection signal="focus_exited" from="ColorRect/HBoxContainer/Human_Readable_LineEdit" to="." method="_on_Human_Readable_LineEdit_focus_exited"]
[connection signal="text_changed" from="ColorRect/HBoxContainer/Human_Readable_LineEdit" to="." method="_on_Human_Readable_LineEdit_text_changed"]

View File

@ -0,0 +1,91 @@
tool
extends Control
signal changed_human_readable_text(did, text)
signal checked(this)
signal edit_pressed(did)
signal rename_pressed(this)
signal unchecked(this)
onready var _DID_LBL = self.get_node("ColorRect/HBoxContainer/DID_LBL")
onready var _Human_Readable_LineEdit = self.get_node("ColorRect/HBoxContainer/Human_Readable_LineEdit")
onready var _Group_List = self.get_node("ColorRect/HBoxContainer/Group_BTN")
onready var _Name_BTN = self.get_node("ColorRect/HBoxContainer/Name_BTN")
onready var _Select_CheckBox = self.get_node("ColorRect/HBoxContainer/CheckBox")
var _did : int = -1
var _Story_Editor
#Virtual Methods
func _ready():
self.update_human_readable_description("Human Readable Description")
#Callback Methods
func _on_CheckBox_toggled(button_pressed):
if button_pressed:
self.emit_signal("checked", self)
else:
self.emit_signal("unchecked", self)
func _on_Edit_BTN_pressed():
self.emit_signal("edit_pressed", self._did)
func _on_Group_BTN_pressed():
var groups = self._Story_Editor.dialog_get_groups(self._did)
self._Group_List.clear()
self._Group_List.text = "TAGS"
for group in groups:
self._Group_List.get_popup().add_item(group)
for idx in range(self._Group_List.get_item_count()):
self._Group_List.set_item_disabled(idx, true)
func _on_Human_Readable_LineEdit_focus_exited():
self._Human_Readable_LineEdit.deselect()
func _on_Human_Readable_LineEdit_text_changed(new_text):
self.emit_signal("changed_human_readable_text", self._did, new_text)
func _on_Name_BTN_pressed():
emit_signal("rename_pressed", self)
#Public Methods
func check():
self._Select_CheckBox.pressed = true
func get_did():
return self._did
func get_record_name():
return self._Name_BTN.text
func set_did(new_did : int):
self._did = new_did
self._DID_LBL.text = "DID: " + str(new_did)
func set_record_name(rename : String):
self._Name_BTN.text = rename
func set_story_editor(editor):
self._Story_Editor = editor
func uncheck():
self._Select_CheckBox.pressed = false
func update_human_readable_description(new_text):
self._Human_Readable_LineEdit.text = new_text
self.emit_signal("changed_human_readable_text", self._did, new_text)

View File

@ -0,0 +1,92 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/Rename Record Box/rename_record_box.gd" type="Script" id=1]
[node name="Record_Rename_Box" type="WindowDialog"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -193.0
margin_top = -64.0
margin_right = 193.0
margin_bottom = 52.0
rect_min_size = Vector2( 386, 116 )
size_flags_horizontal = 3
size_flags_vertical = 3
window_title = "Rename Dialog Record"
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 8.0
margin_right = -8.0
margin_bottom = -8.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_right = 370.0
margin_bottom = 100.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Name_LBL" type="Label" parent="MarginContainer/VBoxContainer"]
margin_right = 370.0
margin_bottom = 14.0
text = "Name:"
[node name="Spacer2" type="Control" parent="MarginContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 370.0
margin_bottom = 22.0
rect_min_size = Vector2( 0, 4 )
[node name="Name_LineEdit" type="LineEdit" parent="MarginContainer/VBoxContainer"]
margin_top = 26.0
margin_right = 370.0
margin_bottom = 50.0
[node name="Spacer3" type="Control" parent="MarginContainer/VBoxContainer"]
margin_top = 54.0
margin_right = 370.0
margin_bottom = 58.0
rect_min_size = Vector2( 0, 4 )
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VBoxContainer"]
margin_top = 62.0
margin_right = 370.0
margin_bottom = 82.0
alignment = 1
[node name="Cancel_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 106.0
margin_right = 160.0
margin_bottom = 20.0
text = "Cancel"
[node name="Spacer" type="Control" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 164.0
margin_right = 196.0
margin_bottom = 20.0
rect_min_size = Vector2( 32, 0 )
[node name="Rename_BTN" type="Button" parent="MarginContainer/VBoxContainer/HBoxContainer"]
margin_left = 200.0
margin_right = 264.0
margin_bottom = 20.0
text = "Rename"
[connection signal="text_entered" from="MarginContainer/VBoxContainer/Name_LineEdit" to="." method="_on_Name_LineEdit_text_entered"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Cancel_BTN" to="." method="_on_Cancel_BTN_pressed"]
[connection signal="pressed" from="MarginContainer/VBoxContainer/HBoxContainer/Rename_BTN" to="." method="_on_Rename_BTN_pressed"]

View File

@ -0,0 +1,32 @@
tool
extends WindowDialog
signal rename_BTN_pressed(text)
onready var _Name_LineEdit = self.get_node("MarginContainer/VBoxContainer/Name_LineEdit")
var _Target_Record = null
#Public Methods
func get_target_record():
return self._Target_Record
func set_target_record(record):
self._Target_Record = record
self._Name_LineEdit.text = record.get_record_name()
#Callback Methods
func _on_Cancel_BTN_pressed():
self.visible = false
func _on_Rename_BTN_pressed():
self.visible = false
self.emit_signal("rename_BTN_pressed", self._Name_LineEdit.text)
func _on_Name_LineEdit_text_entered(new_text):
self._on_Rename_BTN_pressed()

View File

@ -0,0 +1,268 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/EXP-System-Dialog/Story Editor/story_editor.gd" type="Script" id=1]
[node name="Story_Editor" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 256 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
margin_right = 1024.0
margin_bottom = 20.0
[node name="Close_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_right = 47.0
margin_bottom = 20.0
text = "Close"
[node name="VSeparator5" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
margin_left = 51.0
margin_right = 55.0
margin_bottom = 20.0
[node name="Story" type="MenuButton" parent="VBoxContainer/HBoxContainer"]
margin_left = 59.0
margin_right = 103.0
margin_bottom = 20.0
text = "Story"
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 ]
[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
margin_left = 107.0
margin_right = 111.0
margin_bottom = 20.0
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_left = 115.0
margin_top = 3.0
margin_right = 163.0
margin_bottom = 17.0
text = "Dialog: "
[node name="Create_Dialog_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 167.0
margin_right = 220.0
margin_bottom = 20.0
hint_tooltip = "Create a new dialog record."
text = "Create"
[node name="Delete_Dialog_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 224.0
margin_right = 279.0
margin_bottom = 20.0
hint_tooltip = "Delete all checked dialog records."
text = "Delete"
[node name="Check_All_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 283.0
margin_right = 354.0
margin_bottom = 20.0
hint_tooltip = "Check all currently visible dialog records."
text = "Check All"
[node name="UnCheck_All_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 358.0
margin_right = 447.0
margin_bottom = 20.0
hint_tooltip = "Uncheck all currently visible dialog records."
text = "UnCheck All"
[node name="VSeparator2" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
margin_left = 451.0
margin_right = 455.0
margin_bottom = 20.0
[node name="Label3" type="Label" parent="VBoxContainer/HBoxContainer"]
margin_left = 459.0
margin_top = 3.0
margin_right = 495.0
margin_bottom = 17.0
text = "Tags: "
[node name="Group_Manager_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 499.0
margin_right = 590.0
margin_bottom = 20.0
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."
toggle_mode = true
text = "Tag Manager"
[node name="VSeparator3" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
margin_left = 594.0
margin_right = 598.0
margin_bottom = 20.0
[node name="Apply_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 602.0
margin_right = 650.0
margin_bottom = 20.0
hint_tooltip = "Apply the group selected in the Group selector menu to all checked dialog records."
text = "Apply"
[node name="Remove_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer"]
margin_left = 654.0
margin_right = 718.0
margin_bottom = 20.0
hint_tooltip = "Remove the group selected in the Group selector menu from all checked dialog records if the group is applied to them."
text = "Remove"
[node name="Group_Selector_BTN" type="OptionButton" parent="VBoxContainer/HBoxContainer"]
margin_left = 722.0
margin_right = 779.0
margin_bottom = 20.0
hint_tooltip = "Select a group to apply or remove from dialog records."
text = "Tags"
[node name="VSeparator4" type="VSeparator" parent="VBoxContainer/HBoxContainer"]
margin_left = 783.0
margin_right = 787.0
margin_bottom = 20.0
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 24.0
margin_right = 1024.0
margin_bottom = 572.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="Panel" type="Panel" parent="VBoxContainer/HBoxContainer3"]
margin_right = 1024.0
margin_bottom = 548.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="VScrollBar" type="ScrollContainer" parent="VBoxContainer/HBoxContainer3/Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 128 )
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Dialog_Record_Root" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3/Panel/VScrollBar"]
margin_right = 1024.0
margin_bottom = 548.0
rect_min_size = Vector2( 0, 128 )
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Group_Manager" type="VBoxContainer" parent="VBoxContainer/HBoxContainer3"]
visible = false
margin_left = 824.0
margin_right = 1080.0
margin_bottom = 716.0
rect_min_size = Vector2( 256, 0 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/HBoxContainer3/Group_Manager"]
margin_right = 256.0
margin_bottom = 24.0
[node name="Add_Group_LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
margin_right = 156.0
margin_bottom = 24.0
rect_min_size = Vector2( 128, 0 )
size_flags_horizontal = 3
[node name="Add_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
margin_left = 160.0
margin_right = 197.0
margin_bottom = 24.0
hint_tooltip = "Add a group to this story project."
text = "Add"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Delete_Group_BTN" type="Button" parent="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer"]
margin_left = 201.0
margin_right = 256.0
margin_bottom = 24.0
hint_tooltip = "Remove the selected group from this story project."
text = "Delete"
[node name="Group_ItemList" type="ItemList" parent="VBoxContainer/HBoxContainer3/Group_Manager"]
margin_top = 28.0
margin_right = 256.0
margin_bottom = 716.0
size_flags_vertical = 3
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
margin_top = 576.0
margin_right = 1024.0
margin_bottom = 600.0
rect_min_size = Vector2( 0, 24 )
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2"]
margin_top = 5.0
margin_right = 65.0
margin_bottom = 19.0
text = "Search by "
[node name="Search_OptionButton" type="OptionButton" parent="VBoxContainer/HBoxContainer2"]
margin_left = 69.0
margin_right = 233.0
margin_bottom = 24.0
text = "Human Readable LBL"
items = [ "Human Readable LBL", null, false, 0, null, "DID", null, false, 1, null ]
selected = 0
[node name="Search_LineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"]
margin_left = 237.0
margin_right = 493.0
margin_bottom = 24.0
rect_min_size = Vector2( 256, 0 )
[node name="Filter_MenuButton" type="MenuButton" parent="VBoxContainer/HBoxContainer2"]
margin_left = 497.0
margin_right = 537.0
margin_bottom = 24.0
hint_tooltip = "Select the groups that appear listed in the story editor."
keep_pressed_outside = true
text = "Tags"
flat = false
items = [ "-No Tags-", null, 1, true, false, 0, 0, null, "", false ]
[node name="VSeparator" type="VSeparator" parent="VBoxContainer/HBoxContainer2"]
margin_left = 541.0
margin_right = 545.0
margin_bottom = 24.0
[node name="Filename_LBL" type="Label" parent="VBoxContainer/HBoxContainer2"]
margin_left = 549.0
margin_top = 5.0
margin_right = 640.0
margin_bottom = 19.0
text = "Unsaved Story"
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Close_BTN" to="." method="_on_Close_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Create_Dialog_BTN" to="." method="_on_Create_Dialog_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Delete_Dialog_BTN" to="." method="_on_Delete_Dialog_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Check_All_BTN" to="." method="_on_Check_All_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/UnCheck_All_BTN" to="." method="_on_Uncheck_All_BTN_pressed"]
[connection signal="toggled" from="VBoxContainer/HBoxContainer/Group_Manager_BTN" to="." method="_on_Group_Manager_BTN_toggled"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Apply_Group_BTN" to="." method="_on_Apply_Group_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Remove_Group_BTN" to="." method="_on_Remove_Group_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/Group_Selector_BTN" to="." method="_on_Group_Selector_BTN_pressed"]
[connection signal="text_entered" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_LineEdit" to="." method="_on_Add_Group_LineEdit_text_entered"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_BTN" to="." method="_on_Add_Group_BTN_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Delete_Group_BTN" to="." method="_on_Delete_Group_BTN_pressed"]
[connection signal="item_selected" from="VBoxContainer/HBoxContainer2/Search_OptionButton" to="." method="_on_Search_OptionButton_item_selected"]
[connection signal="text_changed" from="VBoxContainer/HBoxContainer2/Search_LineEdit" to="." method="_on_Search_LineEdit_text_changed"]

View File

@ -0,0 +1,753 @@
tool
extends Control
signal changed_story
signal close_pressed
signal dialog_edit_pressed(story, did)
onready var _Dialog_Record_Root = self.get_node("VBoxContainer/HBoxContainer3/Panel/VScrollBar/Dialog_Record_Root")
onready var _Dir = Directory.new()
onready var _Filename_LBL = self.get_node("VBoxContainer/HBoxContainer2/Filename_LBL")
onready var _Filter_Menu = self.get_node("VBoxContainer/HBoxContainer2/Filter_MenuButton")
onready var _Group_List = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager/Group_ItemList")
onready var _Group_Manager_Panel = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager")
onready var _Group_Selector = self.get_node("VBoxContainer/HBoxContainer/Group_Selector_BTN")
onready var _New_Group_LineEdit = self.get_node("VBoxContainer/HBoxContainer3/Group_Manager/HBoxContainer/Add_Group_LineEdit")
onready var _Search_LineEdit = self.get_node("VBoxContainer/HBoxContainer2/Search_LineEdit")
onready var _Search_Option_BTN = self.get_node("VBoxContainer/HBoxContainer2/Search_OptionButton")
onready var _Story_Menu = self.get_node("VBoxContainer/HBoxContainer/Story")
var _Dialog_Record = preload("res://addons/EXP-System-Dialog/Story Editor/Dialog Record/Dialog_Record.tscn")
var _EXP_Baked_Story = preload("res://addons/EXP-System-Dialog/Resource_BakedStory/EXP_BakedStory.gd")
var _EXP_Story = preload("res://addons/EXP-System-Dialog/Resource_EditorStory/EXP_EditorStory.gd")
var _Record_Rename_Box_TSCN = preload("res://addons/EXP-System-Dialog/Story Editor/Rename Record Box/Rename_Record_Box.tscn")
var _available_dids : Array
var _Bake_Story_As : EditorFileDialog
var _checked_dialogs : Array = []
var _groups : Array
var _Load_CSV : EditorFileDialog
var _Load_Story : EditorFileDialog
var _record_names : Dictionary
var _Record_Rename_Box
var _Save_CSV_As : EditorFileDialog
var _Save_Story_As : EditorFileDialog
var _story : Dictionary
#Virtual Methods
func _ready():
self._create_rename_box()
self._populate_story_menu()
self._setup_dialogs()
self._Filter_Menu.get_popup().connect("index_pressed", self, "_on_Filter_Menu_index_pressed")
self._Filter_Menu.get_popup().hide_on_checkable_item_selection = false
self._populate_filter_menu()
self._populate_searchby_menu()
#Callback Methods
func _on_Add_Group_BTN_pressed():
self._add_group()
func _on_Add_Group_LineEdit_text_entered(new_text):
self._add_group()
func _on_Apply_Group_BTN_pressed():
var id = self._Group_Selector.get_selected_id()
if id == -1:
return
var idx = self._Group_Selector.get_item_index(id)
var group = self._Group_Selector.get_popup().get_item_text(idx)
for record in self._checked_dialogs.duplicate():
var did = record.get_did()
self._dialog_apply_group(did, group)
record.uncheck()
self.emit_signal("changed_story")
func _on_Bake_Story_As_file_selected(filename : String):
self._bake_data_to(filename)
func _on_Bake_Story_BTN_pressed():
self._Bake_Story_As.popup_centered_ratio(0.7)
func _on_Check_All_BTN_pressed():
var records = self._Dialog_Record_Root.get_children()
for record in records:
if record.visible:
record.check()
func _on_Close_BTN_pressed():
self.emit_signal("close_pressed")
func _on_Create_Dialog_BTN_pressed():
self._create_dialog_record()
func _on_Delete_Dialog_BTN_pressed():
self._delete_checked_dialogs()
func _on_Delete_Group_BTN_pressed():
var idxs = self._Group_List.get_selected_items()
var group
for idx in idxs:
group = self._Group_List.get_item_text(idx)
self._Group_List.remove_item(idx)
self._delete_group(group)
self._populate_group_selector()
self._populate_filter_menu()
func _on_Dialog_changed_human_readable_text(did : int, new_text : String):
self.set_dialog_property(did, "human_readable_description", new_text)
self.emit_signal("changed_story")
func _on_Dialog_checked(dialog):
self._checked_dialogs.push_front(dialog)
func _on_Dialog_edit_pressed(did : int):
self.emit_signal("dialog_edit_pressed", self, did)
func _on_Dialog_unchecked(dialog):
self._checked_dialogs.erase(dialog)
func _on_Filter_Menu_index_pressed(idx):
var checked = self._Filter_Menu.get_popup().is_item_checked(idx)
if not checked:
self._Filter_Menu.get_popup().set_item_checked(idx, true)
else:
self._Filter_Menu.get_popup().set_item_checked(idx, false)
self._update_filter()
func _on_Group_Manager_BTN_toggled(button_pressed : bool):
if button_pressed:
self._Group_Manager_Panel.visible = true
else:
self._Group_Manager_Panel.visible = false
func _on_Group_Selector_BTN_pressed():
self._populate_group_selector()
func _on_Load_CSV_BTN_pressed():
self._Load_CSV.popup_centered_ratio(0.7)
func _on_Load_CSV_file_selected(filepath : String):
var csv_file = File.new()
var status = csv_file.open(filepath, File.READ)
if not status == OK:
print_debug("EXP_Story_Editor: Error loading file \"" + filepath + "\".")
return
csv_file.get_csv_line()
while not csv_file.eof_reached():
var line = csv_file.get_csv_line()
if line.empty():
continue
var did = int(line[0])
var nid = int(line[1])
var dialog = String(line[2])
if not self._story.has(did):
continue
if not self._story[did]["nodes"].has(nid):
continue
self._story[did]["nodes"][nid]["text"] = dialog
csv_file.close()
func _on_Load_Story_BTN_pressed():
self._Load_Story.popup_centered_ratio(0.7)
func _on_Load_Story_file_selected(filename : String):
var file_data = load(filename)
if not file_data.TYPE == "EXP_Story_editor":
return
self._clear_story()
self._load_data_from(file_data)
self._Filename_LBL.text = filename.get_file()
for group in self._groups:
self._Group_List.add_item(group)
self._populate_filter_menu()
for did in self.get_dids():
var new_dialog_record = _Dialog_Record.instance()
self._Dialog_Record_Root.add_child(new_dialog_record)
new_dialog_record.set_story_editor(self)
new_dialog_record.connect("checked", self, "_on_Dialog_checked")
new_dialog_record.connect("unchecked", self, "_on_Dialog_unchecked")
new_dialog_record.connect("changed_human_readable_text", self,
"_on_Dialog_changed_human_readable_text")
new_dialog_record.connect("edit_pressed", self, "_on_Dialog_edit_pressed")
new_dialog_record.connect("rename_pressed", self, "_on_Record_Rename_pressed")
new_dialog_record.set_did(did)
var human_readable_description = self.get_dialog_property(did, "human_readable_description")
new_dialog_record.update_human_readable_description(human_readable_description)
if self._story[did].has("name"):
var record_name = self._story[did]["name"]
new_dialog_record.set_record_name(record_name)
func _on_New_Story_BTN_pressed():
self._clear_story()
func _on_Record_Rename_pressed(record):
self._Record_Rename_Box.set_target_record(record)
self._Record_Rename_Box.visible = true
func _on_Remove_Group_BTN_pressed():
var id = self._Group_Selector.get_selected_id()
if id == -1:
return
var idx = self._Group_Selector.get_item_index(id)
var group = self._Group_Selector.get_popup().get_item_text(idx)
for record in self._checked_dialogs.duplicate():
var did = record.get_did()
self._dialog_remove_group(did, group)
record.uncheck()
self.emit_signal("changed_story")
func _on_Rename_Box_Rename(rename : String):
var record = self._Record_Rename_Box.get_target_record()
var old_name = record.get_record_name()
var record_did = record.get_did()
if rename.empty() or rename == "NAME":
record.set_record_name("NAME")
self._story[record_did].erase("name")
self._record_names.erase(old_name)
return
if self._record_names.has(rename):
return
self._record_names.erase(old_name)
self._record_names[rename] = record_did
self._story[record_did]["name"] = rename
record.set_record_name(rename)
func _on_Save_CSV_BTN_pressed():
self._Save_CSV_As.popup_centered_ratio(0.7)
func _on_Save_CVS_As_file_selected(filepath : String):
var csv_file = File.new()
var status = csv_file.open(filepath, File.WRITE)
if not status == OK:
print_debug("EXP_Story_Editor: Error saving csv file \"" + filepath + "\".")
return
csv_file.store_csv_line(["DID", "NID", "Dialog"], ",")
for did in self._story.keys():
for nid in self._story[did]["nodes"].keys():
var dialog = self._story[did]["nodes"][nid]["text"]
csv_file.store_csv_line([did, nid, dialog], ",")
csv_file.close()
func _on_Save_Story_As_file_selected(filename : String):
self._save_data_to(filename)
self._Filename_LBL.text = filename.get_file()
func _on_Save_Story_BTN_pressed():
self._Save_Story_As.popup_centered_ratio(0.7)
func _on_Search_LineEdit_text_changed(new_text : String):
self._update_filter()
func _on_Search_OptionButton_item_selected(id):
self._update_filter()
func _on_story_menu_option_pressed(id):
match id:
0:
self._on_New_Story_BTN_pressed()
1:
self._on_Load_Story_BTN_pressed()
2:
self._on_Save_Story_BTN_pressed()
3:
self._on_Bake_Story_BTN_pressed()
4:
self._on_Save_CSV_BTN_pressed()
5:
self._on_Load_CSV_BTN_pressed()
func _on_Uncheck_All_BTN_pressed():
var records = self._Dialog_Record_Root.get_children()
for record in records:
if record.visible:
record.uncheck()
#Public Methods
func create_node(did : int, type : String) -> int:
var new_nid = self._generate_nid(did)
var node_data = {"type": type, "text": "", "graph_offset": Vector2(40, 40),
"rect_size": Vector2(0,0) ,"links": {}, "slot_amount": 1}
self._story[did]["nodes"][new_nid] = node_data
return new_nid
func dialog_get_groups(did : int):
return self._story[did]["groups"]
func erase_all_links(did: int, nid : int):
self._story[did]["nodes"][nid]["links"].clear()
func erase_dialog(did : int):
self._story.erase(did)
self._make_did_available(did)
func erase_link(did : int, nid : int, slot : int):
self._story[did]["nodes"][nid]["links"].erase(slot)
func erase_node(did :int, nid :int):
self._story[did]["nodes"].erase(nid)
self._make_nid_available(did, nid)
func get_dialog_property(did : int, property: String):
return self._story[did][property]
func get_dids():
return self._story.keys()
func get_link_slots(did : int, nid : int):
return self._story[did]["nodes"][nid]["links"].keys()
func get_nid_link_from(did : int, nid: int, slot : int):
return self._story[did]["nodes"][nid]["links"][slot]
func get_nids(did : int):
return self._story[did]["nodes"].keys()
func get_node_property(did : int, nid : int, property: String):
return self._story[did]["nodes"][nid][property]
func set_dialog_property(did : int, property : String , data):
self._story[did][property] = data
func set_link(did : int, this_nid : int, slot : int, that_nid : int):
self._story[did]["nodes"][this_nid]["links"][slot] = that_nid
func set_node_property(did : int, nid : int, property : String , data):
self._story[did]["nodes"][nid][property] = data
func set_node_slot_count(did : int, nid : int, amount : int):
self._story[did]["nodes"][nid]["slot_amount"] = amount
#Private Methods
func _add_group():
var new_group_name = self._New_Group_LineEdit.text
if new_group_name == "" or self._groups.has(new_group_name):
return
self._groups.push_back(new_group_name)
self._New_Group_LineEdit.text = ""
self._Group_List.add_item(new_group_name)
self._populate_filter_menu()
var sort_list : Array
for idx in range(self._Group_List.get_item_count()):
var group = self._Group_List.get_item_text(idx)
sort_list.push_back(group)
sort_list.sort()
self._Group_List.clear()
for group in sort_list:
self._Group_List.add_item(group)
func _bake_data() :
var baked_story = self._story.duplicate(true)
for did in baked_story.keys():
baked_story[did].erase("name")
baked_story[did].erase("groups")
baked_story[did].erase("available_nid")
baked_story[did].erase("human_readable_description")
for nid in baked_story[did]["nodes"].keys():
baked_story[did]["nodes"][nid].erase("type")
baked_story[did]["nodes"][nid].erase("graph_offset")
baked_story[did]["nodes"][nid].erase("rect_size")
baked_story[did]["nodes"][nid].erase("slot_amount")
return baked_story.duplicate(true)
func _bake_data_to(filename):
var file_data
if self._Dir.file_exists(filename):
file_data = load(filename)
if file_data.TYPE == "EXP_Baked_Story":
file_data.story = self._bake_data()
file_data.names = self._record_names.duplicate(true)
ResourceSaver.save(filename, file_data)
else:
file_data = _EXP_Baked_Story.new()
file_data.story = self._bake_data()
file_data.names = self._record_names.duplicate(true)
ResourceSaver.save(filename, file_data)
func _clear_group_manager():
self._groups.clear()
for idx in range(self._Group_List.get_item_count()):
self._Group_List.remove_item(0)
self._populate_group_selector()
self._Filter_Menu.get_popup().clear()
func _clear_story():
self._remove_all_records()
self._clear_group_manager()
self._populate_filter_menu()
self._story.clear()
self._available_dids.clear()
self._checked_dialogs.clear()
self._record_names.clear()
self._Filename_LBL.text = "Unsaved Story"
self.emit_signal("changed_story")
func _create_dialog() -> int:
var new_did = self._generate_did()
var dialog_data = {"human_readable_description":
"New Dialog - Enter Human Readable Description",
"groups": [],
"available_nid": [],
"nodes": {}}
self._story[new_did] = dialog_data
return new_did
func _create_dialog_record():
var new_did = self._create_dialog()
var new_dialog_record = _Dialog_Record.instance()
self._Dialog_Record_Root.add_child(new_dialog_record)
new_dialog_record.set_story_editor(self)
new_dialog_record.connect("checked", self, "_on_Dialog_checked")
new_dialog_record.connect("unchecked", self, "_on_Dialog_unchecked")
new_dialog_record.connect("changed_human_readable_text", self,
"_on_Dialog_changed_human_readable_text")
new_dialog_record.connect("edit_pressed", self, "_on_Dialog_edit_pressed")
new_dialog_record.connect("rename_pressed", self, "_on_Record_Rename_pressed")
new_dialog_record.set_did(new_did)
new_dialog_record.update_human_readable_description(
"New Dialog - Enter Human Readable Description.")
func _create_rename_box():
self._Record_Rename_Box = _Record_Rename_Box_TSCN.instance()
self._Record_Rename_Box.connect("rename_BTN_pressed", self, "_on_Rename_Box_Rename")
self.add_child(self._Record_Rename_Box)
func _delete_checked_dialogs():
for dialog in self._checked_dialogs:
self._delete_dialog(dialog)
self._checked_dialogs.clear()
self.emit_signal("changed_story")
func _delete_dialog(dialog):
var did = dialog.get_did()
self.erase_dialog(did)
self._remove_record(dialog)
func _delete_group(group):
self._groups.erase(group)
self._remove_group_from_story(group)
func _dialog_apply_group(did : int, group : String):
if not self._story[did]["groups"].has(group):
self._story[did]["groups"].push_back(group)
func _dialog_remove_group(did : int, group : String):
if self._story[did]["groups"].has(group):
self._story[did]["groups"].erase(group)
func _generate_did() -> int:
if not self._available_dids.empty():
return self._available_dids.pop_front()
else:
return self._story.size() + 1
func _generate_nid(did : int) -> int:
if not self._story[did]["available_nid"].empty():
return self._story[did]["available_nid"].pop_front()
else:
return self._story[did]["nodes"].size() + 1
func _load_data_from(new_story):
self._story = new_story.story.duplicate(true)
self._available_dids = new_story.available_dids.duplicate(true)
self._groups = new_story.groups.duplicate(true)
self._record_names = new_story.names.duplicate(true)
func _make_did_available(did : int):
self._available_dids.push_front(did)
self._available_dids.sort()
func _make_nid_available(did : int, nid : int):
self._story[did]["available_nid"].push_front(nid)
self._story[did]["available_nid"].sort()
func _make_records_visible():
var children = self._Dialog_Record_Root.get_children()
for child in children:
child.visible = true
func _populate_filter_menu():
self._Filter_Menu.get_popup().clear()
self._Filter_Menu.get_popup().add_check_item("-No Tags-")
for group in self._groups:
self._Filter_Menu.get_popup().add_check_item(group)
for idx in range(self._Filter_Menu.get_popup().get_item_count()):
self._Filter_Menu.get_popup().set_item_checked(idx, true)
func _populate_group_selector():
self._Group_Selector.clear()
self._Group_Selector.text = "Tags"
for group in self._groups:
self._Group_Selector.get_popup().add_item(group)
func _populate_searchby_menu():
self._Search_Option_BTN.clear()
self._Search_Option_BTN.get_popup().add_item("Human Readable LBL", 0)
self._Search_Option_BTN.get_popup().add_item("DID", 1)
self._Search_Option_BTN.get_popup().add_item("Record Name", 2)
self._Search_Option_BTN.select(0)
func _populate_story_menu():
self._Story_Menu.get_popup().clear()
self._Story_Menu.get_popup().add_item("New Story", 0)
self._Story_Menu.get_popup().add_item("Load Story", 1)
self._Story_Menu.get_popup().add_item("Save Story As", 2)
self._Story_Menu.get_popup().add_item("Bake Story As", 3)
self._Story_Menu.get_popup().add_item("Save CSV As", 4)
self._Story_Menu.get_popup().add_item("Load CSV", 5)
self._Story_Menu.get_popup().connect("id_pressed", self, "_on_story_menu_option_pressed")
func _remove_all_records():
var dialog_records = self._Dialog_Record_Root.get_children()
for record in dialog_records:
self._remove_record(record)
func _remove_group_from_story(group : String):
for did in self._story:
if self._story[did]["groups"].has(group):
self._story[did]["groups"].erase(group)
func _remove_record(dialog_record):
dialog_record.disconnect("checked", self, "_on_Dialog_checked")
dialog_record.disconnect("unchecked", self, "_on_Dialog_unchecked")
dialog_record.disconnect("changed_human_readable_text", self,
"_on_Dialog_changed_human_readable_text")
dialog_record.disconnect("rename_pressed", self, "_on_Record_Rename_pressed")
var record_name = dialog_record.get_record_name()
if not record_name == "NAME":
self._record_names.erase(record_name)
dialog_record.free()
func _save_data_to(filename):
var file_data
if self._Dir.file_exists(filename):
file_data = load(filename)
if file_data.TYPE == "EXP_Story_editor":
file_data.names = self._record_names.duplicate(true)
file_data.story = self._story.duplicate(true)
file_data.available_dids = self._available_dids.duplicate(true)
file_data.groups = self._groups.duplicate(true)
ResourceSaver.save(filename, file_data)
else:
file_data = _EXP_Story.new()
file_data.names = self._record_names.duplicate(true)
file_data.story = self._story.duplicate(true)
file_data.available_dids = self._available_dids.duplicate(true)
file_data.groups = self._groups.duplicate(true)
ResourceSaver.save(filename, file_data)
func _setup_dialogs():
self._Load_Story = EditorFileDialog.new()
self._Load_Story.mode = EditorFileDialog.MODE_OPEN_FILE
self._Load_Story.add_filter("*.tres ; Story files")
self._Load_Story.resizable = true
self._Load_Story.access = EditorFileDialog.ACCESS_RESOURCES
self._Load_Story.current_dir = "res://"
self._Load_Story.connect("file_selected", self, "_on_Load_Story_file_selected")
self.add_child(self._Load_Story)
self._Save_Story_As = EditorFileDialog.new()
self._Save_Story_As.mode = EditorFileDialog.MODE_SAVE_FILE
self._Save_Story_As.add_filter("*.tres ; Story files")
self._Save_Story_As.resizable = true
self._Save_Story_As.access = EditorFileDialog.ACCESS_RESOURCES
self._Save_Story_As.current_dir = "res://"
self._Save_Story_As.connect("file_selected", self, "_on_Save_Story_As_file_selected")
self.add_child(self._Save_Story_As)
self._Bake_Story_As = EditorFileDialog.new()
self._Bake_Story_As.mode = EditorFileDialog.MODE_SAVE_FILE
self._Bake_Story_As.add_filter("*.tres ; Baked Story files")
self._Bake_Story_As.resizable = true
self._Bake_Story_As.access = EditorFileDialog.ACCESS_RESOURCES
self._Bake_Story_As.current_dir = "res://"
self._Bake_Story_As.connect("file_selected", self, "_on_Bake_Story_As_file_selected")
self.add_child(self._Bake_Story_As)
self._Save_CSV_As = EditorFileDialog.new()
self._Save_CSV_As.mode = EditorFileDialog.MODE_SAVE_FILE
self._Save_CSV_As.add_filter("*.csv ; CSV files")
self._Save_CSV_As.resizable = true
self._Save_CSV_As.access = EditorFileDialog.ACCESS_FILESYSTEM
self._Save_CSV_As.current_dir = "res://"
self._Save_CSV_As.connect("file_selected", self, "_on_Save_CVS_As_file_selected")
self.add_child(self._Save_CSV_As)
self._Load_CSV = EditorFileDialog.new()
self._Load_CSV .mode = EditorFileDialog.MODE_OPEN_FILE
self._Load_CSV .add_filter("*.csv ; CSV files")
self._Load_CSV .resizable = true
self._Load_CSV .access = EditorFileDialog.ACCESS_FILESYSTEM
self._Load_CSV .current_dir = "res://"
self._Load_CSV .connect("file_selected", self, "_on_Load_CSV_file_selected")
self.add_child(self._Load_CSV)
func _update_filter():
var new_text = self._Search_LineEdit.text
self._make_records_visible()
var filter_groups : Array
for idx in range(self._Filter_Menu.get_popup().get_item_count()):
if self._Filter_Menu.get_popup().is_item_checked(idx):
var group = self._Filter_Menu.get_popup().get_item_text(idx)
filter_groups.push_back(group)
var children = self._Dialog_Record_Root.get_children()
var search_option = self._Search_Option_BTN.selected
match search_option:
0: #Human Readable Search
for child in children:
var did = child.get_did()
var human_readable_description = self.get_dialog_property(did, "human_readable_description")
if human_readable_description.find(new_text) == -1 and not new_text.empty():
child.visible = false
else:
child.visible = false
if self._Filter_Menu.get_popup().get_item_count() == 0:
child.visible = true
var dialog_groups = self.dialog_get_groups(did)
if dialog_groups.empty() and filter_groups.has("-No Tags-"):
child.visible = true
for group in dialog_groups:
if filter_groups.has(group):
child.visible = true
1: #DID Search
for child in children:
var did = child.get_did()
if not new_text == str(did) and not new_text.empty():
child.visible = false
else:
child.visible = false
if self._Filter_Menu.get_popup().get_item_count() == 0:
child.visible = true
var dialog_groups = self.dialog_get_groups(did)
if dialog_groups.empty() and filter_groups.has("-No Tags-"):
child.visible = true
for group in dialog_groups:
if filter_groups.has(group):
child.visible = true
2: #Record Name Search
for child in children:
var did = child.get_did()
var record_name = child.get_record_name()
if record_name.find(new_text) == -1 and not new_text.empty():
child.visible = false
else:
child.visible = false
if self._Filter_Menu.get_popup().get_item_count() == 0:
child.visible = true
var dialog_groups = self.dialog_get_groups(did)
if dialog_groups.empty() and filter_groups.has("-No Tags-"):
child.visible = true
for group in dialog_groups:
if filter_groups.has(group):
child.visible = true