1 /**
2 Main loop is the abstract main loop base class.
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.mainloop;
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.inputevent;
24 /**
25 Main loop is the abstract main loop base class.
26 
27 All other main loop classes are derived from it. Upon application start, a `MainLoop` has to be provided to OS, else the application will exit. This happens automatically (and a $(D SceneTree) is created), unless a main $(D Script) is supplied, which may or not create and return a `MainLoop`.
28 */
29 @GodotBaseClass struct MainLoop
30 {
31 	enum string _GODOT_internal_name = "MainLoop";
32 public:
33 @nogc nothrow:
34 	union { godot_object _godot_object; GodotObject _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("_input_event") GodotMethod!(void, InputEvent) _inputEvent;
42 		@GodotName("_input_text") GodotMethod!(void, String) _inputText;
43 		@GodotName("_initialize") GodotMethod!(void) _initialize;
44 		@GodotName("_iteration") GodotMethod!(void, double) _iteration;
45 		@GodotName("_idle") GodotMethod!(void, double) _idle;
46 		@GodotName("_drop_files") GodotMethod!(void, PoolStringArray, long) _dropFiles;
47 		@GodotName("_finalize") GodotMethod!(void) _finalize;
48 		@GodotName("input_event") GodotMethod!(void, InputEvent) inputEvent;
49 		@GodotName("input_text") GodotMethod!(void, String) inputText;
50 		@GodotName("init") GodotMethod!(void) _init;
51 		@GodotName("iteration") GodotMethod!(bool, double) iteration;
52 		@GodotName("idle") GodotMethod!(bool, double) idle;
53 		@GodotName("finish") GodotMethod!(void) finish;
54 	}
55 	bool opEquals(in MainLoop other) const { return _godot_object.ptr is other._godot_object.ptr; }
56 	MainLoop opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
57 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
58 	mixin baseCasts;
59 	static MainLoop _new()
60 	{
61 		static godot_class_constructor constructor;
62 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MainLoop");
63 		if(constructor is null) return typeof(this).init;
64 		return cast(MainLoop)(constructor());
65 	}
66 	@disable new(size_t s);
67 	/// 
68 	enum Constants : int
69 	{
70 		/**
71 		
72 		*/
73 		notificationWmMouseEnter = 2,
74 		/**
75 		
76 		*/
77 		notificationWmMouseExit = 3,
78 		/**
79 		
80 		*/
81 		notificationWmFocusIn = 4,
82 		/**
83 		
84 		*/
85 		notificationWmFocusOut = 5,
86 		/**
87 		
88 		*/
89 		notificationWmQuitRequest = 6,
90 		/**
91 		
92 		*/
93 		notificationWmGoBackRequest = 7,
94 		/**
95 		
96 		*/
97 		notificationWmUnfocusRequest = 8,
98 		/**
99 		
100 		*/
101 		notificationOsMemoryWarning = 9,
102 		/**
103 		
104 		*/
105 		notificationTranslationChanged = 90,
106 		/**
107 		
108 		*/
109 		notificationWmAbout = 91,
110 		/**
111 		
112 		*/
113 		notificationCrash = 92,
114 	}
115 	/**
116 	
117 	*/
118 	void _inputEvent(InputEvent event)
119 	{
120 		Array _GODOT_args = Array.empty_array;
121 		_GODOT_args.append(event);
122 		String _GODOT_method_name = String("_input_event");
123 		this.callv(_GODOT_method_name, _GODOT_args);
124 	}
125 	/**
126 	
127 	*/
128 	void _inputText(StringArg0)(in StringArg0 text)
129 	{
130 		Array _GODOT_args = Array.empty_array;
131 		_GODOT_args.append(text);
132 		String _GODOT_method_name = String("_input_text");
133 		this.callv(_GODOT_method_name, _GODOT_args);
134 	}
135 	/**
136 	Called once during initialization.
137 	*/
138 	void _initialize()
139 	{
140 		Array _GODOT_args = Array.empty_array;
141 		String _GODOT_method_name = String("_initialize");
142 		this.callv(_GODOT_method_name, _GODOT_args);
143 	}
144 	/**
145 	
146 	*/
147 	void _iteration(in double delta)
148 	{
149 		Array _GODOT_args = Array.empty_array;
150 		_GODOT_args.append(delta);
151 		String _GODOT_method_name = String("_iteration");
152 		this.callv(_GODOT_method_name, _GODOT_args);
153 	}
154 	/**
155 	Called each idle frame with time since last call as an only argument.
156 	*/
157 	void _idle(in double delta)
158 	{
159 		Array _GODOT_args = Array.empty_array;
160 		_GODOT_args.append(delta);
161 		String _GODOT_method_name = String("_idle");
162 		this.callv(_GODOT_method_name, _GODOT_args);
163 	}
164 	/**
165 	
166 	*/
167 	void _dropFiles(in PoolStringArray files, in long screen)
168 	{
169 		Array _GODOT_args = Array.empty_array;
170 		_GODOT_args.append(files);
171 		_GODOT_args.append(screen);
172 		String _GODOT_method_name = String("_drop_files");
173 		this.callv(_GODOT_method_name, _GODOT_args);
174 	}
175 	/**
176 	Called before the program exits.
177 	*/
178 	void _finalize()
179 	{
180 		Array _GODOT_args = Array.empty_array;
181 		String _GODOT_method_name = String("_finalize");
182 		this.callv(_GODOT_method_name, _GODOT_args);
183 	}
184 	/**
185 	
186 	*/
187 	void inputEvent(InputEvent event)
188 	{
189 		checkClassBinding!(typeof(this))();
190 		ptrcall!(void)(_classBinding.inputEvent, _godot_object, event);
191 	}
192 	/**
193 	
194 	*/
195 	void inputText(StringArg0)(in StringArg0 text)
196 	{
197 		checkClassBinding!(typeof(this))();
198 		ptrcall!(void)(_classBinding.inputText, _godot_object, text);
199 	}
200 	/**
201 	
202 	*/
203 	void _init()
204 	{
205 		checkClassBinding!(typeof(this))();
206 		ptrcall!(void)(_classBinding._init, _godot_object);
207 	}
208 	/**
209 	
210 	*/
211 	bool iteration(in double delta)
212 	{
213 		checkClassBinding!(typeof(this))();
214 		return ptrcall!(bool)(_classBinding.iteration, _godot_object, delta);
215 	}
216 	/**
217 	
218 	*/
219 	bool idle(in double delta)
220 	{
221 		checkClassBinding!(typeof(this))();
222 		return ptrcall!(bool)(_classBinding.idle, _godot_object, delta);
223 	}
224 	/**
225 	
226 	*/
227 	void finish()
228 	{
229 		checkClassBinding!(typeof(this))();
230 		ptrcall!(void)(_classBinding.finish, _godot_object);
231 	}
232 }