editor_plugin.cpp 40 KB

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