script_editor_plugin.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /**************************************************************************/
  2. /* script_editor_plugin.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef SCRIPT_EDITOR_PLUGIN_H
  31. #define SCRIPT_EDITOR_PLUGIN_H
  32. #include "core/object/script_language.h"
  33. #include "editor/plugins/editor_plugin.h"
  34. #include "scene/gui/dialogs.h"
  35. #include "scene/gui/panel_container.h"
  36. #include "scene/resources/syntax_highlighter.h"
  37. #include "scene/resources/text_file.h"
  38. class CodeTextEditor;
  39. class EditorFileDialog;
  40. class EditorHelpSearch;
  41. class FindReplaceBar;
  42. class HSplitContainer;
  43. class ItemList;
  44. class MenuButton;
  45. class TabContainer;
  46. class TextureRect;
  47. class Tree;
  48. class VSplitContainer;
  49. class WindowWrapper;
  50. class EditorSyntaxHighlighter : public SyntaxHighlighter {
  51. GDCLASS(EditorSyntaxHighlighter, SyntaxHighlighter)
  52. private:
  53. Ref<RefCounted> edited_resource;
  54. protected:
  55. static void _bind_methods();
  56. GDVIRTUAL0RC(String, _get_name)
  57. GDVIRTUAL0RC(PackedStringArray, _get_supported_languages)
  58. public:
  59. virtual String _get_name() const;
  60. virtual PackedStringArray _get_supported_languages() const;
  61. void _set_edited_resource(const Ref<Resource> &p_res) { edited_resource = p_res; }
  62. Ref<RefCounted> _get_edited_resource() { return edited_resource; }
  63. virtual Ref<EditorSyntaxHighlighter> _create() const;
  64. };
  65. class EditorStandardSyntaxHighlighter : public EditorSyntaxHighlighter {
  66. GDCLASS(EditorStandardSyntaxHighlighter, EditorSyntaxHighlighter)
  67. private:
  68. Ref<CodeHighlighter> highlighter;
  69. ScriptLanguage *script_language = nullptr; // See GH-89610.
  70. public:
  71. virtual void _update_cache() override;
  72. virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
  73. virtual String _get_name() const override { return TTR("Standard"); }
  74. virtual Ref<EditorSyntaxHighlighter> _create() const override;
  75. void _set_script_language(ScriptLanguage *p_script_language) { script_language = p_script_language; }
  76. EditorStandardSyntaxHighlighter() { highlighter.instantiate(); }
  77. };
  78. class EditorPlainTextSyntaxHighlighter : public EditorSyntaxHighlighter {
  79. GDCLASS(EditorPlainTextSyntaxHighlighter, EditorSyntaxHighlighter)
  80. public:
  81. virtual String _get_name() const override { return TTR("Plain Text"); }
  82. virtual Ref<EditorSyntaxHighlighter> _create() const override;
  83. };
  84. class EditorJSONSyntaxHighlighter : public EditorSyntaxHighlighter {
  85. GDCLASS(EditorJSONSyntaxHighlighter, EditorSyntaxHighlighter)
  86. private:
  87. Ref<CodeHighlighter> highlighter;
  88. public:
  89. virtual void _update_cache() override;
  90. virtual Dictionary _get_line_syntax_highlighting_impl(int p_line) override { return highlighter->get_line_syntax_highlighting(p_line); }
  91. virtual PackedStringArray _get_supported_languages() const override { return PackedStringArray{ "json" }; }
  92. virtual String _get_name() const override { return TTR("JSON"); }
  93. virtual Ref<EditorSyntaxHighlighter> _create() const override;
  94. EditorJSONSyntaxHighlighter() { highlighter.instantiate(); }
  95. };
  96. ///////////////////////////////////////////////////////////////////////////////
  97. class ScriptEditorQuickOpen : public ConfirmationDialog {
  98. GDCLASS(ScriptEditorQuickOpen, ConfirmationDialog);
  99. LineEdit *search_box = nullptr;
  100. Tree *search_options = nullptr;
  101. String function;
  102. void _update_search();
  103. void _sbox_input(const Ref<InputEvent> &p_ie);
  104. Vector<String> functions;
  105. void _confirmed();
  106. void _text_changed(const String &p_newtext);
  107. protected:
  108. void _notification(int p_what);
  109. static void _bind_methods();
  110. public:
  111. void popup_dialog(const Vector<String> &p_functions, bool p_dontclear = false);
  112. ScriptEditorQuickOpen();
  113. };
  114. class EditorDebuggerNode;
  115. class ScriptEditorBase : public VBoxContainer {
  116. GDCLASS(ScriptEditorBase, VBoxContainer);
  117. protected:
  118. static void _bind_methods();
  119. public:
  120. virtual void add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
  121. virtual void set_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) = 0;
  122. virtual void apply_code() = 0;
  123. virtual Ref<Resource> get_edited_resource() const = 0;
  124. virtual Vector<String> get_functions() = 0;
  125. virtual void set_edited_resource(const Ref<Resource> &p_res) = 0;
  126. virtual void enable_editor(Control *p_shortcut_context = nullptr) = 0;
  127. virtual void reload_text() = 0;
  128. virtual String get_name() = 0;
  129. virtual Ref<Texture2D> get_theme_icon() = 0;
  130. virtual bool is_unsaved() = 0;
  131. virtual Variant get_edit_state() = 0;
  132. virtual void set_edit_state(const Variant &p_state) = 0;
  133. virtual Variant get_navigation_state() = 0;
  134. virtual void goto_line(int p_line, int p_column = 0) = 0;
  135. virtual void set_executing_line(int p_line) = 0;
  136. virtual void clear_executing_line() = 0;
  137. virtual void trim_trailing_whitespace() = 0;
  138. virtual void trim_final_newlines() = 0;
  139. virtual void insert_final_newline() = 0;
  140. virtual void convert_indent() = 0;
  141. virtual void ensure_focus() = 0;
  142. virtual void tag_saved_version() = 0;
  143. virtual void reload(bool p_soft) {}
  144. virtual PackedInt32Array get_breakpoints() = 0;
  145. virtual void set_breakpoint(int p_line, bool p_enabled) = 0;
  146. virtual void clear_breakpoints() = 0;
  147. virtual void add_callback(const String &p_function, const PackedStringArray &p_args) = 0;
  148. virtual void update_settings() = 0;
  149. virtual void set_debugger_active(bool p_active) = 0;
  150. virtual bool can_lose_focus_on_node_selection() { return true; }
  151. virtual void update_toggle_scripts_button() {}
  152. virtual bool show_members_overview() = 0;
  153. virtual void set_tooltip_request_func(const Callable &p_toolip_callback) = 0;
  154. virtual Control *get_edit_menu() = 0;
  155. virtual void clear_edit_menu() = 0;
  156. virtual void set_find_replace_bar(FindReplaceBar *p_bar) = 0;
  157. virtual Control *get_base_editor() const = 0;
  158. virtual CodeTextEditor *get_code_editor() const = 0;
  159. virtual void validate() = 0;
  160. ScriptEditorBase() {}
  161. };
  162. typedef ScriptEditorBase *(*CreateScriptEditorFunc)(const Ref<Resource> &p_resource);
  163. class EditorScriptCodeCompletionCache;
  164. class FindInFilesDialog;
  165. class FindInFilesPanel;
  166. #ifdef MINGW_ENABLED
  167. #undef FILE_OPEN
  168. #endif
  169. class ScriptEditor : public PanelContainer {
  170. GDCLASS(ScriptEditor, PanelContainer);
  171. enum {
  172. FILE_NEW,
  173. FILE_NEW_TEXTFILE,
  174. FILE_OPEN,
  175. FILE_REOPEN_CLOSED,
  176. FILE_OPEN_RECENT,
  177. FILE_SAVE,
  178. FILE_SAVE_AS,
  179. FILE_SAVE_ALL,
  180. FILE_THEME,
  181. FILE_RUN,
  182. FILE_CLOSE,
  183. CLOSE_DOCS,
  184. CLOSE_ALL,
  185. CLOSE_OTHER_TABS,
  186. TOGGLE_SCRIPTS_PANEL,
  187. SHOW_IN_FILE_SYSTEM,
  188. FILE_COPY_PATH,
  189. FILE_TOOL_RELOAD_SOFT,
  190. SEARCH_IN_FILES,
  191. REPLACE_IN_FILES,
  192. SEARCH_HELP,
  193. SEARCH_WEBSITE,
  194. HELP_SEARCH_FIND,
  195. HELP_SEARCH_FIND_NEXT,
  196. HELP_SEARCH_FIND_PREVIOUS,
  197. WINDOW_MOVE_UP,
  198. WINDOW_MOVE_DOWN,
  199. WINDOW_NEXT,
  200. WINDOW_PREV,
  201. WINDOW_SORT,
  202. WINDOW_SELECT_BASE = 100,
  203. };
  204. enum {
  205. THEME_IMPORT,
  206. THEME_RELOAD,
  207. THEME_SAVE,
  208. THEME_SAVE_AS
  209. };
  210. enum ScriptSortBy {
  211. SORT_BY_NAME,
  212. SORT_BY_PATH,
  213. SORT_BY_NONE
  214. };
  215. enum ScriptListName {
  216. DISPLAY_NAME,
  217. DISPLAY_DIR_AND_NAME,
  218. DISPLAY_FULL_PATH,
  219. };
  220. HBoxContainer *menu_hb = nullptr;
  221. MenuButton *file_menu = nullptr;
  222. MenuButton *edit_menu = nullptr;
  223. MenuButton *script_search_menu = nullptr;
  224. MenuButton *debug_menu = nullptr;
  225. PopupMenu *context_menu = nullptr;
  226. Timer *autosave_timer = nullptr;
  227. uint64_t idle = 0;
  228. PopupMenu *recent_scripts = nullptr;
  229. PopupMenu *theme_submenu = nullptr;
  230. Button *help_search = nullptr;
  231. Button *site_search = nullptr;
  232. Button *make_floating = nullptr;
  233. bool is_floating = false;
  234. EditorHelpSearch *help_search_dialog = nullptr;
  235. ItemList *script_list = nullptr;
  236. HSplitContainer *script_split = nullptr;
  237. ItemList *members_overview = nullptr;
  238. LineEdit *filter_scripts = nullptr;
  239. LineEdit *filter_methods = nullptr;
  240. VBoxContainer *scripts_vbox = nullptr;
  241. VBoxContainer *overview_vbox = nullptr;
  242. HBoxContainer *buttons_hbox = nullptr;
  243. Label *filename = nullptr;
  244. Button *members_overview_alphabeta_sort_button = nullptr;
  245. bool members_overview_enabled;
  246. ItemList *help_overview = nullptr;
  247. bool help_overview_enabled;
  248. VSplitContainer *list_split = nullptr;
  249. TabContainer *tab_container = nullptr;
  250. EditorFileDialog *file_dialog = nullptr;
  251. AcceptDialog *error_dialog = nullptr;
  252. ConfirmationDialog *erase_tab_confirm = nullptr;
  253. ScriptCreateDialog *script_create_dialog = nullptr;
  254. Button *scripts_visible = nullptr;
  255. FindReplaceBar *find_replace_bar = nullptr;
  256. String current_theme;
  257. float zoom_factor = 1.0f;
  258. TextureRect *script_icon = nullptr;
  259. Label *script_name_label = nullptr;
  260. Button *script_back = nullptr;
  261. Button *script_forward = nullptr;
  262. FindInFilesDialog *find_in_files_dialog = nullptr;
  263. FindInFilesPanel *find_in_files = nullptr;
  264. Button *find_in_files_button = nullptr;
  265. WindowWrapper *window_wrapper = nullptr;
  266. enum {
  267. SCRIPT_EDITOR_FUNC_MAX = 32,
  268. };
  269. static int script_editor_func_count;
  270. static CreateScriptEditorFunc script_editor_funcs[SCRIPT_EDITOR_FUNC_MAX];
  271. Vector<Ref<EditorSyntaxHighlighter>> syntax_highlighters;
  272. struct ScriptHistory {
  273. Control *control = nullptr;
  274. Variant state;
  275. };
  276. Vector<ScriptHistory> history;
  277. int history_pos;
  278. List<String> previous_scripts;
  279. List<int> script_close_queue;
  280. void _tab_changed(int p_which);
  281. void _menu_option(int p_option);
  282. void _theme_option(int p_option);
  283. void _show_save_theme_as_dialog();
  284. bool _has_docs_tab() const;
  285. bool _has_script_tab() const;
  286. void _prepare_file_menu();
  287. void _file_menu_closed();
  288. Tree *disk_changed_list = nullptr;
  289. ConfirmationDialog *disk_changed = nullptr;
  290. bool restoring_layout;
  291. String _get_debug_tooltip(const String &p_text, Node *_se);
  292. void _resave_scripts(const String &p_str);
  293. bool _test_script_times_on_disk(Ref<Resource> p_for_script = Ref<Resource>());
  294. void _add_recent_script(const String &p_path);
  295. void _update_recent_scripts();
  296. void _open_recent_script(int p_idx);
  297. void _show_error_dialog(const String &p_path);
  298. void _close_tab(int p_idx, bool p_save = true, bool p_history_back = true);
  299. void _update_find_replace_bar();
  300. void _close_current_tab(bool p_save = true, bool p_history_back = true);
  301. void _close_discard_current_tab(const String &p_str);
  302. void _close_docs_tab();
  303. void _close_other_tabs();
  304. void _close_all_tabs();
  305. void _queue_close_tabs();
  306. void _copy_script_path();
  307. void _ask_close_current_unsaved_tab(ScriptEditorBase *current);
  308. bool grab_focus_block;
  309. bool pending_auto_reload;
  310. bool auto_reload_running_scripts;
  311. bool reload_all_scripts = false;
  312. Vector<String> script_paths_to_reload;
  313. void _live_auto_reload_running_scripts();
  314. void _update_selected_editor_menu();
  315. EditorScriptCodeCompletionCache *completion_cache = nullptr;
  316. void _editor_stop();
  317. int edit_pass;
  318. void _add_callback(Object *p_obj, const String &p_function, const PackedStringArray &p_args);
  319. void _res_saved_callback(const Ref<Resource> &p_res);
  320. void _scene_saved_callback(const String &p_path);
  321. void _mark_built_in_scripts_as_saved(const String &p_parent_path);
  322. bool open_textfile_after_create = true;
  323. bool trim_trailing_whitespace_on_save;
  324. bool trim_final_newlines_on_save;
  325. bool convert_indent_on_save;
  326. bool external_editor_active;
  327. void _goto_script_line2(int p_line);
  328. void _goto_script_line(Ref<RefCounted> p_script, int p_line);
  329. void _set_execution(Ref<RefCounted> p_script, int p_line);
  330. void _clear_execution(Ref<RefCounted> p_script);
  331. void _breaked(bool p_breaked, bool p_can_debug);
  332. void _script_created(Ref<Script> p_script);
  333. void _set_breakpoint(Ref<RefCounted> p_scrpt, int p_line, bool p_enabled);
  334. void _clear_breakpoints();
  335. Array _get_cached_breakpoints_for_script(const String &p_path) const;
  336. ScriptEditorBase *_get_current_editor() const;
  337. TypedArray<ScriptEditorBase> _get_open_script_editors() const;
  338. Ref<ConfigFile> script_editor_cache;
  339. void _save_editor_state(ScriptEditorBase *p_editor);
  340. void _save_layout();
  341. void _editor_settings_changed();
  342. void _apply_editor_settings();
  343. void _filesystem_changed();
  344. void _files_moved(const String &p_old_file, const String &p_new_file);
  345. void _file_removed(const String &p_file);
  346. void _autosave_scripts();
  347. void _update_autosave_timer();
  348. void _reload_scripts(bool p_refresh_only = false);
  349. void _update_members_overview_visibility();
  350. void _update_members_overview();
  351. void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
  352. void _filter_scripts_text_changed(const String &p_newtext);
  353. void _filter_methods_text_changed(const String &p_newtext);
  354. void _update_script_names();
  355. bool _sort_list_on_update;
  356. void _members_overview_selected(int p_idx);
  357. void _script_selected(int p_idx);
  358. void _update_help_overview_visibility();
  359. void _update_help_overview();
  360. void _help_overview_selected(int p_idx);
  361. void _update_online_doc();
  362. void _find_scripts(Node *p_base, Node *p_current, HashSet<Ref<Script>> &used);
  363. void _tree_changed();
  364. void _split_dragged(float);
  365. Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
  366. bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
  367. void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
  368. virtual void input(const Ref<InputEvent> &p_event) override;
  369. virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
  370. void _script_list_clicked(int p_item, Vector2 p_local_mouse_pos, MouseButton p_mouse_button_index);
  371. void _make_script_list_context_menu();
  372. void _help_search(const String &p_text);
  373. void _history_forward();
  374. void _history_back();
  375. bool waiting_update_names;
  376. bool lock_history = false;
  377. void _help_class_open(const String &p_class);
  378. void _help_class_goto(const String &p_desc);
  379. bool _help_tab_goto(const String &p_name, const String &p_desc);
  380. void _update_history_arrows();
  381. void _save_history();
  382. void _save_previous_state(Dictionary p_state);
  383. void _go_to_tab(int p_idx);
  384. void _update_history_pos(int p_new_pos);
  385. void _update_script_colors();
  386. void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
  387. void _script_changed();
  388. int file_dialog_option;
  389. void _file_dialog_action(const String &p_file);
  390. Ref<Script> _get_current_script();
  391. TypedArray<Script> _get_open_scripts() const;
  392. HashSet<String> textfile_extensions;
  393. Ref<TextFile> _load_text_file(const String &p_path, Error *r_error) const;
  394. Error _save_text_file(Ref<TextFile> p_text_file, const String &p_path);
  395. void _on_find_in_files_requested(const String &text);
  396. void _on_replace_in_files_requested(const String &text);
  397. void _on_find_in_files_result_selected(const String &fpath, int line_number, int begin, int end);
  398. void _start_find_in_files(bool with_replace);
  399. void _on_find_in_files_modified_files(const PackedStringArray &paths);
  400. void _on_find_in_files_close_button_clicked();
  401. void _set_zoom_factor(float p_zoom_factor);
  402. void _window_changed(bool p_visible);
  403. static void _open_script_request(const String &p_path);
  404. void _close_builtin_scripts_from_scene(const String &p_scene);
  405. static ScriptEditor *script_editor;
  406. protected:
  407. void _notification(int p_what);
  408. static void _bind_methods();
  409. public:
  410. static ScriptEditor *get_singleton() { return script_editor; }
  411. bool toggle_scripts_panel();
  412. bool is_scripts_panel_toggled();
  413. void apply_scripts() const;
  414. void reload_scripts(bool p_refresh_only = false);
  415. void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
  416. void open_text_file_create_dialog(const String &p_base_path, const String &p_base_name = "");
  417. Ref<Resource> open_file(const String &p_file);
  418. void ensure_select_current();
  419. bool is_editor_floating();
  420. _FORCE_INLINE_ bool edit(const Ref<Resource> &p_resource, bool p_grab_focus = true) { return edit(p_resource, -1, 0, p_grab_focus); }
  421. bool edit(const Ref<Resource> &p_resource, int p_line, int p_col, bool p_grab_focus = true);
  422. void get_breakpoints(List<String> *p_breakpoints);
  423. PackedStringArray get_unsaved_scripts() const;
  424. void save_current_script();
  425. void save_all_scripts();
  426. void set_window_layout(Ref<ConfigFile> p_layout);
  427. void get_window_layout(Ref<ConfigFile> p_layout);
  428. void set_scene_root_script(Ref<Script> p_script);
  429. Vector<Ref<Script>> get_open_scripts() const;
  430. bool script_goto_method(Ref<Script> p_script, const String &p_method);
  431. virtual void edited_scene_changed();
  432. void notify_script_close(const Ref<Script> &p_script);
  433. void notify_script_changed(const Ref<Script> &p_script);
  434. void goto_help(const String &p_desc) { _help_class_goto(p_desc); }
  435. void update_doc(const String &p_name);
  436. void clear_docs_from_script(const Ref<Script> &p_script);
  437. void update_docs_from_script(const Ref<Script> &p_script);
  438. void trigger_live_script_reload(const String &p_script_path);
  439. void trigger_live_script_reload_all();
  440. bool can_take_away_focus() const;
  441. VSplitContainer *get_left_list_split() { return list_split; }
  442. void set_live_auto_reload_running_scripts(bool p_enabled);
  443. void register_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
  444. void unregister_syntax_highlighter(const Ref<EditorSyntaxHighlighter> &p_syntax_highlighter);
  445. static void register_create_script_editor_function(CreateScriptEditorFunc p_func);
  446. ScriptEditor(WindowWrapper *p_wrapper);
  447. ~ScriptEditor();
  448. };
  449. class ScriptEditorPlugin : public EditorPlugin {
  450. GDCLASS(ScriptEditorPlugin, EditorPlugin);
  451. ScriptEditor *script_editor = nullptr;
  452. WindowWrapper *window_wrapper = nullptr;
  453. String last_editor;
  454. void _focus_another_editor();
  455. void _save_last_editor(const String &p_editor);
  456. void _window_visibility_changed(bool p_visible);
  457. protected:
  458. void _notification(int p_what);
  459. public:
  460. virtual String get_name() const override { return "Script"; }
  461. bool has_main_screen() const override { return true; }
  462. virtual void edit(Object *p_object) override;
  463. virtual bool handles(Object *p_object) const override;
  464. virtual void make_visible(bool p_visible) override;
  465. virtual void selected_notify() override;
  466. virtual String get_unsaved_status(const String &p_for_scene) const override;
  467. virtual void save_external_data() override;
  468. virtual void apply_changes() override;
  469. virtual void set_window_layout(Ref<ConfigFile> p_layout) override;
  470. virtual void get_window_layout(Ref<ConfigFile> p_layout) override;
  471. virtual void get_breakpoints(List<String> *p_breakpoints) override;
  472. virtual void edited_scene_changed() override;
  473. ScriptEditorPlugin();
  474. ~ScriptEditorPlugin();
  475. };
  476. #endif // SCRIPT_EDITOR_PLUGIN_H