add scripts for custom font

This commit is contained in:
Nicolò Santilio 2020-10-12 18:18:45 +02:00 committed by GitHub
parent a636be4115
commit 5965161df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 684 additions and 647 deletions

View File

@ -9,9 +9,11 @@ onready var NewFileDialogue_name = $NewFileDialogue/VBoxContainer/new_filename
onready var FileBTN = $FileEditorContainer/TobBar/file_btn.get_popup()
onready var PreviewBTN = $FileEditorContainer/TobBar/preview_btn.get_popup()
onready var EditorBTN = $FileEditorContainer/TobBar/editor_btn.get_popup()
onready var SettingsBTN : PopupMenu = $FileEditorContainer/TobBar/SettingsBtn.get_popup()
onready var Version = $FileEditorContainer/TobBar/version
onready var SelectFontDialog : FileDialog = $SelectFontDialog
onready var FileContainer = $FileEditorContainer/SplitContainer/FileContainer
onready var OpenFileList = $FileEditorContainer/SplitContainer/FileContainer/OpenFileList
@ -62,522 +64,541 @@ var save_as = false
var current_editor : Control
var current_ini_editor : Control
var current_csv_editor : Control
var current_font : DynamicFont
func _ready():
clean_editor()
update_version()
connect_signals()
create_shortcuts()
load_icons()
var opened_files : Array = LastOpenedFiles.load_opened_files()
for open_file in opened_files:
open_file(open_file[1])
FileList.set_filters(EXTENSIONS)
clean_editor()
update_version()
connect_signals()
create_shortcuts()
load_icons()
var opened_files : Array = LastOpenedFiles.load_opened_files()
for opened_file in opened_files:
open_file(opened_file[1], opened_file[2])
FileList.set_filters(EXTENSIONS)
func create_shortcuts():
var hotkey
hotkey = InputEventKey.new()
hotkey.scancode = KEY_S
hotkey.control = true
FileBTN.set_item_accelerator(4,hotkey.get_scancode_with_modifiers()) # save file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_N
hotkey.control = true
FileBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # new file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_O
hotkey.control = true
FileBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # open file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_D
hotkey.control = true
FileBTN.set_item_accelerator(6,hotkey.get_scancode_with_modifiers()) # delete file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_S
hotkey.control = true
hotkey.alt = true
FileBTN.set_item_accelerator(5,hotkey.get_scancode_with_modifiers()) #save file as
hotkey = InputEventKey.new()
hotkey.scancode = KEY_C
hotkey.control = true
hotkey.alt = true
FileBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # close file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_F
hotkey.control = true
FileBTN.set_item_accelerator(8,hotkey.get_scancode_with_modifiers()) # search
hotkey = InputEventKey.new()
hotkey.scancode = KEY_R
hotkey.control = true
FileBTN.set_item_accelerator(9,hotkey.get_scancode_with_modifiers()) # replace
# vanilla editor -----------------------
hotkey = InputEventKey.new()
hotkey.scancode = KEY_1
hotkey.control = true
EditorBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # vanilla editor
hotkey = InputEventKey.new()
hotkey.scancode = KEY_2
hotkey.control = true
EditorBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # csv editor
hotkey = InputEventKey.new()
hotkey.scancode = KEY_3
hotkey.control = true
EditorBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # inieditor editor
var hotkey
hotkey = InputEventKey.new()
hotkey.scancode = KEY_S
hotkey.control = true
FileBTN.set_item_accelerator(4,hotkey.get_scancode_with_modifiers()) # save file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_N
hotkey.control = true
FileBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # new file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_O
hotkey.control = true
FileBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # open file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_D
hotkey.control = true
FileBTN.set_item_accelerator(6,hotkey.get_scancode_with_modifiers()) # delete file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_S
hotkey.control = true
hotkey.alt = true
FileBTN.set_item_accelerator(5,hotkey.get_scancode_with_modifiers()) #save file as
hotkey = InputEventKey.new()
hotkey.scancode = KEY_C
hotkey.control = true
hotkey.alt = true
FileBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # close file
hotkey = InputEventKey.new()
hotkey.scancode = KEY_F
hotkey.control = true
FileBTN.set_item_accelerator(8,hotkey.get_scancode_with_modifiers()) # search
hotkey = InputEventKey.new()
hotkey.scancode = KEY_R
hotkey.control = true
FileBTN.set_item_accelerator(9,hotkey.get_scancode_with_modifiers()) # replace
# vanilla editor -----------------------
hotkey = InputEventKey.new()
hotkey.scancode = KEY_1
hotkey.control = true
EditorBTN.set_item_accelerator(0,hotkey.get_scancode_with_modifiers()) # vanilla editor
hotkey = InputEventKey.new()
hotkey.scancode = KEY_2
hotkey.control = true
EditorBTN.set_item_accelerator(1,hotkey.get_scancode_with_modifiers()) # csv editor
hotkey = InputEventKey.new()
hotkey.scancode = KEY_3
hotkey.control = true
EditorBTN.set_item_accelerator(2,hotkey.get_scancode_with_modifiers()) # inieditor editor
func load_icons():
$FileEditorContainer/TobBar/file_btn.icon = IconLoader.load_icon_from_name("file")
$FileEditorContainer/TobBar/preview_btn.icon = IconLoader.load_icon_from_name("read")
$FileEditorContainer/TobBar/editor_btn.icon = IconLoader.load_icon_from_name("edit_")
$FileEditorContainer/TobBar/file_btn.icon = IconLoader.load_icon_from_name("file")
$FileEditorContainer/TobBar/preview_btn.icon = IconLoader.load_icon_from_name("read")
$FileEditorContainer/TobBar/editor_btn.icon = IconLoader.load_icon_from_name("edit_")
$FileEditorContainer/TobBar/SettingsBtn.icon = IconLoader.load_icon_from_name("settings")
func connect_signals():
FileList.connect("confirmed",self,"update_list")
FileBTN.connect("id_pressed",self,"_on_filebtn_pressed")
PreviewBTN.connect("id_pressed",self,"_on_previewbtn_pressed")
EditorBTN.connect("id_pressed",self,"_on_editorbtn_pressed")
OpenFileList.connect("item_selected",self,"_on_fileitem_pressed")
WrapBTN.connect("item_selected",self,"on_wrap_button")
MapBTN.connect("item_selected",self,"on_minimap_button")
FileList.connect("confirmed",self,"update_list")
FileBTN.connect("id_pressed",self,"_on_filebtn_pressed")
PreviewBTN.connect("id_pressed",self,"_on_previewbtn_pressed")
EditorBTN.connect("id_pressed",self,"_on_editorbtn_pressed")
SettingsBTN.connect("id_pressed",self,"_on_settingsbtn_pressed")
OpenFileList.connect("item_selected",self,"_on_fileitem_pressed")
WrapBTN.connect("item_selected",self,"on_wrap_button")
MapBTN.connect("item_selected",self,"on_minimap_button")
SelectFontDialog.connect("file_selected",self,"_on_font_selected")
func update_version():
var plugin_version = ""
var config = ConfigFile.new()
var err = config.load("res://addons/file-editor/plugin.cfg")
if err == OK:
plugin_version = config.get_value("plugin","version")
Version.set_text("v"+plugin_version)
print(plugin_version)
var plugin_version = ""
var config = ConfigFile.new()
var err = config.load("res://addons/file-editor/plugin.cfg")
if err == OK:
plugin_version = config.get_value("plugin","version")
Version.set_text("v"+plugin_version)
print(plugin_version)
func create_selected_file():
update_list()
FileList.mode = FileDialog.MODE_SAVE_FILE
FileList.set_title("Create a new File")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if not FileList.is_connected("file_selected",self,"create_new_file"):
FileList.connect("file_selected",self,"create_new_file")
open_filelist()
update_list()
FileList.mode = FileDialog.MODE_SAVE_FILE
FileList.set_title("Create a new File")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if not FileList.is_connected("file_selected",self,"create_new_file"):
FileList.connect("file_selected",self,"create_new_file")
open_filelist()
func open_selected_file():
update_list()
FileList.mode = FileDialog.MODE_OPEN_FILE
FileList.set_title("Select a File you want to edit")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"create_new_file"):
FileList.disconnect("file_selected",self,"create_new_file")
if not FileList.is_connected("file_selected",self,"open_file"):
FileList.connect("file_selected",self,"open_file")
open_filelist()
update_list()
FileList.mode = FileDialog.MODE_OPEN_FILE
FileList.set_title("Select a File you want to edit")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"create_new_file"):
FileList.disconnect("file_selected",self,"create_new_file")
if not FileList.is_connected("file_selected",self,"open_file"):
FileList.connect("file_selected",self,"open_file")
open_filelist()
func delete_selected_file():
update_list()
FileList.mode = FileDialog.MODE_OPEN_FILES
FileList.set_title("Select one or more Files you want to delete")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if FileList.is_connected("file_selected",self,"create_new_file"):
FileList.disconnect("file_selected",self,"create_new_file")
if not FileList.is_connected("files_selected",self,"delete_file"):
FileList.connect("files_selected",self,"delete_file")
open_filelist()
update_list()
FileList.mode = FileDialog.MODE_OPEN_FILES
FileList.set_title("Select one or more Files you want to delete")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if FileList.is_connected("file_selected",self,"create_new_file"):
FileList.disconnect("file_selected",self,"create_new_file")
if not FileList.is_connected("files_selected",self,"delete_file"):
FileList.connect("files_selected",self,"delete_file")
open_filelist()
func save_current_file_as():
update_list()
FileList.mode = FileDialog.MODE_SAVE_FILE
FileList.set_title("Save this File as...")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if not FileList.is_connected("file_selected",self,"create_new_file"):
FileList.connect("file_selected",self,"create_new_file")
open_filelist()
update_list()
FileList.mode = FileDialog.MODE_SAVE_FILE
FileList.set_title("Save this File as...")
if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file")
if FileList.is_connected("file_selected",self,"open_file"):
FileList.disconnect("file_selected",self,"open_file")
if not FileList.is_connected("file_selected",self,"create_new_file"):
FileList.connect("file_selected",self,"create_new_file")
open_filelist()
func _on_filebtn_pressed(index : int):
match index:
0:
create_selected_file()
1:
open_selected_file()
2:
if current_file_index!=-1 and current_file_path != "":
close_file(current_file_index)
3:
if current_file_index!=-1 and current_file_path != "":
save_as = false
if current_csv_editor and current_csv_editor.visible:
current_csv_editor.save_table()
save_file(current_file_path)
4:
if current_file_index!=-1 and current_file_path != "":
save_as = true
save_file(current_file_path)
save_current_file_as()
5:
delete_selected_file()
6:
current_editor.open_searchbox()
7:
current_editor.open_replacebox()
match index:
0:
create_selected_file()
1:
open_selected_file()
2:
if current_file_index!=-1 and current_file_path != "":
close_file(current_file_index)
3:
if current_file_index!=-1 and current_file_path != "":
save_as = false
if current_csv_editor and current_csv_editor.visible:
current_csv_editor.save_table()
save_file(current_file_path)
4:
if current_file_index!=-1 and current_file_path != "":
save_as = true
save_file(current_file_path)
save_current_file_as()
5:
delete_selected_file()
6:
current_editor.open_searchbox()
7:
current_editor.open_replacebox()
func _on_previewbtn_pressed(id : int):
if id == 0:
bbcode_preview()
elif id == 1:
markdown_preview()
elif id == 2:
html_preview()
elif id == 3:
csv_preview()
elif id == 4:
xml_preview()
elif id == 5:
json_preview()
if id == 0:
bbcode_preview()
elif id == 1:
markdown_preview()
elif id == 2:
html_preview()
elif id == 3:
csv_preview()
elif id == 4:
xml_preview()
elif id == 5:
json_preview()
func _on_editorbtn_pressed(index : int):
match index:
0:
if not current_editor.visible:
current_editor.show()
if current_csv_editor:
current_csv_editor.hide()
if current_ini_editor:
current_ini_editor.hide()
1:
if current_csv_editor and not current_csv_editor.visible:
if current_ini_editor:
current_ini_editor.hide()
current_editor.hide()
current_csv_editor = open_in_csveditor(current_file_path)
current_csv_editor.show()
2:
if current_ini_editor and not current_ini_editor.visible:
current_editor.hide()
if current_csv_editor:
current_csv_editor.hide()
current_ini_editor = open_in_inieditor(current_file_path)
current_ini_editor.show()
match index:
0:
if not current_editor.visible:
current_editor.show()
if current_csv_editor:
current_csv_editor.hide()
if current_ini_editor:
current_ini_editor.hide()
1:
if current_csv_editor and not current_csv_editor.visible:
if current_ini_editor:
current_ini_editor.hide()
current_editor.hide()
current_csv_editor = open_in_csveditor(current_file_path)
current_csv_editor.show()
2:
if current_ini_editor and not current_ini_editor.visible:
current_editor.hide()
if current_csv_editor:
current_csv_editor.hide()
current_ini_editor = open_in_inieditor(current_file_path)
current_ini_editor.show()
func _on_settingsbtn_pressed(index : int):
match index:
0:
SelectFontDialog.popup()
func _on_font_selected(font_path : String):
current_editor.set_font(font_path)
LastOpenedFiles.store_editor_fonts(current_file_path.get_file(), font_path)
# Enable this part of code to apply the new font to all Vanilla Editors opened
# for file in [0,OpenFileList.get_child_count()]:
# OpenFileList.get_item_metadata(file)[0].set_font(dynamic_font)
# current_font = dynamic_font
func _on_fileitem_pressed(index : int):
current_file_index = index
var selected_item_metadata = OpenFileList.get_item_metadata(current_file_index)
var extension = selected_item_metadata[0].current_path.get_file().get_extension()
current_file_path = selected_item_metadata[0].current_path
if current_editor.visible:
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
current_csv_editor = selected_item_metadata[2]
current_ini_editor = selected_item_metadata[1]
if WrapBTN.get_selected_id() == 1:
current_editor.set_wrap_enabled(true)
else:
current_editor.set_wrap_enabled(false)
if MapBTN.get_selected_id() == 1:
current_editor.draw_minimap(true)
else:
current_editor.draw_minimap(false)
elif current_csv_editor and current_csv_editor.visible:
if extension == "csv":
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
current_csv_editor.show()
OpenFileName.set_text(current_csv_editor.current_file_path)
current_editor = selected_item_metadata[0]
current_ini_editor = selected_item_metadata[1]
else:
if current_csv_editor:
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
if current_ini_editor:
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
elif current_ini_editor and current_ini_editor.visible:
if extension == "cfg" or extension == "ini":
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
current_ini_editor.show()
OpenFileName.set_text(current_ini_editor.current_file_path)
else:
if current_ini_editor:
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
if current_csv_editor:
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
current_file_index = index
var selected_item_metadata = OpenFileList.get_item_metadata(current_file_index)
var extension = selected_item_metadata[0].current_path.get_file().get_extension()
current_file_path = selected_item_metadata[0].current_path
if current_editor.visible:
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
current_csv_editor = selected_item_metadata[2]
current_ini_editor = selected_item_metadata[1]
if WrapBTN.get_selected_id() == 1:
current_editor.set_wrap_enabled(true)
else:
current_editor.set_wrap_enabled(false)
if MapBTN.get_selected_id() == 1:
current_editor.draw_minimap(true)
else:
current_editor.draw_minimap(false)
elif current_csv_editor and current_csv_editor.visible:
if extension == "csv":
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
current_csv_editor.show()
OpenFileName.set_text(current_csv_editor.current_file_path)
current_editor = selected_item_metadata[0]
current_ini_editor = selected_item_metadata[1]
else:
if current_csv_editor:
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
if current_ini_editor:
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
elif current_ini_editor and current_ini_editor.visible:
if extension == "cfg" or extension == "ini":
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
current_ini_editor.show()
OpenFileName.set_text(current_ini_editor.current_file_path)
else:
if current_ini_editor:
current_ini_editor.hide()
current_ini_editor = selected_item_metadata[1]
if current_csv_editor:
current_csv_editor.hide()
current_csv_editor = selected_item_metadata[2]
current_editor.hide()
current_editor = selected_item_metadata[0]
current_editor.show()
OpenFileName.set_text(current_editor.current_path)
func open_file(path : String):
if current_file_path != path:
current_file_path = path
var vanilla_editor = open_in_vanillaeditor(path)
var ini_editor = open_in_inieditor(path)
var csv_editor = open_in_csveditor(path)
generate_file_item(path,vanilla_editor,ini_editor,csv_editor)
LastOpenedFiles.store_opened_files(OpenFileList)
current_editor.show()
func open_file(path : String, font : String = "null"):
if current_file_path != path:
current_file_path = path
var vanilla_editor = open_in_vanillaeditor(path)
if font != "null":
vanilla_editor.set_font(font)
var ini_editor = open_in_inieditor(path)
var csv_editor = open_in_csveditor(path)
generate_file_item(path,vanilla_editor,ini_editor,csv_editor)
LastOpenedFiles.store_opened_files(OpenFileList)
current_editor.show()
func generate_file_item(path : String , veditor : Control , inieditor : Control, csveditor : Control):
OpenFileName.set_text(path)
OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true)
current_file_index = OpenFileList.get_item_count()-1
OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor])
OpenFileList.select(OpenFileList.get_item_count()-1)
OpenFileName.set_text(path)
OpenFileList.add_item(path.get_file(),IconLoader.load_icon_from_name("file"),true)
current_file_index = OpenFileList.get_item_count()-1
OpenFileList.set_item_metadata(current_file_index,[veditor,inieditor,csveditor])
OpenFileList.select(OpenFileList.get_item_count()-1)
func open_in_vanillaeditor(path : String) -> Control:
var editor = VanillaEditor.instance()
SplitEditorContainer.add_child(editor,true)
if current_editor and current_editor!=editor:
editor.show()
current_editor.hide()
if current_csv_editor and current_csv_editor.visible:
current_csv_editor.hide()
if current_ini_editor and current_ini_editor.visible:
current_ini_editor.hide()
current_editor = editor
editor.connect("text_changed",self,"_on_vanillaeditor_text_changed")
var current_file : File = File.new()
current_file.open(path,File.READ)
var current_content = ""
current_content = current_file.get_as_text()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path))
current_file.close()
editor.new_file_open(current_content,last_modified,current_file_path)
update_list()
if WrapBTN.get_selected_id() == 1:
current_editor.set_wrap_enabled(true)
return editor
var editor = VanillaEditor.instance()
SplitEditorContainer.add_child(editor,true)
if current_editor and current_editor!=editor:
editor.show()
current_editor.hide()
if current_csv_editor and current_csv_editor.visible:
current_csv_editor.hide()
if current_ini_editor and current_ini_editor.visible:
current_ini_editor.hide()
current_editor = editor
editor.connect("text_changed",self,"_on_vanillaeditor_text_changed")
var current_file : File = File.new()
current_file.open(path,File.READ)
var current_content = ""
current_content = current_file.get_as_text()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path))
current_file.close()
editor.new_file_open(current_content,last_modified,current_file_path)
update_list()
if WrapBTN.get_selected_id() == 1:
current_editor.set_wrap_enabled(true)
return editor
func open_in_inieditor(path : String) -> Control:
var extension = path.get_file().get_extension()
if extension == "ini" or extension == "cfg":
var inieditor = IniEditor.instance()
SplitEditorContainer.add_child(inieditor)
inieditor.hide()
inieditor.connect("update_file",self,"_on_update_file")
current_ini_editor = inieditor
inieditor.current_file_path = path
var current_file : ConfigFile = ConfigFile.new()
var err = current_file.load(path)
if err == OK:
var sections = current_file.get_sections()
var filemap = []
for section in sections:
var keys = []
var section_keys = current_file.get_section_keys(section)
for key in section_keys:
keys.append([key,current_file.get_value(section,key)])
filemap.append([section,keys])
inieditor.open_file(filemap)
return inieditor
else:
current_ini_editor = null
return null
var extension = path.get_file().get_extension()
if extension == "ini" or extension == "cfg":
var inieditor = IniEditor.instance()
SplitEditorContainer.add_child(inieditor)
inieditor.hide()
inieditor.connect("update_file",self,"_on_update_file")
current_ini_editor = inieditor
inieditor.current_file_path = path
var current_file : ConfigFile = ConfigFile.new()
var err = current_file.load(path)
if err == OK:
var sections = current_file.get_sections()
var filemap = []
for section in sections:
var keys = []
var section_keys = current_file.get_section_keys(section)
for key in section_keys:
keys.append([key,current_file.get_value(section,key)])
filemap.append([section,keys])
inieditor.open_file(filemap)
return inieditor
else:
current_ini_editor = null
return null
func open_in_csveditor(path : String) -> Control:
var extension = path.get_file().get_extension()
if extension == "csv":
var csveditor = CsvEditor.instance()
SplitEditorContainer.add_child(csveditor)
csveditor.hide()
csveditor.connect("update_file",self,"_on_update_file")
current_csv_editor = csveditor
csveditor.current_file_path = path
csveditor.open_csv_file(path,"|")
return csveditor
else:
current_csv_editor = null
return null
var extension = path.get_file().get_extension()
if extension == "csv":
var csveditor = CsvEditor.instance()
SplitEditorContainer.add_child(csveditor)
csveditor.hide()
csveditor.connect("update_file",self,"_on_update_file")
current_csv_editor = csveditor
csveditor.current_file_path = path
csveditor.open_csv_file(path,"|")
return csveditor
else:
current_csv_editor = null
return null
func close_file(index):
LastOpenedFiles.remove_opened_file(index,OpenFileList)
OpenFileList.remove_item(index)
OpenFileName.clear()
current_editor.queue_free()
if index>0:
OpenFileList.select(OpenFileList.get_item_count()-1)
_on_fileitem_pressed(OpenFileList.get_item_count()-1)
LastOpenedFiles.remove_opened_file(index,OpenFileList)
OpenFileList.remove_item(index)
OpenFileName.clear()
current_editor.queue_free()
if index>0:
OpenFileList.select(OpenFileList.get_item_count()-1)
_on_fileitem_pressed(OpenFileList.get_item_count()-1)
func _on_update_file():
# current_editor.clean_editor()
var current_file : File = File.new()
current_file.open(current_file_path,File.READ)
var current_content = current_file.get_as_text()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
current_file.close()
current_editor.new_file_open(current_content,last_modified,current_file_path)
var current_file : File = File.new()
current_file.open(current_file_path,File.READ)
var current_content = current_file.get_as_text()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
current_file.close()
current_editor.new_file_open(current_content,last_modified,current_file_path)
func delete_file(files_selected : PoolStringArray):
var dir = Directory.new()
for file in files_selected:
dir.remove(file)
update_list()
var dir = Directory.new()
for file in files_selected:
dir.remove(file)
update_list()
func open_newfiledialogue():
NewFileDialogue.popup()
NewFileDialogue.set_position(OS.get_screen_size()/2 - NewFileDialogue.get_size()/2)
NewFileDialogue.popup()
NewFileDialogue.set_position(OS.get_screen_size()/2 - NewFileDialogue.get_size()/2)
func open_filelist():
update_list()
FileList.popup()
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
update_list()
FileList.popup()
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
func create_new_file(given_path : String):
var current_file = File.new()
current_file.open(given_path,File.WRITE)
if save_as :
current_file.store_line(current_editor.get_node("TextEditor").get_text())
current_file.close()
open_file(given_path)
var current_file = File.new()
current_file.open(given_path,File.WRITE)
if save_as :
current_file.store_line(current_editor.get_node("TextEditor").get_text())
current_file.close()
open_file(given_path)
func save_file(current_path : String):
var current_file = File.new()
current_file.open(current_path,File.WRITE)
var current_content = ""
var lines = current_editor.get_node("TextEditor").get_line_count()
for line in range(0,lines):
current_content = current_editor.get_node("TextEditor").get_text()
current_file.store_line(current_editor.get_node("TextEditor").get_line(line))
current_file.close()
current_file_path = current_path
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
current_editor.update_lastmodified(last_modified,"save")
OpenFileList.set_item_metadata(current_file_index,[current_editor,current_ini_editor,current_csv_editor])
print(OpenFileList.get_item_metadata(current_file_index))
if OpenFileList.get_item_text(current_file_index).ends_with("(*)"):
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index).rstrip("(*)"))
var current_file = File.new()
current_file.open(current_path,File.WRITE)
var current_content = ""
var lines = current_editor.get_node("TextEditor").get_line_count()
for line in range(0,lines):
current_content = current_editor.get_node("TextEditor").get_text()
current_file.store_line(current_editor.get_node("TextEditor").get_line(line))
current_file.close()
current_file_path = current_path
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_file_path))
current_editor.update_lastmodified(last_modified,"save")
OpenFileList.set_item_metadata(current_file_index,[current_editor,current_ini_editor,current_csv_editor])
print(OpenFileList.get_item_metadata(current_file_index))
if OpenFileList.get_item_text(current_file_index).ends_with("(*)"):
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index).rstrip("(*)"))
# OpenFileList.set_item_metadata(current_file_index,[current_editor,open_in_inieditor(current_file_path),open_in_csveditor(current_file_path)])
update_list()
update_list()
func clean_editor() -> void :
for inieditor in get_tree().get_nodes_in_group("ini_editor"):
inieditor.queue_free()
for vanillaeditor in get_tree().get_nodes_in_group("vanilla_editor"):
vanillaeditor.queue_free()
OpenFileName.clear()
OpenFileList.clear()
for inieditor in get_tree().get_nodes_in_group("ini_editor"):
inieditor.queue_free()
for vanillaeditor in get_tree().get_nodes_in_group("vanilla_editor"):
vanillaeditor.queue_free()
OpenFileName.clear()
OpenFileList.clear()
func csv_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
var lines = current_editor.get_node("TextEditor").get_line_count()
var rows = []
for i in range(0,lines-1):
rows.append(current_editor.get_node("TextEditor").get_line(i).rsplit(",",false))
preview.print_csv(rows)
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
var lines = current_editor.get_node("TextEditor").get_line_count()
var rows = []
for i in range(0,lines-1):
rows.append(current_editor.get_node("TextEditor").get_line(i).rsplit(",",false))
preview.print_csv(rows)
func bbcode_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_bb(current_editor.get_node("TextEditor").get_text())
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_bb(current_editor.get_node("TextEditor").get_text())
func markdown_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_markdown(current_editor.get_node("TextEditor").get_text())
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_markdown(current_editor.get_node("TextEditor").get_text())
func html_preview():
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_html(current_editor.get_node("TextEditor").get_text())
var preview = Preview.instance()
get_parent().get_parent().get_parent().add_child(preview)
preview.popup()
preview.window_title += " ("+current_file_path.get_file()+")"
preview.print_html(current_editor.get_node("TextEditor").get_text())
func xml_preview():
pass
pass
func json_preview():
pass
pass
func _on_vanillaeditor_text_changed():
if not OpenFileList.get_item_text(current_file_index).ends_with("(*)"):
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index)+"(*)")
if not OpenFileList.get_item_text(current_file_index).ends_with("(*)"):
OpenFileList.set_item_text(current_file_index,OpenFileList.get_item_text(current_file_index)+"(*)")
func update_list():
FileList.invalidate()
FileList.invalidate()
func on_wrap_button(index:int):
match index:
0:
current_editor.set_wrap_enabled(false)
1:
current_editor.set_wrap_enabled(true)
match index:
0:
current_editor.set_wrap_enabled(false)
1:
current_editor.set_wrap_enabled(true)
func on_minimap_button(index:int):
match index:
0:
current_editor.draw_minimap(false)
1:
current_editor.draw_minimap(true)
match index:
0:
current_editor.draw_minimap(false)
1:
current_editor.draw_minimap(true)
func check_file_preview(file : String):
# check whether the opened file has a corresponding preview session for its extension
pass
# check whether the opened file has a corresponding preview session for its extension
pass

View File

@ -26,259 +26,259 @@ var current_file_path : String = ""
signal update_file()
func _ready():
create_table_names()
connect_signals()
load_icons()
clean_editor()
add_to_group("ini_editor")
create_table_names()
connect_signals()
load_icons()
clean_editor()
add_to_group("ini_editor")
# var metadata = [["name","Godot Engine"],["version","1.0.0"],["color","Light Blue"]]
# load_section("Engine", metadata)
func connect_signals():
Sections.connect("item_selected",self,"_on_section_selected")
Sections.connect("nothing_selected",self,"_on_nosection_selected")
BtnAddSection.connect("pressed",self,"_on_addsection_pressed")
BtnRemoveSection.connect("pressed",self,"_on_removesection_pressed")
Keys.connect("item_selected",self,"_on_key_selected")
Keys.connect("nothing_selected",self,"_on_nokey_selected")
BtnAddKey.connect("pressed",self,"_on_addkey_pressed")
BtnRemoveKey.connect("pressed",self,"_on_removekey_pressed")
BtnEditKey.connect("pressed",self,"_on_editkey_pressed")
connect("visibility_changed",self,"_on_visibility_changed")
Sections.connect("item_selected",self,"_on_section_selected")
Sections.connect("nothing_selected",self,"_on_nosection_selected")
BtnAddSection.connect("pressed",self,"_on_addsection_pressed")
BtnRemoveSection.connect("pressed",self,"_on_removesection_pressed")
Keys.connect("item_selected",self,"_on_key_selected")
Keys.connect("nothing_selected",self,"_on_nokey_selected")
BtnAddKey.connect("pressed",self,"_on_addkey_pressed")
BtnRemoveKey.connect("pressed",self,"_on_removekey_pressed")
BtnEditKey.connect("pressed",self,"_on_editkey_pressed")
connect("visibility_changed",self,"_on_visibility_changed")
func create_table_names():
create_root()
Keys.hide_root = true
Keys.set_column_titles_visible(true)
Keys.set_column_title(0,"Name")
Keys.set_column_title(1,"Value")
create_root()
Keys.hide_root = true
Keys.set_column_titles_visible(true)
Keys.set_column_title(0,"Name")
Keys.set_column_title(1,"Value")
func load_icons():
$VBoxContainer/HSplitContainer/VBoxContainer/HBoxContainer/sections_icon.texture = IconLoader.load_icon_from_name("sections")
$VBoxContainer/HSplitContainer/VBoxContainer2/HBoxContainer2/keys_icon.texture = IconLoader.load_icon_from_name("keys")
BtnAddSection.icon = IconLoader.load_icon_from_name("add")
BtnAddSection.hint_tooltip = "Add a new Section"
BtnRemoveSection.icon = IconLoader.load_icon_from_name("delete")
BtnRemoveSection.hint_tooltip = "Remove selected Section"
BtnAddKey.icon = IconLoader.load_icon_from_name("add")
BtnAddKey.hint_tooltip = "Add a new Key"
BtnRemoveKey.icon = IconLoader.load_icon_from_name("delete")
BtnRemoveKey.hint_tooltip = "Remove selected Key"
BtnEditKey.icon = IconLoader.load_icon_from_name("edit_")
BtnEditKey.hint_tooltip = "Edit selected Key"
$VBoxContainer/HSplitContainer/VBoxContainer/HBoxContainer/sections_icon.texture = IconLoader.load_icon_from_name("sections")
$VBoxContainer/HSplitContainer/VBoxContainer2/HBoxContainer2/keys_icon.texture = IconLoader.load_icon_from_name("keys")
BtnAddSection.icon = IconLoader.load_icon_from_name("add")
BtnAddSection.hint_tooltip = "Add a new Section"
BtnRemoveSection.icon = IconLoader.load_icon_from_name("delete")
BtnRemoveSection.hint_tooltip = "Remove selected Section"
BtnAddKey.icon = IconLoader.load_icon_from_name("add")
BtnAddKey.hint_tooltip = "Add a new Key"
BtnRemoveKey.icon = IconLoader.load_icon_from_name("delete")
BtnRemoveKey.hint_tooltip = "Remove selected Key"
BtnEditKey.icon = IconLoader.load_icon_from_name("edit_")
BtnEditKey.hint_tooltip = "Edit selected Key"
func _on_addsection_pressed():
Section.get_node("Container/section/_name").show()
Section.window_title = "Add a new Section"
if not Section.is_connected("confirmed",self,"new_section"):
Section.connect("confirmed",self,"new_section")
if Section.is_connected("confirmed",self,"remove_section"):
Section.disconnect("confirmed",self,"remove_section")
Section.popup()
Section.get_node("Container/section/_name").show()
Section.window_title = "Add a new Section"
if not Section.is_connected("confirmed",self,"new_section"):
Section.connect("confirmed",self,"new_section")
if Section.is_connected("confirmed",self,"remove_section"):
Section.disconnect("confirmed",self,"remove_section")
Section.popup()
func _on_removesection_pressed():
Section.get_node("Container").hide()
Section.window_title = "Remove selected Section"
Section.dialog_text = "Are you sure you want to remove this Section?"
if not Section.is_connected("confirmed",self,"remove_section"):
Section.connect("confirmed",self,"remove_section")
if Section.is_connected("confirmed",self,"new_section"):
Section.disconnect("confirmed",self,"new_section")
Section.popup()
Section.get_node("Container").hide()
Section.window_title = "Remove selected Section"
Section.dialog_text = "Are you sure you want to remove this Section?"
if not Section.is_connected("confirmed",self,"remove_section"):
Section.connect("confirmed",self,"remove_section")
if Section.is_connected("confirmed",self,"new_section"):
Section.disconnect("confirmed",self,"new_section")
Section.popup()
func _on_addkey_pressed():
Key.get_node("data").show()
Key.get_node("data/HBoxContainer/name").editable = true
Key.get_node("data/HBoxContainer/name").set_text("")
Key.window_title = "Add a new Key"
Key.dialog_text = ""
if not Key.is_connected("confirmed",self,"new_key"):
Key.connect("confirmed",self,"new_key")
if Key.is_connected("confirmed",self,"edit_key"):
Key.disconnect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"remove_key"):
Key.disconnect("confirmed",self,"remove_key")
Key.popup()
Key.get_node("data").show()
Key.get_node("data/HBoxContainer/name").editable = true
Key.get_node("data/HBoxContainer/name").set_text("")
Key.window_title = "Add a new Key"
Key.dialog_text = ""
if not Key.is_connected("confirmed",self,"new_key"):
Key.connect("confirmed",self,"new_key")
if Key.is_connected("confirmed",self,"edit_key"):
Key.disconnect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"remove_key"):
Key.disconnect("confirmed",self,"remove_key")
Key.popup()
func _on_removekey_pressed():
Key.get_node("data").hide()
Key.window_title = "Delete selected Key"
Key.dialog_text = "Are you sure you want to remove the selected Key?"
if not Key.is_connected("confirmed",self,"remove_key"):
Key.connect("confirmed",self,"remove_key")
if Key.is_connected("confirmed",self,"edit_key"):
Key.disconnect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"new_key"):
Key.disconnect("confirmed",self,"new_key")
Key.popup()
Key.get_node("data").hide()
Key.window_title = "Delete selected Key"
Key.dialog_text = "Are you sure you want to remove the selected Key?"
if not Key.is_connected("confirmed",self,"remove_key"):
Key.connect("confirmed",self,"remove_key")
if Key.is_connected("confirmed",self,"edit_key"):
Key.disconnect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"new_key"):
Key.disconnect("confirmed",self,"new_key")
Key.popup()
func _on_editkey_pressed():
Key.get_node("data").show()
Key.get_node("data/HBoxContainer/name").editable = false
Key.get_node("data/HBoxContainer/name").set_text(str(selected_key.get_text(0)))
Key.get_node("data/HBoxContainer2/value").set_text(str(selected_key.get_text(1)))
Key.window_title = "Edit selected Key"
Key.dialog_text = ""
if not Key.is_connected("confirmed",self,"edit_key"):
Key.connect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"remove_key"):
Key.disconnect("confirmed",self,"remove_key")
if Key.is_connected("confirmed",self,"new_key"):
Key.disconnect("confirmed",self,"new_key")
Key.popup()
Key.get_node("data").show()
Key.get_node("data/HBoxContainer/name").editable = false
Key.get_node("data/HBoxContainer/name").set_text(str(selected_key.get_text(0)))
Key.get_node("data/HBoxContainer2/value").set_text(str(selected_key.get_text(1)))
Key.window_title = "Edit selected Key"
Key.dialog_text = ""
if not Key.is_connected("confirmed",self,"edit_key"):
Key.connect("confirmed",self,"edit_key")
if Key.is_connected("confirmed",self,"remove_key"):
Key.disconnect("confirmed",self,"remove_key")
if Key.is_connected("confirmed",self,"new_key"):
Key.disconnect("confirmed",self,"new_key")
Key.popup()
func clean_editor():
Keys.clear()
Sections.clear()
selected_section = -1
BtnAddKey.disabled = true
if current_file_path == "":
BtnAddSection.disabled = true
else:
BtnAddSection.disabled = false
BtnEditKey.disabled = true
BtnRemoveKey.disabled = true
BtnRemoveSection.disabled = true
create_root()
Keys.clear()
Sections.clear()
selected_section = -1
BtnAddKey.disabled = true
if current_file_path == "":
BtnAddSection.disabled = true
else:
BtnAddSection.disabled = false
BtnEditKey.disabled = true
BtnRemoveKey.disabled = true
BtnRemoveSection.disabled = true
create_root()
func open_file(filemap : Array):
clean_editor()
for section in filemap:
load_sections(section[0],section[1])
clean_editor()
for section in filemap:
load_sections(section[0],section[1])
func new_section():
var file = ConfigFile.new()
file.load(current_file_path)
var section_name = str(Section.get_node("Container/section/_name").get_text())
var key_name = str(Section.get_node("Container/key/_name").get_text())
var key_value = Section.get_node("Container/value/_value").get_text()
if section_name and key_name and key_value:
file.set_value(section_name,key_name,key_value)
file.save(current_file_path)
load_sections(section_name,[[key_name,key_value]])
emit_signal("update_file")
else:
print("Section <",section_name,"> with Key name: <",key_name,"> and Key value: <",key_value,"> not valid.")
var file = ConfigFile.new()
file.load(current_file_path)
var section_name = str(Section.get_node("Container/section/_name").get_text())
var key_name = str(Section.get_node("Container/key/_name").get_text())
var key_value = Section.get_node("Container/value/_value").get_text()
if section_name and key_name and key_value:
file.set_value(section_name,key_name,key_value)
file.save(current_file_path)
load_sections(section_name,[[key_name,key_value]])
emit_signal("update_file")
else:
print("Section <",section_name,"> with Key name: <",key_name,"> and Key value: <",key_value,"> not valid.")
func remove_section():
var file = ConfigFile.new()
file.load(current_file_path)
var current_section = Sections.get_item_text(selected_section)
file.erase_section(current_section)
Sections.remove_item(selected_section)
file.save(current_file_path)
emit_signal("update_file")
var file = ConfigFile.new()
file.load(current_file_path)
var current_section = Sections.get_item_text(selected_section)
file.erase_section(current_section)
Sections.remove_item(selected_section)
file.save(current_file_path)
emit_signal("update_file")
func new_key():
var key_name = str(Key.get_node("data/HBoxContainer/name").get_text())
var key_value = Key.get_node("data/HBoxContainer2/value").get_text()
if key_name and key_value:
var file = ConfigFile.new()
file.load(current_file_path)
var current_section = Sections.get_item_text(selected_section)
file.set_value(current_section,key_name,key_value)
file.save(current_file_path)
load_keys_selected_section([[key_name,key_value]])
file.save(current_file_path)
emit_signal("update_file")
else:
print("Key name: <",key_name,"> with Key value: <",key_value,"> not valid.")
var key_name = str(Key.get_node("data/HBoxContainer/name").get_text())
var key_value = Key.get_node("data/HBoxContainer2/value").get_text()
if key_name and key_value:
var file = ConfigFile.new()
file.load(current_file_path)
var current_section = Sections.get_item_text(selected_section)
file.set_value(current_section,key_name,key_value)
file.save(current_file_path)
load_keys_selected_section([[key_name,key_value]])
file.save(current_file_path)
emit_signal("update_file")
else:
print("Key name: <",key_name,"> with Key value: <",key_value,"> not valid.")
func remove_key():
var section = Sections.get_item_text(selected_section)
var sectionmetadata = Sections.get_item_metadata(selected_section)
for meta in sectionmetadata:
if meta.has(selected_key.get_text(0)):
sectionmetadata.erase(meta)
Sections.set_item_metadata(selected_section,sectionmetadata)
if Sections.get_item_metadata(selected_section) == []:
Sections.remove_item(selected_section)
var file = ConfigFile.new()
file.load(current_file_path)
file.set_value(section,selected_key.get_text(0),null)
file.save(current_file_path)
Keys.clear()
create_root()
load_keys_selected_section(sectionmetadata)
emit_signal("update_file")
var section = Sections.get_item_text(selected_section)
var sectionmetadata = Sections.get_item_metadata(selected_section)
for meta in sectionmetadata:
if meta.has(selected_key.get_text(0)):
sectionmetadata.erase(meta)
Sections.set_item_metadata(selected_section,sectionmetadata)
if Sections.get_item_metadata(selected_section) == []:
Sections.remove_item(selected_section)
var file = ConfigFile.new()
file.load(current_file_path)
file.set_value(section,selected_key.get_text(0),null)
file.save(current_file_path)
Keys.clear()
create_root()
load_keys_selected_section(sectionmetadata)
emit_signal("update_file")
func edit_key():
remove_key()
new_key()
remove_key()
new_key()
# load a section with custom fields @section_name = name of section ; @section_metadata = keys of this section with keys' properties
func load_sections(section_name : String, section_metadata : Array):
Sections.add_item(section_name,IconLoader.load_icon_from_name("section"),true)
Sections.set_item_metadata(Sections.get_item_count()-1,section_metadata)
Sections.add_item(section_name,IconLoader.load_icon_from_name("section"),true)
Sections.set_item_metadata(Sections.get_item_count()-1,section_metadata)
# load a key of a selected section to fill the "keys" list
func load_keys_selected_section(metadata : Array):
for key in metadata:
var key_item = Keys.create_item(root)
key_item.set_text(0,key[0])
key_item.set_text(1,key[1])
for key in metadata:
var key_item = Keys.create_item(root)
key_item.set_text(0,key[0])
key_item.set_text(1,key[1])
func _on_section_selected(index : int):
Keys.clear()
create_root()
BtnRemoveSection.disabled = false
BtnAddSection.disabled = false
BtnAddKey.disabled = false
BtnRemoveKey.disabled = true
BtnEditKey.disabled = true
selected_section = index
if Sections.get_item_metadata(index):
load_keys_selected_section(Sections.get_item_metadata(index))
Keys.clear()
create_root()
BtnRemoveSection.disabled = false
BtnAddSection.disabled = false
BtnAddKey.disabled = false
BtnRemoveKey.disabled = true
BtnEditKey.disabled = true
selected_section = index
if Sections.get_item_metadata(index):
load_keys_selected_section(Sections.get_item_metadata(index))
func _on_key_selected():
selected_key = Keys.get_selected()
BtnRemoveKey.disabled = false
BtnEditKey.disabled = false
selected_key = Keys.get_selected()
BtnRemoveKey.disabled = false
BtnEditKey.disabled = false
func _on_nosection_selected():
BtnRemoveKey.disabled = true
BtnAddKey.disabled = true
BtnEditKey.disabled = true
BtnRemoveSection.disabled = true
Keys.clear()
selected_section = -1
BtnRemoveKey.disabled = true
BtnAddKey.disabled = true
BtnEditKey.disabled = true
BtnRemoveSection.disabled = true
Keys.clear()
selected_section = -1
func _on_nokey_selected():
BtnRemoveKey.disabled = true
BtnEditKey.disabled = true
BtnRemoveKey.disabled = true
BtnEditKey.disabled = true
func create_root():
root = Keys.create_item()
root.set_text(0,"KEY_NAME")
root.set_text(1,"KEY_VALUE")
root = Keys.create_item()
root.set_text(0,"KEY_NAME")
root.set_text(1,"KEY_VALUE")
func _on_visibility_changed():
if visible:
pass
if visible:
pass

View File

@ -26,8 +26,17 @@ func load_opened_files() -> Array:
var file = ConfigFile.new()
file.load(lastopenedfile_path)
var keys = []
# Load opened files
if file.has_section("Opened"):
var openedfiles = file.get_section_keys("Opened")
for openedfile in openedfiles:
keys.append([openedfile,file.get_value("Opened",openedfile)])
# 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"])
return keys
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)

View File

@ -40,6 +40,13 @@ func _ready():
add_to_group("vanilla_editor")
func set_font(font_path : String) -> void:
var dynamic_font : DynamicFont = DynamicFont.new()
var dynamic_font_data : DynamicFontData = DynamicFontData.new()
dynamic_font_data.set_font_path(font_path)
dynamic_font.set_font_data(dynamic_font_data)
TextEditor.set("custom_fonts/font",dynamic_font)
func set_wrap_enabled(enabled:bool):
TextEditor.set_wrap_enabled(enabled)
TextEditor.update()