mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-09 12:29:35 +01:00
Now the TextEditor addon will add it's own "create file" entry to the editor's filesystem dock.
This commit is contained in:
parent
0cbc01144d
commit
1d101bfea1
@ -24,6 +24,9 @@ SOFTWARE.
|
||||
|
||||
#include "text_editor_file.h"
|
||||
#include "text_file_editor.h"
|
||||
#include "editor/editor_node.h"
|
||||
|
||||
#include "editor/filesystem_dock.h"
|
||||
|
||||
void TextEditorEditorPlugin::make_visible(const bool visible) {
|
||||
window->set_visible(visible);
|
||||
@ -59,6 +62,10 @@ TextEditorEditorPlugin::TextEditorEditorPlugin(EditorNode *p_node) {
|
||||
window = memnew(TextFileEditor);
|
||||
|
||||
get_editor_interface()->get_editor_viewport()->add_child(window);
|
||||
|
||||
_filesystem_dock_entry_id = get_editor_interface()->get_file_system_dock()->add_custom_popup_creation_entry("New Textfile...", "TextEditorFile", "EditorIcons");
|
||||
get_editor_interface()->get_file_system_dock()->connect("custom_popup_creation_entry_pressed", this, "_on_filesystem_dock_entry_pressed");
|
||||
|
||||
make_visible(false);
|
||||
_icon = get_editor_interface()->get_base_control()->get_theme_icon("File", "EditorIcons");
|
||||
}
|
||||
@ -66,5 +73,13 @@ TextEditorEditorPlugin::TextEditorEditorPlugin(EditorNode *p_node) {
|
||||
TextEditorEditorPlugin::~TextEditorEditorPlugin() {
|
||||
}
|
||||
|
||||
void TextEditorEditorPlugin::_bind_methods() {
|
||||
void TextEditorEditorPlugin::_on_filesystem_dock_entry_pressed(int id) {
|
||||
if (_filesystem_dock_entry_id == id) {
|
||||
editor->select_editor_by_name(get_name());
|
||||
window->create_selected_file();
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditorEditorPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_on_filesystem_dock_entry_pressed"), &TextEditorEditorPlugin::_on_filesystem_dock_entry_pressed);
|
||||
}
|
||||
|
@ -49,9 +49,12 @@ public:
|
||||
TextFileEditor *window;
|
||||
|
||||
protected:
|
||||
void _on_filesystem_dock_entry_pressed(int id);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
Ref<Texture> _icon;
|
||||
int _filesystem_dock_entry_id;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user