editor_plugin.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  1. /*************************************************************************/
  2. /* editor_plugin.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #include "editor_plugin.h"
  31. #include "editor/editor_command_palette.h"
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_paths.h"
  34. #include "editor/editor_resource_preview.h"
  35. #include "editor/editor_settings.h"
  36. #include "editor/editor_undo_redo_manager.h"
  37. #include "editor/export/editor_export.h"
  38. #include "editor/filesystem_dock.h"
  39. #include "editor/plugins/canvas_item_editor_plugin.h"
  40. #include "editor/plugins/node_3d_editor_plugin.h"
  41. #include "editor/plugins/script_editor_plugin.h"
  42. #include "editor/project_settings_editor.h"
  43. #include "editor/scene_tree_dock.h"
  44. #include "main/main.h"
  45. #include "scene/3d/camera_3d.h"
  46. #include "scene/gui/popup_menu.h"
  47. #include "servers/rendering_server.h"
  48. TypedArray<Texture2D> EditorInterface::_make_mesh_previews(const TypedArray<Mesh> &p_meshes, int p_preview_size) {
  49. Vector<Ref<Mesh>> meshes;
  50. for (int i = 0; i < p_meshes.size(); i++) {
  51. meshes.push_back(p_meshes[i]);
  52. }
  53. Vector<Ref<Texture2D>> textures = make_mesh_previews(meshes, nullptr, p_preview_size);
  54. TypedArray<Texture2D> ret;
  55. for (int i = 0; i < textures.size(); i++) {
  56. ret.push_back(textures[i]);
  57. }
  58. return ret;
  59. }
  60. Vector<Ref<Texture2D>> EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>> &p_meshes, Vector<Transform3D> *p_transforms, int p_preview_size) {
  61. int size = p_preview_size;
  62. RID scenario = RS::get_singleton()->scenario_create();
  63. RID viewport = RS::get_singleton()->viewport_create();
  64. RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ALWAYS);
  65. RS::get_singleton()->viewport_set_scenario(viewport, scenario);
  66. RS::get_singleton()->viewport_set_size(viewport, size, size);
  67. RS::get_singleton()->viewport_set_transparent_background(viewport, true);
  68. RS::get_singleton()->viewport_set_active(viewport, true);
  69. RID viewport_texture = RS::get_singleton()->viewport_get_texture(viewport);
  70. RID camera = RS::get_singleton()->camera_create();
  71. RS::get_singleton()->viewport_attach_camera(viewport, camera);
  72. RID light = RS::get_singleton()->directional_light_create();
  73. RID light_instance = RS::get_singleton()->instance_create2(light, scenario);
  74. RID light2 = RS::get_singleton()->directional_light_create();
  75. RS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
  76. RID light_instance2 = RS::get_singleton()->instance_create2(light2, scenario);
  77. EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
  78. Vector<Ref<Texture2D>> textures;
  79. for (int i = 0; i < p_meshes.size(); i++) {
  80. Ref<Mesh> mesh = p_meshes[i];
  81. if (!mesh.is_valid()) {
  82. textures.push_back(Ref<Texture2D>());
  83. continue;
  84. }
  85. Transform3D mesh_xform;
  86. if (p_transforms != nullptr) {
  87. mesh_xform = (*p_transforms)[i];
  88. }
  89. RID inst = RS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
  90. RS::get_singleton()->instance_set_transform(inst, mesh_xform);
  91. AABB aabb = mesh->get_aabb();
  92. Vector3 ofs = aabb.get_center();
  93. aabb.position -= ofs;
  94. Transform3D xform;
  95. xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
  96. xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
  97. AABB rot_aabb = xform.xform(aabb);
  98. float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
  99. if (m == 0) {
  100. textures.push_back(Ref<Texture2D>());
  101. continue;
  102. }
  103. xform.origin = -xform.basis.xform(ofs); //-ofs*m;
  104. xform.origin.z -= rot_aabb.size.z * 2;
  105. xform.invert();
  106. xform = mesh_xform * xform;
  107. RS::get_singleton()->camera_set_transform(camera, xform * Transform3D(Basis(), Vector3(0, 0, 3)));
  108. RS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
  109. RS::get_singleton()->instance_set_transform(light_instance, xform * Transform3D().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
  110. RS::get_singleton()->instance_set_transform(light_instance2, xform * Transform3D().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
  111. ep.step(TTR("Thumbnail..."), i);
  112. Main::iteration();
  113. Main::iteration();
  114. Ref<Image> img = RS::get_singleton()->texture_2d_get(viewport_texture);
  115. ERR_CONTINUE(!img.is_valid() || img->is_empty());
  116. Ref<ImageTexture> it = ImageTexture::create_from_image(img);
  117. RS::get_singleton()->free(inst);
  118. textures.push_back(it);
  119. }
  120. RS::get_singleton()->free(viewport);
  121. RS::get_singleton()->free(light);
  122. RS::get_singleton()->free(light_instance);
  123. RS::get_singleton()->free(light2);
  124. RS::get_singleton()->free(light_instance2);
  125. RS::get_singleton()->free(camera);
  126. RS::get_singleton()->free(scenario);
  127. return textures;
  128. }
  129. void EditorInterface::set_main_screen_editor(const String &p_name) {
  130. EditorNode::get_singleton()->select_editor_by_name(p_name);
  131. }
  132. VBoxContainer *EditorInterface::get_editor_main_screen() {
  133. return EditorNode::get_singleton()->get_main_screen_control();
  134. }
  135. void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
  136. EditorNode::get_singleton()->edit_resource(p_resource);
  137. }
  138. void EditorInterface::edit_node(Node *p_node) {
  139. EditorNode::get_singleton()->edit_node(p_node);
  140. }
  141. void EditorInterface::edit_script(const Ref<Script> &p_script, int p_line, int p_col, bool p_grab_focus) {
  142. ScriptEditor::get_singleton()->edit(p_script, p_line, p_col, p_grab_focus);
  143. }
  144. void EditorInterface::open_scene_from_path(const String &scene_path) {
  145. if (EditorNode::get_singleton()->is_changing_scene()) {
  146. return;
  147. }
  148. EditorNode::get_singleton()->open_request(scene_path);
  149. }
  150. void EditorInterface::reload_scene_from_path(const String &scene_path) {
  151. if (EditorNode::get_singleton()->is_changing_scene()) {
  152. return;
  153. }
  154. EditorNode::get_singleton()->reload_scene(scene_path);
  155. }
  156. void EditorInterface::play_main_scene() {
  157. EditorNode::get_singleton()->run_play();
  158. }
  159. void EditorInterface::play_current_scene() {
  160. EditorNode::get_singleton()->run_play_current();
  161. }
  162. void EditorInterface::play_custom_scene(const String &scene_path) {
  163. EditorNode::get_singleton()->run_play_custom(scene_path);
  164. }
  165. void EditorInterface::stop_playing_scene() {
  166. EditorNode::get_singleton()->run_stop();
  167. }
  168. bool EditorInterface::is_playing_scene() const {
  169. return EditorNode::get_singleton()->is_run_playing();
  170. }
  171. String EditorInterface::get_playing_scene() const {
  172. return EditorNode::get_singleton()->get_run_playing_scene();
  173. }
  174. Node *EditorInterface::get_edited_scene_root() {
  175. return EditorNode::get_singleton()->get_edited_scene();
  176. }
  177. PackedStringArray EditorInterface::get_open_scenes() const {
  178. PackedStringArray ret;
  179. Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes();
  180. int scns_amount = scenes.size();
  181. for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
  182. if (scenes[idx_scn].root == nullptr) {
  183. continue;
  184. }
  185. ret.push_back(scenes[idx_scn].root->get_scene_file_path());
  186. }
  187. return ret;
  188. }
  189. ScriptEditor *EditorInterface::get_script_editor() {
  190. return ScriptEditor::get_singleton();
  191. }
  192. void EditorInterface::select_file(const String &p_file) {
  193. FileSystemDock::get_singleton()->select_file(p_file);
  194. }
  195. String EditorInterface::get_selected_path() const {
  196. return FileSystemDock::get_singleton()->get_selected_path();
  197. }
  198. String EditorInterface::get_current_path() const {
  199. return FileSystemDock::get_singleton()->get_current_path();
  200. }
  201. void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property, bool p_inspector_only) {
  202. EditorNode::get_singleton()->push_item(p_obj, p_for_property, p_inspector_only);
  203. }
  204. EditorFileSystem *EditorInterface::get_resource_file_system() {
  205. return EditorFileSystem::get_singleton();
  206. }
  207. FileSystemDock *EditorInterface::get_file_system_dock() {
  208. return FileSystemDock::get_singleton();
  209. }
  210. EditorSelection *EditorInterface::get_selection() {
  211. return EditorNode::get_singleton()->get_editor_selection();
  212. }
  213. Ref<EditorSettings> EditorInterface::get_editor_settings() {
  214. return EditorSettings::get_singleton();
  215. }
  216. EditorPaths *EditorInterface::get_editor_paths() {
  217. return EditorPaths::get_singleton();
  218. }
  219. EditorResourcePreview *EditorInterface::get_resource_previewer() {
  220. return EditorResourcePreview::get_singleton();
  221. }
  222. Control *EditorInterface::get_base_control() {
  223. return EditorNode::get_singleton()->get_gui_base();
  224. }
  225. float EditorInterface::get_editor_scale() const {
  226. return EDSCALE;
  227. }
  228. void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
  229. EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
  230. }
  231. bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
  232. return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
  233. }
  234. EditorInspector *EditorInterface::get_inspector() const {
  235. return InspectorDock::get_inspector_singleton();
  236. }
  237. Error EditorInterface::save_scene() {
  238. if (!get_edited_scene_root()) {
  239. return ERR_CANT_CREATE;
  240. }
  241. if (get_edited_scene_root()->get_scene_file_path().is_empty()) {
  242. return ERR_CANT_CREATE;
  243. }
  244. save_scene_as(get_edited_scene_root()->get_scene_file_path());
  245. return OK;
  246. }
  247. void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
  248. EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
  249. }
  250. void EditorInterface::set_distraction_free_mode(bool p_enter) {
  251. EditorNode::get_singleton()->set_distraction_free_mode(p_enter);
  252. }
  253. void EditorInterface::restart_editor(bool p_save) {
  254. if (p_save) {
  255. EditorNode::get_singleton()->save_all_scenes();
  256. }
  257. EditorNode::get_singleton()->restart_editor();
  258. }
  259. bool EditorInterface::is_distraction_free_mode_enabled() const {
  260. return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
  261. }
  262. EditorCommandPalette *EditorInterface::get_command_palette() const {
  263. return EditorCommandPalette::get_singleton();
  264. }
  265. EditorInterface *EditorInterface::singleton = nullptr;
  266. void EditorInterface::_bind_methods() {
  267. ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property", "inspector_only"), &EditorInterface::inspect_object, DEFVAL(String()), DEFVAL(false));
  268. ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
  269. ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
  270. ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
  271. ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
  272. ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
  273. ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
  274. ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
  275. ClassDB::bind_method(D_METHOD("edit_script", "script", "line", "column", "grab_focus"), &EditorInterface::edit_script, DEFVAL(-1), DEFVAL(0), DEFVAL(true));
  276. ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
  277. ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
  278. ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene);
  279. ClassDB::bind_method(D_METHOD("play_current_scene"), &EditorInterface::play_current_scene);
  280. ClassDB::bind_method(D_METHOD("play_custom_scene", "scene_filepath"), &EditorInterface::play_custom_scene);
  281. ClassDB::bind_method(D_METHOD("stop_playing_scene"), &EditorInterface::stop_playing_scene);
  282. ClassDB::bind_method(D_METHOD("is_playing_scene"), &EditorInterface::is_playing_scene);
  283. ClassDB::bind_method(D_METHOD("get_playing_scene"), &EditorInterface::get_playing_scene);
  284. ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
  285. ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
  286. ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
  287. ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
  288. ClassDB::bind_method(D_METHOD("get_editor_main_screen"), &EditorInterface::get_editor_main_screen);
  289. ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
  290. ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file);
  291. ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path);
  292. ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path);
  293. ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock);
  294. ClassDB::bind_method(D_METHOD("get_editor_paths"), &EditorInterface::get_editor_paths);
  295. ClassDB::bind_method(D_METHOD("get_command_palette"), &EditorInterface::get_command_palette);
  296. ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
  297. ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
  298. ClassDB::bind_method(D_METHOD("get_inspector"), &EditorInterface::get_inspector);
  299. ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
  300. ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
  301. ClassDB::bind_method(D_METHOD("restart_editor", "save"), &EditorInterface::restart_editor, DEFVAL(true));
  302. ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
  303. ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
  304. ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
  305. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled");
  306. }
  307. EditorInterface::EditorInterface() {
  308. singleton = this;
  309. }
  310. ///////////////////////////////////////////
  311. void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
  312. EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
  313. }
  314. void EditorPlugin::remove_custom_type(const String &p_type) {
  315. EditorNode::get_editor_data().remove_custom_type(p_type);
  316. }
  317. void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) {
  318. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path);
  319. }
  320. void EditorPlugin::remove_autoload_singleton(const String &p_name) {
  321. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
  322. }
  323. Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
  324. ERR_FAIL_NULL_V(p_control, nullptr);
  325. return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
  326. }
  327. void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
  328. ERR_FAIL_NULL(p_control);
  329. EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
  330. }
  331. void EditorPlugin::remove_control_from_docks(Control *p_control) {
  332. ERR_FAIL_NULL(p_control);
  333. EditorNode::get_singleton()->remove_control_from_dock(p_control);
  334. }
  335. void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
  336. ERR_FAIL_NULL(p_control);
  337. EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
  338. }
  339. void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
  340. ERR_FAIL_NULL(p_control);
  341. switch (p_location) {
  342. case CONTAINER_TOOLBAR: {
  343. EditorNode::get_menu_hb()->add_child(p_control);
  344. } break;
  345. case CONTAINER_SPATIAL_EDITOR_MENU: {
  346. Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
  347. } break;
  348. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
  349. Node3DEditor::get_singleton()->add_control_to_left_panel(p_control);
  350. } break;
  351. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  352. Node3DEditor::get_singleton()->add_control_to_right_panel(p_control);
  353. } break;
  354. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  355. Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
  356. } break;
  357. case CONTAINER_CANVAS_EDITOR_MENU: {
  358. CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
  359. } break;
  360. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
  361. CanvasItemEditor::get_singleton()->add_control_to_left_panel(p_control);
  362. } break;
  363. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  364. CanvasItemEditor::get_singleton()->add_control_to_right_panel(p_control);
  365. } break;
  366. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  367. CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
  368. } break;
  369. case CONTAINER_INSPECTOR_BOTTOM: {
  370. InspectorDock::get_singleton()->get_addon_area()->add_child(p_control);
  371. } break;
  372. case CONTAINER_PROJECT_SETTING_TAB_LEFT: {
  373. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  374. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0);
  375. } break;
  376. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  377. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  378. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1);
  379. } break;
  380. }
  381. }
  382. void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *p_control) {
  383. ERR_FAIL_NULL(p_control);
  384. switch (p_location) {
  385. case CONTAINER_TOOLBAR: {
  386. EditorNode::get_menu_hb()->remove_child(p_control);
  387. } break;
  388. case CONTAINER_SPATIAL_EDITOR_MENU: {
  389. Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  390. } break;
  391. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
  392. Node3DEditor::get_singleton()->remove_control_from_left_panel(p_control);
  393. } break;
  394. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  395. Node3DEditor::get_singleton()->remove_control_from_right_panel(p_control);
  396. } break;
  397. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  398. Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
  399. } break;
  400. case CONTAINER_CANVAS_EDITOR_MENU: {
  401. CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  402. } break;
  403. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
  404. CanvasItemEditor::get_singleton()->remove_control_from_left_panel(p_control);
  405. } break;
  406. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  407. CanvasItemEditor::get_singleton()->remove_control_from_right_panel(p_control);
  408. } break;
  409. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  410. CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);
  411. } break;
  412. case CONTAINER_INSPECTOR_BOTTOM: {
  413. InspectorDock::get_singleton()->get_addon_area()->remove_child(p_control);
  414. } break;
  415. case CONTAINER_PROJECT_SETTING_TAB_LEFT:
  416. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  417. ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control);
  418. } break;
  419. }
  420. }
  421. void EditorPlugin::add_tool_menu_item(const String &p_name, const Callable &p_callable) {
  422. EditorNode::get_singleton()->add_tool_menu_item(p_name, p_callable);
  423. }
  424. void EditorPlugin::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) {
  425. ERR_FAIL_NULL(p_submenu);
  426. EditorNode::get_singleton()->add_tool_submenu_item(p_name, p_submenu);
  427. }
  428. void EditorPlugin::remove_tool_menu_item(const String &p_name) {
  429. EditorNode::get_singleton()->remove_tool_menu_item(p_name);
  430. }
  431. PopupMenu *EditorPlugin::get_export_as_menu() {
  432. return EditorNode::get_singleton()->get_export_as_menu();
  433. }
  434. void EditorPlugin::set_input_event_forwarding_always_enabled() {
  435. input_event_forwarding_always_enabled = true;
  436. EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
  437. always_input_forwarding_list->add_plugin(this);
  438. }
  439. void EditorPlugin::set_force_draw_over_forwarding_enabled() {
  440. force_draw_over_forwarding_enabled = true;
  441. EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
  442. always_draw_over_forwarding_list->add_plugin(this);
  443. }
  444. void EditorPlugin::notify_scene_changed(const Node *scn_root) {
  445. emit_signal(SNAME("scene_changed"), scn_root);
  446. }
  447. void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
  448. if (screen_name == last_main_screen_name) {
  449. return;
  450. }
  451. emit_signal(SNAME("main_screen_changed"), screen_name);
  452. last_main_screen_name = screen_name;
  453. }
  454. void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
  455. emit_signal(SNAME("scene_closed"), scene_filepath);
  456. }
  457. void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
  458. emit_signal(SNAME("resource_saved"), p_resource);
  459. }
  460. bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
  461. bool success = false;
  462. if (GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success)) {
  463. return success;
  464. }
  465. return false;
  466. }
  467. void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
  468. GDVIRTUAL_CALL(_forward_canvas_draw_over_viewport, p_overlay);
  469. }
  470. void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
  471. GDVIRTUAL_CALL(_forward_canvas_force_draw_over_viewport, p_overlay);
  472. }
  473. // Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
  474. int EditorPlugin::update_overlays() const {
  475. if (Node3DEditor::get_singleton()->is_visible()) {
  476. int count = 0;
  477. for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
  478. Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i);
  479. if (vp->is_visible()) {
  480. vp->update_surface();
  481. count++;
  482. }
  483. }
  484. return count;
  485. } else {
  486. // This will update the normal viewport itself as well
  487. CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw();
  488. return 1;
  489. }
  490. }
  491. EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
  492. int success = EditorPlugin::AFTER_GUI_INPUT_PASS;
  493. if (GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success)) {
  494. return static_cast<EditorPlugin::AfterGUIInput>(success);
  495. }
  496. return EditorPlugin::AFTER_GUI_INPUT_PASS;
  497. }
  498. void EditorPlugin::forward_3d_draw_over_viewport(Control *p_overlay) {
  499. GDVIRTUAL_CALL(_forward_3d_draw_over_viewport, p_overlay);
  500. }
  501. void EditorPlugin::forward_3d_force_draw_over_viewport(Control *p_overlay) {
  502. GDVIRTUAL_CALL(_forward_3d_force_draw_over_viewport, p_overlay);
  503. }
  504. String EditorPlugin::get_name() const {
  505. String name;
  506. if (GDVIRTUAL_CALL(_get_plugin_name, name)) {
  507. return name;
  508. }
  509. return String();
  510. }
  511. const Ref<Texture2D> EditorPlugin::get_icon() const {
  512. Ref<Texture2D> icon;
  513. if (GDVIRTUAL_CALL(_get_plugin_icon, icon)) {
  514. return icon;
  515. }
  516. return Ref<Texture2D>();
  517. }
  518. bool EditorPlugin::has_main_screen() const {
  519. bool success;
  520. if (GDVIRTUAL_CALL(_has_main_screen, success)) {
  521. return success;
  522. }
  523. return false;
  524. }
  525. void EditorPlugin::make_visible(bool p_visible) {
  526. GDVIRTUAL_CALL(_make_visible, p_visible);
  527. }
  528. void EditorPlugin::edit(Object *p_object) {
  529. if (p_object->is_class("Resource")) {
  530. GDVIRTUAL_CALL(_edit, Ref<Resource>(Object::cast_to<Resource>(p_object)));
  531. } else {
  532. GDVIRTUAL_CALL(_edit, p_object);
  533. }
  534. }
  535. bool EditorPlugin::handles(Object *p_object) const {
  536. bool success = false;
  537. if (GDVIRTUAL_CALL(_handles, p_object, success)) {
  538. return success;
  539. }
  540. return false;
  541. }
  542. Dictionary EditorPlugin::get_state() const {
  543. Dictionary state;
  544. if (GDVIRTUAL_CALL(_get_state, state)) {
  545. return state;
  546. }
  547. return Dictionary();
  548. }
  549. void EditorPlugin::set_state(const Dictionary &p_state) {
  550. GDVIRTUAL_CALL(_set_state, p_state);
  551. }
  552. void EditorPlugin::clear() {
  553. GDVIRTUAL_CALL(_clear);
  554. }
  555. // if editor references external resources/scenes, save them
  556. void EditorPlugin::save_external_data() {
  557. GDVIRTUAL_CALL(_save_external_data);
  558. }
  559. // if changes are pending in editor, apply them
  560. void EditorPlugin::apply_changes() {
  561. GDVIRTUAL_CALL(_apply_changes);
  562. }
  563. void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
  564. PackedStringArray arr;
  565. if (GDVIRTUAL_CALL(_get_breakpoints, arr)) {
  566. for (int i = 0; i < arr.size(); i++) {
  567. p_breakpoints->push_back(arr[i]);
  568. }
  569. }
  570. }
  571. bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
  572. return false;
  573. }
  574. void EditorPlugin::restore_global_state() {}
  575. void EditorPlugin::save_global_state() {}
  576. void EditorPlugin::add_undo_redo_inspector_hook_callback(Callable p_callable) {
  577. EditorNode::get_singleton()->get_editor_data().add_undo_redo_inspector_hook_callback(p_callable);
  578. }
  579. void EditorPlugin::remove_undo_redo_inspector_hook_callback(Callable p_callable) {
  580. EditorNode::get_singleton()->get_editor_data().remove_undo_redo_inspector_hook_callback(p_callable);
  581. }
  582. void EditorPlugin::add_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
  583. ERR_FAIL_COND(!p_parser.is_valid());
  584. EditorTranslationParser::get_singleton()->add_parser(p_parser, EditorTranslationParser::CUSTOM);
  585. }
  586. void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
  587. ERR_FAIL_COND(!p_parser.is_valid());
  588. EditorTranslationParser::get_singleton()->remove_parser(p_parser, EditorTranslationParser::CUSTOM);
  589. }
  590. void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer, bool p_first_priority) {
  591. ERR_FAIL_COND(!p_importer.is_valid());
  592. ResourceFormatImporter::get_singleton()->add_importer(p_importer, p_first_priority);
  593. EditorFileSystem::get_singleton()->call_deferred(SNAME("scan"));
  594. }
  595. void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
  596. ERR_FAIL_COND(!p_importer.is_valid());
  597. ResourceFormatImporter::get_singleton()->remove_importer(p_importer);
  598. EditorFileSystem::get_singleton()->call_deferred(SNAME("scan"));
  599. }
  600. void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  601. ERR_FAIL_COND(!p_exporter.is_valid());
  602. EditorExport::get_singleton()->add_export_plugin(p_exporter);
  603. }
  604. void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  605. ERR_FAIL_COND(!p_exporter.is_valid());
  606. EditorExport::get_singleton()->remove_export_plugin(p_exporter);
  607. }
  608. void EditorPlugin::add_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
  609. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  610. Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
  611. }
  612. void EditorPlugin::remove_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
  613. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  614. Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
  615. }
  616. void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  617. ERR_FAIL_COND(!p_plugin.is_valid());
  618. EditorInspector::add_inspector_plugin(p_plugin);
  619. }
  620. void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  621. ERR_FAIL_COND(!p_plugin.is_valid());
  622. EditorInspector::remove_inspector_plugin(p_plugin);
  623. }
  624. void EditorPlugin::add_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer, bool p_first_priority) {
  625. ERR_FAIL_COND(!p_importer.is_valid());
  626. ResourceImporterScene::add_importer(p_importer, p_first_priority);
  627. }
  628. void EditorPlugin::remove_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer) {
  629. ERR_FAIL_COND(!p_importer.is_valid());
  630. ResourceImporterScene::remove_importer(p_importer);
  631. }
  632. void EditorPlugin::add_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin, bool p_first_priority) {
  633. ResourceImporterScene::add_post_importer_plugin(p_plugin, p_first_priority);
  634. }
  635. void EditorPlugin::remove_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
  636. ResourceImporterScene::remove_post_importer_plugin(p_plugin);
  637. }
  638. int find(const PackedStringArray &a, const String &v) {
  639. const String *r = a.ptr();
  640. for (int j = 0; j < a.size(); ++j) {
  641. if (r[j] == v) {
  642. return j;
  643. }
  644. }
  645. return -1;
  646. }
  647. void EditorPlugin::enable_plugin() {
  648. // Called when the plugin gets enabled in project settings, after it's added to the tree.
  649. // You can implement it to register autoloads.
  650. GDVIRTUAL_CALL(_enable_plugin);
  651. }
  652. void EditorPlugin::disable_plugin() {
  653. // Last function called when the plugin gets disabled in project settings.
  654. // Implement it to cleanup things from the project, such as unregister autoloads.
  655. GDVIRTUAL_CALL(_disable_plugin);
  656. }
  657. void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
  658. GDVIRTUAL_CALL(_set_window_layout, p_layout);
  659. }
  660. void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
  661. GDVIRTUAL_CALL(_get_window_layout, p_layout);
  662. }
  663. bool EditorPlugin::build() {
  664. bool success;
  665. if (GDVIRTUAL_CALL(_build, success)) {
  666. return success;
  667. }
  668. return true;
  669. }
  670. void EditorPlugin::queue_save_layout() {
  671. EditorNode::get_singleton()->save_layout();
  672. }
  673. void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
  674. EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
  675. }
  676. void EditorPlugin::hide_bottom_panel() {
  677. EditorNode::get_singleton()->hide_bottom_panel();
  678. }
  679. EditorInterface *EditorPlugin::get_editor_interface() {
  680. return EditorInterface::get_singleton();
  681. }
  682. ScriptCreateDialog *EditorPlugin::get_script_create_dialog() {
  683. return SceneTreeDock::get_singleton()->get_script_create_dialog();
  684. }
  685. void EditorPlugin::add_debugger_plugin(const Ref<Script> &p_script) {
  686. EditorDebuggerNode::get_singleton()->add_debugger_plugin(p_script);
  687. }
  688. void EditorPlugin::remove_debugger_plugin(const Ref<Script> &p_script) {
  689. EditorDebuggerNode::get_singleton()->remove_debugger_plugin(p_script);
  690. }
  691. void EditorPlugin::_editor_project_settings_changed() {
  692. emit_signal(SNAME("project_settings_changed"));
  693. }
  694. void EditorPlugin::_notification(int p_what) {
  695. switch (p_what) {
  696. case NOTIFICATION_ENTER_TREE: {
  697. EditorNode::get_singleton()->connect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
  698. } break;
  699. case NOTIFICATION_EXIT_TREE: {
  700. EditorNode::get_singleton()->disconnect("project_settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
  701. } break;
  702. }
  703. }
  704. void EditorPlugin::_bind_methods() {
  705. ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
  706. ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel);
  707. ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock);
  708. ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
  709. ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
  710. ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
  711. ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "callable"), &EditorPlugin::add_tool_menu_item);
  712. ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
  713. ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
  714. ClassDB::bind_method(D_METHOD("get_export_as_menu"), &EditorPlugin::get_export_as_menu);
  715. ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
  716. ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
  717. ClassDB::bind_method(D_METHOD("add_autoload_singleton", "name", "path"), &EditorPlugin::add_autoload_singleton);
  718. ClassDB::bind_method(D_METHOD("remove_autoload_singleton", "name"), &EditorPlugin::remove_autoload_singleton);
  719. ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);
  720. ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
  721. ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
  722. ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::get_undo_redo);
  723. ClassDB::bind_method(D_METHOD("add_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::add_undo_redo_inspector_hook_callback);
  724. ClassDB::bind_method(D_METHOD("remove_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::remove_undo_redo_inspector_hook_callback);
  725. ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
  726. ClassDB::bind_method(D_METHOD("add_translation_parser_plugin", "parser"), &EditorPlugin::add_translation_parser_plugin);
  727. ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin);
  728. ClassDB::bind_method(D_METHOD("add_import_plugin", "importer", "first_priority"), &EditorPlugin::add_import_plugin, DEFVAL(false));
  729. ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
  730. ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer", "first_priority"), &EditorPlugin::add_scene_format_importer_plugin, DEFVAL(false));
  731. ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin);
  732. ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin", "first_priority"), &EditorPlugin::add_scene_post_import_plugin, DEFVAL(false));
  733. ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin);
  734. ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
  735. ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
  736. ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin);
  737. ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin);
  738. ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
  739. ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
  740. ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
  741. ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
  742. ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
  743. ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog);
  744. ClassDB::bind_method(D_METHOD("add_debugger_plugin", "script"), &EditorPlugin::add_debugger_plugin);
  745. ClassDB::bind_method(D_METHOD("remove_debugger_plugin", "script"), &EditorPlugin::remove_debugger_plugin);
  746. GDVIRTUAL_BIND(_forward_canvas_gui_input, "event");
  747. GDVIRTUAL_BIND(_forward_canvas_draw_over_viewport, "viewport_control");
  748. GDVIRTUAL_BIND(_forward_canvas_force_draw_over_viewport, "viewport_control");
  749. GDVIRTUAL_BIND(_forward_3d_gui_input, "viewport_camera", "event");
  750. GDVIRTUAL_BIND(_forward_3d_draw_over_viewport, "viewport_control");
  751. GDVIRTUAL_BIND(_forward_3d_force_draw_over_viewport, "viewport_control");
  752. GDVIRTUAL_BIND(_get_plugin_name);
  753. GDVIRTUAL_BIND(_get_plugin_icon);
  754. GDVIRTUAL_BIND(_has_main_screen);
  755. GDVIRTUAL_BIND(_make_visible, "visible");
  756. GDVIRTUAL_BIND(_edit, "object");
  757. GDVIRTUAL_BIND(_handles, "object");
  758. GDVIRTUAL_BIND(_get_state);
  759. GDVIRTUAL_BIND(_set_state, "state");
  760. GDVIRTUAL_BIND(_clear);
  761. GDVIRTUAL_BIND(_save_external_data);
  762. GDVIRTUAL_BIND(_apply_changes);
  763. GDVIRTUAL_BIND(_get_breakpoints);
  764. GDVIRTUAL_BIND(_set_window_layout, "configuration");
  765. GDVIRTUAL_BIND(_get_window_layout, "configuration");
  766. GDVIRTUAL_BIND(_build);
  767. GDVIRTUAL_BIND(_enable_plugin);
  768. GDVIRTUAL_BIND(_disable_plugin);
  769. ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
  770. ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
  771. ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
  772. ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
  773. ADD_SIGNAL(MethodInfo("project_settings_changed"));
  774. BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
  775. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
  776. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT);
  777. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT);
  778. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
  779. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
  780. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_LEFT);
  781. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT);
  782. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM);
  783. BIND_ENUM_CONSTANT(CONTAINER_INSPECTOR_BOTTOM);
  784. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_LEFT);
  785. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_RIGHT);
  786. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL);
  787. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL);
  788. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UR);
  789. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BR);
  790. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UL);
  791. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BL);
  792. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
  793. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
  794. BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
  795. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS);
  796. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP);
  797. BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_CUSTOM);
  798. }
  799. Ref<EditorUndoRedoManager> EditorPlugin::get_undo_redo() {
  800. return undo_redo;
  801. }
  802. EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
  803. int EditorPlugins::creation_func_count = 0;