Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/plugins/editor_plugin.cpp
9896 views
1
/**************************************************************************/
2
/* editor_plugin.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "editor_plugin.h"
32
#include "editor_plugin.compat.inc"
33
34
#include "editor/debugger/editor_debugger_node.h"
35
#include "editor/debugger/editor_debugger_plugin.h"
36
#include "editor/docks/editor_dock_manager.h"
37
#include "editor/docks/inspector_dock.h"
38
#include "editor/docks/scene_tree_dock.h"
39
#include "editor/editor_interface.h"
40
#include "editor/editor_node.h"
41
#include "editor/editor_undo_redo_manager.h"
42
#include "editor/export/editor_export.h"
43
#include "editor/export/editor_export_platform.h"
44
#include "editor/file_system/editor_file_system.h"
45
#include "editor/gui/editor_bottom_panel.h"
46
#include "editor/gui/editor_title_bar.h"
47
#include "editor/import/3d/resource_importer_scene.h"
48
#include "editor/import/editor_import_plugin.h"
49
#include "editor/inspector/editor_inspector.h"
50
#include "editor/plugins/editor_resource_conversion_plugin.h"
51
#include "editor/scene/3d/node_3d_editor_plugin.h"
52
#include "editor/scene/canvas_item_editor_plugin.h"
53
#include "editor/script/script_editor_plugin.h"
54
#include "editor/settings/project_settings_editor.h"
55
#include "editor/translations/editor_translation_parser.h"
56
#include "scene/3d/camera_3d.h"
57
#include "scene/gui/popup_menu.h"
58
59
void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon) {
60
EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
61
}
62
63
void EditorPlugin::remove_custom_type(const String &p_type) {
64
EditorNode::get_editor_data().remove_custom_type(p_type);
65
}
66
67
void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) {
68
if (p_path.begins_with("res://")) {
69
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path);
70
} else {
71
const Ref<Script> plugin_script = static_cast<Ref<Script>>(get_script());
72
ERR_FAIL_COND(plugin_script.is_null());
73
const String script_base_path = plugin_script->get_path().get_base_dir();
74
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, script_base_path.path_join(p_path));
75
}
76
}
77
78
void EditorPlugin::remove_autoload_singleton(const String &p_name) {
79
EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
80
}
81
82
Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title, const Ref<Shortcut> &p_shortcut) {
83
ERR_FAIL_NULL_V(p_control, nullptr);
84
return EditorNode::get_bottom_panel()->add_item(p_title, p_control, p_shortcut);
85
}
86
87
void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control, const Ref<Shortcut> &p_shortcut) {
88
ERR_FAIL_NULL(p_control);
89
EditorDockManager::get_singleton()->add_dock(p_control, String(), EditorDockManager::DockSlot(p_slot), p_shortcut);
90
}
91
92
void EditorPlugin::remove_control_from_docks(Control *p_control) {
93
ERR_FAIL_NULL(p_control);
94
EditorDockManager::get_singleton()->remove_dock(p_control);
95
}
96
97
void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
98
ERR_FAIL_NULL(p_control);
99
EditorNode::get_bottom_panel()->remove_item(p_control);
100
}
101
102
void EditorPlugin::set_dock_tab_icon(Control *p_control, const Ref<Texture2D> &p_icon) {
103
ERR_FAIL_NULL(p_control);
104
EditorDockManager::get_singleton()->set_dock_tab_icon(p_control, p_icon);
105
}
106
107
void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
108
ERR_FAIL_NULL(p_control);
109
110
switch (p_location) {
111
case CONTAINER_TOOLBAR: {
112
EditorNode::get_title_bar()->add_child(p_control);
113
} break;
114
115
case CONTAINER_SPATIAL_EDITOR_MENU: {
116
Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
117
118
} break;
119
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
120
Node3DEditor::get_singleton()->add_control_to_left_panel(p_control);
121
} break;
122
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
123
Node3DEditor::get_singleton()->add_control_to_right_panel(p_control);
124
} break;
125
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
126
Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
127
128
} break;
129
case CONTAINER_CANVAS_EDITOR_MENU: {
130
CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
131
132
} break;
133
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
134
CanvasItemEditor::get_singleton()->add_control_to_left_panel(p_control);
135
} break;
136
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
137
CanvasItemEditor::get_singleton()->add_control_to_right_panel(p_control);
138
} break;
139
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
140
CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
141
142
} break;
143
case CONTAINER_INSPECTOR_BOTTOM: {
144
InspectorDock::get_singleton()->get_addon_area()->add_child(p_control);
145
146
} break;
147
case CONTAINER_PROJECT_SETTING_TAB_LEFT: {
148
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
149
ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0);
150
151
} break;
152
case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
153
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
154
155
} break;
156
}
157
}
158
159
void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *p_control) {
160
ERR_FAIL_NULL(p_control);
161
162
switch (p_location) {
163
case CONTAINER_TOOLBAR: {
164
EditorNode::get_title_bar()->remove_child(p_control);
165
} break;
166
167
case CONTAINER_SPATIAL_EDITOR_MENU: {
168
Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
169
170
} break;
171
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
172
Node3DEditor::get_singleton()->remove_control_from_left_panel(p_control);
173
} break;
174
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
175
Node3DEditor::get_singleton()->remove_control_from_right_panel(p_control);
176
} break;
177
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
178
Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
179
180
} break;
181
case CONTAINER_CANVAS_EDITOR_MENU: {
182
CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
183
184
} break;
185
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
186
CanvasItemEditor::get_singleton()->remove_control_from_left_panel(p_control);
187
} break;
188
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
189
CanvasItemEditor::get_singleton()->remove_control_from_right_panel(p_control);
190
} break;
191
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
192
CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);
193
194
} break;
195
case CONTAINER_INSPECTOR_BOTTOM: {
196
InspectorDock::get_singleton()->get_addon_area()->remove_child(p_control);
197
198
} break;
199
case CONTAINER_PROJECT_SETTING_TAB_LEFT:
200
case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
201
ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control);
202
203
} break;
204
}
205
}
206
207
void EditorPlugin::add_tool_menu_item(const String &p_name, const Callable &p_callable) {
208
EditorNode::get_singleton()->add_tool_menu_item(p_name, p_callable);
209
}
210
211
void EditorPlugin::add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu) {
212
ERR_FAIL_NULL(p_submenu);
213
EditorNode::get_singleton()->add_tool_submenu_item(p_name, p_submenu);
214
}
215
216
void EditorPlugin::remove_tool_menu_item(const String &p_name) {
217
EditorNode::get_singleton()->remove_tool_menu_item(p_name);
218
}
219
220
PopupMenu *EditorPlugin::get_export_as_menu() {
221
return EditorNode::get_singleton()->get_export_as_menu();
222
}
223
224
void EditorPlugin::set_input_event_forwarding_always_enabled() {
225
input_event_forwarding_always_enabled = true;
226
EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
227
always_input_forwarding_list->add_plugin(this);
228
}
229
230
void EditorPlugin::set_force_draw_over_forwarding_enabled() {
231
force_draw_over_forwarding_enabled = true;
232
EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
233
always_draw_over_forwarding_list->add_plugin(this);
234
}
235
236
void EditorPlugin::notify_scene_changed(const Node *scn_root) {
237
emit_signal(SNAME("scene_changed"), scn_root);
238
}
239
240
void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
241
if (screen_name == last_main_screen_name) {
242
return;
243
}
244
245
emit_signal(SNAME("main_screen_changed"), screen_name);
246
last_main_screen_name = screen_name;
247
}
248
249
void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
250
emit_signal(SNAME("scene_closed"), scene_filepath);
251
}
252
253
void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
254
emit_signal(SNAME("resource_saved"), p_resource);
255
}
256
257
void EditorPlugin::notify_scene_saved(const String &p_scene_filepath) {
258
emit_signal(SNAME("scene_saved"), p_scene_filepath);
259
}
260
261
bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
262
bool success = false;
263
GDVIRTUAL_CALL(_forward_canvas_gui_input, p_event, success);
264
return success;
265
}
266
267
void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
268
GDVIRTUAL_CALL(_forward_canvas_draw_over_viewport, p_overlay);
269
}
270
271
void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
272
GDVIRTUAL_CALL(_forward_canvas_force_draw_over_viewport, p_overlay);
273
}
274
275
// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
276
int EditorPlugin::update_overlays() const {
277
if (Node3DEditor::get_singleton()->is_visible()) {
278
int count = 0;
279
for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
280
Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i);
281
if (vp->is_visible()) {
282
vp->update_surface();
283
count++;
284
}
285
}
286
return count;
287
} else {
288
// This will update the normal viewport itself as well
289
CanvasItemEditor::get_singleton()->get_viewport_control()->queue_redraw();
290
return 1;
291
}
292
}
293
294
EditorPlugin::AfterGUIInput EditorPlugin::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
295
int success = EditorPlugin::AFTER_GUI_INPUT_PASS;
296
GDVIRTUAL_CALL(_forward_3d_gui_input, p_camera, p_event, success);
297
return static_cast<EditorPlugin::AfterGUIInput>(success);
298
}
299
300
void EditorPlugin::forward_3d_draw_over_viewport(Control *p_overlay) {
301
GDVIRTUAL_CALL(_forward_3d_draw_over_viewport, p_overlay);
302
}
303
304
void EditorPlugin::forward_3d_force_draw_over_viewport(Control *p_overlay) {
305
GDVIRTUAL_CALL(_forward_3d_force_draw_over_viewport, p_overlay);
306
}
307
308
String EditorPlugin::get_plugin_name() const {
309
String name;
310
GDVIRTUAL_CALL(_get_plugin_name, name);
311
return name;
312
}
313
314
const Ref<Texture2D> EditorPlugin::get_plugin_icon() const {
315
Ref<Texture2D> icon;
316
GDVIRTUAL_CALL(_get_plugin_icon, icon);
317
return icon;
318
}
319
320
String EditorPlugin::get_plugin_version() const {
321
return plugin_version;
322
}
323
324
void EditorPlugin::set_plugin_version(const String &p_version) {
325
plugin_version = p_version;
326
}
327
328
bool EditorPlugin::has_main_screen() const {
329
bool success = false;
330
GDVIRTUAL_CALL(_has_main_screen, success);
331
return success;
332
}
333
334
void EditorPlugin::make_visible(bool p_visible) {
335
GDVIRTUAL_CALL(_make_visible, p_visible);
336
}
337
338
void EditorPlugin::edit(Object *p_object) {
339
GDVIRTUAL_CALL(_edit, p_object);
340
}
341
342
bool EditorPlugin::handles(Object *p_object) const {
343
bool success = false;
344
GDVIRTUAL_CALL(_handles, p_object, success);
345
return success;
346
}
347
348
bool EditorPlugin::can_auto_hide() const {
349
return true;
350
}
351
352
Dictionary EditorPlugin::get_state() const {
353
Dictionary state;
354
GDVIRTUAL_CALL(_get_state, state);
355
return state;
356
}
357
358
void EditorPlugin::set_state(const Dictionary &p_state) {
359
GDVIRTUAL_CALL(_set_state, p_state);
360
}
361
362
void EditorPlugin::clear() {
363
GDVIRTUAL_CALL(_clear);
364
}
365
366
String EditorPlugin::get_unsaved_status(const String &p_for_scene) const {
367
String ret;
368
GDVIRTUAL_CALL(_get_unsaved_status, p_for_scene, ret);
369
return ret;
370
}
371
372
void EditorPlugin::save_external_data() {
373
GDVIRTUAL_CALL(_save_external_data);
374
}
375
376
// if changes are pending in editor, apply them
377
void EditorPlugin::apply_changes() {
378
GDVIRTUAL_CALL(_apply_changes);
379
}
380
381
void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
382
PackedStringArray arr;
383
if (GDVIRTUAL_CALL(_get_breakpoints, arr)) {
384
for (int i = 0; i < arr.size(); i++) {
385
p_breakpoints->push_back(arr[i]);
386
}
387
}
388
}
389
390
bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
391
return false;
392
}
393
394
void EditorPlugin::add_undo_redo_inspector_hook_callback(Callable p_callable) {
395
EditorNode::get_editor_data().add_undo_redo_inspector_hook_callback(p_callable);
396
}
397
398
void EditorPlugin::remove_undo_redo_inspector_hook_callback(Callable p_callable) {
399
EditorNode::get_editor_data().remove_undo_redo_inspector_hook_callback(p_callable);
400
}
401
402
void EditorPlugin::add_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
403
ERR_FAIL_COND(p_parser.is_null());
404
EditorTranslationParser::get_singleton()->add_parser(p_parser, EditorTranslationParser::CUSTOM);
405
}
406
407
void EditorPlugin::remove_translation_parser_plugin(const Ref<EditorTranslationParserPlugin> &p_parser) {
408
ERR_FAIL_COND(p_parser.is_null());
409
EditorTranslationParser::get_singleton()->remove_parser(p_parser, EditorTranslationParser::CUSTOM);
410
}
411
412
void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer, bool p_first_priority) {
413
ERR_FAIL_COND(p_importer.is_null());
414
ResourceFormatImporter::get_singleton()->add_importer(p_importer, p_first_priority);
415
// Plugins are now loaded during the first scan. It's important not to start another scan,
416
// even a deferred one, as it would cause a scan during a scan at the next main thread iteration.
417
if (!EditorFileSystem::get_singleton()->doing_first_scan()) {
418
callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan).call_deferred();
419
}
420
}
421
422
void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
423
ERR_FAIL_COND(p_importer.is_null());
424
ResourceFormatImporter::get_singleton()->remove_importer(p_importer);
425
// Plugins are now loaded during the first scan. It's important not to start another scan,
426
// even a deferred one, as it would cause a scan during a scan at the next main thread iteration.
427
if (!EditorNode::get_singleton()->is_exiting() && !EditorFileSystem::get_singleton()->doing_first_scan()) {
428
callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan).call_deferred();
429
}
430
}
431
432
void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
433
ERR_FAIL_COND(p_exporter.is_null());
434
EditorExport::get_singleton()->add_export_plugin(p_exporter);
435
}
436
437
void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
438
ERR_FAIL_COND(p_exporter.is_null());
439
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
440
}
441
442
void EditorPlugin::add_export_platform(const Ref<EditorExportPlatform> &p_platform) {
443
ERR_FAIL_COND(p_platform.is_null());
444
EditorExport::get_singleton()->add_export_platform(p_platform);
445
}
446
447
void EditorPlugin::remove_export_platform(const Ref<EditorExportPlatform> &p_platform) {
448
ERR_FAIL_COND(p_platform.is_null());
449
EditorExport::get_singleton()->remove_export_platform(p_platform);
450
}
451
452
void EditorPlugin::add_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
453
ERR_FAIL_COND(p_gizmo_plugin.is_null());
454
Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
455
}
456
457
void EditorPlugin::remove_node_3d_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
458
ERR_FAIL_COND(p_gizmo_plugin.is_null());
459
Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
460
}
461
462
void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
463
ERR_FAIL_COND(p_plugin.is_null());
464
EditorInspector::add_inspector_plugin(p_plugin);
465
}
466
467
void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
468
ERR_FAIL_COND(p_plugin.is_null());
469
EditorInspector::remove_inspector_plugin(p_plugin);
470
}
471
472
void EditorPlugin::add_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer, bool p_first_priority) {
473
ERR_FAIL_COND(p_importer.is_null());
474
ResourceImporterScene::add_scene_importer(p_importer, p_first_priority);
475
}
476
477
void EditorPlugin::remove_scene_format_importer_plugin(const Ref<EditorSceneFormatImporter> &p_importer) {
478
ERR_FAIL_COND(p_importer.is_null());
479
ResourceImporterScene::remove_scene_importer(p_importer);
480
}
481
482
void EditorPlugin::add_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin, bool p_first_priority) {
483
ResourceImporterScene::add_post_importer_plugin(p_plugin, p_first_priority);
484
}
485
486
void EditorPlugin::remove_scene_post_import_plugin(const Ref<EditorScenePostImportPlugin> &p_plugin) {
487
ResourceImporterScene::remove_post_importer_plugin(p_plugin);
488
}
489
490
void EditorPlugin::add_context_menu_plugin(EditorContextMenuPlugin::ContextMenuSlot p_slot, const Ref<EditorContextMenuPlugin> &p_plugin) {
491
EditorContextMenuPluginManager::get_singleton()->add_plugin(p_slot, p_plugin);
492
}
493
494
void EditorPlugin::remove_context_menu_plugin(const Ref<EditorContextMenuPlugin> &p_plugin) {
495
EditorContextMenuPluginManager::get_singleton()->remove_plugin(p_plugin);
496
}
497
498
int find(const PackedStringArray &a, const String &v) {
499
const String *r = a.ptr();
500
for (int j = 0; j < a.size(); ++j) {
501
if (r[j] == v) {
502
return j;
503
}
504
}
505
return -1;
506
}
507
508
void EditorPlugin::enable_plugin() {
509
// Called when the plugin gets enabled in project settings, after it's added to the tree.
510
// You can implement it to register autoloads.
511
GDVIRTUAL_CALL(_enable_plugin);
512
}
513
514
void EditorPlugin::disable_plugin() {
515
// Last function called when the plugin gets disabled in project settings.
516
// Implement it to cleanup things from the project, such as unregister autoloads.
517
GDVIRTUAL_CALL(_disable_plugin);
518
}
519
520
void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
521
GDVIRTUAL_CALL(_set_window_layout, p_layout);
522
}
523
524
void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
525
GDVIRTUAL_CALL(_get_window_layout, p_layout);
526
}
527
528
bool EditorPlugin::build() {
529
bool success = true;
530
GDVIRTUAL_CALL(_build, success);
531
return success;
532
}
533
534
void EditorPlugin::queue_save_layout() {
535
EditorNode::get_singleton()->save_editor_layout_delayed();
536
}
537
538
void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
539
EditorNode::get_bottom_panel()->make_item_visible(p_item);
540
}
541
542
void EditorPlugin::hide_bottom_panel() {
543
EditorNode::get_bottom_panel()->hide_bottom_panel();
544
}
545
546
EditorInterface *EditorPlugin::get_editor_interface() {
547
return EditorInterface::get_singleton();
548
}
549
550
ScriptCreateDialog *EditorPlugin::get_script_create_dialog() {
551
return SceneTreeDock::get_singleton()->get_script_create_dialog();
552
}
553
554
void EditorPlugin::add_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
555
EditorDebuggerNode::get_singleton()->add_debugger_plugin(p_plugin);
556
}
557
558
void EditorPlugin::remove_debugger_plugin(const Ref<EditorDebuggerPlugin> &p_plugin) {
559
EditorDebuggerNode::get_singleton()->remove_debugger_plugin(p_plugin);
560
}
561
562
void EditorPlugin::add_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin) {
563
EditorNode::get_singleton()->add_resource_conversion_plugin(p_plugin);
564
}
565
566
void EditorPlugin::remove_resource_conversion_plugin(const Ref<EditorResourceConversionPlugin> &p_plugin) {
567
EditorNode::get_singleton()->remove_resource_conversion_plugin(p_plugin);
568
}
569
570
#ifndef DISABLE_DEPRECATED
571
void EditorPlugin::_editor_project_settings_changed() {
572
emit_signal(SNAME("project_settings_changed"));
573
}
574
#endif
575
576
void EditorPlugin::_notification(int p_what) {
577
#ifndef DISABLE_DEPRECATED
578
switch (p_what) {
579
case NOTIFICATION_ENTER_TREE: {
580
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
581
} break;
582
583
case NOTIFICATION_EXIT_TREE: {
584
ProjectSettings::get_singleton()->disconnect("settings_changed", callable_mp(this, &EditorPlugin::_editor_project_settings_changed));
585
} break;
586
}
587
#endif
588
}
589
590
void EditorPlugin::_bind_methods() {
591
ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
592
ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title", "shortcut"), &EditorPlugin::add_control_to_bottom_panel, DEFVAL(Ref<Shortcut>()));
593
ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control", "shortcut"), &EditorPlugin::add_control_to_dock, DEFVAL(Ref<Shortcut>()));
594
ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
595
ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
596
ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
597
ClassDB::bind_method(D_METHOD("set_dock_tab_icon", "control", "icon"), &EditorPlugin::set_dock_tab_icon);
598
ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "callable"), &EditorPlugin::add_tool_menu_item);
599
ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
600
ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
601
ClassDB::bind_method(D_METHOD("get_export_as_menu"), &EditorPlugin::get_export_as_menu);
602
ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
603
ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
604
605
ClassDB::bind_method(D_METHOD("add_autoload_singleton", "name", "path"), &EditorPlugin::add_autoload_singleton);
606
ClassDB::bind_method(D_METHOD("remove_autoload_singleton", "name"), &EditorPlugin::remove_autoload_singleton);
607
608
ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);
609
610
ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
611
ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
612
613
ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::get_undo_redo);
614
ClassDB::bind_method(D_METHOD("add_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::add_undo_redo_inspector_hook_callback);
615
ClassDB::bind_method(D_METHOD("remove_undo_redo_inspector_hook_callback", "callable"), &EditorPlugin::remove_undo_redo_inspector_hook_callback);
616
ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
617
ClassDB::bind_method(D_METHOD("add_translation_parser_plugin", "parser"), &EditorPlugin::add_translation_parser_plugin);
618
ClassDB::bind_method(D_METHOD("remove_translation_parser_plugin", "parser"), &EditorPlugin::remove_translation_parser_plugin);
619
ClassDB::bind_method(D_METHOD("add_import_plugin", "importer", "first_priority"), &EditorPlugin::add_import_plugin, DEFVAL(false));
620
ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
621
ClassDB::bind_method(D_METHOD("add_scene_format_importer_plugin", "scene_format_importer", "first_priority"), &EditorPlugin::add_scene_format_importer_plugin, DEFVAL(false));
622
ClassDB::bind_method(D_METHOD("remove_scene_format_importer_plugin", "scene_format_importer"), &EditorPlugin::remove_scene_format_importer_plugin);
623
ClassDB::bind_method(D_METHOD("add_scene_post_import_plugin", "scene_import_plugin", "first_priority"), &EditorPlugin::add_scene_post_import_plugin, DEFVAL(false));
624
ClassDB::bind_method(D_METHOD("remove_scene_post_import_plugin", "scene_import_plugin"), &EditorPlugin::remove_scene_post_import_plugin);
625
ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
626
ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
627
ClassDB::bind_method(D_METHOD("add_export_platform", "platform"), &EditorPlugin::add_export_platform);
628
ClassDB::bind_method(D_METHOD("remove_export_platform", "platform"), &EditorPlugin::remove_export_platform);
629
ClassDB::bind_method(D_METHOD("add_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::add_node_3d_gizmo_plugin);
630
ClassDB::bind_method(D_METHOD("remove_node_3d_gizmo_plugin", "plugin"), &EditorPlugin::remove_node_3d_gizmo_plugin);
631
ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
632
ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
633
ClassDB::bind_method(D_METHOD("add_resource_conversion_plugin", "plugin"), &EditorPlugin::add_resource_conversion_plugin);
634
ClassDB::bind_method(D_METHOD("remove_resource_conversion_plugin", "plugin"), &EditorPlugin::remove_resource_conversion_plugin);
635
ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
636
ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
637
ClassDB::bind_method(D_METHOD("add_context_menu_plugin", "slot", "plugin"), &EditorPlugin::add_context_menu_plugin);
638
ClassDB::bind_method(D_METHOD("remove_context_menu_plugin", "plugin"), &EditorPlugin::remove_context_menu_plugin);
639
640
ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
641
ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog);
642
ClassDB::bind_method(D_METHOD("add_debugger_plugin", "script"), &EditorPlugin::add_debugger_plugin);
643
ClassDB::bind_method(D_METHOD("remove_debugger_plugin", "script"), &EditorPlugin::remove_debugger_plugin);
644
ClassDB::bind_method(D_METHOD("get_plugin_version"), &EditorPlugin::get_plugin_version);
645
646
GDVIRTUAL_BIND(_forward_canvas_gui_input, "event");
647
GDVIRTUAL_BIND(_forward_canvas_draw_over_viewport, "viewport_control");
648
GDVIRTUAL_BIND(_forward_canvas_force_draw_over_viewport, "viewport_control");
649
GDVIRTUAL_BIND(_forward_3d_gui_input, "viewport_camera", "event");
650
GDVIRTUAL_BIND(_forward_3d_draw_over_viewport, "viewport_control");
651
GDVIRTUAL_BIND(_forward_3d_force_draw_over_viewport, "viewport_control");
652
GDVIRTUAL_BIND(_get_plugin_name);
653
GDVIRTUAL_BIND(_get_plugin_icon);
654
GDVIRTUAL_BIND(_has_main_screen);
655
GDVIRTUAL_BIND(_make_visible, "visible");
656
GDVIRTUAL_BIND(_edit, "object");
657
GDVIRTUAL_BIND(_handles, "object");
658
GDVIRTUAL_BIND(_get_state);
659
GDVIRTUAL_BIND(_set_state, "state");
660
GDVIRTUAL_BIND(_clear);
661
GDVIRTUAL_BIND(_get_unsaved_status, "for_scene");
662
GDVIRTUAL_BIND(_save_external_data);
663
GDVIRTUAL_BIND(_apply_changes);
664
GDVIRTUAL_BIND(_get_breakpoints);
665
GDVIRTUAL_BIND(_set_window_layout, "configuration");
666
GDVIRTUAL_BIND(_get_window_layout, "configuration");
667
GDVIRTUAL_BIND(_build);
668
GDVIRTUAL_BIND(_enable_plugin);
669
GDVIRTUAL_BIND(_disable_plugin);
670
671
ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
672
ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
673
ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
674
ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
675
ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "filepath")));
676
ADD_SIGNAL(MethodInfo("project_settings_changed"));
677
678
BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
679
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
680
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT);
681
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT);
682
BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
683
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
684
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_LEFT);
685
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT);
686
BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM);
687
BIND_ENUM_CONSTANT(CONTAINER_INSPECTOR_BOTTOM);
688
BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_LEFT);
689
BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_RIGHT);
690
691
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL);
692
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL);
693
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UR);
694
BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BR);
695
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UL);
696
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BL);
697
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
698
BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
699
BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
700
701
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_PASS);
702
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_STOP);
703
BIND_ENUM_CONSTANT(AFTER_GUI_INPUT_CUSTOM);
704
}
705
706
EditorUndoRedoManager *EditorPlugin::get_undo_redo() {
707
return EditorUndoRedoManager::get_singleton();
708
}
709
710
EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
711
712
int EditorPlugins::creation_func_count = 0;
713
714