104 lines
2.9 KiB
GDScript
104 lines
2.9 KiB
GDScript
extends Control
|
|
|
|
onready var story_list = $board/story_list
|
|
onready var card_list = $board/card_list
|
|
onready var post_it_list = $board/label_list/postIt_list
|
|
onready var connections_list = $board/label_list/connections_list
|
|
onready var final_list = $board/final_list
|
|
|
|
onready var story_template = $"templates/Ingest Story"
|
|
onready var card_template = $"templates/Ingest Card"
|
|
onready var connection_template = $"templates/Ingest Connection"
|
|
onready var post_it_template = $"templates/Ingest Post-It"
|
|
onready var pick_template = $templates/Pick
|
|
|
|
var copybuffer
|
|
var pick_source
|
|
|
|
var all_cards:Array = []
|
|
var all_post_its:Array = []
|
|
|
|
func _on_add_story_pressed():
|
|
|
|
var tmp = story_template.duplicate()
|
|
tmp.show()
|
|
story_list.add_child(tmp)
|
|
|
|
func show_labels(source):
|
|
pick_source = source
|
|
for child in final_list.get_children():
|
|
final_list.remove_child(child)
|
|
for post_it in all_post_its:
|
|
pick_template.pick = post_it
|
|
final_list.add_child(pick_template.duplicate())
|
|
|
|
func pick(pick):
|
|
pick_source.select(pick)
|
|
pick_source = null
|
|
|
|
func copy(buffer):
|
|
copybuffer = buffer
|
|
|
|
func paste():
|
|
return copybuffer
|
|
|
|
|
|
func _on_save_pressed():
|
|
var save_stories = File.new()
|
|
save_stories.open("res://dev-util/export.json", File.WRITE)
|
|
var stories = []
|
|
for story in story_list.get_children():
|
|
stories.append(story.save())
|
|
var cards = []
|
|
for card in all_cards:
|
|
cards.append(card.save())
|
|
var postits = []
|
|
for postit in all_post_its:
|
|
postits.append(postit.save())
|
|
var connections = []
|
|
for connection in connections_list.get_children():
|
|
connections.append(connection.save())
|
|
var save_dict = {
|
|
stories = stories,
|
|
cards = cards,
|
|
postits = postits,
|
|
connections = connections
|
|
}
|
|
save_stories.store_string(JSON.print(save_dict, "\t", false))
|
|
save_stories.close()
|
|
|
|
func import_from_file(fileName:String):
|
|
clear_data()
|
|
var import_source = File.new()
|
|
import_source.open(fileName, File.READ)
|
|
var import_dict = parse_json(import_source.get_as_text())
|
|
import_source.close()
|
|
for story in import_dict.stories:
|
|
var new_story = story_template.duplicate()
|
|
new_story.show()
|
|
story_list.add_child(new_story)
|
|
new_story.digest(story, import_dict.cards, import_dict.postits, import_dict.connections)
|
|
|
|
|
|
func _on_load_pressed():
|
|
import_from_file("res://dev-util/export.json")
|
|
|
|
func clear_data():
|
|
for i in story_list.get_children():
|
|
story_list.remove_child(i)
|
|
|
|
for i in card_list.get_children():
|
|
card_list.remove_child(i)
|
|
|
|
for i in post_it_list.get_children():
|
|
post_it_list.remove_child(i)
|
|
|
|
for i in connections_list.get_children():
|
|
connections_list.remove_child(i)
|
|
|
|
for i in final_list.get_children():
|
|
final_list.remove_child(i)
|
|
|
|
all_cards = []
|
|
all_post_its = []
|