update v0.1.0
14
file-editor/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# Godot Text Editor
|
||||
A little plugin to easy-way manage your text files inside your project folder.
|
||||
|
||||
Author: *"Nicolo (fenix) Santilio"*
|
||||
Version: *0.1.0*
|
||||
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)!**
|
||||
|
||||
## What is this?
|
||||
Building...
|
||||
|
||||
## How does it work?
|
||||
Building...
|
1
file-editor/TODO.md
Normal file
@ -0,0 +1 @@
|
||||
### to do (v-0.x.x)
|
3
file-editor/VERSION.md
Normal file
@ -0,0 +1,3 @@
|
||||
**version 0.1.0**
|
||||
|
||||
|
BIN
file-editor/fonts/Roboto-Black.ttf
Normal file
BIN
file-editor/fonts/Roboto-Regular.ttf
Normal file
BIN
file-editor/icon.png
Normal file
After Width: | Height: | Size: 889 B |
5
file-editor/icons/delete.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<path transform="translate(0 1036.4)" d="m5 1v1h-4v2h14v-2h-4v-1h-6zm-3 4v8a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2v-8h-12zm1 2h2v6h-2v-6zm4 0h2v6h-2v-6zm4 0h2v6h-2v-6z" fill="#e0e0e0" fill-opacity=".99608"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 347 B |
BIN
file-editor/icons/edit.png
Normal file
After Width: | Height: | Size: 244 B |
7
file-editor/icons/file.svg
Normal file
@ -0,0 +1,7 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<g transform="translate(0 -1.6949e-5)">
|
||||
<path transform="translate(0 1036.4)" d="m2 1v14h12v-9h-5v-5zm8 0v4h4z" fill="#e0e0e0"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 281 B |
8
file-editor/icons/new.svg
Normal file
@ -0,0 +1,8 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<g transform="translate(0 -1.6949e-5)">
|
||||
<path transform="translate(0 1036.4)" d="m2 1v14h8v-1h-2v-4h2v-2h4v-2h-5v-5zm8 0v4h4z" fill="#e0e0e0"/>
|
||||
<path d="m11 1045.4v2h-2v2h2v2h2v-2h2v-2h-2v-2z" fill="#84ffb1"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 362 B |
3
file-editor/icons/read.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m8 2c-2.5567 0-5.7907 1.9477-6.9551 5.7051a1.0001 1.0001 0 0 0 -0.00586 0.57031c1.1244 3.9354 4.4609 5.7246 6.9609 5.7246s5.8365-1.7892 6.9609-5.7246a1.0001 1.0001 0 0 0 0 -0.55273c-1.1003-3.7876-4.4066-5.7227-6.9609-5.7227zm0 2a4 4 0 0 1 4 4 4 4 0 0 1 -4 4 4 4 0 0 1 -4 -4 4 4 0 0 1 4 -4zm0 2a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -2 -2z" color="#000000" color-rendering="auto" fill="#e0e0e0" fill-opacity=".99608" fill-rule="evenodd" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="isolation:auto;mix-blend-mode:normal;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-transform:none;white-space:normal"/>
|
||||
</svg>
|
After Width: | Height: | Size: 818 B |
5
file-editor/icons/save.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<g transform="translate(0 -1036.4)">
|
||||
<path transform="translate(0 1036.4)" d="m3 1c-1.1046 0-2 0.89543-2 2v10c0 1.1046 0.89543 2 2 2h10c1.1046 0 2-0.89543 2-2v-7-1-1l-3-3h-1v5 1h-8v-6zm1 0v5h3v-5h-3zm4 8c1.1046 0 2 0.89543 2 2 0 1.1046-0.89543 2-2 2s-2-0.89543-2-2c0-1.1046 0.89543-2 2-2z" fill="#e0e0e0"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 417 B |
BIN
file-editor/icons/saveas.png
Normal file
After Width: | Height: | Size: 250 B |
7
file-editor/plugin.cfg
Normal file
@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
name="File Editor"
|
||||
description="An internal file editor to view and edit text files in your project folder."
|
||||
author="Nicolò 'fenix' Santilio"
|
||||
version="0.1.0"
|
||||
script="scripts/file-editor.gd"
|
163
file-editor/scenes/FileEditor.tscn
Normal file
@ -0,0 +1,163 @@
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[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/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/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]
|
||||
outline_size = 3
|
||||
outline_color = Color( 0.168627, 0.160784, 0.192157, 1 )
|
||||
font_data = ExtResource( 5 )
|
||||
|
||||
[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="StyleBoxEmpty" id=7]
|
||||
|
||||
[sub_resource type="DynamicFont" id=8]
|
||||
font_data = ExtResource( 5 )
|
||||
|
||||
[node name="FileEditor" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Container" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="Container"]
|
||||
editor/display_folded = true
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 22.0
|
||||
|
||||
[node name="newfile_btn" type="Button" parent="Container/Buttons"]
|
||||
margin_right = 338.0
|
||||
margin_bottom = 22.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Create new File"
|
||||
icon = ExtResource( 2 )
|
||||
|
||||
[node name="openfile_btn" type="Button" parent="Container/Buttons"]
|
||||
margin_left = 342.0
|
||||
margin_right = 680.0
|
||||
margin_bottom = 22.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Open File"
|
||||
icon = ExtResource( 3 )
|
||||
|
||||
[node name="deletefile_btn" type="Button" parent="Container/Buttons"]
|
||||
margin_left = 684.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 22.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Delete File"
|
||||
icon = ExtResource( 4 )
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="Container"]
|
||||
margin_top = 26.0
|
||||
margin_right = 1024.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_bottom = 600.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TopBar" type="HBoxContainer" parent="Container/Editor"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="Filename" type="LineEdit" parent="Container/Editor/TopBar"]
|
||||
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="."]
|
||||
margin_top = 24.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_vertical = 3
|
||||
popup_exclusive = true
|
||||
dialog_hide_on_ok = true
|
||||
[connection signal="toggled" from="Container/Editor/TopBar/Readonly" to="." method="_on_Readonly_toggled"]
|
165
file-editor/scripts/FileEditor.gd
Normal file
@ -0,0 +1,165 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
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 OpenFile = $Container/Buttons/openfile_btn
|
||||
onready var NewFile = $Container/Buttons/newfile_btn
|
||||
onready var DeleteFile = $Container/Buttons/deletefile_btn
|
||||
|
||||
onready var SaveFile = $Container/Editor/EditorButtons/savefile_btn
|
||||
onready var SaveFileAs = $Container/Editor/EditorButtons/savefileas_btn
|
||||
|
||||
onready var ReadOnly = $Container/Editor/TopBar/Readonly
|
||||
|
||||
var DIRECTORY : String = "res://"
|
||||
var EXCEPTIONS : String = "addons"
|
||||
var EXTENSIONS : 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",
|
||||
]
|
||||
|
||||
var directories = []
|
||||
var files = []
|
||||
|
||||
# -----
|
||||
var current_file : File = File.new()
|
||||
var current_path : String = ""
|
||||
var current_content : String = ""
|
||||
# -----
|
||||
|
||||
func _ready():
|
||||
OpenFile.connect("pressed",self,"open_selected_file")
|
||||
NewFile.connect("pressed",self,"create_new_file")
|
||||
DeleteFile.connect("pressed",self,"delete_selected_file")
|
||||
|
||||
SaveFile.connect("pressed",self,"save_file")
|
||||
SaveFileAs.connect("pressed",self,"save_file_as")
|
||||
|
||||
CloseFile.connect("pressed",self,"close_editor")
|
||||
|
||||
Filename.set_editable(false)
|
||||
SaveFile.set_disabled(true)
|
||||
|
||||
FileList.set_filters(EXTENSIONS)
|
||||
|
||||
Editor.hide()
|
||||
|
||||
func close_editor():
|
||||
Editor.hide()
|
||||
Filename.set_text("")
|
||||
TextEditor.set_text("")
|
||||
current_file.close()
|
||||
current_file = File.new()
|
||||
current_path = ""
|
||||
current_content = ""
|
||||
|
||||
func clear_editor():
|
||||
TextEditor.set_text("")
|
||||
Filename.set_text("")
|
||||
current_file = File.new()
|
||||
|
||||
func create_new_file():
|
||||
close_editor()
|
||||
SaveFile.set_disabled(true)
|
||||
Editor.show()
|
||||
|
||||
func open_filelist():
|
||||
FileList.update()
|
||||
FileList.popup()
|
||||
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():
|
||||
clear_editor()
|
||||
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 not FileList.is_connected("file_selected",self,"open_file"):
|
||||
FileList.connect("file_selected",self,"open_file",[""])
|
||||
else:
|
||||
FileList.disconnect("file_selected",self,"open_file")
|
||||
FileList.connect("file_selected",self,"open_file",[""])
|
||||
open_filelist()
|
||||
|
||||
func delete_selected_file():
|
||||
FileList.mode = FileDialog.MODE_OPEN_FILE
|
||||
FileList.set_title("Select a file you want to delete")
|
||||
if FileList.is_connected("file_selected",self,"open_file"):
|
||||
FileList.disconnect("file_selected",self,"open_file")
|
||||
if not FileList.is_connected("file_selected",self,"delete_file"):
|
||||
FileList.connect("file_selected",self,"delete_file")
|
||||
else:
|
||||
FileList.disconnect("file_selected",self,"delete_file")
|
||||
FileList.connect("file_selected",self,"delete_file")
|
||||
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):
|
||||
clear_editor()
|
||||
var dir = Directory.new()
|
||||
dir.remove(path)
|
||||
|
||||
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)
|
14
file-editor/scripts/file-editor.gd
Normal file
@ -0,0 +1,14 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
var doc
|
||||
|
||||
func _enter_tree():
|
||||
doc = preload("../scenes/FileEditor.tscn").instance()
|
||||
add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR,doc)
|
||||
# add_autoload_singleton("UserData","res://addons/github-integration/scripts/user_data.gd")
|
||||
|
||||
func _exit_tree():
|
||||
remove_control_from_docks(doc)
|
||||
# remove_autoload_singleton("UserData")
|
||||
doc.queue_free()
|