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