1 /**
2 A scripted Visual Script node.
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.visualscriptcustomnode;
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.classdb;
24 import godot.visualscriptnode;
25 /**
26 A scripted Visual Script node.
27 
28 A custom Visual Script node which can be scripted in powerful ways.
29 */
30 @GodotBaseClass struct VisualScriptCustomNode
31 {
32 	package(godot) enum string _GODOT_internal_name = "VisualScriptCustomNode";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ VisualScriptNode _GODOT_base; }
36 	alias _GODOT_base this;
37 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
38 	package(godot) __gshared bool _classBindingInitialized = false;
39 	package(godot) static struct GDNativeClassBinding
40 	{
41 		__gshared:
42 		@GodotName("_get_caption") GodotMethod!(String) _getCaption;
43 		@GodotName("_get_category") GodotMethod!(String) _getCategory;
44 		@GodotName("_get_input_value_port_count") GodotMethod!(long) _getInputValuePortCount;
45 		@GodotName("_get_input_value_port_name") GodotMethod!(String, long) _getInputValuePortName;
46 		@GodotName("_get_input_value_port_type") GodotMethod!(long, long) _getInputValuePortType;
47 		@GodotName("_get_output_sequence_port_count") GodotMethod!(long) _getOutputSequencePortCount;
48 		@GodotName("_get_output_sequence_port_text") GodotMethod!(String, long) _getOutputSequencePortText;
49 		@GodotName("_get_output_value_port_count") GodotMethod!(long) _getOutputValuePortCount;
50 		@GodotName("_get_output_value_port_name") GodotMethod!(String, long) _getOutputValuePortName;
51 		@GodotName("_get_output_value_port_type") GodotMethod!(long, long) _getOutputValuePortType;
52 		@GodotName("_get_text") GodotMethod!(String) _getText;
53 		@GodotName("_get_working_memory_size") GodotMethod!(long) _getWorkingMemorySize;
54 		@GodotName("_has_input_sequence_port") GodotMethod!(bool) _hasInputSequencePort;
55 		@GodotName("_script_changed") GodotMethod!(void) _scriptChanged;
56 		@GodotName("_step") GodotMethod!(Variant, Array, Array, long, Array) _step;
57 	}
58 	/// 
59 	pragma(inline, true) bool opEquals(in VisualScriptCustomNode other) const
60 	{ return _godot_object.ptr is other._godot_object.ptr; }
61 	/// 
62 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
63 	{ _godot_object.ptr = n; return null; }
64 	/// 
65 	pragma(inline, true) bool opEquals(typeof(null) n) const
66 	{ return _godot_object.ptr is n; }
67 	/// 
68 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
69 	mixin baseCasts;
70 	/// Construct a new instance of VisualScriptCustomNode.
71 	/// Note: use `memnew!VisualScriptCustomNode` instead.
72 	static VisualScriptCustomNode _new()
73 	{
74 		static godot_class_constructor constructor;
75 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualScriptCustomNode");
76 		if(constructor is null) return typeof(this).init;
77 		return cast(VisualScriptCustomNode)(constructor());
78 	}
79 	@disable new(size_t s);
80 	/// 
81 	enum StartMode : int
82 	{
83 		/**
84 		The start mode used the first time when $(D _step) is called.
85 		*/
86 		startModeBeginSequence = 0,
87 		/**
88 		The start mode used when $(D _step) is called after coming back from a $(D constant STEP_PUSH_STACK_BIT).
89 		*/
90 		startModeContinueSequence = 1,
91 		/**
92 		The start mode used when $(D _step) is called after resuming from $(D constant STEP_YIELD_BIT).
93 		*/
94 		startModeResumeYield = 2,
95 	}
96 	/// 
97 	enum Constants : int
98 	{
99 		startModeBeginSequence = 0,
100 		startModeContinueSequence = 1,
101 		startModeResumeYield = 2,
102 		/**
103 		Hint used by $(D _step) to tell that control should return to it when there is no other node left to execute.
104 		This is used by $(D VisualScriptCondition) to redirect the sequence to the "Done" port after the `true`/`false` branch has finished execution.
105 		*/
106 		stepPushStackBit = 16777216,
107 		/**
108 		Hint used by $(D _step) to tell that control should return back, either hitting a previous $(D constant STEP_PUSH_STACK_BIT) or exiting the function.
109 		*/
110 		stepGoBackBit = 33554432,
111 		/**
112 		
113 		*/
114 		stepNoAdvanceBit = 67108864,
115 		/**
116 		Hint used by $(D _step) to tell that control should stop and exit the function.
117 		*/
118 		stepExitFunctionBit = 134217728,
119 		/**
120 		Hint used by $(D _step) to tell that the function should be yielded.
121 		Using this requires you to have at least one working memory slot, which is used for the $(D VisualScriptFunctionState).
122 		*/
123 		stepYieldBit = 268435456,
124 	}
125 	/**
126 	Return the node's title.
127 	*/
128 	String _getCaption()
129 	{
130 		Array _GODOT_args = Array.make();
131 		String _GODOT_method_name = String("_get_caption");
132 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
133 	}
134 	/**
135 	Return the node's category.
136 	*/
137 	String _getCategory()
138 	{
139 		Array _GODOT_args = Array.make();
140 		String _GODOT_method_name = String("_get_category");
141 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
142 	}
143 	/**
144 	Return the count of input value ports.
145 	*/
146 	long _getInputValuePortCount()
147 	{
148 		Array _GODOT_args = Array.make();
149 		String _GODOT_method_name = String("_get_input_value_port_count");
150 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
151 	}
152 	/**
153 	Return the specified input port's name.
154 	*/
155 	String _getInputValuePortName(in long idx)
156 	{
157 		Array _GODOT_args = Array.make();
158 		_GODOT_args.append(idx);
159 		String _GODOT_method_name = String("_get_input_value_port_name");
160 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
161 	}
162 	/**
163 	Return the specified input port's type. See the $(D Variant.type) values.
164 	*/
165 	long _getInputValuePortType(in long idx)
166 	{
167 		Array _GODOT_args = Array.make();
168 		_GODOT_args.append(idx);
169 		String _GODOT_method_name = String("_get_input_value_port_type");
170 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
171 	}
172 	/**
173 	Return the amount of output $(B sequence) ports.
174 	*/
175 	long _getOutputSequencePortCount()
176 	{
177 		Array _GODOT_args = Array.make();
178 		String _GODOT_method_name = String("_get_output_sequence_port_count");
179 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
180 	}
181 	/**
182 	Return the specified $(B sequence) output's name.
183 	*/
184 	String _getOutputSequencePortText(in long idx)
185 	{
186 		Array _GODOT_args = Array.make();
187 		_GODOT_args.append(idx);
188 		String _GODOT_method_name = String("_get_output_sequence_port_text");
189 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
190 	}
191 	/**
192 	Return the amount of output value ports.
193 	*/
194 	long _getOutputValuePortCount()
195 	{
196 		Array _GODOT_args = Array.make();
197 		String _GODOT_method_name = String("_get_output_value_port_count");
198 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
199 	}
200 	/**
201 	Return the specified output's name.
202 	*/
203 	String _getOutputValuePortName(in long idx)
204 	{
205 		Array _GODOT_args = Array.make();
206 		_GODOT_args.append(idx);
207 		String _GODOT_method_name = String("_get_output_value_port_name");
208 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
209 	}
210 	/**
211 	Return the specified output's type. See the $(D Variant.type) values.
212 	*/
213 	long _getOutputValuePortType(in long idx)
214 	{
215 		Array _GODOT_args = Array.make();
216 		_GODOT_args.append(idx);
217 		String _GODOT_method_name = String("_get_output_value_port_type");
218 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
219 	}
220 	/**
221 	Return the custom node's text, which is shown right next to the input $(B sequence) port (if there is none, on the place that is usually taken by it).
222 	*/
223 	String _getText()
224 	{
225 		Array _GODOT_args = Array.make();
226 		String _GODOT_method_name = String("_get_text");
227 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!String);
228 	}
229 	/**
230 	Return the size of the custom node's working memory. See $(D _step) for more details.
231 	*/
232 	long _getWorkingMemorySize()
233 	{
234 		Array _GODOT_args = Array.make();
235 		String _GODOT_method_name = String("_get_working_memory_size");
236 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!long);
237 	}
238 	/**
239 	Return whether the custom node has an input $(B sequence) port.
240 	*/
241 	bool _hasInputSequencePort()
242 	{
243 		Array _GODOT_args = Array.make();
244 		String _GODOT_method_name = String("_has_input_sequence_port");
245 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!bool);
246 	}
247 	/**
248 	
249 	*/
250 	void _scriptChanged()
251 	{
252 		Array _GODOT_args = Array.make();
253 		String _GODOT_method_name = String("_script_changed");
254 		this.callv(_GODOT_method_name, _GODOT_args);
255 	}
256 	/**
257 	Execute the custom node's logic, returning the index of the output sequence port to use or a $(D String) when there is an error.
258 	The `inputs` array contains the values of the input ports.
259 	`outputs` is an array whose indices should be set to the respective outputs.
260 	The `start_mode` is usually $(D constant START_MODE_BEGIN_SEQUENCE), unless you have used the `STEP_*` constants.
261 	`working_mem` is an array which can be used to persist information between runs of the custom node.
262 	When returning, you can mask the returned value with one of the `STEP_*` constants.
263 	*/
264 	Variant _step(in Array inputs, in Array outputs, in long start_mode, in Array working_mem)
265 	{
266 		Array _GODOT_args = Array.make();
267 		_GODOT_args.append(inputs);
268 		_GODOT_args.append(outputs);
269 		_GODOT_args.append(start_mode);
270 		_GODOT_args.append(working_mem);
271 		String _GODOT_method_name = String("_step");
272 		return this.callv(_GODOT_method_name, _GODOT_args);
273 	}
274 }