1 /** 2 A script implemented in the Visual Script programming environment. 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.visualscript; 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.classdb; 23 import godot.script; 24 import godot.visualscriptnode; 25 import godot.resource; 26 import godot.reference; 27 /** 28 A script implemented in the Visual Script programming environment. 29 30 A script implemented in the Visual Script programming environment. The script extends the functionality of all objects that instance it. 31 $(D GodotObject.setScript) extends an existing object, if that object's class matches one of the script's base classes. 32 You are most likely to use this class via the Visual Script editor or when writing plugins for it. 33 */ 34 @GodotBaseClass struct VisualScript 35 { 36 enum string _GODOT_internal_name = "VisualScript"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; Script _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct _classBinding 44 { 45 __gshared: 46 @GodotName("_node_ports_changed") GodotMethod!(void, long) _nodePortsChanged; 47 @GodotName("add_function") GodotMethod!(void, String) addFunction; 48 @GodotName("has_function") GodotMethod!(bool, String) hasFunction; 49 @GodotName("remove_function") GodotMethod!(void, String) removeFunction; 50 @GodotName("rename_function") GodotMethod!(void, String, String) renameFunction; 51 @GodotName("set_function_scroll") GodotMethod!(void, String, Vector2) setFunctionScroll; 52 @GodotName("get_function_scroll") GodotMethod!(Vector2, String) getFunctionScroll; 53 @GodotName("add_node") GodotMethod!(void, String, long, VisualScriptNode, Vector2) addNode; 54 @GodotName("remove_node") GodotMethod!(void, String, long) removeNode; 55 @GodotName("get_function_node_id") GodotMethod!(long, String) getFunctionNodeId; 56 @GodotName("get_node") GodotMethod!(VisualScriptNode, String, long) getNode; 57 @GodotName("has_node") GodotMethod!(bool, String, long) hasNode; 58 @GodotName("set_node_position") GodotMethod!(void, String, long, Vector2) setNodePosition; 59 @GodotName("get_node_position") GodotMethod!(Vector2, String, long) getNodePosition; 60 @GodotName("sequence_connect") GodotMethod!(void, String, long, long, long) sequenceConnect; 61 @GodotName("sequence_disconnect") GodotMethod!(void, String, long, long, long) sequenceDisconnect; 62 @GodotName("has_sequence_connection") GodotMethod!(bool, String, long, long, long) hasSequenceConnection; 63 @GodotName("data_connect") GodotMethod!(void, String, long, long, long, long) dataConnect; 64 @GodotName("data_disconnect") GodotMethod!(void, String, long, long, long, long) dataDisconnect; 65 @GodotName("has_data_connection") GodotMethod!(bool, String, long, long, long, long) hasDataConnection; 66 @GodotName("add_variable") GodotMethod!(void, String, Variant, bool) addVariable; 67 @GodotName("has_variable") GodotMethod!(bool, String) hasVariable; 68 @GodotName("remove_variable") GodotMethod!(void, String) removeVariable; 69 @GodotName("set_variable_default_value") GodotMethod!(void, String, Variant) setVariableDefaultValue; 70 @GodotName("get_variable_default_value") GodotMethod!(Variant, String) getVariableDefaultValue; 71 @GodotName("set_variable_info") GodotMethod!(void, String, Dictionary) setVariableInfo; 72 @GodotName("get_variable_info") GodotMethod!(Dictionary, String) getVariableInfo; 73 @GodotName("set_variable_export") GodotMethod!(void, String, bool) setVariableExport; 74 @GodotName("get_variable_export") GodotMethod!(bool, String) getVariableExport; 75 @GodotName("rename_variable") GodotMethod!(void, String, String) renameVariable; 76 @GodotName("add_custom_signal") GodotMethod!(void, String) addCustomSignal; 77 @GodotName("has_custom_signal") GodotMethod!(bool, String) hasCustomSignal; 78 @GodotName("custom_signal_add_argument") GodotMethod!(void, String, long, String, long) customSignalAddArgument; 79 @GodotName("custom_signal_set_argument_type") GodotMethod!(void, String, long, long) customSignalSetArgumentType; 80 @GodotName("custom_signal_get_argument_type") GodotMethod!(Variant.Type, String, long) customSignalGetArgumentType; 81 @GodotName("custom_signal_set_argument_name") GodotMethod!(void, String, long, String) customSignalSetArgumentName; 82 @GodotName("custom_signal_get_argument_name") GodotMethod!(String, String, long) customSignalGetArgumentName; 83 @GodotName("custom_signal_remove_argument") GodotMethod!(void, String, long) customSignalRemoveArgument; 84 @GodotName("custom_signal_get_argument_count") GodotMethod!(long, String) customSignalGetArgumentCount; 85 @GodotName("custom_signal_swap_argument") GodotMethod!(void, String, long, long) customSignalSwapArgument; 86 @GodotName("remove_custom_signal") GodotMethod!(void, String) removeCustomSignal; 87 @GodotName("rename_custom_signal") GodotMethod!(void, String, String) renameCustomSignal; 88 @GodotName("set_instance_base_type") GodotMethod!(void, String) setInstanceBaseType; 89 @GodotName("_set_data") GodotMethod!(void, Dictionary) _setData; 90 @GodotName("_get_data") GodotMethod!(Dictionary) _getData; 91 } 92 bool opEquals(in VisualScript other) const { return _godot_object.ptr is other._godot_object.ptr; } 93 VisualScript opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 94 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 95 mixin baseCasts; 96 static VisualScript _new() 97 { 98 static godot_class_constructor constructor; 99 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisualScript"); 100 if(constructor is null) return typeof(this).init; 101 return cast(VisualScript)(constructor()); 102 } 103 @disable new(size_t s); 104 /** 105 106 */ 107 void _nodePortsChanged(in long arg0) 108 { 109 Array _GODOT_args = Array.empty_array; 110 _GODOT_args.append(arg0); 111 String _GODOT_method_name = String("_node_ports_changed"); 112 this.callv(_GODOT_method_name, _GODOT_args); 113 } 114 /** 115 Add a function with the specified name to the VisualScript. 116 */ 117 void addFunction(StringArg0)(in StringArg0 name) 118 { 119 checkClassBinding!(typeof(this))(); 120 ptrcall!(void)(_classBinding.addFunction, _godot_object, name); 121 } 122 /** 123 Returns whether a function exists with the specified name. 124 */ 125 bool hasFunction(StringArg0)(in StringArg0 name) const 126 { 127 checkClassBinding!(typeof(this))(); 128 return ptrcall!(bool)(_classBinding.hasFunction, _godot_object, name); 129 } 130 /** 131 Remove a specific function and its nodes from the script. 132 */ 133 void removeFunction(StringArg0)(in StringArg0 name) 134 { 135 checkClassBinding!(typeof(this))(); 136 ptrcall!(void)(_classBinding.removeFunction, _godot_object, name); 137 } 138 /** 139 Change the name of a function. 140 */ 141 void renameFunction(StringArg0, StringArg1)(in StringArg0 name, in StringArg1 new_name) 142 { 143 checkClassBinding!(typeof(this))(); 144 ptrcall!(void)(_classBinding.renameFunction, _godot_object, name, new_name); 145 } 146 /** 147 Position the center of the screen for a function. 148 */ 149 void setFunctionScroll(StringArg0)(in StringArg0 name, in Vector2 ofs) 150 { 151 checkClassBinding!(typeof(this))(); 152 ptrcall!(void)(_classBinding.setFunctionScroll, _godot_object, name, ofs); 153 } 154 /** 155 Returns the position of the center of the screen for a given function. 156 */ 157 Vector2 getFunctionScroll(StringArg0)(in StringArg0 name) const 158 { 159 checkClassBinding!(typeof(this))(); 160 return ptrcall!(Vector2)(_classBinding.getFunctionScroll, _godot_object, name); 161 } 162 /** 163 Add a node to a function of the VisualScript. 164 */ 165 void addNode(StringArg0)(in StringArg0 func, in long id, VisualScriptNode node, in Vector2 position = Vector2(0, 0)) 166 { 167 checkClassBinding!(typeof(this))(); 168 ptrcall!(void)(_classBinding.addNode, _godot_object, func, id, node, position); 169 } 170 /** 171 Remove a specific node. 172 */ 173 void removeNode(StringArg0)(in StringArg0 func, in long id) 174 { 175 checkClassBinding!(typeof(this))(); 176 ptrcall!(void)(_classBinding.removeNode, _godot_object, func, id); 177 } 178 /** 179 Returns the id of a function's entry point node. 180 */ 181 long getFunctionNodeId(StringArg0)(in StringArg0 name) const 182 { 183 checkClassBinding!(typeof(this))(); 184 return ptrcall!(long)(_classBinding.getFunctionNodeId, _godot_object, name); 185 } 186 /** 187 Returns a node given its id and its function. 188 */ 189 Ref!VisualScriptNode getNode(StringArg0)(in StringArg0 func, in long id) const 190 { 191 checkClassBinding!(typeof(this))(); 192 return ptrcall!(VisualScriptNode)(_classBinding.getNode, _godot_object, func, id); 193 } 194 /** 195 Returns whether a node exists with the given id. 196 */ 197 bool hasNode(StringArg0)(in StringArg0 func, in long id) const 198 { 199 checkClassBinding!(typeof(this))(); 200 return ptrcall!(bool)(_classBinding.hasNode, _godot_object, func, id); 201 } 202 /** 203 Position a node on the screen. 204 */ 205 void setNodePosition(StringArg0)(in StringArg0 func, in long id, in Vector2 position) 206 { 207 checkClassBinding!(typeof(this))(); 208 ptrcall!(void)(_classBinding.setNodePosition, _godot_object, func, id, position); 209 } 210 /** 211 Returns a node's position in pixels. 212 */ 213 Vector2 getNodePosition(StringArg0)(in StringArg0 func, in long id) const 214 { 215 checkClassBinding!(typeof(this))(); 216 return ptrcall!(Vector2)(_classBinding.getNodePosition, _godot_object, func, id); 217 } 218 /** 219 Connect two sequence ports. The execution will flow from of `from_node`'s `from_output` into `to_node`. 220 Unlike $(D dataConnect), there isn't a `to_port`, since the target node can have only one sequence port. 221 */ 222 void sequenceConnect(StringArg0)(in StringArg0 func, in long from_node, in long from_output, in long to_node) 223 { 224 checkClassBinding!(typeof(this))(); 225 ptrcall!(void)(_classBinding.sequenceConnect, _godot_object, func, from_node, from_output, to_node); 226 } 227 /** 228 Disconnect two sequence ports previously connected with $(D sequenceConnect). 229 */ 230 void sequenceDisconnect(StringArg0)(in StringArg0 func, in long from_node, in long from_output, in long to_node) 231 { 232 checkClassBinding!(typeof(this))(); 233 ptrcall!(void)(_classBinding.sequenceDisconnect, _godot_object, func, from_node, from_output, to_node); 234 } 235 /** 236 Returns whether the specified sequence ports are connected. 237 */ 238 bool hasSequenceConnection(StringArg0)(in StringArg0 func, in long from_node, in long from_output, in long to_node) const 239 { 240 checkClassBinding!(typeof(this))(); 241 return ptrcall!(bool)(_classBinding.hasSequenceConnection, _godot_object, func, from_node, from_output, to_node); 242 } 243 /** 244 Connect two data ports. The value of `from_node`'s `from_port` would be fed into `to_node`'s `to_port`. 245 */ 246 void dataConnect(StringArg0)(in StringArg0 func, in long from_node, in long from_port, in long to_node, in long to_port) 247 { 248 checkClassBinding!(typeof(this))(); 249 ptrcall!(void)(_classBinding.dataConnect, _godot_object, func, from_node, from_port, to_node, to_port); 250 } 251 /** 252 Disconnect two data ports previously connected with $(D dataConnect). 253 */ 254 void dataDisconnect(StringArg0)(in StringArg0 func, in long from_node, in long from_port, in long to_node, in long to_port) 255 { 256 checkClassBinding!(typeof(this))(); 257 ptrcall!(void)(_classBinding.dataDisconnect, _godot_object, func, from_node, from_port, to_node, to_port); 258 } 259 /** 260 Returns whether the specified data ports are connected. 261 */ 262 bool hasDataConnection(StringArg0)(in StringArg0 func, in long from_node, in long from_port, in long to_node, in long to_port) const 263 { 264 checkClassBinding!(typeof(this))(); 265 return ptrcall!(bool)(_classBinding.hasDataConnection, _godot_object, func, from_node, from_port, to_node, to_port); 266 } 267 /** 268 Add a variable to the VisualScript, optionally giving it a default value or marking it as exported. 269 */ 270 void addVariable(StringArg0, VariantArg1)(in StringArg0 name, in VariantArg1 default_value = Variant.nil, in bool _export = false) 271 { 272 checkClassBinding!(typeof(this))(); 273 ptrcall!(void)(_classBinding.addVariable, _godot_object, name, default_value, _export); 274 } 275 /** 276 Returns whether a variable exists with the specified name. 277 */ 278 bool hasVariable(StringArg0)(in StringArg0 name) const 279 { 280 checkClassBinding!(typeof(this))(); 281 return ptrcall!(bool)(_classBinding.hasVariable, _godot_object, name); 282 } 283 /** 284 Remove a variable with the given name. 285 */ 286 void removeVariable(StringArg0)(in StringArg0 name) 287 { 288 checkClassBinding!(typeof(this))(); 289 ptrcall!(void)(_classBinding.removeVariable, _godot_object, name); 290 } 291 /** 292 Change the default (initial) value of a variable. 293 */ 294 void setVariableDefaultValue(StringArg0, VariantArg1)(in StringArg0 name, in VariantArg1 value) 295 { 296 checkClassBinding!(typeof(this))(); 297 ptrcall!(void)(_classBinding.setVariableDefaultValue, _godot_object, name, value); 298 } 299 /** 300 Returns the default (initial) value of a variable. 301 */ 302 Variant getVariableDefaultValue(StringArg0)(in StringArg0 name) const 303 { 304 checkClassBinding!(typeof(this))(); 305 return ptrcall!(Variant)(_classBinding.getVariableDefaultValue, _godot_object, name); 306 } 307 /** 308 Set a variable's info, using the same format as $(D getVariableInfo). 309 */ 310 void setVariableInfo(StringArg0)(in StringArg0 name, in Dictionary value) 311 { 312 checkClassBinding!(typeof(this))(); 313 ptrcall!(void)(_classBinding.setVariableInfo, _godot_object, name, value); 314 } 315 /** 316 Returns the info for a given variable as a dictionary. The information includes its name, type, hint and usage. 317 */ 318 Dictionary getVariableInfo(StringArg0)(in StringArg0 name) const 319 { 320 checkClassBinding!(typeof(this))(); 321 return ptrcall!(Dictionary)(_classBinding.getVariableInfo, _godot_object, name); 322 } 323 /** 324 Change whether a variable is exported. 325 */ 326 void setVariableExport(StringArg0)(in StringArg0 name, in bool enable) 327 { 328 checkClassBinding!(typeof(this))(); 329 ptrcall!(void)(_classBinding.setVariableExport, _godot_object, name, enable); 330 } 331 /** 332 Returns whether a variable is exported. 333 */ 334 bool getVariableExport(StringArg0)(in StringArg0 name) const 335 { 336 checkClassBinding!(typeof(this))(); 337 return ptrcall!(bool)(_classBinding.getVariableExport, _godot_object, name); 338 } 339 /** 340 Change the name of a variable. 341 */ 342 void renameVariable(StringArg0, StringArg1)(in StringArg0 name, in StringArg1 new_name) 343 { 344 checkClassBinding!(typeof(this))(); 345 ptrcall!(void)(_classBinding.renameVariable, _godot_object, name, new_name); 346 } 347 /** 348 Add a custom signal with the specified name to the VisualScript. 349 */ 350 void addCustomSignal(StringArg0)(in StringArg0 name) 351 { 352 checkClassBinding!(typeof(this))(); 353 ptrcall!(void)(_classBinding.addCustomSignal, _godot_object, name); 354 } 355 /** 356 Returns whether a signal exists with the specified name. 357 */ 358 bool hasCustomSignal(StringArg0)(in StringArg0 name) const 359 { 360 checkClassBinding!(typeof(this))(); 361 return ptrcall!(bool)(_classBinding.hasCustomSignal, _godot_object, name); 362 } 363 /** 364 Add an argument to a custom signal added with $(D addCustomSignal). 365 */ 366 void customSignalAddArgument(StringArg0, StringArg2)(in StringArg0 name, in long type, in StringArg2 argname, in long index = -1) 367 { 368 checkClassBinding!(typeof(this))(); 369 ptrcall!(void)(_classBinding.customSignalAddArgument, _godot_object, name, type, argname, index); 370 } 371 /** 372 Change the type of a custom signal's argument. 373 */ 374 void customSignalSetArgumentType(StringArg0)(in StringArg0 name, in long argidx, in long type) 375 { 376 checkClassBinding!(typeof(this))(); 377 ptrcall!(void)(_classBinding.customSignalSetArgumentType, _godot_object, name, argidx, type); 378 } 379 /** 380 Get the type of a custom signal's argument. 381 */ 382 Variant.Type customSignalGetArgumentType(StringArg0)(in StringArg0 name, in long argidx) const 383 { 384 checkClassBinding!(typeof(this))(); 385 return ptrcall!(Variant.Type)(_classBinding.customSignalGetArgumentType, _godot_object, name, argidx); 386 } 387 /** 388 Rename a custom signal's argument. 389 */ 390 void customSignalSetArgumentName(StringArg0, StringArg2)(in StringArg0 name, in long argidx, in StringArg2 argname) 391 { 392 checkClassBinding!(typeof(this))(); 393 ptrcall!(void)(_classBinding.customSignalSetArgumentName, _godot_object, name, argidx, argname); 394 } 395 /** 396 Get the name of a custom signal's argument. 397 */ 398 String customSignalGetArgumentName(StringArg0)(in StringArg0 name, in long argidx) const 399 { 400 checkClassBinding!(typeof(this))(); 401 return ptrcall!(String)(_classBinding.customSignalGetArgumentName, _godot_object, name, argidx); 402 } 403 /** 404 Remove a specific custom signal's argument. 405 */ 406 void customSignalRemoveArgument(StringArg0)(in StringArg0 name, in long argidx) 407 { 408 checkClassBinding!(typeof(this))(); 409 ptrcall!(void)(_classBinding.customSignalRemoveArgument, _godot_object, name, argidx); 410 } 411 /** 412 Get the count of a custom signal's arguments. 413 */ 414 long customSignalGetArgumentCount(StringArg0)(in StringArg0 name) const 415 { 416 checkClassBinding!(typeof(this))(); 417 return ptrcall!(long)(_classBinding.customSignalGetArgumentCount, _godot_object, name); 418 } 419 /** 420 Swap two of the arguments of a custom signal. 421 */ 422 void customSignalSwapArgument(StringArg0)(in StringArg0 name, in long argidx, in long withidx) 423 { 424 checkClassBinding!(typeof(this))(); 425 ptrcall!(void)(_classBinding.customSignalSwapArgument, _godot_object, name, argidx, withidx); 426 } 427 /** 428 Remove a custom signal with the given name. 429 */ 430 void removeCustomSignal(StringArg0)(in StringArg0 name) 431 { 432 checkClassBinding!(typeof(this))(); 433 ptrcall!(void)(_classBinding.removeCustomSignal, _godot_object, name); 434 } 435 /** 436 Change the name of a custom signal. 437 */ 438 void renameCustomSignal(StringArg0, StringArg1)(in StringArg0 name, in StringArg1 new_name) 439 { 440 checkClassBinding!(typeof(this))(); 441 ptrcall!(void)(_classBinding.renameCustomSignal, _godot_object, name, new_name); 442 } 443 /** 444 Set the base type of the script. 445 */ 446 void setInstanceBaseType(StringArg0)(in StringArg0 type) 447 { 448 checkClassBinding!(typeof(this))(); 449 ptrcall!(void)(_classBinding.setInstanceBaseType, _godot_object, type); 450 } 451 /** 452 453 */ 454 void _setData(in Dictionary data) 455 { 456 Array _GODOT_args = Array.empty_array; 457 _GODOT_args.append(data); 458 String _GODOT_method_name = String("_set_data"); 459 this.callv(_GODOT_method_name, _GODOT_args); 460 } 461 /** 462 463 */ 464 Dictionary _getData() const 465 { 466 Array _GODOT_args = Array.empty_array; 467 String _GODOT_method_name = String("_get_data"); 468 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Dictionary); 469 } 470 /** 471 472 */ 473 @property Dictionary data() 474 { 475 return _getData(); 476 } 477 /// ditto 478 @property void data(Dictionary v) 479 { 480 _setData(v); 481 } 482 }