diff 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
line wrap: on
line diff
--- a/mde/mde.d	Thu Sep 11 11:33:51 2008 +0100
+++ b/mde/mde.d	Fri Sep 12 17:36:14 2008 +0100
@@ -30,22 +30,45 @@
 import tango.core.Thread : Thread;	// Thread.sleep()
 import tango.time.Clock;                // Clock.now()
 import tango.util.log.Log : Log, Logger;
-debug (mdeUnitTest) {
+debug (mdeUnitTest) {                   // These modules contain unittests which wouldn't be run otherwise.
     import mde.file.ssi;
     import mde.file.mergetag.mdeUT;
 }
 
+//BEGIN A simple drawable to print a message in the window.
+import mde.font.font;
+class SimpleDrawable : Screen.IDrawable {
+    this () {
+        msg = "Welcome to mde.\nThis executable is only for testing, and\nas such doesn't do anything interesting.";
+        debug msg ~= "\nRunning in debug mode.";
+        font = FontStyle.get("default");// get the default or fallback font
+    }
+    void sizeEvent (int,int) {};        // Don't care what the size is
+    void draw () {
+        font.textBlock (16,32, msg, textCache, Colour.WHITE);
+    }
+    char[] msg;
+    FontStyle font;
+    TextBlock textCache;
+}
+//END A simple drawable to print a message in the window.
+
+
 int main(char[][] args)
 {
+    Logger logger = Log.getLogger ("mde.mde");
+    
     // If compiled with unittests, notify that they completed and exit:
     debug (mdeUnitTest) {
-        Logger logger = Log.getLogger ("mde.mde");
         logger.info ("Compiled unittests have completed; terminating.");
         return 0;
     }
     
     scope Init init = new Init(args);	// initialize mde
     
+    // Note: must create the drawable after init, since it uses font (initialized in init).
+    Screen.addDrawable (new SimpleDrawable);    // a drawable to print a message.
+    
     // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range
     if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0)
         miscOpts.set!(double) ("pollInterval", 0.01);