2019-10-08 00:25:16 +02:00
|
|
|
tool
|
|
|
|
extends Node
|
|
|
|
|
|
|
|
const lastopenedfile_path : String = "res://addons/file-editor/lastopenedfiles.lastcfg"
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
pass
|
|
|
|
|
|
|
|
func store_opened_files(filecontainer : Control):
|
|
|
|
var file = ConfigFile.new()
|
|
|
|
file.load(lastopenedfile_path)
|
|
|
|
for child in range(0,filecontainer.get_item_count()):
|
2019-10-18 01:22:11 +02:00
|
|
|
var filepath = filecontainer.get_item_metadata(child)[0].current_path
|
2019-10-08 00:25:16 +02:00
|
|
|
file.set_value("Opened",filepath.get_file(),filepath)
|
|
|
|
|
|
|
|
file.save(lastopenedfile_path)
|
|
|
|
|
|
|
|
func remove_opened_file(index : int , filecontainer : Control):
|
|
|
|
var file = ConfigFile.new()
|
|
|
|
file.load(lastopenedfile_path)
|
2019-10-18 01:22:11 +02:00
|
|
|
var filepath = filecontainer.get_item_metadata(index)[0].current_path
|
2019-10-08 00:25:16 +02:00
|
|
|
file.set_value("Opened",filepath.get_file(),null)
|
|
|
|
file.save(lastopenedfile_path)
|
|
|
|
|
|
|
|
func load_opened_files() -> Array:
|
|
|
|
var file = ConfigFile.new()
|
|
|
|
file.load(lastopenedfile_path)
|
|
|
|
var keys = []
|
2020-10-12 18:18:45 +02:00
|
|
|
# Load opened files
|
2019-10-08 00:25:16 +02:00
|
|
|
if file.has_section("Opened"):
|
|
|
|
var openedfiles = file.get_section_keys("Opened")
|
|
|
|
for openedfile in openedfiles:
|
2020-10-12 18:18:45 +02:00
|
|
|
# Load each single file which was opened
|
|
|
|
# creating and returning an Array with this format [1:file name, 2:file path, 3:file font]
|
|
|
|
keys.append([openedfile, file.get_value("Opened",openedfile), file.get_value("Fonts",openedfile) if file.has_section_key("Fonts",openedfile) else "null"])
|
2019-10-18 01:22:11 +02:00
|
|
|
return keys
|
2020-10-12 18:18:45 +02:00
|
|
|
|
|
|
|
func store_editor_fonts(file_name : String, font_path : String):
|
|
|
|
var file = ConfigFile.new()
|
|
|
|
file.load(lastopenedfile_path)
|
|
|
|
file.set_value("Fonts",file_name,font_path)
|
|
|
|
file.save(lastopenedfile_path)
|