diff --git a/addons/file-editor/README.md b/addons/file-editor/README.md index fe6e11b..c4905a7 100644 --- a/addons/file-editor/README.md +++ b/addons/file-editor/README.md @@ -2,7 +2,7 @@ A little plugin to easy-way manage your text files inside your project folder. Author: *"Nicolo (fenix) Santilio"* -Version: *0.2.5* +Version: *0.3.1* 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)!** @@ -28,11 +28,12 @@ Then, go to `Project > Plugins > "File Editor" > Status > Activate`. 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 +### Current version To check all the features included in the current version, please read the [VERSION file](./VERSION.md) -#### Upcoming features +### 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* + diff --git a/addons/file-editor/TODO.md b/addons/file-editor/TODO.md index 9be6dab..f88ece3 100644 --- a/addons/file-editor/TODO.md +++ b/addons/file-editor/TODO.md @@ -1,2 +1,4 @@ ### to do (v-0.x.x) - Popup dialog when closing a tab if there is new content +- Module for markdown support/conversion + diff --git a/addons/file-editor/VERSION.md b/addons/file-editor/VERSION.md index 605e6d8..0ed22d7 100644 --- a/addons/file-editor/VERSION.md +++ b/addons/file-editor/VERSION.md @@ -23,8 +23,6 @@ **version 0.2.5** *removed* - Old layout - ------------------------ *added* - New Layout @@ -33,3 +31,13 @@ ----------------------- +**version 0.3.1** +*added* +- Version check +- Preview support +- Context menu in editor +- BBCode converter +- Light Mardkwon converter (DEMO) + +----------------------- + diff --git a/addons/file-editor/fonts/COUR.TTF b/addons/file-editor/fonts/COUR.TTF new file mode 100644 index 0000000..46a0712 Binary files /dev/null and b/addons/file-editor/fonts/COUR.TTF differ diff --git a/addons/file-editor/fonts/Carlito-Bold.ttf b/addons/file-editor/fonts/Carlito-Bold.ttf new file mode 100644 index 0000000..b29a590 Binary files /dev/null and b/addons/file-editor/fonts/Carlito-Bold.ttf differ diff --git a/addons/file-editor/fonts/Carlito-BoldItalic.ttf b/addons/file-editor/fonts/Carlito-BoldItalic.ttf new file mode 100644 index 0000000..0eaa04e Binary files /dev/null and b/addons/file-editor/fonts/Carlito-BoldItalic.ttf differ diff --git a/addons/file-editor/fonts/Carlito-Italic.ttf b/addons/file-editor/fonts/Carlito-Italic.ttf new file mode 100644 index 0000000..64df01e Binary files /dev/null and b/addons/file-editor/fonts/Carlito-Italic.ttf differ diff --git a/addons/file-editor/fonts/Carlito-Regular.ttf b/addons/file-editor/fonts/Carlito-Regular.ttf new file mode 100644 index 0000000..6b7e0e3 Binary files /dev/null and b/addons/file-editor/fonts/Carlito-Regular.ttf differ diff --git a/addons/file-editor/plugin.cfg b/addons/file-editor/plugin.cfg index f910703..8246ec0 100644 --- a/addons/file-editor/plugin.cfg +++ b/addons/file-editor/plugin.cfg @@ -2,6 +2,6 @@ name="File Editor" description="An internal file editor to view and edit text files in your project folder." -author="Nicolò 'fenix' Santi" -version="0.2.5" +author="Nicolò 'fenix' Santilio" +version="0.3.1" script="scripts/file-editor.gd" diff --git a/addons/file-editor/scenes/FileEditor.tscn b/addons/file-editor/scenes/FileEditor.tscn index b7ae545..f503833 100644 --- a/addons/file-editor/scenes/FileEditor.tscn +++ b/addons/file-editor/scenes/FileEditor.tscn @@ -1,11 +1,16 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 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] -[sub_resource type="StyleBoxFlat" id=1] +[sub_resource type="DynamicFont" id=1] +size = 13 +font_data = ExtResource( 5 ) + +[sub_resource type="StyleBoxFlat" id=2] content_margin_left = 10.0 content_margin_right = 10.0 bg_color = Color( 0.196078, 0.231373, 0.309804, 1 ) @@ -25,7 +30,7 @@ border_width_right = 1 border_color = Color( 0.121569, 0.145098, 0.192157, 1 ) expand_margin_bottom = 1.0 -[sub_resource type="StyleBoxFlat" id=2] +[sub_resource type="StyleBoxFlat" id=4] bg_color = Color( 0.121569, 0.145098, 0.192157, 1 ) draw_center = false border_width_left = 1 @@ -44,42 +49,50 @@ 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_right = 337.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_left = 341.0 +margin_right = 678.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_left = 682.0 +margin_right = 1019.0 margin_bottom = 22.0 size_flags_horizontal = 3 text = "Delete File" icon = ExtResource( 4 ) +[node name="version" type="Label" parent="Container/Buttons"] +margin_left = 1023.0 +margin_top = 2.0 +margin_right = 1023.0 +margin_bottom = 19.0 +custom_fonts/font = SubResource( 1 ) +custom_colors/font_color = Color( 0.121569, 0.145098, 0.192157, 1 ) +align = 1 + [node name="Editor" type="TabContainer" parent="Container"] visible = false margin_top = 32.0 margin_right = 1024.0 margin_bottom = 600.0 size_flags_vertical = 3 -custom_styles/tab_fg = SubResource( 1 ) +custom_styles/tab_fg = SubResource( 2 ) custom_styles/tab_bg = SubResource( 3 ) -custom_styles/panel = SubResource( 2 ) +custom_styles/panel = SubResource( 4 ) custom_colors/font_color_fg = Color( 1, 1, 1, 1 ) tab_align = 0 drag_to_rearrange_enabled = true diff --git a/addons/file-editor/scenes/FileScene.tscn b/addons/file-editor/scenes/FileScene.tscn index 977e92b..aa1cb2e 100644 --- a/addons/file-editor/scenes/FileScene.tscn +++ b/addons/file-editor/scenes/FileScene.tscn @@ -5,13 +5,11 @@ [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] +[sub_resource type="StyleBoxFlat" id=1] 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] @@ -22,7 +20,9 @@ bg_color = Color( 0.145098, 0.172549, 0.231373, 1 ) [sub_resource type="StyleBoxEmpty" id=6] -[sub_resource type="DynamicFont" id=7] +[sub_resource type="StyleBoxEmpty" id=7] + +[sub_resource type="DynamicFont" id=8] font_data = ExtResource( 4 ) [node name="filename" type="VBoxContainer"] @@ -40,7 +40,6 @@ 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 @@ -53,11 +52,11 @@ margin_bottom = 20.0 margin_left = 8.0 margin_right = 51.0 margin_bottom = 20.0 -custom_styles/hover = SubResource( 8 ) -custom_styles/normal = SubResource( 8 ) +custom_styles/hover = SubResource( 1 ) +custom_styles/normal = SubResource( 1 ) 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 ] +items = [ "Save File", null, 0, false, false, 0, 0, null, "", false, "Save file As...", null, 0, false, false, 1, 0, null, "", false, "", null, 0, false, false, -1, 0, null, "", true, "Normal Preview", null, 0, false, false, 2, 0, null, "", false, "BBCode Preview", null, 0, false, false, 3, 0, null, "", false, "Markdown Preview (DEMO)", null, 0, false, false, 4, 0, null, "", false ] [node name="filepath" type="Label" parent="TopBar"] margin_left = 519.0 @@ -90,7 +89,8 @@ highlight_all_occurrences = true smooth_scrolling = true wrap_enabled = true caret_blink = true -caret_blink_speed = 0.1 +caret_blink_speed = 1.0 +caret_moving_by_right_click = false [node name="FileInfo" type="HBoxContainer" parent="."] editor/display_folded = true @@ -117,13 +117,13 @@ 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_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" diff --git a/addons/file-editor/scenes/Preview.tscn b/addons/file-editor/scenes/Preview.tscn new file mode 100644 index 0000000..f382193 --- /dev/null +++ b/addons/file-editor/scenes/Preview.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=12 format=2] + +[ext_resource path="res://addons/file-editor/scripts/Preview.gd" type="Script" id=1] +[ext_resource path="res://addons/file-editor/fonts/COUR.TTF" type="DynamicFontData" id=2] +[ext_resource path="res://addons/file-editor/fonts/Carlito-BoldItalic.ttf" type="DynamicFontData" id=3] +[ext_resource path="res://addons/file-editor/fonts/Carlito-Italic.ttf" type="DynamicFontData" id=4] +[ext_resource path="res://addons/file-editor/fonts/Carlito-Bold.ttf" type="DynamicFontData" id=5] +[ext_resource path="res://addons/file-editor/fonts/Carlito-Regular.ttf" type="DynamicFontData" id=6] + +[sub_resource type="DynamicFont" id=5] +use_mipmaps = true +use_filter = true +font_data = ExtResource( 2 ) + +[sub_resource type="DynamicFont" id=1] +font_data = ExtResource( 3 ) + +[sub_resource type="DynamicFont" id=2] +font_data = ExtResource( 4 ) + +[sub_resource type="DynamicFont" id=3] +font_data = ExtResource( 5 ) + +[sub_resource type="DynamicFont" id=4] +font_data = ExtResource( 6 ) + +[node name="Preview" type="WindowDialog"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 81.0 +margin_top = 47.0 +margin_right = -80.0 +margin_bottom = -48.0 +window_title = "File preview" +resizable = true +script = ExtResource( 1 ) + +[node name="Container" type="VBoxContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="TextPreview" type="RichTextLabel" parent="Container"] +margin_right = 863.0 +margin_bottom = 505.0 +size_flags_vertical = 3 +custom_fonts/mono_font = SubResource( 5 ) +custom_fonts/bold_italics_font = SubResource( 1 ) +custom_fonts/italics_font = SubResource( 2 ) +custom_fonts/bold_font = SubResource( 3 ) +custom_fonts/normal_font = SubResource( 4 ) +bbcode_enabled = true +scroll_following = true +[connection signal="popup_hide" from="." to="." method="_on_Preview_popup_hide"] diff --git a/addons/file-editor/scripts/FileEditor.gd b/addons/file-editor/scripts/FileEditor.gd index fc25ac1..06a5a3e 100644 --- a/addons/file-editor/scripts/FileEditor.gd +++ b/addons/file-editor/scripts/FileEditor.gd @@ -12,6 +12,8 @@ onready var DeleteFile = $Container/Buttons/deletefile_btn onready var NewFileDialogue = $NewFileDialogue onready var NewFileDialogue_name = $NewFileDialogue/VBoxContainer/new_filename +onready var Version = $Container/Buttons/version + var FileScene = load("res://addons/file-editor/scenes/FileScene.tscn") var DIRECTORY : String = "res://" @@ -31,7 +33,6 @@ var EXTENSIONS : PoolStringArray = [ var directories = [] var files = [] - func _ready(): OpenFile.connect("pressed",self,"open_selected_file") NewFile.connect("pressed",self,"open_newfiledialogue") @@ -45,6 +46,16 @@ func _ready(): FileList.set_filters(EXTENSIONS) Editor.hide() + + 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") + update_version("v"+plugin_version) + +func update_version(v : String): + Version.set_text(v) func open_file(path : String): var current_file : File = File.new() diff --git a/addons/file-editor/scripts/FileScene.gd b/addons/file-editor/scripts/FileScene.gd index 1c00b62..0052763 100644 --- a/addons/file-editor/scripts/FileScene.gd +++ b/addons/file-editor/scripts/FileScene.gd @@ -17,6 +17,8 @@ onready var FilePath = $TopBar/filepath var current_path = "" var current_filename = "" +var Preview = load("res://addons/file-editor/scenes/Preview.tscn") + func _ready(): FileButton.connect("id_pressed",self,"button_pressed") @@ -55,6 +57,7 @@ func save_file(current_path : String): 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)) @@ -84,6 +87,30 @@ func button_pressed(id : int): save_file(current_path) elif id == 1: save_file_as() + elif id == 2: + open_preview() + elif id == 3: + bbcode_preview() + elif id == 4: + markdown_preview() + +func open_preview(): + var preview = Preview.instance() + get_parent().get_parent().get_parent().add_child(preview) + preview.popup() + preview.print_preview(TextEditor.get_text()) + +func bbcode_preview(): + var preview = Preview.instance() + get_parent().get_parent().get_parent().add_child(preview) + preview.popup() + preview.print_bb(TextEditor.get_text()) + +func markdown_preview(): + var preview = Preview.instance() + get_parent().get_parent().get_parent().add_child(preview) + preview.popup() + preview.print_markdown(TextEditor.get_text()) func close_editor(): queue_free() diff --git a/addons/file-editor/scripts/Preview.gd b/addons/file-editor/scripts/Preview.gd new file mode 100644 index 0000000..7d9e234 --- /dev/null +++ b/addons/file-editor/scripts/Preview.gd @@ -0,0 +1,31 @@ +tool +extends WindowDialog + +onready var TextPreview = $Container/TextPreview + +func _ready(): + pass + +func print_preview(content : String): + TextPreview.append_bbcode(content) + +func print_bb(content : String): + TextPreview.append_bbcode(content) + +func print_markdown(content : String): + content = content.replace(" **"," [b]") + content = content.replace("**","[/b]") + + content = content.replace(" *"," [i]") + content = content.replace("*","[/i] ") + + content = content.replace(" ~~","[s] ") + content = content.replace("~~","[/s]") + + content = content.replace(" `"," [code]") + content = content.replace("`","[/code]") + + TextPreview.append_bbcode(content) + +func _on_Preview_popup_hide(): + queue_free() diff --git a/addons/file-editor/scripts/file-editor.gd b/addons/file-editor/scripts/file-editor.gd index 52a57d3..266c2a5 100644 --- a/addons/file-editor/scripts/file-editor.gd +++ b/addons/file-editor/scripts/file-editor.gd @@ -2,11 +2,13 @@ tool extends EditorPlugin var doc +var plugin_version func _enter_tree(): doc = preload("../scenes/FileEditor.tscn").instance() add_control_to_dock(EditorPlugin.DOCK_SLOT_LEFT_BR,doc) + func _exit_tree(): remove_control_from_docks(doc) doc.queue_free() \ No newline at end of file