Mercurial > projects > mde
comparison mde/mde.d @ 25:2c28ee04a4ed
Some minor and some futile efforts.
Played around with init functions, had problems, gave up and put them back.
Removed idea for multiple init stages; it's not good for performance or simplicity.
Adjusted exception messages.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 03 Apr 2008 17:26:52 +0100 |
parents | 32eff0e01c05 |
children | 611f7b9063c6 |
comparison
equal
deleted
inserted
replaced
24:32eff0e01c05 | 25:2c28ee04a4ed |
---|---|
13 with this program; if not, write to the Free Software Foundation, Inc., | 13 with this program; if not, write to the Free Software Foundation, Inc., |
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ | 14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ |
15 | 15 |
16 /** Modular D Engine | 16 /** Modular D Engine |
17 * | 17 * |
18 * This module contains main(). | 18 * This module contains main(), which calls Init and runs the main loop. |
19 */ | 19 */ |
20 module mde.mde; | 20 module mde.mde; |
21 | 21 |
22 // Package imports | 22 // Comment to show use, where only used minimally: |
23 import global = mde.global; | |
24 import mde.events; | |
25 import mde.exception; | |
26 | 23 |
27 import mde.SDL; // This module is ONLY imported because otherwise it wouldn't be compiled in | 24 import global = mde.global; // global.run |
25 import mde.SDL; // unused (but must be linked in) | |
26 import mde.events; // unused (but must be linked in) | |
28 | 27 |
29 import mde.scheduler.Init; | 28 import mde.scheduler.Init; |
30 import mde.scheduler.runTime; | 29 import mde.scheduler.runTime; // Scheduler.run() |
31 import mde.scheduler.exception; | 30 import mde.scheduler.exception; // InitException |
32 | 31 |
33 import mde.input.input; | 32 import tango.core.Thread : Thread; // Thread.sleep() |
34 | 33 import tango.time.Clock; // Clock.now() |
35 import tango.core.Thread : Thread; // for sleep | |
36 import tango.time.Clock; | |
37 import tango.util.log.Log : Log, Logger; | 34 import tango.util.log.Log : Log, Logger; |
38 | |
39 import derelict.sdl.sdl; | |
40 | 35 |
41 int main() | 36 int main() |
42 { | 37 { |
43 //BEGIN Initialisation | 38 //BEGIN Initialisation |
44 Logger logger = Log.getLogger ("mde.mde"); | 39 Logger logger = Log.getLogger ("mde.mde"); |
46 | 41 |
47 scope Init init; | 42 scope Init init; |
48 try { | 43 try { |
49 init = new Init(); // initialisation | 44 init = new Init(); // initialisation |
50 } catch (InitException e) { | 45 } catch (InitException e) { |
51 logger.fatal ("Initialisation failed; error was:"); | 46 logger.fatal ("Initialisation failed: " ~ e.msg); |
52 logger.fatal (e.msg); | |
53 return 1; | 47 return 1; |
54 } | 48 } |
55 | |
56 global.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) { | |
57 if (b) { | |
58 logger.info ("Quiting..."); | |
59 global.run = false; | |
60 } | |
61 } ); | |
62 //END Initialisation | 49 //END Initialisation |
63 | 50 |
64 while (global.run) { | 51 while (global.run) { |
65 Scheduler.run (Clock.now()); | 52 Scheduler.run (Clock.now()); |
66 | 53 |