1 /**
2 Interactive $(D Resource) loader.
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.resourceinteractiveloader;
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.resource;
25 /**
26 Interactive $(D Resource) loader.
27 
28 This object is returned by $(D ResourceLoader) when performing an interactive load. It allows loading resources with high granularity, which makes it mainly useful for displaying loading bars or percentages.
29 */
30 @GodotBaseClass struct ResourceInteractiveLoader
31 {
32 	package(godot) enum string _GODOT_internal_name = "ResourceInteractiveLoader";
33 public:
34 @nogc nothrow:
35 	union { /** */ godot_object _godot_object; /** */ Reference _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_resource") GodotMethod!(Resource) getResource;
43 		@GodotName("get_stage") GodotMethod!(long) getStage;
44 		@GodotName("get_stage_count") GodotMethod!(long) getStageCount;
45 		@GodotName("poll") GodotMethod!(GodotError) poll;
46 		@GodotName("wait") GodotMethod!(GodotError) wait;
47 	}
48 	/// 
49 	pragma(inline, true) bool opEquals(in ResourceInteractiveLoader other) const
50 	{ return _godot_object.ptr is other._godot_object.ptr; }
51 	/// 
52 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
53 	{ _godot_object.ptr = n; return null; }
54 	/// 
55 	pragma(inline, true) bool opEquals(typeof(null) n) const
56 	{ return _godot_object.ptr is n; }
57 	/// 
58 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
59 	mixin baseCasts;
60 	/// Construct a new instance of ResourceInteractiveLoader.
61 	/// Note: use `memnew!ResourceInteractiveLoader` instead.
62 	static ResourceInteractiveLoader _new()
63 	{
64 		static godot_class_constructor constructor;
65 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ResourceInteractiveLoader");
66 		if(constructor is null) return typeof(this).init;
67 		return cast(ResourceInteractiveLoader)(constructor());
68 	}
69 	@disable new(size_t s);
70 	/**
71 	Returns the loaded resource if the load operation completed successfully, `null` otherwise.
72 	*/
73 	Ref!Resource getResource()
74 	{
75 		checkClassBinding!(typeof(this))();
76 		return ptrcall!(Resource)(GDNativeClassBinding.getResource, _godot_object);
77 	}
78 	/**
79 	Returns the load stage. The total amount of stages can be queried with $(D getStageCount).
80 	*/
81 	long getStage() const
82 	{
83 		checkClassBinding!(typeof(this))();
84 		return ptrcall!(long)(GDNativeClassBinding.getStage, _godot_object);
85 	}
86 	/**
87 	Returns the total amount of stages (calls to $(D poll)) needed to completely load this resource.
88 	*/
89 	long getStageCount() const
90 	{
91 		checkClassBinding!(typeof(this))();
92 		return ptrcall!(long)(GDNativeClassBinding.getStageCount, _godot_object);
93 	}
94 	/**
95 	Polls the loading operation, i.e. loads a data chunk up to the next stage.
96 	Returns $(D constant OK) if the poll is successful but the load operation has not finished yet (intermediate stage). This means $(D poll) will have to be called again until the last stage is completed.
97 	Returns $(D constant ERR_FILE_EOF) if the load operation has completed successfully. The loaded resource can be obtained by calling $(D getResource).
98 	Returns another $(D error) code if the poll has failed.
99 	*/
100 	GodotError poll()
101 	{
102 		checkClassBinding!(typeof(this))();
103 		return ptrcall!(GodotError)(GDNativeClassBinding.poll, _godot_object);
104 	}
105 	/**
106 	Polls the loading operation successively until the resource is completely loaded or a $(D poll) fails.
107 	Returns $(D constant ERR_FILE_EOF) if the load operation has completed successfully. The loaded resource can be obtained by calling $(D getResource).
108 	Returns another $(D error) code if a poll has failed, aborting the operation.
109 	*/
110 	GodotError wait()
111 	{
112 		checkClassBinding!(typeof(this))();
113 		return ptrcall!(GodotError)(GDNativeClassBinding.wait, _godot_object);
114 	}
115 }