2020-05-26 23:52:45 +02:00
|
|
|
tool
|
|
|
|
extends Node
|
|
|
|
|
|
|
|
var plugin_name : String = "Easy Charts"
|
|
|
|
var templates : Dictionary = {}
|
|
|
|
|
|
|
|
func _ready():
|
2020-08-04 15:22:30 +02:00
|
|
|
templates = _load_templates()
|
|
|
|
_print_message("Templates loaded")
|
2020-05-26 23:52:45 +02:00
|
|
|
|
|
|
|
func _print_message(message : String, type : int = 0):
|
2020-08-04 15:22:30 +02:00
|
|
|
match type:
|
|
|
|
0:
|
|
|
|
print("[%s] => %s" % [plugin_name, message])
|
|
|
|
1:
|
|
|
|
printerr("ERROR: [%s] => %s" % [plugin_name, message])
|
2020-05-26 23:52:45 +02:00
|
|
|
|
|
|
|
func _load_templates() -> Dictionary:
|
2020-08-04 15:22:30 +02:00
|
|
|
var template_file : File = File.new()
|
|
|
|
template_file.open("res://addons/easy_charts/templates.json",File.READ)
|
|
|
|
var templates = JSON.parse(template_file.get_as_text()).get_result()
|
|
|
|
template_file.close()
|
|
|
|
return templates
|
2020-05-30 01:42:58 +02:00
|
|
|
|
|
|
|
func get_template(template_index : int):
|
2020-08-04 15:22:30 +02:00
|
|
|
return templates.get(templates.keys()[template_index])
|