annotate mde/mde.d @ 20:838577503598

Reworked much of Init. Moved mde.Init to mde.scheduler.Init and largely cleaned up the code. Implemented mde.scheduler.InitStage to reduce dependancies of modules running Init functions. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 22 Mar 2008 16:22:59 +0000
parents 56a42ec95024
children a60cbb7359dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
1 /* LICENSE BLOCK
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
2 Part of mde: a Modular D game-oriented Engine
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
4
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
5 This program is free software; you can redistribute it and/or modify it under the terms of
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
6 the GNU General Public License, version 2, as published by the Free Software Foundation.
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
7
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
8 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
10 See the GNU General Public License for more details.
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
11
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
12 You should have received a copy of the GNU General Public License along
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
13 with this program; if not, write to the Free Software Foundation, Inc.,
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
5f90774ea1ef Applied the GNU GPL v2 to mde.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 16
diff changeset
15
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /** Modular D Engine
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 *
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18 * This module contains main().
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 */
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20 module mde.mde;
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22 // Package imports
10
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
23 import global = mde.global;
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
24 import mde.events;
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 12
diff changeset
25 import mde.i18n.I18nTranslation; // greeting message
10
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
26 import mde.exception;
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27
20
838577503598 Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 18
diff changeset
28 import mde.SDL; // This module is ONLY imported because otherwise it wouldn't be compiled in
838577503598 Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 18
diff changeset
29
838577503598 Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 18
diff changeset
30 import mde.scheduler.Init;
838577503598 Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 18
diff changeset
31 import mde.scheduler.runTime;
838577503598 Reworked much of Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 18
diff changeset
32 import mde.scheduler.exception;
16
9cb7b9310168 Improvements to Options and Init.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 15
diff changeset
33
2
78eb491bd642 mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 0
diff changeset
34 import mde.input.input;
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35
10
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
36 import tango.core.Thread : Thread; // for sleep
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
37 import tango.time.Clock;
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
38 import tango.util.log.Log : Log, Logger;
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
39
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
40 import derelict.sdl.sdl;
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
41
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
42 int main()
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
43 {
11
b940f267419e Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 10
diff changeset
44 //BEGIN Initialisation
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
45 Logger logger = Log.getLogger ("mde.mde");
18
56a42ec95024 Changes to Init and logging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
46 logger.info ("Starting mde...");
56a42ec95024 Changes to Init and logging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 17
diff changeset
47
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48 try {
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
49 init = new Init(); // initialisation
15
4608be19ebe2 Use OS paths (linux only for now), merging multiple paths. Init changes regarding options.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 12
diff changeset
50 } catch (InitException e) {
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
51 logger.fatal ("Initialisation failed; error was:");
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
52 logger.fatal (e.msg);
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
53 return 1;
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
54 }
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
55
10
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
56 global.input.addButtonCallback (cast(Input.inputID) 0x0u, delegate void(Input.inputID i, bool b) {
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
57 if (b) {
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
58 logger.info ("Quiting...");
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
59 global.run = false;
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
60 }
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
61 } );
11
b940f267419e Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 10
diff changeset
62 //END Initialisation
b940f267419e Options class created & changes to mergetag exception messages.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 10
diff changeset
63
12
bff0d802cb7d Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 11
diff changeset
64 /* Log a greeting message. Just a little test really, but it can stay until i18n finds a proper use. */
bff0d802cb7d Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 11
diff changeset
65 I18nTranslation transl = I18nTranslation.load ("mde");
bff0d802cb7d Implemented some internationalization support.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 11
diff changeset
66 logger.info (transl.getEntry ("greeting"));
9
1885a9080f2a Joystick button input now works with config.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 8
diff changeset
67
10
4c3575400769 DefaultData largely rewritten with unittest, SDL input event handling completed with unittest, changes to Init threading.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 9
diff changeset
68 while (global.run) {
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
69 Scheduler.run (Clock.now());
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
70
9
1885a9080f2a Joystick button input now works with config.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 8
diff changeset
71 Thread.sleep (0.050); // sleep this many seconds
4
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
72 }
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
73
9a990644948c Many changes: upgraded to tango 0.99.4, reorganised mde/input, large changes to mde/mergetag and mde/init, separated off test/MTTest.d and more.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 3
diff changeset
74 return 0; // cleanup handled by init's DTOR
0
d547009c104c Repository creation.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
75 }