diff mde/setup/Screen.d @ 137:9f035cd139c6

BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed. Content restrutured a lot: New IContent module, Content module includes more functionality. New ContentLoader module to manage content loading/saving/translation. Translation module moved to content dir and cut down to reflect current usage. File format unchanged except renames: FontOptions -> Font, VideoOptions -> Screen. Font render mode and LCD filter options are now enums. GUI loading needs to create content (and set type for enums), but doesn't save/load value. Some setup of mainSchedule moved to mde.mainLoop. Content callbacks are called on content change now. ContentLists are set up implicitly from content symbols. Not as fast but much easier! Bug-fix in the new MTTagReader. Renamed MT *Reader maker functions to avoid confusion in paths.d. New mde.setup.logger module to allow logger setup before any other module's static this().
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 07 Feb 2009 12:46:03 +0000
parents 5ee69b3ed9c9
children
line wrap: on
line diff
--- a/mde/setup/Screen.d	Sun Feb 01 12:36:21 2009 +0000
+++ b/mde/setup/Screen.d	Sat Feb 07 12:46:03 2009 +0000
@@ -19,7 +19,7 @@
 module mde.setup.Screen;
 
 import mde.setup.exception;
-import mde.lookup.Options;
+import mde.content.AStringContent;
 import imde = mde.imde;
 debug (drawGlyphCache) import mde.font.font;
 
@@ -47,11 +47,6 @@
         void draw ();
     }
     
-    /** All video options. */
-    class VideoOptions : Options {
-        mixin (impl!("bool fullscreen,hardware,resizable,noFrame; int screenW,screenH,windowW,windowH;"));
-    }
-    
 static:
     /** Init function to initialize SDL. */
     StageState init () {      // init func
@@ -77,19 +72,19 @@
         //BEGIN Create window and initialize OpenGL
         // Window creation flags and size
         flags = SDL_OPENGL;
-        if (videoOpts.hardware()) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+        if (hardware()) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
         else flags |= SDL_SWSURFACE;
         int w, h;
-        if (videoOpts.fullscreen()) {
+        if (fullscreen()) {
             flags |= SDL_FULLSCREEN;
-            w = videoOpts.screenW();
-            h = videoOpts.screenH();
+            w = screenW();
+            h = screenH();
         }
         else {
-            if (videoOpts.resizable()) flags |= SDL_RESIZABLE;
-            if (videoOpts.noFrame()) flags |= SDL_NOFRAME;
-            w = videoOpts.windowW();
-            h = videoOpts.windowH();
+            if (resizable()) flags |= SDL_RESIZABLE;
+            if (noFrame()) flags |= SDL_NOFRAME;
+            w = windowW();
+            h = windowH();
         }
         
         // OpenGL attributes
@@ -156,12 +151,12 @@
     /** Called when a resize event occurs (when the window manager resizes the window). */
     void resizeEvent (int w, int h) {
         // Save new size to config
-        if (videoOpts.fullscreen()) {       // probably resizeEvent only called when not fullscreen
-            videoOpts.screenW = w;
-            videoOpts.screenH = h;
+        if (fullscreen()) {       // probably resizeEvent only called when not fullscreen
+            screenW = w;
+            screenH = h;
         } else {
-            videoOpts.windowW = w;
-            videoOpts.windowH = h;
+            windowW = w;
+            windowH = h;
         }
         
         if (setWindow (w,h))
@@ -264,7 +259,14 @@
     static this() {
         logger = Log.getLogger ("mde.setup.Screen");
         
-        videoOpts = new VideoOptions ("VideoOptions");
+        fullscreen = new BoolContent ("Screen.fullscreen");
+        hardware = new BoolContent ("Screen.hardware");
+        resizable = new BoolContent ("Screen.resizable");
+        noFrame = new BoolContent ("Screen.noFrame");
+        screenW = new IntContent ("Screen.screenW");
+        screenH = new IntContent ("Screen.screenH");
+        windowW = new IntContent ("Screen.windowW");
+        windowH = new IntContent ("Screen.windowH");
     }
     
     // DATA:
@@ -272,5 +274,8 @@
     uint flags = 0;
     IDrawable[] drawables;
     Logger logger;
-    VideoOptions videoOpts;
+    
+    // Option values:
+    BoolContent fullscreen, hardware, resizable, noFrame;
+    IntContent screenW,screenH, windowW,windowH;
 }