1 /** 2 Resource Preloader 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.resourcepreloader; 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.node; 24 import godot.resource; 25 /** 26 Resource Preloader Node. 27 28 This node is used to preload sub-resources inside a scene, so when the scene is loaded all the resources are ready to use and be retrieved from here. 29 */ 30 @GodotBaseClass struct ResourcePreloader 31 { 32 enum string _GODOT_internal_name = "ResourcePreloader"; 33 public: 34 @nogc nothrow: 35 union { godot_object _godot_object; Node _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 _classBinding 40 { 41 __gshared: 42 @GodotName("_set_resources") GodotMethod!(void, Array) _setResources; 43 @GodotName("_get_resources") GodotMethod!(Array) _getResources; 44 @GodotName("add_resource") GodotMethod!(void, String, Resource) addResource; 45 @GodotName("remove_resource") GodotMethod!(void, String) removeResource; 46 @GodotName("rename_resource") GodotMethod!(void, String, String) renameResource; 47 @GodotName("has_resource") GodotMethod!(bool, String) hasResource; 48 @GodotName("get_resource") GodotMethod!(Resource, String) getResource; 49 @GodotName("get_resource_list") GodotMethod!(PoolStringArray) getResourceList; 50 } 51 bool opEquals(in ResourcePreloader other) const { return _godot_object.ptr is other._godot_object.ptr; } 52 ResourcePreloader opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 53 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 54 mixin baseCasts; 55 static ResourcePreloader _new() 56 { 57 static godot_class_constructor constructor; 58 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ResourcePreloader"); 59 if(constructor is null) return typeof(this).init; 60 return cast(ResourcePreloader)(constructor()); 61 } 62 @disable new(size_t s); 63 /** 64 65 */ 66 void _setResources(in Array arg0) 67 { 68 Array _GODOT_args = Array.empty_array; 69 _GODOT_args.append(arg0); 70 String _GODOT_method_name = String("_set_resources"); 71 this.callv(_GODOT_method_name, _GODOT_args); 72 } 73 /** 74 75 */ 76 Array _getResources() const 77 { 78 Array _GODOT_args = Array.empty_array; 79 String _GODOT_method_name = String("_get_resources"); 80 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 81 } 82 /** 83 84 */ 85 void addResource(StringArg0)(in StringArg0 name, Resource resource) 86 { 87 checkClassBinding!(typeof(this))(); 88 ptrcall!(void)(_classBinding.addResource, _godot_object, name, resource); 89 } 90 /** 91 Remove a resource from the preloader by text id. 92 */ 93 void removeResource(StringArg0)(in StringArg0 name) 94 { 95 checkClassBinding!(typeof(this))(); 96 ptrcall!(void)(_classBinding.removeResource, _godot_object, name); 97 } 98 /** 99 Rename a resource inside the preloader, from a text-id to a new text-id. 100 */ 101 void renameResource(StringArg0, StringArg1)(in StringArg0 name, in StringArg1 newname) 102 { 103 checkClassBinding!(typeof(this))(); 104 ptrcall!(void)(_classBinding.renameResource, _godot_object, name, newname); 105 } 106 /** 107 Return true if the preloader has a given resource. 108 */ 109 bool hasResource(StringArg0)(in StringArg0 name) const 110 { 111 checkClassBinding!(typeof(this))(); 112 return ptrcall!(bool)(_classBinding.hasResource, _godot_object, name); 113 } 114 /** 115 Return the resource given a text-id. 116 */ 117 Ref!Resource getResource(StringArg0)(in StringArg0 name) const 118 { 119 checkClassBinding!(typeof(this))(); 120 return ptrcall!(Resource)(_classBinding.getResource, _godot_object, name); 121 } 122 /** 123 Return the list of resources inside the preloader. 124 */ 125 PoolStringArray getResourceList() const 126 { 127 checkClassBinding!(typeof(this))(); 128 return ptrcall!(PoolStringArray)(_classBinding.getResourceList, _godot_object); 129 } 130 /** 131 132 */ 133 @property Array resources() 134 { 135 return _getResources(); 136 } 137 /// ditto 138 @property void resources(Array v) 139 { 140 _setResources(v); 141 } 142 }