Add files via upload

This commit is contained in:
fenix-hub 2019-09-24 00:42:50 +02:00 committed by GitHub
parent 01e69923e9
commit 8768285f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 417 additions and 211 deletions

View File

@ -1,14 +1,38 @@
# Godot Text Editor # Godot Text Editor
A little plugin to easy-way manage your text files inside your project folder. A little plugin to easy-way manage your text files inside your project folder.
Author: *"Nicolo (fenix) Santilio"* Author: *"Nicolo (fenix) Santilio"*
Version: *0.1.1* Version: *0.2.5*
Godot Version: *3.1.1-stable* Godot Version: *3.1.1-stable*
**This repository was pushed directly from Godot Engine Editor thanks to [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integration)!** **This repository was pushed directly from Godot Engine Editor thanks to [GitHub Integration](https://github.com/fenix-hub/godot-engine.github-integration)!**
## What is this? ## What is this?
Building... This is a little plugin I've made to easily edit text files in your project folder.
## How does it work? ## How does it work?
Building... You can open an existing file, create a new file and delete a file.
When opening / creating a file, the editor will open and you will be able to edit it and save it.
You can just *Save* the file, or *Save file As* a new file (if it is a new file but also to make some copies).
You will also be able to see some informations about the file you are editing (time and date of last edit) and you can set your editor to *Read Only* if you don't want to make changes but still read the content of the file.
Multiple files can be opened in different tabs.
Always remember to save your file when you close the tab!
![preview](https://i.imgur.com/7sxxZN9.png)
## How do I install it?
**Manual**
Just download this whole repository and put it in your `res://addons` folder inside the project you want to work on.
Then, go to `Project > Plugins > "File Editor" > Status > Activate`.
**Automatic**
You can find this plugin in the AssetLib of Godot Engine Editor. Just download it from there and everything should be fine!
(Remember to activate this plugin)
#### Current version
To check all the features included in the current version, please read the [VERSION file](./VERSION.md)
#### Upcoming features
To check all the features I'm currently working on, please read the [TODO file](./TODO.md)
# Want to contact me?
I'm planning to create a Discord group to collect each plugin I've made (and I will make), but until then you can directly talk with my via e-mail at *n.santilio97@gmail.com*

View File

@ -1 +1,2 @@
### to do (v-0.x.x) ### to do (v-0.x.x)
- Popup dialog when closing a tab if there is new content

View File

@ -1,3 +1,35 @@
**version 0.1.0** **version 0.0.1**
*added*
- Plugin Created
-----------------------
**version 0.1.1**
*added*
- "Create new File" option
- "Open File" option
- "Delete File" option
- "Save File" option
- "Save File As.." option
-----------------------
**version 0.1.2**
*fixed*
- Repository Installation, folder order
-----------------------
**version 0.2.5**
*removed*
- Old layout
-----------------------
*added*
- New Layout
- Last modified time and date
- Tabs
-----------------------

View File

@ -1,34 +1,38 @@
[gd_scene load_steps=18 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://addons/file-editor/scripts/FileEditor.gd" type="Script" id=1] [ext_resource path="res://addons/file-editor/scripts/FileEditor.gd" type="Script" id=1]
[ext_resource path="res://addons/file-editor/icons/new.svg" type="Texture" id=2] [ext_resource path="res://addons/file-editor/icons/new.svg" type="Texture" id=2]
[ext_resource path="res://addons/file-editor/icons/file.svg" type="Texture" id=3] [ext_resource path="res://addons/file-editor/icons/file.svg" type="Texture" id=3]
[ext_resource path="res://addons/file-editor/icons/delete.svg" type="Texture" id=4] [ext_resource path="res://addons/file-editor/icons/delete.svg" type="Texture" id=4]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://addons/file-editor/icons/read.svg" type="Texture" id=6]
[ext_resource path="res://addons/file-editor/icons/edit.png" type="Texture" id=7]
[ext_resource path="res://addons/file-editor/icons/save.svg" type="Texture" id=8]
[ext_resource path="res://addons/file-editor/icons/saveas.png" type="Texture" id=9]
[sub_resource type="DynamicFont" id=1] [sub_resource type="StyleBoxFlat" id=1]
outline_size = 3 content_margin_left = 10.0
outline_color = Color( 0.168627, 0.160784, 0.192157, 1 ) content_margin_right = 10.0
font_data = ExtResource( 5 ) bg_color = Color( 0.196078, 0.231373, 0.309804, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0
[sub_resource type="StyleBoxEmpty" id=2] [sub_resource type="StyleBoxFlat" id=3]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 )
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
expand_margin_bottom = 1.0
[sub_resource type="StyleBoxEmpty" id=3] [sub_resource type="StyleBoxFlat" id=2]
bg_color = Color( 0.121569, 0.145098, 0.192157, 1 )
[sub_resource type="StyleBoxEmpty" id=4] draw_center = false
border_width_left = 1
[sub_resource type="StyleBoxEmpty" id=5] border_width_top = 1
border_width_right = 1
[sub_resource type="StyleBoxEmpty" id=6] border_width_bottom = 1
border_color = Color( 0.121569, 0.145098, 0.192157, 1 )
[sub_resource type="StyleBoxEmpty" id=7]
[sub_resource type="DynamicFont" id=8]
font_data = ExtResource( 5 )
[node name="FileEditor" type="Control"] [node name="FileEditor" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
@ -67,91 +71,18 @@ size_flags_horizontal = 3
text = "Delete File" text = "Delete File"
icon = ExtResource( 4 ) icon = ExtResource( 4 )
[node name="HSeparator" type="HSeparator" parent="Container"] [node name="Editor" type="TabContainer" parent="Container"]
margin_top = 26.0 visible = false
margin_right = 1024.0 margin_top = 32.0
margin_bottom = 30.0
[node name="Label" type="Label" parent="Container"]
margin_top = 34.0
margin_right = 1024.0
margin_bottom = 53.0
custom_fonts/font = SubResource( 1 )
text = "EDITOR"
align = 1
[node name="Editor" type="VBoxContainer" parent="Container"]
margin_top = 57.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 600.0 margin_bottom = 600.0
size_flags_vertical = 3 size_flags_vertical = 3
custom_styles/tab_fg = SubResource( 1 )
[node name="TopBar" type="HBoxContainer" parent="Container/Editor"] custom_styles/tab_bg = SubResource( 3 )
margin_right = 1024.0 custom_styles/panel = SubResource( 2 )
margin_bottom = 24.0 custom_colors/font_color_fg = Color( 1, 1, 1, 1 )
tab_align = 0
[node name="Filename" type="LineEdit" parent="Container/Editor/TopBar"] drag_to_rearrange_enabled = true
margin_right = 917.0
margin_bottom = 24.0
size_flags_horizontal = 11
expand_to_text_length = true
[node name="Readonly" type="CheckBox" parent="Container/Editor/TopBar"]
margin_left = 921.0
margin_right = 1000.0
margin_bottom = 24.0
custom_icons/checked = ExtResource( 6 )
custom_icons/unchecked = ExtResource( 7 )
custom_styles/hover = SubResource( 2 )
custom_styles/pressed = SubResource( 3 )
custom_styles/focus = SubResource( 4 )
custom_styles/disabled = SubResource( 5 )
custom_styles/hover_pressed = SubResource( 6 )
custom_styles/normal = SubResource( 7 )
custom_fonts/font = SubResource( 8 )
custom_colors/font_color = Color( 0.145098, 0.172549, 0.231373, 1 )
custom_colors/font_color_pressed = Color( 1, 1, 1, 1 )
text = "Can Edit"
flat = true
[node name="close_btn" type="Button" parent="Container/Editor/TopBar"]
margin_left = 1004.0
margin_right = 1024.0
margin_bottom = 24.0
text = "X"
[node name="TextEditor" type="TextEdit" parent="Container/Editor"]
margin_top = 28.0
margin_right = 1024.0
margin_bottom = 517.0
size_flags_vertical = 3
syntax_highlighting = true
show_line_numbers = true
breakpoint_gutter = true
highlight_all_occurrences = true
smooth_scrolling = true
caret_blink = true
caret_blink_speed = 0.1
[node name="EditorButtons" type="HBoxContainer" parent="Container/Editor"]
margin_top = 521.0
margin_right = 1024.0
margin_bottom = 543.0
[node name="savefile_btn" type="Button" parent="Container/Editor/EditorButtons"]
margin_right = 510.0
margin_bottom = 22.0
size_flags_horizontal = 3
text = "Save File"
icon = ExtResource( 8 )
[node name="savefileas_btn" type="Button" parent="Container/Editor/EditorButtons"]
margin_left = 514.0
margin_right = 1024.0
margin_bottom = 22.0
size_flags_horizontal = 3
text = "Save File as..."
icon = ExtResource( 9 )
[node name="FileList" type="FileDialog" parent="."] [node name="FileList" type="FileDialog" parent="."]
margin_top = 24.0 margin_top = 24.0
@ -160,4 +91,39 @@ margin_bottom = 600.0
size_flags_vertical = 3 size_flags_vertical = 3
popup_exclusive = true popup_exclusive = true
dialog_hide_on_ok = true dialog_hide_on_ok = true
[connection signal="toggled" from="Container/Editor/TopBar/Readonly" to="." method="_on_Readonly_toggled"] filters = PoolStringArray( "*.txt ; Plain Text File", "*.rtf ; Rich Text Format File", "*.log ; Log File", "*.md ; MD File", "*.doc ; WordPad Document", "*.doc ; Microsoft Word Document", "*.docm ; Word Open XML Macro-Enabled Document", "*.docx ; Microsoft Word Open XML Document", "*.bbs ; Bulletin Board System Text" )
[node name="NewFileDialogue" type="AcceptDialog" parent="."]
editor/display_folded = true
margin_left = 348.254
margin_top = 232.623
margin_right = 644.254
margin_bottom = 321.623
window_title = "Create new File"
[node name="VBoxContainer" type="VBoxContainer" parent="NewFileDialogue"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 8.0
margin_right = -8.0
margin_bottom = -36.0
[node name="Label" type="Label" parent="NewFileDialogue/VBoxContainer"]
margin_right = 280.0
margin_bottom = 17.0
size_flags_vertical = 3
text = "Insert file name (no extension needed)"
align = 1
valign = 1
[node name="new_filename" type="LineEdit" parent="NewFileDialogue/VBoxContainer"]
margin_left = 40.0
margin_top = 21.0
margin_right = 240.0
margin_bottom = 45.0
rect_min_size = Vector2( 200, 0 )
size_flags_horizontal = 6
size_flags_vertical = 3
clear_button_enabled = true
placeholder_text = "example"

View File

@ -0,0 +1,135 @@
[gd_scene load_steps=13 format=2]
[ext_resource path="res://addons/file-editor/scripts/FileScene.gd" type="Script" id=1]
[ext_resource path="res://addons/file-editor/icons/read.svg" type="Texture" id=2]
[ext_resource path="res://addons/file-editor/icons/edit.png" type="Texture" id=3]
[ext_resource path="res://addons/file-editor/fonts/Roboto-Black.ttf" type="DynamicFontData" id=4]
[sub_resource type="StyleBoxFlat" id=8]
content_margin_left = 10.0
content_margin_right = 10.0
bg_color = Color( 0.145098, 0.172549, 0.231373, 1 )
[sub_resource type="StyleBoxEmpty" id=1]
[sub_resource type="StyleBoxEmpty" id=2]
[sub_resource type="StyleBoxEmpty" id=3]
[sub_resource type="StyleBoxEmpty" id=4]
[sub_resource type="StyleBoxEmpty" id=5]
[sub_resource type="StyleBoxEmpty" id=6]
[sub_resource type="DynamicFont" id=7]
font_data = ExtResource( 4 )
[node name="filename" type="VBoxContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 4.0
margin_top = 32.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_vertical = 3
script = ExtResource( 1 )
[node name="HSeparator" type="HSeparator" parent="."]
margin_right = 1016.0
margin_bottom = 4.0
[node name="TopBar" type="HBoxContainer" parent="."]
editor/display_folded = true
margin_top = 8.0
margin_right = 1016.0
margin_bottom = 28.0
[node name="VSeparator" type="VSeparator" parent="TopBar"]
margin_right = 4.0
margin_bottom = 20.0
[node name="FileButton" type="MenuButton" parent="TopBar"]
margin_left = 8.0
margin_right = 51.0
margin_bottom = 20.0
custom_styles/hover = SubResource( 8 )
custom_styles/normal = SubResource( 8 )
text = "File"
flat = false
items = [ "Save File", null, 0, false, false, 0, 0, null, "", false, "Save file As...", null, 0, false, false, 1, 0, null, "", false ]
[node name="filepath" type="Label" parent="TopBar"]
margin_left = 519.0
margin_top = 3.0
margin_right = 519.0
margin_bottom = 17.0
size_flags_horizontal = 6
[node name="close_btn" type="Button" parent="TopBar"]
margin_left = 988.0
margin_right = 1008.0
margin_bottom = 20.0
size_flags_horizontal = 8
text = "X"
[node name="VSeparator2" type="VSeparator" parent="TopBar"]
margin_left = 1012.0
margin_right = 1016.0
margin_bottom = 20.0
[node name="TextEditor" type="TextEdit" parent="."]
margin_top = 32.0
margin_right = 1016.0
margin_bottom = 541.0
size_flags_vertical = 3
syntax_highlighting = true
show_line_numbers = true
breakpoint_gutter = true
highlight_all_occurrences = true
smooth_scrolling = true
wrap_enabled = true
caret_blink = true
caret_blink_speed = 0.1
[node name="FileInfo" type="HBoxContainer" parent="."]
editor/display_folded = true
margin_top = 545.0
margin_right = 1016.0
margin_bottom = 564.0
[node name="Label" type="Label" parent="FileInfo"]
margin_top = 2.0
margin_right = 125.0
margin_bottom = 16.0
text = "Last modified time:"
[node name="lastmodified" type="Label" parent="FileInfo"]
margin_left = 129.0
margin_top = 2.0
margin_right = 129.0
margin_bottom = 16.0
[node name="Readonly" type="CheckBox" parent="FileInfo"]
margin_left = 929.0
margin_right = 1008.0
margin_bottom = 19.0
size_flags_horizontal = 10
custom_icons/checked = ExtResource( 2 )
custom_icons/unchecked = ExtResource( 3 )
custom_styles/hover = SubResource( 1 )
custom_styles/pressed = SubResource( 2 )
custom_styles/focus = SubResource( 3 )
custom_styles/disabled = SubResource( 4 )
custom_styles/hover_pressed = SubResource( 5 )
custom_styles/normal = SubResource( 6 )
custom_fonts/font = SubResource( 7 )
custom_colors/font_color = Color( 0.145098, 0.172549, 0.231373, 1 )
custom_colors/font_color_pressed = Color( 1, 1, 1, 1 )
text = "Can Edit"
flat = true
[node name="VSeparator3" type="VSeparator" parent="FileInfo"]
margin_left = 1012.0
margin_right = 1016.0
margin_bottom = 19.0

View File

@ -3,19 +3,16 @@ extends Control
onready var FileList = $FileList onready var FileList = $FileList
onready var TextEditor = $Container/Editor/TextEditor
onready var Filename = $Container/Editor/TopBar/Filename
onready var CloseFile = $Container/Editor/TopBar/close_btn
onready var Editor = $Container/Editor onready var Editor = $Container/Editor
onready var OpenFile = $Container/Buttons/openfile_btn onready var OpenFile = $Container/Buttons/openfile_btn
onready var NewFile = $Container/Buttons/newfile_btn onready var NewFile = $Container/Buttons/newfile_btn
onready var DeleteFile = $Container/Buttons/deletefile_btn onready var DeleteFile = $Container/Buttons/deletefile_btn
onready var SaveFile = $Container/Editor/EditorButtons/savefile_btn onready var NewFileDialogue = $NewFileDialogue
onready var SaveFileAs = $Container/Editor/EditorButtons/savefileas_btn onready var NewFileDialogue_name = $NewFileDialogue/VBoxContainer/new_filename
onready var ReadOnly = $Container/Editor/TopBar/Readonly var FileScene = load("res://addons/file-editor/scenes/FileScene.tscn")
var DIRECTORY : String = "res://" var DIRECTORY : String = "res://"
var EXCEPTIONS : String = "addons" var EXCEPTIONS : String = "addons"
@ -34,80 +31,70 @@ var EXTENSIONS : PoolStringArray = [
var directories = [] var directories = []
var files = [] var files = []
# -----
var current_file : File = File.new()
var current_path : String = ""
var current_content : String = ""
# -----
func _ready(): func _ready():
OpenFile.connect("pressed",self,"open_selected_file") OpenFile.connect("pressed",self,"open_selected_file")
NewFile.connect("pressed",self,"create_new_file") NewFile.connect("pressed",self,"open_newfiledialogue")
DeleteFile.connect("pressed",self,"delete_selected_file") DeleteFile.connect("pressed",self,"delete_selected_file")
SaveFile.connect("pressed",self,"save_file") NewFileDialogue.connect("confirmed",self,"create_new_file")
SaveFileAs.connect("pressed",self,"save_file_as")
CloseFile.connect("pressed",self,"close_editor")
Filename.set_editable(false) FileList.connect("confirmed",self,"update_list")
SaveFile.set_disabled(true)
FileList.set_filters(EXTENSIONS) FileList.set_filters(EXTENSIONS)
Editor.hide() Editor.hide()
func close_editor(): func open_file(path : String):
Editor.hide() var current_file : File = File.new()
Filename.set_text("") current_file.open(path,File.READ)
TextEditor.set_text("") var current_content = current_file.get_as_text()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(path))
var file_tab = FileScene.instance()
Editor.add_child(file_tab)
file_tab.new_file_open(path,current_content,last_modified)
Editor.show()
current_file.close() current_file.close()
current_file = File.new() update_list()
current_path = ""
current_content = ""
func clear_editor(): func open_newfiledialogue():
TextEditor.set_text("") NewFileDialogue.popup()
Filename.set_text("") NewFileDialogue.set_position(OS.get_screen_size()/2 - NewFileDialogue.get_size()/2)
current_file = File.new()
func create_new_file(): func create_new_file():
close_editor() NewFileDialogue.hide()
SaveFile.set_disabled(true) var new_file_tab = FileScene.instance()
Editor.add_child(new_file_tab)
new_file_tab.new_file_create(NewFileDialogue_name.get_text())
Editor.show() Editor.show()
update_list()
func open_filelist(): func open_filelist():
FileList.update() update_list()
FileList.popup() FileList.popup()
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2) FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
func save_file_as():
current_content = TextEditor.get_text()
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 not FileList.is_connected("file_selected",self,"open_file"):
FileList.connect("file_selected",self,"open_file",[current_content])
else:
FileList.disconnect("file_selected",self,"open_file")
FileList.connect("file_selected",self,"open_file",[current_content])
open_filelist()
func open_selected_file(): func open_selected_file():
clear_editor() update_list()
FileList.mode = FileDialog.MODE_OPEN_FILE FileList.mode = FileDialog.MODE_OPEN_FILE
FileList.set_title("Select a file you want to edit") FileList.set_title("Select a file you want to edit")
if FileList.is_connected("file_selected",self,"delete_file"): if FileList.is_connected("file_selected",self,"delete_file"):
FileList.disconnect("file_selected",self,"delete_file") FileList.disconnect("file_selected",self,"delete_file")
if not FileList.is_connected("file_selected",self,"open_file"): if not FileList.is_connected("file_selected",self,"open_file"):
FileList.connect("file_selected",self,"open_file",[""]) FileList.connect("file_selected",self,"open_file")
else: else:
FileList.disconnect("file_selected",self,"open_file") FileList.disconnect("file_selected",self,"open_file")
FileList.connect("file_selected",self,"open_file",[""]) FileList.connect("file_selected",self,"open_file")
open_filelist() open_filelist()
func delete_selected_file(): func delete_selected_file():
update_list()
FileList.mode = FileDialog.MODE_OPEN_FILE FileList.mode = FileDialog.MODE_OPEN_FILE
FileList.set_title("Select a file you want to delete") FileList.set_title("Select a file you want to delete")
if FileList.is_connected("file_selected",self,"open_file"): if FileList.is_connected("file_selected",self,"open_file"):
@ -119,47 +106,11 @@ func delete_selected_file():
FileList.connect("file_selected",self,"delete_file") FileList.connect("file_selected",self,"delete_file")
open_filelist() open_filelist()
func open_file(path : String, content_file : String):
var content = ""
if content_file == "" or content_file == null:
current_file.open(path,File.READ)
content = current_file.get_as_text()
else:
content = content_file
current_file.open(path,File.WRITE)
current_file.store_line(content)
TextEditor.set_text(content)
Filename.set_text(path)
current_file.close()
current_path = path
current_content = content
Editor.show()
SaveFile.set_disabled(false)
func save_file():
if current_path == "" or current_path == null:
save_file_as()
else:
current_file.open(current_path,File.WRITE)
current_content = TextEditor.get_text()
if current_content == null:
current_content = ""
current_file.store_line(current_content)
current_file.close()
func delete_file(path : String): func delete_file(path : String):
clear_editor()
var dir = Directory.new() var dir = Directory.new()
dir.remove(path) dir.remove(path)
update_list()
func _on_Readonly_toggled(button_pressed): func update_list():
if button_pressed: FileList.invalidate()
ReadOnly.set_text("Read Only")
TextEditor.readonly = (true)
else:
ReadOnly.set_text("Can Edit")
TextEditor.readonly = (false)

View File

@ -0,0 +1,97 @@
tool
extends VBoxContainer
onready var CloseFile = $TopBar/close_btn
onready var ReadOnly = $FileInfo/Readonly
onready var FileButton = $TopBar/FileButton.get_popup()
onready var TextEditor = $TextEditor
onready var LastModified = $FileInfo/lastmodified
onready var FileList = get_parent().get_parent().get_parent().get_node("FileList")
onready var FilePath = $TopBar/filepath
var current_path = ""
var current_filename = ""
func _ready():
FileButton.connect("id_pressed",self,"button_pressed")
CloseFile.connect("pressed",self,"close_editor")
ReadOnly.connect("toggled",self,"_on_Readonly_toggled")
func new_file_open(file_path, file_content, last_modified) :
current_path = file_path
var filename_ = file_path.get_file().replace(".","-")
FilePath.set_text(current_path)
if get_parent().has_node(filename_):
queue_free()
else:
set_name(filename_)
current_filename = filename_
TextEditor.set_text(file_content)
LastModified.set_text(str(last_modified.hour)+":"+str(last_modified.minute)+" "+str(last_modified.day)+"/"+str(last_modified.month)+"/"+str(last_modified.year))
FileList.invalidate()
func new_file_create(file_name):
set_name(file_name)
current_filename = file_name
FileButton.set_item_disabled(0,true)
FileList.invalidate()
func save_file(current_path : String):
var current_file = File.new()
current_file.open(current_path,File.WRITE)
var current_content = TextEditor.get_text()
if current_content == null:
current_content = ""
current_file.store_line(current_content)
current_file.close()
var last_modified = OS.get_datetime_from_unix_time(current_file.get_modified_time(current_path))
LastModified.set_text(str(last_modified.hour)+":"+str(last_modified.minute)+" "+str(last_modified.day)+"/"+str(last_modified.month)+"/"+str(last_modified.year))
FilePath.set_text(current_path)
FileList.invalidate()
func save_file_as():
var current_content = TextEditor.get_text()
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 not FileList.is_connected("file_selected",self,"save_file"):
FileList.connect("file_selected",self,"save_file")
FileList.current_file = current_filename.replace("-",".")
open_filelist()
FileList.invalidate()
func open_filelist():
FileList.popup()
FileList.set_position(OS.get_screen_size()/2 - FileList.get_size()/2)
func button_pressed(id : int):
if id == 0:
save_file(current_path)
elif id == 1:
save_file_as()
func close_editor():
queue_free()
func _on_Readonly_toggled(button_pressed):
if button_pressed:
ReadOnly.set_text("Read Only")
TextEditor.readonly = (true)
else:
ReadOnly.set_text("Can Edit")
TextEditor.readonly = (false)