1 /** 2 Used by the editor to extend its functionality. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.editorplugin; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.node; 24 import godot.toolbutton; 25 import godot.control; 26 import godot.script; 27 import godot.texture; 28 import godot.editorexportplugin; 29 import godot.editorimportplugin; 30 import godot.editorinspectorplugin; 31 import godot.editorsceneimporter; 32 import godot.editorspatialgizmoplugin; 33 import godot.inputevent; 34 import godot.camera; 35 import godot.editorinterface; 36 import godot.scriptcreatedialog; 37 import godot.undoredo; 38 import godot.configfile; 39 /** 40 Used by the editor to extend its functionality. 41 42 Plugins are used by the editor to extend functionality. The most common types of plugins are those which edit a given node or resource type, import plugins and export plugins. See also $(D EditorScript) to add functions to the editor. 43 */ 44 @GodotBaseClass struct EditorPlugin 45 { 46 package(godot) enum string _GODOT_internal_name = "EditorPlugin"; 47 public: 48 @nogc nothrow: 49 union { /** */ godot_object _godot_object; /** */ Node _GODOT_base; } 50 alias _GODOT_base this; 51 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 52 package(godot) __gshared bool _classBindingInitialized = false; 53 package(godot) static struct GDNativeClassBinding 54 { 55 __gshared: 56 @GodotName("add_autoload_singleton") GodotMethod!(void, String, String) addAutoloadSingleton; 57 @GodotName("add_control_to_bottom_panel") GodotMethod!(ToolButton, Control, String) addControlToBottomPanel; 58 @GodotName("add_control_to_container") GodotMethod!(void, long, Control) addControlToContainer; 59 @GodotName("add_control_to_dock") GodotMethod!(void, long, Control) addControlToDock; 60 @GodotName("add_custom_type") GodotMethod!(void, String, String, Script, Texture) addCustomType; 61 @GodotName("add_export_plugin") GodotMethod!(void, EditorExportPlugin) addExportPlugin; 62 @GodotName("add_import_plugin") GodotMethod!(void, EditorImportPlugin) addImportPlugin; 63 @GodotName("add_inspector_plugin") GodotMethod!(void, EditorInspectorPlugin) addInspectorPlugin; 64 @GodotName("add_scene_import_plugin") GodotMethod!(void, EditorSceneImporter) addSceneImportPlugin; 65 @GodotName("add_spatial_gizmo_plugin") GodotMethod!(void, EditorSpatialGizmoPlugin) addSpatialGizmoPlugin; 66 @GodotName("add_tool_menu_item") GodotMethod!(void, String, GodotObject, String, Variant) addToolMenuItem; 67 @GodotName("add_tool_submenu_item") GodotMethod!(void, String, GodotObject) addToolSubmenuItem; 68 @GodotName("apply_changes") GodotMethod!(void) applyChanges; 69 @GodotName("build") GodotMethod!(bool) build; 70 @GodotName("clear") GodotMethod!(void) clear; 71 @GodotName("disable_plugin") GodotMethod!(void) disablePlugin; 72 @GodotName("edit") GodotMethod!(void, GodotObject) edit; 73 @GodotName("enable_plugin") GodotMethod!(void) enablePlugin; 74 @GodotName("forward_canvas_draw_over_viewport") GodotMethod!(void, Control) forwardCanvasDrawOverViewport; 75 @GodotName("forward_canvas_force_draw_over_viewport") GodotMethod!(void, Control) forwardCanvasForceDrawOverViewport; 76 @GodotName("forward_canvas_gui_input") GodotMethod!(bool, InputEvent) forwardCanvasGuiInput; 77 @GodotName("forward_spatial_draw_over_viewport") GodotMethod!(void, Control) forwardSpatialDrawOverViewport; 78 @GodotName("forward_spatial_force_draw_over_viewport") GodotMethod!(void, Control) forwardSpatialForceDrawOverViewport; 79 @GodotName("forward_spatial_gui_input") GodotMethod!(bool, Camera, InputEvent) forwardSpatialGuiInput; 80 @GodotName("get_breakpoints") GodotMethod!(PoolStringArray) getBreakpoints; 81 @GodotName("get_editor_interface") GodotMethod!(EditorInterface) getEditorInterface; 82 @GodotName("get_plugin_icon") GodotMethod!(Texture) getPluginIcon; 83 @GodotName("get_plugin_name") GodotMethod!(String) getPluginName; 84 @GodotName("get_script_create_dialog") GodotMethod!(ScriptCreateDialog) getScriptCreateDialog; 85 @GodotName("get_state") GodotMethod!(Dictionary) getState; 86 @GodotName("get_undo_redo") GodotMethod!(UndoRedo) getUndoRedo; 87 @GodotName("get_window_layout") GodotMethod!(void, ConfigFile) getWindowLayout; 88 @GodotName("handles") GodotMethod!(bool, GodotObject) handles; 89 @GodotName("has_main_screen") GodotMethod!(bool) hasMainScreen; 90 @GodotName("hide_bottom_panel") GodotMethod!(void) hideBottomPanel; 91 @GodotName("make_bottom_panel_item_visible") GodotMethod!(void, Control) makeBottomPanelItemVisible; 92 @GodotName("make_visible") GodotMethod!(void, bool) makeVisible; 93 @GodotName("queue_save_layout") GodotMethod!(void) queueSaveLayout; 94 @GodotName("remove_autoload_singleton") GodotMethod!(void, String) removeAutoloadSingleton; 95 @GodotName("remove_control_from_bottom_panel") GodotMethod!(void, Control) removeControlFromBottomPanel; 96 @GodotName("remove_control_from_container") GodotMethod!(void, long, Control) removeControlFromContainer; 97 @GodotName("remove_control_from_docks") GodotMethod!(void, Control) removeControlFromDocks; 98 @GodotName("remove_custom_type") GodotMethod!(void, String) removeCustomType; 99 @GodotName("remove_export_plugin") GodotMethod!(void, EditorExportPlugin) removeExportPlugin; 100 @GodotName("remove_import_plugin") GodotMethod!(void, EditorImportPlugin) removeImportPlugin; 101 @GodotName("remove_inspector_plugin") GodotMethod!(void, EditorInspectorPlugin) removeInspectorPlugin; 102 @GodotName("remove_scene_import_plugin") GodotMethod!(void, EditorSceneImporter) removeSceneImportPlugin; 103 @GodotName("remove_spatial_gizmo_plugin") GodotMethod!(void, EditorSpatialGizmoPlugin) removeSpatialGizmoPlugin; 104 @GodotName("remove_tool_menu_item") GodotMethod!(void, String) removeToolMenuItem; 105 @GodotName("save_external_data") GodotMethod!(void) saveExternalData; 106 @GodotName("set_force_draw_over_forwarding_enabled") GodotMethod!(void) setForceDrawOverForwardingEnabled; 107 @GodotName("set_input_event_forwarding_always_enabled") GodotMethod!(void) setInputEventForwardingAlwaysEnabled; 108 @GodotName("set_state") GodotMethod!(void, Dictionary) setState; 109 @GodotName("set_window_layout") GodotMethod!(void, ConfigFile) setWindowLayout; 110 @GodotName("update_overlays") GodotMethod!(long) updateOverlays; 111 } 112 /// 113 pragma(inline, true) bool opEquals(in EditorPlugin other) const 114 { return _godot_object.ptr is other._godot_object.ptr; } 115 /// 116 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 117 { _godot_object.ptr = n; return null; } 118 /// 119 pragma(inline, true) bool opEquals(typeof(null) n) const 120 { return _godot_object.ptr is n; } 121 /// 122 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 123 mixin baseCasts; 124 /// Construct a new instance of EditorPlugin. 125 /// Note: use `memnew!EditorPlugin` instead. 126 static EditorPlugin _new() 127 { 128 static godot_class_constructor constructor; 129 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorPlugin"); 130 if(constructor is null) return typeof(this).init; 131 return cast(EditorPlugin)(constructor()); 132 } 133 @disable new(size_t s); 134 /// 135 enum DockSlot : int 136 { 137 /** 138 139 */ 140 dockSlotLeftUl = 0, 141 /** 142 143 */ 144 dockSlotLeftBl = 1, 145 /** 146 147 */ 148 dockSlotLeftUr = 2, 149 /** 150 151 */ 152 dockSlotLeftBr = 3, 153 /** 154 155 */ 156 dockSlotRightUl = 4, 157 /** 158 159 */ 160 dockSlotRightBl = 5, 161 /** 162 163 */ 164 dockSlotRightUr = 6, 165 /** 166 167 */ 168 dockSlotRightBr = 7, 169 /** 170 Represents the size of the $(D dockslot) enum. 171 */ 172 dockSlotMax = 8, 173 } 174 /// 175 enum CustomControlContainer : int 176 { 177 /** 178 179 */ 180 containerToolbar = 0, 181 /** 182 183 */ 184 containerSpatialEditorMenu = 1, 185 /** 186 187 */ 188 containerSpatialEditorSideLeft = 2, 189 /** 190 191 */ 192 containerSpatialEditorSideRight = 3, 193 /** 194 195 */ 196 containerSpatialEditorBottom = 4, 197 /** 198 199 */ 200 containerCanvasEditorMenu = 5, 201 /** 202 203 */ 204 containerCanvasEditorSideLeft = 6, 205 /** 206 207 */ 208 containerCanvasEditorSideRight = 7, 209 /** 210 211 */ 212 containerCanvasEditorBottom = 8, 213 /** 214 215 */ 216 containerPropertyEditorBottom = 9, 217 /** 218 219 */ 220 containerProjectSettingTabLeft = 10, 221 /** 222 223 */ 224 containerProjectSettingTabRight = 11, 225 } 226 /// 227 enum Constants : int 228 { 229 containerToolbar = 0, 230 dockSlotLeftUl = 0, 231 containerSpatialEditorMenu = 1, 232 dockSlotLeftBl = 1, 233 containerSpatialEditorSideLeft = 2, 234 dockSlotLeftUr = 2, 235 containerSpatialEditorSideRight = 3, 236 dockSlotLeftBr = 3, 237 containerSpatialEditorBottom = 4, 238 dockSlotRightUl = 4, 239 containerCanvasEditorMenu = 5, 240 dockSlotRightBl = 5, 241 containerCanvasEditorSideLeft = 6, 242 dockSlotRightUr = 6, 243 containerCanvasEditorSideRight = 7, 244 dockSlotRightBr = 7, 245 containerCanvasEditorBottom = 8, 246 dockSlotMax = 8, 247 containerPropertyEditorBottom = 9, 248 containerProjectSettingTabLeft = 10, 249 containerProjectSettingTabRight = 11, 250 } 251 /** 252 Adds a script at `path` to the Autoload list as `name`. 253 */ 254 void addAutoloadSingleton(in String name, in String path) 255 { 256 checkClassBinding!(typeof(this))(); 257 ptrcall!(void)(GDNativeClassBinding.addAutoloadSingleton, _godot_object, name, path); 258 } 259 /** 260 Adds a control to the bottom panel (together with Output, Debug, Animation, etc). Returns a reference to the button added. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with $(D removeControlFromBottomPanel) and free it with $(D Node.queueFree). 261 */ 262 ToolButton addControlToBottomPanel(Control control, in String title) 263 { 264 checkClassBinding!(typeof(this))(); 265 return ptrcall!(ToolButton)(GDNativeClassBinding.addControlToBottomPanel, _godot_object, control, title); 266 } 267 /** 268 Adds a custom control to a container (see $(D customcontrolcontainer)). There are many locations where custom controls can be added in the editor UI. 269 Please remember that you have to manage the visibility of your custom controls yourself (and likely hide it after adding it). 270 When your plugin is deactivated, make sure to remove your custom control with $(D removeControlFromContainer) and free it with $(D Node.queueFree). 271 */ 272 void addControlToContainer(in long container, Control control) 273 { 274 checkClassBinding!(typeof(this))(); 275 ptrcall!(void)(GDNativeClassBinding.addControlToContainer, _godot_object, container, control); 276 } 277 /** 278 Adds the control to a specific dock slot (see $(D dockslot) for options). 279 If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions. 280 When your plugin is deactivated, make sure to remove your custom control with $(D removeControlFromDocks) and free it with $(D Node.queueFree). 281 */ 282 void addControlToDock(in long slot, Control control) 283 { 284 checkClassBinding!(typeof(this))(); 285 ptrcall!(void)(GDNativeClassBinding.addControlToDock, _godot_object, slot, control); 286 } 287 /** 288 Adds a custom type, which will appear in the list of nodes or resources. An icon can be optionally passed. 289 When given node or resource is selected, the base type will be instanced (ie, "Spatial", "Control", "Resource"), then the script will be loaded and set to this object. 290 You can use the virtual method $(D handles) to check if your custom object is being edited by checking the script or using the `is` keyword. 291 During run-time, this will be a simple object with a script so this function does not need to be called then. 292 */ 293 void addCustomType(in String type, in String base, Script script, Texture icon) 294 { 295 checkClassBinding!(typeof(this))(); 296 ptrcall!(void)(GDNativeClassBinding.addCustomType, _godot_object, type, base, script, icon); 297 } 298 /** 299 Registers a new $(D EditorExportPlugin). Export plugins are used to perform tasks when the project is being exported. 300 See $(D addInspectorPlugin) for an example of how to register a plugin. 301 */ 302 void addExportPlugin(EditorExportPlugin plugin) 303 { 304 checkClassBinding!(typeof(this))(); 305 ptrcall!(void)(GDNativeClassBinding.addExportPlugin, _godot_object, plugin); 306 } 307 /** 308 Registers a new $(D EditorImportPlugin). Import plugins are used to import custom and unsupported assets as a custom $(D Resource) type. 309 $(B Note:) If you want to import custom 3D asset formats use $(D addSceneImportPlugin) instead. 310 See $(D addInspectorPlugin) for an example of how to register a plugin. 311 */ 312 void addImportPlugin(EditorImportPlugin importer) 313 { 314 checkClassBinding!(typeof(this))(); 315 ptrcall!(void)(GDNativeClassBinding.addImportPlugin, _godot_object, importer); 316 } 317 /** 318 Registers a new $(D EditorInspectorPlugin). Inspector plugins are used to extend $(D EditorInspector) and provide custom configuration tools for your object's properties. 319 $(B Note:) Always use $(D removeInspectorPlugin) to remove the registered $(D EditorInspectorPlugin) when your $(D EditorPlugin) is disabled to prevent leaks and an unexpected behavior. 320 321 322 const MyInspectorPlugin = preload("res://addons/your_addon/path/to/your/script.gd") 323 var inspector_plugin = MyInspectorPlugin.new() 324 325 func _enter_tree(): 326 add_inspector_plugin(inspector_plugin) 327 328 func _exit_tree(): 329 remove_inspector_plugin(inspector_plugin) 330 331 332 */ 333 void addInspectorPlugin(EditorInspectorPlugin plugin) 334 { 335 checkClassBinding!(typeof(this))(); 336 ptrcall!(void)(GDNativeClassBinding.addInspectorPlugin, _godot_object, plugin); 337 } 338 /** 339 Registers a new $(D EditorSceneImporter). Scene importers are used to import custom 3D asset formats as scenes. 340 */ 341 void addSceneImportPlugin(EditorSceneImporter scene_importer) 342 { 343 checkClassBinding!(typeof(this))(); 344 ptrcall!(void)(GDNativeClassBinding.addSceneImportPlugin, _godot_object, scene_importer); 345 } 346 /** 347 Registers a new $(D EditorSpatialGizmoPlugin). Gizmo plugins are used to add custom gizmos to the 3D preview viewport for a $(D Spatial). 348 See $(D addInspectorPlugin) for an example of how to register a plugin. 349 */ 350 void addSpatialGizmoPlugin(EditorSpatialGizmoPlugin plugin) 351 { 352 checkClassBinding!(typeof(this))(); 353 ptrcall!(void)(GDNativeClassBinding.addSpatialGizmoPlugin, _godot_object, plugin); 354 } 355 /** 356 Adds a custom menu item to $(B Project > Tools) as `name` that calls `callback` on an instance of `handler` with a parameter `ud` when user activates it. 357 */ 358 void addToolMenuItem(VariantArg3)(in String name, GodotObject handler, in String callback, in VariantArg3 ud = Variant.nil) 359 { 360 checkClassBinding!(typeof(this))(); 361 ptrcall!(void)(GDNativeClassBinding.addToolMenuItem, _godot_object, name, handler, callback, ud); 362 } 363 /** 364 Adds a custom submenu under $(B Project > Tools >) `name`. `submenu` should be an object of class $(D PopupMenu). This submenu should be cleaned up using `remove_tool_menu_item(name)`. 365 */ 366 void addToolSubmenuItem(in String name, GodotObject submenu) 367 { 368 checkClassBinding!(typeof(this))(); 369 ptrcall!(void)(GDNativeClassBinding.addToolSubmenuItem, _godot_object, name, submenu); 370 } 371 /** 372 This method is called when the editor is about to save the project, switch to another tab, etc. It asks the plugin to apply any pending state changes to ensure consistency. 373 This is used, for example, in shader editors to let the plugin know that it must apply the shader code being written by the user to the object. 374 */ 375 void applyChanges() 376 { 377 Array _GODOT_args = Array.make(); 378 String _GODOT_method_name = String("apply_changes"); 379 this.callv(_GODOT_method_name, _GODOT_args); 380 } 381 /** 382 This method is called when the editor is about to run the project. The plugin can then perform required operations before the project runs. 383 This method must return a boolean. If this method returns `false`, the project will not run. The run is aborted immediately, so this also prevents all other plugins' $(D build) methods from running. 384 */ 385 bool build() 386 { 387 Array _GODOT_args = Array.make(); 388 String _GODOT_method_name = String("build"); 389 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 390 } 391 /** 392 Clear all the state and reset the object being edited to zero. This ensures your plugin does not keep editing a currently existing node, or a node from the wrong scene. 393 */ 394 void clear() 395 { 396 Array _GODOT_args = Array.make(); 397 String _GODOT_method_name = String("clear"); 398 this.callv(_GODOT_method_name, _GODOT_args); 399 } 400 /** 401 Called by the engine when the user disables the $(D EditorPlugin) in the Plugin tab of the project settings window. 402 */ 403 void disablePlugin() 404 { 405 Array _GODOT_args = Array.make(); 406 String _GODOT_method_name = String("disable_plugin"); 407 this.callv(_GODOT_method_name, _GODOT_args); 408 } 409 /** 410 This function is used for plugins that edit specific object types (nodes or resources). It requests the editor to edit the given object. 411 */ 412 void edit(GodotObject object) 413 { 414 Array _GODOT_args = Array.make(); 415 _GODOT_args.append(object); 416 String _GODOT_method_name = String("edit"); 417 this.callv(_GODOT_method_name, _GODOT_args); 418 } 419 /** 420 Called by the engine when the user enables the $(D EditorPlugin) in the Plugin tab of the project settings window. 421 */ 422 void enablePlugin() 423 { 424 Array _GODOT_args = Array.make(); 425 String _GODOT_method_name = String("enable_plugin"); 426 this.callv(_GODOT_method_name, _GODOT_args); 427 } 428 /** 429 Called by the engine when the 2D editor's viewport is updated. Use the `overlay` $(D Control) for drawing. You can update the viewport manually by calling $(D updateOverlays). 430 431 432 func forward_canvas_draw_over_viewport(overlay): 433 # Draw a circle at cursor position. 434 overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.white) 435 436 func forward_canvas_gui_input(event): 437 if event is InputEventMouseMotion: 438 # Redraw viewport when cursor is moved. 439 update_overlays() 440 return true 441 return false 442 443 444 */ 445 void forwardCanvasDrawOverViewport(Control overlay) 446 { 447 Array _GODOT_args = Array.make(); 448 _GODOT_args.append(overlay); 449 String _GODOT_method_name = String("forward_canvas_draw_over_viewport"); 450 this.callv(_GODOT_method_name, _GODOT_args); 451 } 452 /** 453 This method is the same as $(D forwardCanvasDrawOverViewport), except it draws on top of everything. Useful when you need an extra layer that shows over anything else. 454 You need to enable calling of this method by using $(D setForceDrawOverForwardingEnabled). 455 */ 456 void forwardCanvasForceDrawOverViewport(Control overlay) 457 { 458 Array _GODOT_args = Array.make(); 459 _GODOT_args.append(overlay); 460 String _GODOT_method_name = String("forward_canvas_force_draw_over_viewport"); 461 this.callv(_GODOT_method_name, _GODOT_args); 462 } 463 /** 464 Called when there is a root node in the current edited scene, $(D handles) is implemented and an $(D InputEvent) happens in the 2D viewport. Intercepts the $(D InputEvent), if `return true` $(D EditorPlugin) consumes the `event`, otherwise forwards `event` to other Editor classes. Example: 465 466 467 # Prevents the InputEvent to reach other Editor classes 468 func forward_canvas_gui_input(event): 469 var forward = true 470 return forward 471 472 473 Must `return false` in order to forward the $(D InputEvent) to other Editor classes. Example: 474 475 476 # Consumes InputEventMouseMotion and forwards other InputEvent types 477 func forward_canvas_gui_input(event): 478 var forward = false 479 if event is InputEventMouseMotion: 480 forward = true 481 return forward 482 483 484 */ 485 bool forwardCanvasGuiInput(InputEvent event) 486 { 487 Array _GODOT_args = Array.make(); 488 _GODOT_args.append(event); 489 String _GODOT_method_name = String("forward_canvas_gui_input"); 490 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 491 } 492 /** 493 Called by the engine when the 3D editor's viewport is updated. Use the `overlay` $(D Control) for drawing. You can update the viewport manually by calling $(D updateOverlays). 494 495 496 func forward_spatial_draw_over_viewport(overlay): 497 # Draw a circle at cursor position. 498 overlay.draw_circle(overlay.get_local_mouse_position(), 64) 499 500 func forward_spatial_gui_input(camera, event): 501 if event is InputEventMouseMotion: 502 # Redraw viewport when cursor is moved. 503 update_overlays() 504 return true 505 return false 506 507 508 */ 509 void forwardSpatialDrawOverViewport(Control overlay) 510 { 511 Array _GODOT_args = Array.make(); 512 _GODOT_args.append(overlay); 513 String _GODOT_method_name = String("forward_spatial_draw_over_viewport"); 514 this.callv(_GODOT_method_name, _GODOT_args); 515 } 516 /** 517 This method is the same as $(D forwardSpatialDrawOverViewport), except it draws on top of everything. Useful when you need an extra layer that shows over anything else. 518 You need to enable calling of this method by using $(D setForceDrawOverForwardingEnabled). 519 */ 520 void forwardSpatialForceDrawOverViewport(Control overlay) 521 { 522 Array _GODOT_args = Array.make(); 523 _GODOT_args.append(overlay); 524 String _GODOT_method_name = String("forward_spatial_force_draw_over_viewport"); 525 this.callv(_GODOT_method_name, _GODOT_args); 526 } 527 /** 528 Called when there is a root node in the current edited scene, $(D handles) is implemented and an $(D InputEvent) happens in the 3D viewport. Intercepts the $(D InputEvent), if `return true` $(D EditorPlugin) consumes the `event`, otherwise forwards `event` to other Editor classes. Example: 529 530 531 # Prevents the InputEvent to reach other Editor classes 532 func forward_spatial_gui_input(camera, event): 533 var forward = true 534 return forward 535 536 537 Must `return false` in order to forward the $(D InputEvent) to other Editor classes. Example: 538 539 540 # Consumes InputEventMouseMotion and forwards other InputEvent types 541 func forward_spatial_gui_input(camera, event): 542 var forward = false 543 if event is InputEventMouseMotion: 544 forward = true 545 return forward 546 547 548 */ 549 bool forwardSpatialGuiInput(Camera camera, InputEvent event) 550 { 551 Array _GODOT_args = Array.make(); 552 _GODOT_args.append(camera); 553 _GODOT_args.append(event); 554 String _GODOT_method_name = String("forward_spatial_gui_input"); 555 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 556 } 557 /** 558 This is for editors that edit script-based objects. You can return a list of breakpoints in the format (`script:line`), for example: `res://path_to_script.gd:25`. 559 */ 560 PoolStringArray getBreakpoints() 561 { 562 Array _GODOT_args = Array.make(); 563 String _GODOT_method_name = String("get_breakpoints"); 564 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!PoolStringArray); 565 } 566 /** 567 Returns the $(D EditorInterface) object that gives you control over Godot editor's window and its functionalities. 568 */ 569 EditorInterface getEditorInterface() 570 { 571 checkClassBinding!(typeof(this))(); 572 return ptrcall!(EditorInterface)(GDNativeClassBinding.getEditorInterface, _godot_object); 573 } 574 /** 575 Override this method in your plugin to return a $(D Texture) in order to give it an icon. 576 For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons. 577 Ideally, the plugin icon should be white with a transparent background and 16x16 pixels in size. 578 579 580 func get_plugin_icon(): 581 # You can use a custom icon: 582 return preload("res://addons/my_plugin/my_plugin_icon.svg") 583 # Or use a built-in icon: 584 return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons") 585 586 587 */ 588 Ref!Texture getPluginIcon() 589 { 590 Array _GODOT_args = Array.make(); 591 String _GODOT_method_name = String("get_plugin_icon"); 592 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Texture); 593 } 594 /** 595 Override this method in your plugin to provide the name of the plugin when displayed in the Godot editor. 596 For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", and "AssetLib" buttons. 597 */ 598 String getPluginName() 599 { 600 Array _GODOT_args = Array.make(); 601 String _GODOT_method_name = String("get_plugin_name"); 602 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String); 603 } 604 /** 605 Gets the Editor's dialogue used for making scripts. 606 $(B Note:) Users can configure it before use. 607 */ 608 ScriptCreateDialog getScriptCreateDialog() 609 { 610 checkClassBinding!(typeof(this))(); 611 return ptrcall!(ScriptCreateDialog)(GDNativeClassBinding.getScriptCreateDialog, _godot_object); 612 } 613 /** 614 Gets the state of your plugin editor. This is used when saving the scene (so state is kept when opening it again) and for switching tabs (so state can be restored when the tab returns). 615 */ 616 Dictionary getState() 617 { 618 Array _GODOT_args = Array.make(); 619 String _GODOT_method_name = String("get_state"); 620 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Dictionary); 621 } 622 /** 623 Gets the undo/redo object. Most actions in the editor can be undoable, so use this object to make sure this happens when it's worth it. 624 */ 625 UndoRedo getUndoRedo() 626 { 627 checkClassBinding!(typeof(this))(); 628 return ptrcall!(UndoRedo)(GDNativeClassBinding.getUndoRedo, _godot_object); 629 } 630 /** 631 Gets the GUI layout of the plugin. This is used to save the project's editor layout when $(D queueSaveLayout) is called or the editor layout was changed(For example changing the position of a dock). 632 */ 633 void getWindowLayout(ConfigFile layout) 634 { 635 Array _GODOT_args = Array.make(); 636 _GODOT_args.append(layout); 637 String _GODOT_method_name = String("get_window_layout"); 638 this.callv(_GODOT_method_name, _GODOT_args); 639 } 640 /** 641 Implement this function if your plugin edits a specific type of object (Resource or Node). If you return `true`, then you will get the functions $(D edit) and $(D makeVisible) called when the editor requests them. If you have declared the methods $(D forwardCanvasGuiInput) and $(D forwardSpatialGuiInput) these will be called too. 642 */ 643 bool handles(GodotObject object) 644 { 645 Array _GODOT_args = Array.make(); 646 _GODOT_args.append(object); 647 String _GODOT_method_name = String("handles"); 648 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 649 } 650 /** 651 Returns `true` if this is a main screen editor plugin (it goes in the workspace selector together with $(B 2D), $(B 3D), $(B Script) and $(B AssetLib)). 652 */ 653 bool hasMainScreen() 654 { 655 Array _GODOT_args = Array.make(); 656 String _GODOT_method_name = String("has_main_screen"); 657 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool); 658 } 659 /** 660 Minimizes the bottom panel. 661 */ 662 void hideBottomPanel() 663 { 664 checkClassBinding!(typeof(this))(); 665 ptrcall!(void)(GDNativeClassBinding.hideBottomPanel, _godot_object); 666 } 667 /** 668 Makes a specific item in the bottom panel visible. 669 */ 670 void makeBottomPanelItemVisible(Control item) 671 { 672 checkClassBinding!(typeof(this))(); 673 ptrcall!(void)(GDNativeClassBinding.makeBottomPanelItemVisible, _godot_object, item); 674 } 675 /** 676 This function will be called when the editor is requested to become visible. It is used for plugins that edit a specific object type. 677 Remember that you have to manage the visibility of all your editor controls manually. 678 */ 679 void makeVisible(in bool visible) 680 { 681 Array _GODOT_args = Array.make(); 682 _GODOT_args.append(visible); 683 String _GODOT_method_name = String("make_visible"); 684 this.callv(_GODOT_method_name, _GODOT_args); 685 } 686 /** 687 Queue save the project's editor layout. 688 */ 689 void queueSaveLayout() const 690 { 691 checkClassBinding!(typeof(this))(); 692 ptrcall!(void)(GDNativeClassBinding.queueSaveLayout, _godot_object); 693 } 694 /** 695 Removes an Autoload `name` from the list. 696 */ 697 void removeAutoloadSingleton(in String name) 698 { 699 checkClassBinding!(typeof(this))(); 700 ptrcall!(void)(GDNativeClassBinding.removeAutoloadSingleton, _godot_object, name); 701 } 702 /** 703 Removes the control from the bottom panel. You have to manually $(D Node.queueFree) the control. 704 */ 705 void removeControlFromBottomPanel(Control control) 706 { 707 checkClassBinding!(typeof(this))(); 708 ptrcall!(void)(GDNativeClassBinding.removeControlFromBottomPanel, _godot_object, control); 709 } 710 /** 711 Removes the control from the specified container. You have to manually $(D Node.queueFree) the control. 712 */ 713 void removeControlFromContainer(in long container, Control control) 714 { 715 checkClassBinding!(typeof(this))(); 716 ptrcall!(void)(GDNativeClassBinding.removeControlFromContainer, _godot_object, container, control); 717 } 718 /** 719 Removes the control from the dock. You have to manually $(D Node.queueFree) the control. 720 */ 721 void removeControlFromDocks(Control control) 722 { 723 checkClassBinding!(typeof(this))(); 724 ptrcall!(void)(GDNativeClassBinding.removeControlFromDocks, _godot_object, control); 725 } 726 /** 727 Removes a custom type added by $(D addCustomType). 728 */ 729 void removeCustomType(in String type) 730 { 731 checkClassBinding!(typeof(this))(); 732 ptrcall!(void)(GDNativeClassBinding.removeCustomType, _godot_object, type); 733 } 734 /** 735 Removes an export plugin registered by $(D addExportPlugin). 736 */ 737 void removeExportPlugin(EditorExportPlugin plugin) 738 { 739 checkClassBinding!(typeof(this))(); 740 ptrcall!(void)(GDNativeClassBinding.removeExportPlugin, _godot_object, plugin); 741 } 742 /** 743 Removes an import plugin registered by $(D addImportPlugin). 744 */ 745 void removeImportPlugin(EditorImportPlugin importer) 746 { 747 checkClassBinding!(typeof(this))(); 748 ptrcall!(void)(GDNativeClassBinding.removeImportPlugin, _godot_object, importer); 749 } 750 /** 751 Removes an inspector plugin registered by $(D addImportPlugin) 752 */ 753 void removeInspectorPlugin(EditorInspectorPlugin plugin) 754 { 755 checkClassBinding!(typeof(this))(); 756 ptrcall!(void)(GDNativeClassBinding.removeInspectorPlugin, _godot_object, plugin); 757 } 758 /** 759 Removes a scene importer registered by $(D addSceneImportPlugin). 760 */ 761 void removeSceneImportPlugin(EditorSceneImporter scene_importer) 762 { 763 checkClassBinding!(typeof(this))(); 764 ptrcall!(void)(GDNativeClassBinding.removeSceneImportPlugin, _godot_object, scene_importer); 765 } 766 /** 767 Removes a gizmo plugin registered by $(D addSpatialGizmoPlugin). 768 */ 769 void removeSpatialGizmoPlugin(EditorSpatialGizmoPlugin plugin) 770 { 771 checkClassBinding!(typeof(this))(); 772 ptrcall!(void)(GDNativeClassBinding.removeSpatialGizmoPlugin, _godot_object, plugin); 773 } 774 /** 775 Removes a menu `name` from $(B Project > Tools). 776 */ 777 void removeToolMenuItem(in String name) 778 { 779 checkClassBinding!(typeof(this))(); 780 ptrcall!(void)(GDNativeClassBinding.removeToolMenuItem, _godot_object, name); 781 } 782 /** 783 This method is called after the editor saves the project or when it's closed. It asks the plugin to save edited external scenes/resources. 784 */ 785 void saveExternalData() 786 { 787 Array _GODOT_args = Array.make(); 788 String _GODOT_method_name = String("save_external_data"); 789 this.callv(_GODOT_method_name, _GODOT_args); 790 } 791 /** 792 Enables calling of $(D forwardCanvasForceDrawOverViewport) for the 2D editor and $(D forwardSpatialForceDrawOverViewport) for the 3D editor when their viewports are updated. You need to call this method only once and it will work permanently for this plugin. 793 */ 794 void setForceDrawOverForwardingEnabled() 795 { 796 checkClassBinding!(typeof(this))(); 797 ptrcall!(void)(GDNativeClassBinding.setForceDrawOverForwardingEnabled, _godot_object); 798 } 799 /** 800 Use this method if you always want to receive inputs from 3D view screen inside $(D forwardSpatialGuiInput). It might be especially usable if your plugin will want to use raycast in the scene. 801 */ 802 void setInputEventForwardingAlwaysEnabled() 803 { 804 checkClassBinding!(typeof(this))(); 805 ptrcall!(void)(GDNativeClassBinding.setInputEventForwardingAlwaysEnabled, _godot_object); 806 } 807 /** 808 Restore the state saved by $(D getState). 809 */ 810 void setState(in Dictionary state) 811 { 812 Array _GODOT_args = Array.make(); 813 _GODOT_args.append(state); 814 String _GODOT_method_name = String("set_state"); 815 this.callv(_GODOT_method_name, _GODOT_args); 816 } 817 /** 818 Restore the plugin GUI layout saved by $(D getWindowLayout). 819 */ 820 void setWindowLayout(ConfigFile layout) 821 { 822 Array _GODOT_args = Array.make(); 823 _GODOT_args.append(layout); 824 String _GODOT_method_name = String("set_window_layout"); 825 this.callv(_GODOT_method_name, _GODOT_args); 826 } 827 /** 828 Updates the overlays of the 2D and 3D editor viewport. Causes methods $(D forwardCanvasDrawOverViewport), $(D forwardCanvasForceDrawOverViewport), $(D forwardSpatialDrawOverViewport) and $(D forwardSpatialForceDrawOverViewport) to be called. 829 */ 830 long updateOverlays() const 831 { 832 checkClassBinding!(typeof(this))(); 833 return ptrcall!(long)(GDNativeClassBinding.updateOverlays, _godot_object); 834 } 835 }