1 /** 2 A script interface to a scene file's data. 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.scenestate; 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.reference; 24 import godot.packedscene; 25 /** 26 A script interface to a scene file's data. 27 28 Maintains a list of resources, nodes, exported, and overridden properties, and built-in scripts associated with a scene. 29 This class cannot be instantiated directly, it is retrieved for a given scene as the result of $(D PackedScene.getState). 30 */ 31 @GodotBaseClass struct SceneState 32 { 33 package(godot) enum string _GODOT_internal_name = "SceneState"; 34 public: 35 @nogc nothrow: 36 union { /** */ godot_object _godot_object; /** */ Reference _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct GDNativeClassBinding 41 { 42 __gshared: 43 @GodotName("get_connection_binds") GodotMethod!(Array, long) getConnectionBinds; 44 @GodotName("get_connection_count") GodotMethod!(long) getConnectionCount; 45 @GodotName("get_connection_flags") GodotMethod!(long, long) getConnectionFlags; 46 @GodotName("get_connection_method") GodotMethod!(String, long) getConnectionMethod; 47 @GodotName("get_connection_signal") GodotMethod!(String, long) getConnectionSignal; 48 @GodotName("get_connection_source") GodotMethod!(NodePath, long) getConnectionSource; 49 @GodotName("get_connection_target") GodotMethod!(NodePath, long) getConnectionTarget; 50 @GodotName("get_node_count") GodotMethod!(long) getNodeCount; 51 @GodotName("get_node_groups") GodotMethod!(PoolStringArray, long) getNodeGroups; 52 @GodotName("get_node_index") GodotMethod!(long, long) getNodeIndex; 53 @GodotName("get_node_instance") GodotMethod!(PackedScene, long) getNodeInstance; 54 @GodotName("get_node_instance_placeholder") GodotMethod!(String, long) getNodeInstancePlaceholder; 55 @GodotName("get_node_name") GodotMethod!(String, long) getNodeName; 56 @GodotName("get_node_owner_path") GodotMethod!(NodePath, long) getNodeOwnerPath; 57 @GodotName("get_node_path") GodotMethod!(NodePath, long, bool) getNodePath; 58 @GodotName("get_node_property_count") GodotMethod!(long, long) getNodePropertyCount; 59 @GodotName("get_node_property_name") GodotMethod!(String, long, long) getNodePropertyName; 60 @GodotName("get_node_property_value") GodotMethod!(Variant, long, long) getNodePropertyValue; 61 @GodotName("get_node_type") GodotMethod!(String, long) getNodeType; 62 @GodotName("is_node_instance_placeholder") GodotMethod!(bool, long) isNodeInstancePlaceholder; 63 } 64 /// 65 pragma(inline, true) bool opEquals(in SceneState other) const 66 { return _godot_object.ptr is other._godot_object.ptr; } 67 /// 68 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 69 { _godot_object.ptr = n; return null; } 70 /// 71 pragma(inline, true) bool opEquals(typeof(null) n) const 72 { return _godot_object.ptr is n; } 73 /// 74 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 75 mixin baseCasts; 76 /// Construct a new instance of SceneState. 77 /// Note: use `memnew!SceneState` instead. 78 static SceneState _new() 79 { 80 static godot_class_constructor constructor; 81 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("SceneState"); 82 if(constructor is null) return typeof(this).init; 83 return cast(SceneState)(constructor()); 84 } 85 @disable new(size_t s); 86 /// 87 enum GenEditState : int 88 { 89 /** 90 If passed to $(D PackedScene.instance), blocks edits to the scene state. 91 */ 92 genEditStateDisabled = 0, 93 /** 94 If passed to $(D PackedScene.instance), provides inherited scene resources to the local scene. 95 $(B Note:) Only available in editor builds. 96 */ 97 genEditStateInstance = 1, 98 /** 99 If passed to $(D PackedScene.instance), provides local scene resources to the local scene. Only the main scene should receive the main edit state. 100 $(B Note:) Only available in editor builds. 101 */ 102 genEditStateMain = 2, 103 } 104 /// 105 enum Constants : int 106 { 107 genEditStateDisabled = 0, 108 genEditStateInstance = 1, 109 genEditStateMain = 2, 110 } 111 /** 112 Returns the list of bound parameters for the signal at `idx`. 113 */ 114 Array getConnectionBinds(in long idx) const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(Array)(GDNativeClassBinding.getConnectionBinds, _godot_object, idx); 118 } 119 /** 120 Returns the number of signal connections in the scene. 121 The `idx` argument used to query connection metadata in other `get_connection_*` methods in the interval `$(D 0, get_connection_count() - 1)`. 122 */ 123 long getConnectionCount() const 124 { 125 checkClassBinding!(typeof(this))(); 126 return ptrcall!(long)(GDNativeClassBinding.getConnectionCount, _godot_object); 127 } 128 /** 129 Returns the connection flags for the signal at `idx`. See $(D GodotObject.connectflags) constants. 130 */ 131 long getConnectionFlags(in long idx) const 132 { 133 checkClassBinding!(typeof(this))(); 134 return ptrcall!(long)(GDNativeClassBinding.getConnectionFlags, _godot_object, idx); 135 } 136 /** 137 Returns the method connected to the signal at `idx`. 138 */ 139 String getConnectionMethod(in long idx) const 140 { 141 checkClassBinding!(typeof(this))(); 142 return ptrcall!(String)(GDNativeClassBinding.getConnectionMethod, _godot_object, idx); 143 } 144 /** 145 Returns the name of the signal at `idx`. 146 */ 147 String getConnectionSignal(in long idx) const 148 { 149 checkClassBinding!(typeof(this))(); 150 return ptrcall!(String)(GDNativeClassBinding.getConnectionSignal, _godot_object, idx); 151 } 152 /** 153 Returns the path to the node that owns the signal at `idx`, relative to the root node. 154 */ 155 NodePath getConnectionSource(in long idx) const 156 { 157 checkClassBinding!(typeof(this))(); 158 return ptrcall!(NodePath)(GDNativeClassBinding.getConnectionSource, _godot_object, idx); 159 } 160 /** 161 Returns the path to the node that owns the method connected to the signal at `idx`, relative to the root node. 162 */ 163 NodePath getConnectionTarget(in long idx) const 164 { 165 checkClassBinding!(typeof(this))(); 166 return ptrcall!(NodePath)(GDNativeClassBinding.getConnectionTarget, _godot_object, idx); 167 } 168 /** 169 Returns the number of nodes in the scene. 170 The `idx` argument used to query node data in other `get_node_*` methods in the interval `$(D 0, get_node_count() - 1)`. 171 */ 172 long getNodeCount() const 173 { 174 checkClassBinding!(typeof(this))(); 175 return ptrcall!(long)(GDNativeClassBinding.getNodeCount, _godot_object); 176 } 177 /** 178 Returns the list of group names associated with the node at `idx`. 179 */ 180 PoolStringArray getNodeGroups(in long idx) const 181 { 182 checkClassBinding!(typeof(this))(); 183 return ptrcall!(PoolStringArray)(GDNativeClassBinding.getNodeGroups, _godot_object, idx); 184 } 185 /** 186 Returns the node's index, which is its position relative to its siblings. This is only relevant and saved in scenes for cases where new nodes are added to an instanced or inherited scene among siblings from the base scene. Despite the name, this index is not related to the `idx` argument used here and in other methods. 187 */ 188 long getNodeIndex(in long idx) const 189 { 190 checkClassBinding!(typeof(this))(); 191 return ptrcall!(long)(GDNativeClassBinding.getNodeIndex, _godot_object, idx); 192 } 193 /** 194 Returns a $(D PackedScene) for the node at `idx` (i.e. the whole branch starting at this node, with its child nodes and resources), or `null` if the node is not an instance. 195 */ 196 Ref!PackedScene getNodeInstance(in long idx) const 197 { 198 checkClassBinding!(typeof(this))(); 199 return ptrcall!(PackedScene)(GDNativeClassBinding.getNodeInstance, _godot_object, idx); 200 } 201 /** 202 Returns the path to the represented scene file if the node at `idx` is an $(D InstancePlaceholder). 203 */ 204 String getNodeInstancePlaceholder(in long idx) const 205 { 206 checkClassBinding!(typeof(this))(); 207 return ptrcall!(String)(GDNativeClassBinding.getNodeInstancePlaceholder, _godot_object, idx); 208 } 209 /** 210 Returns the name of the node at `idx`. 211 */ 212 String getNodeName(in long idx) const 213 { 214 checkClassBinding!(typeof(this))(); 215 return ptrcall!(String)(GDNativeClassBinding.getNodeName, _godot_object, idx); 216 } 217 /** 218 Returns the path to the owner of the node at `idx`, relative to the root node. 219 */ 220 NodePath getNodeOwnerPath(in long idx) const 221 { 222 checkClassBinding!(typeof(this))(); 223 return ptrcall!(NodePath)(GDNativeClassBinding.getNodeOwnerPath, _godot_object, idx); 224 } 225 /** 226 Returns the path to the node at `idx`. 227 If `for_parent` is `true`, returns the path of the `idx` node's parent instead. 228 */ 229 NodePath getNodePath(in long idx, in bool for_parent = false) const 230 { 231 checkClassBinding!(typeof(this))(); 232 return ptrcall!(NodePath)(GDNativeClassBinding.getNodePath, _godot_object, idx, for_parent); 233 } 234 /** 235 Returns the number of exported or overridden properties for the node at `idx`. 236 The `prop_idx` argument used to query node property data in other `get_node_property_*` methods in the interval `$(D 0, get_node_property_count() - 1)`. 237 */ 238 long getNodePropertyCount(in long idx) const 239 { 240 checkClassBinding!(typeof(this))(); 241 return ptrcall!(long)(GDNativeClassBinding.getNodePropertyCount, _godot_object, idx); 242 } 243 /** 244 Returns the name of the property at `prop_idx` for the node at `idx`. 245 */ 246 String getNodePropertyName(in long idx, in long prop_idx) const 247 { 248 checkClassBinding!(typeof(this))(); 249 return ptrcall!(String)(GDNativeClassBinding.getNodePropertyName, _godot_object, idx, prop_idx); 250 } 251 /** 252 Returns the value of the property at `prop_idx` for the node at `idx`. 253 */ 254 Variant getNodePropertyValue(in long idx, in long prop_idx) const 255 { 256 checkClassBinding!(typeof(this))(); 257 return ptrcall!(Variant)(GDNativeClassBinding.getNodePropertyValue, _godot_object, idx, prop_idx); 258 } 259 /** 260 Returns the type of the node at `idx`. 261 */ 262 String getNodeType(in long idx) const 263 { 264 checkClassBinding!(typeof(this))(); 265 return ptrcall!(String)(GDNativeClassBinding.getNodeType, _godot_object, idx); 266 } 267 /** 268 Returns `true` if the node at `idx` is an $(D InstancePlaceholder). 269 */ 270 bool isNodeInstancePlaceholder(in long idx) const 271 { 272 checkClassBinding!(typeof(this))(); 273 return ptrcall!(bool)(GDNativeClassBinding.isNodeInstancePlaceholder, _godot_object, idx); 274 } 275 }