comparison mde/mde.d @ 86:79d816b3e2d2

New InitStage system, Screen & Screen.Drawable, separate testing and guiDemo binaries. This (and the previous) commit are the result of several quite significant changes to mde. All the unittests run, but it hasn't had a huge amount of testing so don't be surprised if bugs show up.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 12 Sep 2008 17:36:14 +0100
parents 56c0ddd90193
children 97e6dce08037
comparison
equal deleted inserted replaced
85:56c0ddd90193 86:79d816b3e2d2
28 import mde.setup.Screen; // Screen.draw() 28 import mde.setup.Screen; // Screen.draw()
29 29
30 import tango.core.Thread : Thread; // Thread.sleep() 30 import tango.core.Thread : Thread; // Thread.sleep()
31 import tango.time.Clock; // Clock.now() 31 import tango.time.Clock; // Clock.now()
32 import tango.util.log.Log : Log, Logger; 32 import tango.util.log.Log : Log, Logger;
33 debug (mdeUnitTest) { 33 debug (mdeUnitTest) { // These modules contain unittests which wouldn't be run otherwise.
34 import mde.file.ssi; 34 import mde.file.ssi;
35 import mde.file.mergetag.mdeUT; 35 import mde.file.mergetag.mdeUT;
36 } 36 }
37 37
38 //BEGIN A simple drawable to print a message in the window.
39 import mde.font.font;
40 class SimpleDrawable : Screen.IDrawable {
41 this () {
42 msg = "Welcome to mde.\nThis executable is only for testing, and\nas such doesn't do anything interesting.";
43 debug msg ~= "\nRunning in debug mode.";
44 font = FontStyle.get("default");// get the default or fallback font
45 }
46 void sizeEvent (int,int) {}; // Don't care what the size is
47 void draw () {
48 font.textBlock (16,32, msg, textCache, Colour.WHITE);
49 }
50 char[] msg;
51 FontStyle font;
52 TextBlock textCache;
53 }
54 //END A simple drawable to print a message in the window.
55
56
38 int main(char[][] args) 57 int main(char[][] args)
39 { 58 {
59 Logger logger = Log.getLogger ("mde.mde");
60
40 // If compiled with unittests, notify that they completed and exit: 61 // If compiled with unittests, notify that they completed and exit:
41 debug (mdeUnitTest) { 62 debug (mdeUnitTest) {
42 Logger logger = Log.getLogger ("mde.mde");
43 logger.info ("Compiled unittests have completed; terminating."); 63 logger.info ("Compiled unittests have completed; terminating.");
44 return 0; 64 return 0;
45 } 65 }
46 66
47 scope Init init = new Init(args); // initialize mde 67 scope Init init = new Init(args); // initialize mde
68
69 // Note: must create the drawable after init, since it uses font (initialized in init).
70 Screen.addDrawable (new SimpleDrawable); // a drawable to print a message.
48 71
49 // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range 72 // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range
50 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0) 73 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0)
51 miscOpts.set!(double) ("pollInterval", 0.01); 74 miscOpts.set!(double) ("pollInterval", 0.01);
52 75