2014-02-10 01:10:30 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* script_editor_plugin.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
#ifndef SCRIPT_EDITOR_PLUGIN_H
|
|
|
|
#define SCRIPT_EDITOR_PLUGIN_H
|
|
|
|
|
2023-09-06 19:02:52 +00:00
|
|
|
#include "core/object/script_language.h"
|
2024-04-21 08:11:35 +00:00
|
|
|
#include "editor/plugins/editor_plugin.h"
|
2022-11-19 11:45:49 +00:00
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
#include "scene/resources/syntax_highlighter.h"
|
2018-05-28 15:52:28 +00:00
|
|
|
#include "scene/resources/text_file.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-02-18 02:16:58 +00:00
|
|
|
class CodeTextEditor;
|
2022-02-12 01:46:22 +00:00
|
|
|
class EditorFileDialog;
|
2022-11-19 11:45:49 +00:00
|
|
|
class EditorHelpSearch;
|
|
|
|
class FindReplaceBar;
|
|
|
|
class HSplitContainer;
|
|
|
|
class ItemList;
|
|
|
|
class MenuButton;
|
|
|
|
class TabContainer;
|
2022-11-11 19:12:48 +00:00
|
|
|
class TextureRect;
|
2022-11-19 11:45:49 +00:00
|
|
|
class Tree;
|
|
|
|
class VSplitContainer;
|
2022-11-02 14:23:25 +00:00
|
|
|
class WindowWrapper;
|
2022-02-12 01:46:22 +00:00
|
|
|
|
2020-05-03 16:08:15 +00:00
|
|
|
class EditorSyntaxHighlighter : public SyntaxHighlighter {
|
|
|
|
GDCLASS(EditorSyntaxHighlighter, SyntaxHighlighter)
|
|
|
|
|
|
|
|
private:
|
2024-07-17 16:44:27 +00:00
|
|
|
Ref<RefCounted> edited_resource;
|
2020-05-03 16:08:15 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2021-08-22 01:52:44 +00:00
|
|
|
GDVIRTUAL0RC(String, _get_name)
|
2022-08-05 01:41:48 +00:00
|
|
|
GDVIRTUAL0RC(PackedStringArray, _get_supported_languages)
|
2021-08-22 01:52:44 +00:00
|
|
|
|
2020-05-03 16:08:15 +00:00
|
|
|
public:
|
|
|
|
virtual String _get_name() const;
|
2022-08-05 01:41:48 +00:00
|
|
|
virtual PackedStringArray _get_supported_languages() const;
|
2020-05-03 16:08:15 +00:00
|
|
|
|
2024-07-17 16:44:27 +00:00
|
|
|
void _set_edited_resource(const Ref<Resource> &p_res) { edited_resource = p_res; }
|
|
|
|
Ref<RefCounted> _get_edited_resource() { return edited_resource; }
|
2020-05-03 16:08:15 +00:00
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorStandardSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|
|
|
GDCLASS(EditorStandardSyntaxHighlighter, EditorSyntaxHighlighter)
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ref<CodeHighlighter> highlighter;
|
2024-03-24 17:09:07 +00:00
|
|
|
ScriptLanguage *script_language = nullptr; // See GH-89610.
|
2020-05-03 16:08:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void _update_cache() override;
|
2021-08-22 01:52:44 +00:00
|
|
|
virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
|
2020-05-03 16:08:15 +00:00
|
|
|
|
|
|
|
virtual String _get_name() const override { return TTR("Standard"); }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
|
|
|
|
2024-03-24 17:09:07 +00:00
|
|
|
void _set_script_language(ScriptLanguage *p_script_language) { script_language = p_script_language; }
|
|
|
|
|
2021-06-17 22:03:09 +00:00
|
|
|
EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
|
2020-05-03 16:08:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EditorPlainTextSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|
|
|
GDCLASS(EditorPlainTextSyntaxHighlighter, EditorSyntaxHighlighter)
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String _get_name() const override { return TTR("Plain Text"); }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
|
|
|
};
|
|
|
|
|
2023-01-28 14:05:23 +00:00
|
|
|
class EditorJSONSyntaxHighlighter : public EditorSyntaxHighlighter {
|
|
|
|
GDCLASS(EditorJSONSyntaxHighlighter, EditorSyntaxHighlighter)
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ref<CodeHighlighter> highlighter;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual void _update_cache() override;
|
|
|
|
virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
|
|
|
|
|
|
|
|
virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "json" }; }
|
|
|
|
virtual String _get_name() const override { return TTR("JSON"); }
|
|
|
|
|
|
|
|
virtual Ref<EditorSyntaxHighlighter> _create() const override;
|
|
|
|
|
|
|
|
EditorJSONSyntaxHighlighter() { highlighter.instantiate(); }
|
|
|
|
};
|
|
|
|
|
2020-05-03 16:08:15 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
class ScriptEditorQuickOpen : public ConfirmationDialog {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
LineEdit *search_box = nullptr;
|
|
|
|
Tree *search_options = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
String function;
|
|
|
|
|
|
|
|
void _update_search();
|
|
|
|
|
2017-05-20 15:38:03 +00:00
|
|
|
void _sbox_input(const Ref<InputEvent> &p_ie);
|
2014-02-10 01:10:30 +00:00
|
|
|
Vector<String> functions;
|
|
|
|
|
|
|
|
void _confirmed();
|
|
|
|
void _text_changed(const String &p_newtext);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
public:
|
2018-10-02 10:07:44 +00:00
|
|
|
void popup_dialog(const Vector<String> &p_functions, bool p_dontclear = false);
|
2014-02-10 01:10:30 +00:00
|
|
|
ScriptEditorQuickOpen();
|
|
|
|
};
|
|
|
|
|
2020-02-07 01:52:05 +00:00
|
|
|
class EditorDebuggerNode;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-06-10 22:10:32 +00:00
|
|
|
class ScriptEditorBase : public VBoxContainer {
|
2019-03-19 18:35:57 +00:00
|
|
|
GDCLASS(ScriptEditorBase, VBoxContainer);
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2016-09-12 13:52:29 +00:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-05-03 16:08:15 +00:00
|
|
|
virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
|
|
|
|
virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
|
2018-04-02 11:41:44 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void apply_code() = 0;
|
2022-05-02 23:43:50 +00:00
|
|
|
virtual Ref<Resource> get_edited_resource() const = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual Vector<String> get_functions() = 0;
|
2022-05-02 23:43:50 +00:00
|
|
|
virtual void set_edited_resource(const Ref<Resource> &p_res) = 0;
|
2022-10-23 08:45:44 +00:00
|
|
|
virtual void enable_editor(Control *p_shortcut_context = nullptr) = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void reload_text() = 0;
|
|
|
|
virtual String get_name() = 0;
|
2020-03-12 12:37:40 +00:00
|
|
|
virtual Ref<Texture2D> get_theme_icon() = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual bool is_unsaved() = 0;
|
|
|
|
virtual Variant get_edit_state() = 0;
|
|
|
|
virtual void set_edit_state(const Variant &p_state) = 0;
|
2022-09-23 12:46:28 +00:00
|
|
|
virtual Variant get_navigation_state() = 0;
|
2024-07-05 23:27:19 +00:00
|
|
|
virtual void goto_line(int p_line, int p_column = 0) = 0;
|
2019-04-22 16:20:27 +00:00
|
|
|
virtual void set_executing_line(int p_line) = 0;
|
|
|
|
virtual void clear_executing_line() = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void trim_trailing_whitespace() = 0;
|
2024-01-12 05:32:13 +00:00
|
|
|
virtual void trim_final_newlines() = 0;
|
2019-05-28 21:27:32 +00:00
|
|
|
virtual void insert_final_newline() = 0;
|
2023-05-01 20:41:50 +00:00
|
|
|
virtual void convert_indent() = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void ensure_focus() = 0;
|
|
|
|
virtual void tag_saved_version() = 0;
|
2018-05-28 15:52:28 +00:00
|
|
|
virtual void reload(bool p_soft) {}
|
2022-08-05 01:41:48 +00:00
|
|
|
virtual PackedInt32Array get_breakpoints() = 0;
|
2021-07-20 11:24:56 +00:00
|
|
|
virtual void set_breakpoint(int p_line, bool p_enabled) = 0;
|
|
|
|
virtual void clear_breakpoints() = 0;
|
2024-02-15 16:25:58 +00:00
|
|
|
virtual void add_callback(const String &p_function, const PackedStringArray &p_args) = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual void update_settings() = 0;
|
2016-08-06 22:00:54 +00:00
|
|
|
virtual void set_debugger_active(bool p_active) = 0;
|
2016-08-25 20:45:20 +00:00
|
|
|
virtual bool can_lose_focus_on_node_selection() { return true; }
|
2021-09-14 09:17:47 +00:00
|
|
|
virtual void update_toggle_scripts_button() {}
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2017-05-28 14:20:38 +00:00
|
|
|
virtual bool show_members_overview() = 0;
|
|
|
|
|
2021-11-07 17:26:15 +00:00
|
|
|
virtual void set_tooltip_request_func(const Callable &p_toolip_callback) = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
virtual Control *get_edit_menu() = 0;
|
2017-07-01 00:30:17 +00:00
|
|
|
virtual void clear_edit_menu() = 0;
|
2021-06-02 23:05:41 +00:00
|
|
|
virtual void set_find_replace_bar(FindReplaceBar *p_bar) = 0;
|
2016-08-02 22:11:05 +00:00
|
|
|
|
2021-05-13 19:50:25 +00:00
|
|
|
virtual Control *get_base_editor() const = 0;
|
2024-02-18 02:16:58 +00:00
|
|
|
virtual CodeTextEditor *get_code_editor() const = 0;
|
2021-05-13 19:50:25 +00:00
|
|
|
|
2019-05-08 16:49:49 +00:00
|
|
|
virtual void validate() = 0;
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
ScriptEditorBase() {}
|
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-05-02 23:43:50 +00:00
|
|
|
typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Resource> &p_resource);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-06-26 04:14:31 +00:00
|
|
|
class EditorScriptCodeCompletionCache;
|
2018-02-12 01:36:15 +00:00
|
|
|
class FindInFilesDialog;
|
|
|
|
class FindInFilesPanel;
|
2015-06-26 04:14:31 +00:00
|
|
|
|
2023-11-17 19:44:38 +00:00
|
|
|
#ifdef MINGW_ENABLED
|
|
|
|
#undef FILE_OPEN
|
|
|
|
#endif
|
|
|
|
|
2017-07-15 04:40:17 +00:00
|
|
|
class ScriptEditor : public PanelContainer {
|
|
|
|
GDCLASS(ScriptEditor, PanelContainer);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
enum {
|
2015-08-09 23:39:59 +00:00
|
|
|
FILE_NEW,
|
2018-08-14 22:41:23 +00:00
|
|
|
FILE_NEW_TEXTFILE,
|
2014-02-10 01:10:30 +00:00
|
|
|
FILE_OPEN,
|
2019-07-31 19:06:15 +00:00
|
|
|
FILE_REOPEN_CLOSED,
|
2017-04-27 15:07:39 +00:00
|
|
|
FILE_OPEN_RECENT,
|
2014-02-10 01:10:30 +00:00
|
|
|
FILE_SAVE,
|
|
|
|
FILE_SAVE_AS,
|
|
|
|
FILE_SAVE_ALL,
|
2018-06-21 09:10:43 +00:00
|
|
|
FILE_THEME,
|
2017-08-27 22:03:19 +00:00
|
|
|
FILE_RUN,
|
2015-06-22 03:03:19 +00:00
|
|
|
FILE_CLOSE,
|
2016-07-17 22:18:48 +00:00
|
|
|
CLOSE_DOCS,
|
2016-08-13 00:56:38 +00:00
|
|
|
CLOSE_ALL,
|
2017-11-20 05:15:40 +00:00
|
|
|
CLOSE_OTHER_TABS,
|
2017-07-10 12:11:31 +00:00
|
|
|
TOGGLE_SCRIPTS_PANEL,
|
2018-01-02 02:11:54 +00:00
|
|
|
SHOW_IN_FILE_SYSTEM,
|
2017-12-07 03:57:41 +00:00
|
|
|
FILE_COPY_PATH,
|
2016-06-08 23:00:02 +00:00
|
|
|
FILE_TOOL_RELOAD_SOFT,
|
2019-05-02 23:07:06 +00:00
|
|
|
SEARCH_IN_FILES,
|
2020-02-09 09:10:58 +00:00
|
|
|
REPLACE_IN_FILES,
|
2016-08-02 22:11:05 +00:00
|
|
|
SEARCH_HELP,
|
|
|
|
SEARCH_WEBSITE,
|
|
|
|
HELP_SEARCH_FIND,
|
|
|
|
HELP_SEARCH_FIND_NEXT,
|
2019-10-09 15:41:49 +00:00
|
|
|
HELP_SEARCH_FIND_PREVIOUS,
|
2017-11-12 02:42:56 +00:00
|
|
|
WINDOW_MOVE_UP,
|
|
|
|
WINDOW_MOVE_DOWN,
|
2015-11-17 12:46:08 +00:00
|
|
|
WINDOW_NEXT,
|
|
|
|
WINDOW_PREV,
|
2017-11-12 02:42:56 +00:00
|
|
|
WINDOW_SORT,
|
2022-11-02 14:23:25 +00:00
|
|
|
WINDOW_SELECT_BASE = 100,
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2018-06-21 09:10:43 +00:00
|
|
|
enum {
|
|
|
|
THEME_IMPORT,
|
|
|
|
THEME_RELOAD,
|
|
|
|
THEME_SAVE,
|
|
|
|
THEME_SAVE_AS
|
|
|
|
};
|
|
|
|
|
2017-02-02 12:31:01 +00:00
|
|
|
enum ScriptSortBy {
|
|
|
|
SORT_BY_NAME,
|
|
|
|
SORT_BY_PATH,
|
2018-02-14 16:32:33 +00:00
|
|
|
SORT_BY_NONE
|
2017-02-02 12:31:01 +00:00
|
|
|
};
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2017-02-02 12:31:01 +00:00
|
|
|
enum ScriptListName {
|
|
|
|
DISPLAY_NAME,
|
|
|
|
DISPLAY_DIR_AND_NAME,
|
|
|
|
DISPLAY_FULL_PATH,
|
|
|
|
};
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
HBoxContainer *menu_hb = nullptr;
|
|
|
|
MenuButton *file_menu = nullptr;
|
|
|
|
MenuButton *edit_menu = nullptr;
|
|
|
|
MenuButton *script_search_menu = nullptr;
|
|
|
|
MenuButton *debug_menu = nullptr;
|
|
|
|
PopupMenu *context_menu = nullptr;
|
|
|
|
Timer *autosave_timer = nullptr;
|
2022-05-02 14:28:25 +00:00
|
|
|
uint64_t idle = 0;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
PopupMenu *recent_scripts = nullptr;
|
|
|
|
PopupMenu *theme_submenu = nullptr;
|
|
|
|
|
|
|
|
Button *help_search = nullptr;
|
|
|
|
Button *site_search = nullptr;
|
2022-11-02 14:23:25 +00:00
|
|
|
Button *make_floating = nullptr;
|
2023-08-15 04:40:32 +00:00
|
|
|
bool is_floating = false;
|
2022-04-04 13:06:57 +00:00
|
|
|
EditorHelpSearch *help_search_dialog = nullptr;
|
|
|
|
|
|
|
|
ItemList *script_list = nullptr;
|
|
|
|
HSplitContainer *script_split = nullptr;
|
|
|
|
ItemList *members_overview = nullptr;
|
|
|
|
LineEdit *filter_scripts = nullptr;
|
|
|
|
LineEdit *filter_methods = nullptr;
|
|
|
|
VBoxContainer *scripts_vbox = nullptr;
|
|
|
|
VBoxContainer *overview_vbox = nullptr;
|
|
|
|
HBoxContainer *buttons_hbox = nullptr;
|
|
|
|
Label *filename = nullptr;
|
|
|
|
Button *members_overview_alphabeta_sort_button = nullptr;
|
2017-05-28 14:20:38 +00:00
|
|
|
bool members_overview_enabled;
|
2022-04-04 13:06:57 +00:00
|
|
|
ItemList *help_overview = nullptr;
|
2017-09-14 00:56:37 +00:00
|
|
|
bool help_overview_enabled;
|
2022-04-04 13:06:57 +00:00
|
|
|
VSplitContainer *list_split = nullptr;
|
|
|
|
TabContainer *tab_container = nullptr;
|
|
|
|
EditorFileDialog *file_dialog = nullptr;
|
|
|
|
AcceptDialog *error_dialog = nullptr;
|
|
|
|
ConfirmationDialog *erase_tab_confirm = nullptr;
|
|
|
|
ScriptCreateDialog *script_create_dialog = nullptr;
|
|
|
|
Button *scripts_visible = nullptr;
|
|
|
|
FindReplaceBar *find_replace_bar = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-04-12 14:45:31 +00:00
|
|
|
String current_theme;
|
|
|
|
|
2024-02-18 02:16:58 +00:00
|
|
|
float zoom_factor = 1.0f;
|
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
TextureRect *script_icon = nullptr;
|
|
|
|
Label *script_name_label = nullptr;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Button *script_back = nullptr;
|
|
|
|
Button *script_forward = nullptr;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
FindInFilesDialog *find_in_files_dialog = nullptr;
|
|
|
|
FindInFilesPanel *find_in_files = nullptr;
|
|
|
|
Button *find_in_files_button = nullptr;
|
2018-02-12 01:36:15 +00:00
|
|
|
|
2022-11-02 14:23:25 +00:00
|
|
|
WindowWrapper *window_wrapper = nullptr;
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
enum {
|
2018-04-02 11:41:44 +00:00
|
|
|
SCRIPT_EDITOR_FUNC_MAX = 32,
|
2016-08-02 22:11:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int script_editor_func_count;
|
|
|
|
static CreateScriptEditorFunc script_editor_funcs[SCRIPT_EDITOR_FUNC_MAX];
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2020-05-03 16:08:15 +00:00
|
|
|
Vector<Ref<EditorSyntaxHighlighter>> syntax_highlighters;
|
2018-04-02 11:41:44 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
struct ScriptHistory {
|
2020-11-24 09:12:55 +00:00
|
|
|
Control *control = nullptr;
|
2016-08-02 22:11:05 +00:00
|
|
|
Variant state;
|
2015-11-17 12:46:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Vector<ScriptHistory> history;
|
|
|
|
int history_pos;
|
|
|
|
|
2019-07-31 19:06:15 +00:00
|
|
|
List<String> previous_scripts;
|
2021-09-07 21:38:19 +00:00
|
|
|
List<int> script_close_queue;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _tab_changed(int p_which);
|
2017-08-12 16:52:50 +00:00
|
|
|
void _menu_option(int p_option);
|
2018-06-21 09:10:43 +00:00
|
|
|
void _theme_option(int p_option);
|
2019-05-23 15:18:24 +00:00
|
|
|
void _show_save_theme_as_dialog();
|
2022-01-21 04:12:48 +00:00
|
|
|
bool _has_docs_tab() const;
|
|
|
|
bool _has_script_tab() const;
|
|
|
|
void _prepare_file_menu();
|
2023-03-03 18:13:58 +00:00
|
|
|
void _file_menu_closed();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
Tree *disk_changed_list = nullptr;
|
|
|
|
ConfirmationDialog *disk_changed = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-06-22 03:03:19 +00:00
|
|
|
bool restoring_layout;
|
|
|
|
|
2017-08-12 16:52:50 +00:00
|
|
|
String _get_debug_tooltip(const String &p_text, Node *_se);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _resave_scripts(const String &p_str);
|
|
|
|
|
2022-05-02 23:43:50 +00:00
|
|
|
bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-02-15 16:25:58 +00:00
|
|
|
void _add_recent_script(const String &p_path);
|
2017-04-27 15:07:39 +00:00
|
|
|
void _update_recent_scripts();
|
|
|
|
void _open_recent_script(int p_idx);
|
|
|
|
|
2024-02-15 16:25:58 +00:00
|
|
|
void _show_error_dialog(const String &p_path);
|
2018-01-08 00:31:36 +00:00
|
|
|
|
2018-02-06 21:32:03 +00:00
|
|
|
void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
|
2021-06-24 13:38:29 +00:00
|
|
|
void _update_find_replace_bar();
|
2016-07-06 23:35:49 +00:00
|
|
|
|
2024-04-23 21:33:01 +00:00
|
|
|
void _close_current_tab(bool p_save = true, bool p_history_back = true);
|
2017-01-02 18:45:59 +00:00
|
|
|
void _close_discard_current_tab(const String &p_str);
|
2016-07-17 22:18:48 +00:00
|
|
|
void _close_docs_tab();
|
2017-11-20 05:15:40 +00:00
|
|
|
void _close_other_tabs();
|
2016-08-13 00:56:38 +00:00
|
|
|
void _close_all_tabs();
|
2021-09-07 21:38:19 +00:00
|
|
|
void _queue_close_tabs();
|
2016-08-13 00:56:38 +00:00
|
|
|
|
2017-12-07 03:57:41 +00:00
|
|
|
void _copy_script_path();
|
|
|
|
|
2016-08-13 00:56:38 +00:00
|
|
|
void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-06-22 03:03:19 +00:00
|
|
|
bool grab_focus_block;
|
|
|
|
|
2016-06-03 15:34:11 +00:00
|
|
|
bool pending_auto_reload;
|
|
|
|
bool auto_reload_running_scripts;
|
2023-12-30 07:06:54 +00:00
|
|
|
bool reload_all_scripts = false;
|
|
|
|
Vector<String> script_paths_to_reload;
|
2016-06-03 15:34:11 +00:00
|
|
|
void _live_auto_reload_running_scripts();
|
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
void _update_selected_editor_menu();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
EditorScriptCodeCompletionCache *completion_cache = nullptr;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void _editor_stop();
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
int edit_pass;
|
|
|
|
|
2020-02-17 21:06:54 +00:00
|
|
|
void _add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _res_saved_callback(const Ref<Resource> &p_res);
|
2021-11-06 01:15:19 +00:00
|
|
|
void _scene_saved_callback(const String &p_path);
|
2024-01-02 11:53:18 +00:00
|
|
|
void _mark_built_in_scripts_as_saved(const String &p_parent_path);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2021-09-23 21:09:15 +00:00
|
|
|
bool open_textfile_after_create = true;
|
2016-04-23 18:21:34 +00:00
|
|
|
bool trim_trailing_whitespace_on_save;
|
2024-01-12 05:32:13 +00:00
|
|
|
bool trim_final_newlines_on_save;
|
2017-04-17 13:46:00 +00:00
|
|
|
bool convert_indent_on_save;
|
2023-10-07 11:05:36 +00:00
|
|
|
bool external_editor_active;
|
2016-04-23 18:21:34 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void _goto_script_line2(int p_line);
|
2022-05-02 23:43:50 +00:00
|
|
|
void _goto_script_line(Ref<RefCounted> p_script, int p_line);
|
|
|
|
void _set_execution(Ref<RefCounted> p_script, int p_line);
|
|
|
|
void _clear_execution(Ref<RefCounted> p_script);
|
2014-02-10 01:10:30 +00:00
|
|
|
void _breaked(bool p_breaked, bool p_can_debug);
|
2015-08-09 23:39:59 +00:00
|
|
|
void _script_created(Ref<Script> p_script);
|
2022-05-02 23:43:50 +00:00
|
|
|
void _set_breakpoint(Ref<RefCounted> p_scrpt, int p_line, bool p_enabled);
|
2021-07-20 11:24:56 +00:00
|
|
|
void _clear_breakpoints();
|
2021-10-07 18:46:44 +00:00
|
|
|
Array _get_cached_breakpoints_for_script(const String &p_path) const;
|
2014-05-06 09:43:14 +00:00
|
|
|
|
2018-02-12 01:36:15 +00:00
|
|
|
ScriptEditorBase *_get_current_editor() const;
|
2022-08-05 18:35:08 +00:00
|
|
|
TypedArray<ScriptEditorBase> _get_open_script_editors() const;
|
2018-02-12 01:36:15 +00:00
|
|
|
|
2021-10-07 18:44:23 +00:00
|
|
|
Ref<ConfigFile> script_editor_cache;
|
|
|
|
void _save_editor_state(ScriptEditorBase *p_editor);
|
2016-07-18 15:30:43 +00:00
|
|
|
void _save_layout();
|
2015-05-05 02:32:40 +00:00
|
|
|
void _editor_settings_changed();
|
2024-02-18 02:16:58 +00:00
|
|
|
void _apply_editor_settings();
|
2020-07-23 12:21:28 +00:00
|
|
|
void _filesystem_changed();
|
2021-10-07 18:44:23 +00:00
|
|
|
void _files_moved(const String &p_old_file, const String &p_new_file);
|
2020-07-23 12:21:28 +00:00
|
|
|
void _file_removed(const String &p_file);
|
2015-05-05 02:32:40 +00:00
|
|
|
void _autosave_scripts();
|
2019-10-10 20:19:47 +00:00
|
|
|
void _update_autosave_timer();
|
2024-08-23 20:34:24 +00:00
|
|
|
void _reload_scripts(bool p_refresh_only = false);
|
2015-05-05 02:32:40 +00:00
|
|
|
|
2017-05-28 14:20:38 +00:00
|
|
|
void _update_members_overview_visibility();
|
|
|
|
void _update_members_overview();
|
2018-04-30 12:27:00 +00:00
|
|
|
void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
|
2019-06-03 19:57:06 +00:00
|
|
|
void _filter_scripts_text_changed(const String &p_newtext);
|
|
|
|
void _filter_methods_text_changed(const String &p_newtext);
|
2015-06-22 03:03:19 +00:00
|
|
|
void _update_script_names();
|
2017-11-12 02:42:56 +00:00
|
|
|
bool _sort_list_on_update;
|
2015-06-22 03:03:19 +00:00
|
|
|
|
2017-05-28 14:20:38 +00:00
|
|
|
void _members_overview_selected(int p_idx);
|
2015-06-22 03:03:19 +00:00
|
|
|
void _script_selected(int p_idx);
|
|
|
|
|
2017-09-14 00:56:37 +00:00
|
|
|
void _update_help_overview_visibility();
|
|
|
|
void _update_help_overview();
|
|
|
|
void _help_overview_selected(int p_idx);
|
|
|
|
|
2024-04-20 16:16:14 +00:00
|
|
|
void _update_online_doc();
|
|
|
|
|
2022-05-19 15:00:06 +00:00
|
|
|
void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used);
|
2015-06-22 03:03:19 +00:00
|
|
|
|
|
|
|
void _tree_changed();
|
|
|
|
|
2022-02-02 21:35:40 +00:00
|
|
|
void _split_dragged(float);
|
2015-06-22 03:03:19 +00:00
|
|
|
|
2017-11-12 02:42:56 +00:00
|
|
|
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
|
|
|
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
|
|
|
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
|
|
|
|
2020-03-08 16:32:49 +00:00
|
|
|
virtual void input(const Ref<InputEvent> &p_event) override;
|
2022-01-11 13:59:52 +00:00
|
|
|
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
|
2016-06-26 00:02:17 +00:00
|
|
|
|
2022-07-28 11:38:13 +00:00
|
|
|
void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);
|
2017-11-11 21:36:46 +00:00
|
|
|
void _make_script_list_context_menu();
|
|
|
|
|
2024-02-15 16:25:58 +00:00
|
|
|
void _help_search(const String &p_text);
|
2015-11-17 12:46:08 +00:00
|
|
|
|
|
|
|
void _history_forward();
|
|
|
|
void _history_back();
|
|
|
|
|
2015-06-22 03:03:19 +00:00
|
|
|
bool waiting_update_names;
|
2022-10-22 21:54:37 +00:00
|
|
|
bool lock_history = false;
|
2015-06-22 03:03:19 +00:00
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void _help_class_open(const String &p_class);
|
|
|
|
void _help_class_goto(const String &p_desc);
|
2022-04-05 07:18:45 +00:00
|
|
|
bool _help_tab_goto(const String &p_name, const String &p_desc);
|
2015-11-17 12:46:08 +00:00
|
|
|
void _update_history_arrows();
|
2016-09-12 13:52:29 +00:00
|
|
|
void _save_history();
|
2022-10-22 21:54:37 +00:00
|
|
|
void _save_previous_state(Dictionary p_state);
|
2015-11-17 12:46:08 +00:00
|
|
|
void _go_to_tab(int p_idx);
|
|
|
|
void _update_history_pos(int p_new_pos);
|
|
|
|
void _update_script_colors();
|
2016-06-20 01:07:07 +00:00
|
|
|
void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-08-18 19:43:23 +00:00
|
|
|
void _script_changed();
|
2016-04-12 14:45:31 +00:00
|
|
|
int file_dialog_option;
|
2024-02-15 16:25:58 +00:00
|
|
|
void _file_dialog_action(const String &p_file);
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-07-06 07:18:20 +00:00
|
|
|
Ref<Script> _get_current_script();
|
2022-08-05 18:35:08 +00:00
|
|
|
TypedArray<Script> _get_open_scripts() const;
|
2017-07-06 07:18:20 +00:00
|
|
|
|
2022-05-19 15:00:06 +00:00
|
|
|
HashSet<String> textfile_extensions;
|
2021-10-12 16:31:20 +00:00
|
|
|
Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;
|
2018-05-28 15:52:28 +00:00
|
|
|
Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
|
|
|
|
|
2024-02-15 16:25:58 +00:00
|
|
|
void _on_find_in_files_requested(const String &text);
|
|
|
|
void _on_replace_in_files_requested(const String &text);
|
|
|
|
void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end);
|
2018-02-12 01:36:15 +00:00
|
|
|
void _start_find_in_files(bool with_replace);
|
2024-02-15 16:25:58 +00:00
|
|
|
void _on_find_in_files_modified_files(const PackedStringArray &paths);
|
2024-02-25 14:40:39 +00:00
|
|
|
void _on_find_in_files_close_button_clicked();
|
2018-02-12 01:36:15 +00:00
|
|
|
|
2024-02-18 02:16:58 +00:00
|
|
|
void _set_zoom_factor(float p_zoom_factor);
|
|
|
|
|
2022-11-02 14:23:25 +00:00
|
|
|
void _window_changed(bool p_visible);
|
|
|
|
|
2016-08-25 20:45:20 +00:00
|
|
|
static void _open_script_request(const String &p_path);
|
2023-04-09 18:43:55 +00:00
|
|
|
void _close_builtin_scripts_from_scene(const String &p_scene);
|
2016-08-25 20:45:20 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
static ScriptEditor *script_editor;
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2014-02-10 01:10:30 +00:00
|
|
|
static ScriptEditor *get_singleton() { return script_editor; }
|
|
|
|
|
2019-12-18 19:32:25 +00:00
|
|
|
bool toggle_scripts_panel();
|
2019-12-15 13:35:16 +00:00
|
|
|
bool is_scripts_panel_toggled();
|
2014-02-10 01:10:30 +00:00
|
|
|
void apply_scripts() const;
|
2022-09-25 15:13:39 +00:00
|
|
|
void reload_scripts(bool p_refresh_only = false);
|
2017-12-13 17:41:28 +00:00
|
|
|
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
|
2021-09-23 21:09:15 +00:00
|
|
|
void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = "");
|
2022-05-02 23:43:50 +00:00
|
|
|
Ref<Resource> open_file(const String &p_file);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
void ensure_select_current();
|
2017-04-15 17:48:10 +00:00
|
|
|
|
2023-08-15 04:40:32 +00:00
|
|
|
bool is_editor_floating();
|
|
|
|
|
2022-05-02 23:43:50 +00:00
|
|
|
_FORCE_INLINE_ bool edit(const Ref<Resource> &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
|
|
|
|
bool edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus = true);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2024-04-17 07:44:44 +00:00
|
|
|
Vector<String> _get_breakpoints();
|
2014-02-10 01:10:30 +00:00
|
|
|
void get_breakpoints(List<String> *p_breakpoints);
|
|
|
|
|
2022-10-16 17:30:38 +00:00
|
|
|
PackedStringArray get_unsaved_scripts() const;
|
2021-05-09 10:29:50 +00:00
|
|
|
void save_current_script();
|
2016-02-03 00:10:52 +00:00
|
|
|
void save_all_scripts();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2015-06-22 03:03:19 +00:00
|
|
|
void set_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
void get_window_layout(Ref<ConfigFile> p_layout);
|
|
|
|
|
2015-11-17 12:46:08 +00:00
|
|
|
void set_scene_root_script(Ref<Script> p_script);
|
2020-03-17 06:33:00 +00:00
|
|
|
Vector<Ref<Script>> get_open_scripts() const;
|
2015-11-17 12:46:08 +00:00
|
|
|
|
2017-04-15 17:48:10 +00:00
|
|
|
bool script_goto_method(Ref<Script> p_script, const String &p_method);
|
2016-06-11 23:01:17 +00:00
|
|
|
|
2015-12-09 12:08:41 +00:00
|
|
|
virtual void edited_scene_changed();
|
|
|
|
|
2017-07-06 07:18:20 +00:00
|
|
|
void notify_script_close(const Ref<Script> &p_script);
|
|
|
|
void notify_script_changed(const Ref<Script> &p_script);
|
|
|
|
|
2016-08-24 02:15:16 +00:00
|
|
|
void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
|
2020-11-29 02:37:57 +00:00
|
|
|
void update_doc(const String &p_name);
|
2022-10-04 05:58:58 +00:00
|
|
|
void clear_docs_from_script(const Ref<Script> &p_script);
|
|
|
|
void update_docs_from_script(const Ref<Script> &p_script);
|
2016-08-24 02:15:16 +00:00
|
|
|
|
2023-12-30 07:06:54 +00:00
|
|
|
void trigger_live_script_reload(const String &p_script_path);
|
|
|
|
void trigger_live_script_reload_all();
|
2023-10-08 02:14:54 +00:00
|
|
|
|
2016-08-25 20:45:20 +00:00
|
|
|
bool can_take_away_focus() const;
|
|
|
|
|
2017-07-01 00:30:17 +00:00
|
|
|
VSplitContainer *get_left_list_split() { return list_split; }
|
|
|
|
|
2016-06-03 15:34:11 +00:00
|
|
|
void set_live_auto_reload_running_scripts(bool p_enabled);
|
2015-08-02 15:29:37 +00:00
|
|
|
|
2020-05-03 16:08:15 +00:00
|
|
|
void register_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
|
|
|
|
void unregister_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
|
2020-03-07 14:29:44 +00:00
|
|
|
|
2016-08-02 22:11:05 +00:00
|
|
|
static void register_create_script_editor_function(CreateScriptEditorFunc p_func);
|
2018-04-02 11:41:44 +00:00
|
|
|
|
2022-11-02 14:23:25 +00:00
|
|
|
ScriptEditor(WindowWrapper *p_wrapper);
|
2015-06-26 04:14:31 +00:00
|
|
|
~ScriptEditor();
|
2014-02-10 01:10:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class ScriptEditorPlugin : public EditorPlugin {
|
2017-01-03 02:03:46 +00:00
|
|
|
GDCLASS(ScriptEditorPlugin, EditorPlugin);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
ScriptEditor *script_editor = nullptr;
|
2022-11-02 14:23:25 +00:00
|
|
|
WindowWrapper *window_wrapper = nullptr;
|
|
|
|
|
|
|
|
String last_editor;
|
|
|
|
|
|
|
|
void _focus_another_editor();
|
|
|
|
|
2024-02-15 16:25:58 +00:00
|
|
|
void _save_last_editor(const String &p_editor);
|
2022-11-02 14:23:25 +00:00
|
|
|
void _window_visibility_changed(bool p_visible);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual String get_name() const override { return "Script"; }
|
|
|
|
bool has_main_screen() const override { return true; }
|
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
|
|
|
virtual void selected_notify() override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2023-04-05 13:45:41 +00:00
|
|
|
virtual String get_unsaved_status(const String &p_for_scene) const override;
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void save_external_data() override;
|
|
|
|
virtual void apply_changes() override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void set_window_layout(Ref<ConfigFile> p_layout) override;
|
|
|
|
virtual void get_window_layout(Ref<ConfigFile> p_layout) override;
|
2015-06-22 03:03:19 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void get_breakpoints(List<String> *p_breakpoints) override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 10:34:39 +00:00
|
|
|
virtual void edited_scene_changed() override;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2022-01-27 09:36:51 +00:00
|
|
|
ScriptEditorPlugin();
|
2014-02-10 01:10:30 +00:00
|
|
|
~ScriptEditorPlugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SCRIPT_EDITOR_PLUGIN_H
|