1 /** 2 Godot editor's interface. 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.editorinterface; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.node; 23 import godot.editorselection; 24 import godot.editorsettings; 25 import godot.scripteditor; 26 import godot.control; 27 import godot.resource; 28 import godot.editorresourcepreview; 29 import godot.editorfilesystem; 30 /** 31 Godot editor's interface. 32 33 EditorInterface gives you control over Godot editor's window. It allows customizing the window, saving and (re-)loading scenes, rendering mesh previews, inspecting and editing resources and objects, and provides access to $(D EditorSettings), $(D EditorFileSystem), $(D EditorResourcePreview), $(D ScriptEditor), the editor viewport, and information about scenes. 34 */ 35 @GodotBaseClass struct EditorInterface 36 { 37 enum string _GODOT_internal_name = "EditorInterface"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; Node _GODOT_base; } 41 alias _GODOT_base this; 42 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 43 package(godot) __gshared bool _classBindingInitialized = false; 44 package(godot) static struct _classBinding 45 { 46 __gshared: 47 @GodotName("inspect_object") GodotMethod!(void, GodotObject, String) inspectObject; 48 @GodotName("get_selection") GodotMethod!(EditorSelection) getSelection; 49 @GodotName("get_editor_settings") GodotMethod!(EditorSettings) getEditorSettings; 50 @GodotName("get_script_editor") GodotMethod!(ScriptEditor) getScriptEditor; 51 @GodotName("get_base_control") GodotMethod!(Control) getBaseControl; 52 @GodotName("edit_resource") GodotMethod!(void, Resource) editResource; 53 @GodotName("open_scene_from_path") GodotMethod!(void, String) openSceneFromPath; 54 @GodotName("reload_scene_from_path") GodotMethod!(void, String) reloadSceneFromPath; 55 @GodotName("get_open_scenes") GodotMethod!(Array) getOpenScenes; 56 @GodotName("get_edited_scene_root") GodotMethod!(Node) getEditedSceneRoot; 57 @GodotName("get_resource_previewer") GodotMethod!(EditorResourcePreview) getResourcePreviewer; 58 @GodotName("get_resource_filesystem") GodotMethod!(EditorFileSystem) getResourceFilesystem; 59 @GodotName("get_editor_viewport") GodotMethod!(Control) getEditorViewport; 60 @GodotName("make_mesh_previews") GodotMethod!(Array, Array, long) makeMeshPreviews; 61 @GodotName("select_file") GodotMethod!(void, String) selectFile; 62 @GodotName("get_selected_path") GodotMethod!(String) getSelectedPath; 63 @GodotName("set_plugin_enabled") GodotMethod!(void, String, bool) setPluginEnabled; 64 @GodotName("is_plugin_enabled") GodotMethod!(bool, String) isPluginEnabled; 65 @GodotName("save_scene") GodotMethod!(GodotError) saveScene; 66 @GodotName("save_scene_as") GodotMethod!(void, String, bool) saveSceneAs; 67 } 68 bool opEquals(in EditorInterface other) const { return _godot_object.ptr is other._godot_object.ptr; } 69 EditorInterface opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 70 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 71 mixin baseCasts; 72 static EditorInterface _new() 73 { 74 static godot_class_constructor constructor; 75 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("EditorInterface"); 76 if(constructor is null) return typeof(this).init; 77 return cast(EditorInterface)(constructor()); 78 } 79 @disable new(size_t s); 80 /** 81 Shows the given property on the given `object` in the Editor's Inspector dock. 82 */ 83 void inspectObject(StringArg1)(GodotObject object, in StringArg1 for_property = "") 84 { 85 checkClassBinding!(typeof(this))(); 86 ptrcall!(void)(_classBinding.inspectObject, _godot_object, object, for_property); 87 } 88 /** 89 Returns the $(D EditorSelection). 90 */ 91 EditorSelection getSelection() 92 { 93 checkClassBinding!(typeof(this))(); 94 return ptrcall!(EditorSelection)(_classBinding.getSelection, _godot_object); 95 } 96 /** 97 Returns the $(D EditorSettings). 98 */ 99 Ref!EditorSettings getEditorSettings() 100 { 101 checkClassBinding!(typeof(this))(); 102 return ptrcall!(EditorSettings)(_classBinding.getEditorSettings, _godot_object); 103 } 104 /** 105 Returns the $(D ScriptEditor). 106 */ 107 ScriptEditor getScriptEditor() 108 { 109 checkClassBinding!(typeof(this))(); 110 return ptrcall!(ScriptEditor)(_classBinding.getScriptEditor, _godot_object); 111 } 112 /** 113 Returns the main container of Godot editor's window. You can use it, for example, to retrieve the size of the container and place your controls accordingly. 114 */ 115 Control getBaseControl() 116 { 117 checkClassBinding!(typeof(this))(); 118 return ptrcall!(Control)(_classBinding.getBaseControl, _godot_object); 119 } 120 /** 121 Edits the given $(D Resource). 122 */ 123 void editResource(Resource resource) 124 { 125 checkClassBinding!(typeof(this))(); 126 ptrcall!(void)(_classBinding.editResource, _godot_object, resource); 127 } 128 /** 129 Opens the scene at the given path. 130 */ 131 void openSceneFromPath(StringArg0)(in StringArg0 scene_filepath) 132 { 133 checkClassBinding!(typeof(this))(); 134 ptrcall!(void)(_classBinding.openSceneFromPath, _godot_object, scene_filepath); 135 } 136 /** 137 Reloads the scene at the given path. 138 */ 139 void reloadSceneFromPath(StringArg0)(in StringArg0 scene_filepath) 140 { 141 checkClassBinding!(typeof(this))(); 142 ptrcall!(void)(_classBinding.reloadSceneFromPath, _godot_object, scene_filepath); 143 } 144 /** 145 Returns an $(D Array) with the file paths of the currently opened scenes. 146 */ 147 Array getOpenScenes() const 148 { 149 checkClassBinding!(typeof(this))(); 150 return ptrcall!(Array)(_classBinding.getOpenScenes, _godot_object); 151 } 152 /** 153 Returns the edited (current) scene's root $(D Node). 154 */ 155 Node getEditedSceneRoot() 156 { 157 checkClassBinding!(typeof(this))(); 158 return ptrcall!(Node)(_classBinding.getEditedSceneRoot, _godot_object); 159 } 160 /** 161 Returns the $(D EditorResourcePreview). 162 */ 163 EditorResourcePreview getResourcePreviewer() 164 { 165 checkClassBinding!(typeof(this))(); 166 return ptrcall!(EditorResourcePreview)(_classBinding.getResourcePreviewer, _godot_object); 167 } 168 /** 169 Returns the $(D EditorFileSystem). 170 */ 171 EditorFileSystem getResourceFilesystem() 172 { 173 checkClassBinding!(typeof(this))(); 174 return ptrcall!(EditorFileSystem)(_classBinding.getResourceFilesystem, _godot_object); 175 } 176 /** 177 Returns the editor $(D Viewport). 178 */ 179 Control getEditorViewport() 180 { 181 checkClassBinding!(typeof(this))(); 182 return ptrcall!(Control)(_classBinding.getEditorViewport, _godot_object); 183 } 184 /** 185 Returns mesh previews rendered at the given size as an $(D Array) of $(D Texture)s. 186 */ 187 Array makeMeshPreviews(in Array meshes, in long preview_size) 188 { 189 checkClassBinding!(typeof(this))(); 190 return ptrcall!(Array)(_classBinding.makeMeshPreviews, _godot_object, meshes, preview_size); 191 } 192 /** 193 194 */ 195 void selectFile(StringArg0)(in StringArg0 p_file) 196 { 197 checkClassBinding!(typeof(this))(); 198 ptrcall!(void)(_classBinding.selectFile, _godot_object, p_file); 199 } 200 /** 201 202 */ 203 String getSelectedPath() const 204 { 205 checkClassBinding!(typeof(this))(); 206 return ptrcall!(String)(_classBinding.getSelectedPath, _godot_object); 207 } 208 /** 209 Sets the enabled status of a plugin. The plugin name is the same as its directory name. 210 */ 211 void setPluginEnabled(StringArg0)(in StringArg0 plugin, in bool enabled) 212 { 213 checkClassBinding!(typeof(this))(); 214 ptrcall!(void)(_classBinding.setPluginEnabled, _godot_object, plugin, enabled); 215 } 216 /** 217 Returns the enabled status of a plugin. The plugin name is the same as its directory name. 218 */ 219 bool isPluginEnabled(StringArg0)(in StringArg0 plugin) const 220 { 221 checkClassBinding!(typeof(this))(); 222 return ptrcall!(bool)(_classBinding.isPluginEnabled, _godot_object, plugin); 223 } 224 /** 225 Saves the scene. Returns either OK or ERR_CANT_CREATE. See $(D @GlobalScope) constants. 226 */ 227 GodotError saveScene() 228 { 229 checkClassBinding!(typeof(this))(); 230 return ptrcall!(GodotError)(_classBinding.saveScene, _godot_object); 231 } 232 /** 233 Saves the scene as a file at `path`. 234 */ 235 void saveSceneAs(StringArg0)(in StringArg0 path, in bool with_preview = true) 236 { 237 checkClassBinding!(typeof(this))(); 238 ptrcall!(void)(_classBinding.saveSceneAs, _godot_object, path, with_preview); 239 } 240 }