diff mde/setup/Screen.d @ 94:9520cc0448e5

Boolean options are now encapsulated within a Content class (currently an experiment). This should facilitate generic option editing widgets.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 23 Oct 2008 17:45:49 +0100
parents 4d5d53e4f881
children 2a364c7d82c9
line wrap: on
line diff
--- a/mde/setup/Screen.d	Tue Oct 21 11:35:15 2008 +0100
+++ b/mde/setup/Screen.d	Thu Oct 23 17:45:49 2008 +0100
@@ -48,7 +48,7 @@
     }
     
     /** All video options. */
-    class OptionsVideo : Options {
+    class VideoOptions : Options {
         mixin (impl!("bool fullscreen,hardware,resizable,noFrame; int screenW,screenH,windowW,windowH;"));
     }
     
@@ -75,19 +75,19 @@
         //BEGIN Create window and initialize OpenGL
         // Window creation flags and size
         flags = SDL_OPENGL;
-        if (vidOpts.hardware) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+        if (videoOpts.hardware()) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
         else flags |= SDL_SWSURFACE;
         int w, h;
-        if (vidOpts.fullscreen) {
+        if (videoOpts.fullscreen()) {
             flags |= SDL_FULLSCREEN;
-            w = vidOpts.screenW;
-            h = vidOpts.screenH;
+            w = videoOpts.screenW;
+            h = videoOpts.screenH;
         }
         else {
-            if (vidOpts.resizable) flags |= SDL_RESIZABLE;
-            if (vidOpts.noFrame) flags |= SDL_NOFRAME;
-            w = vidOpts.windowW;
-            h = vidOpts.windowH;
+            if (videoOpts.resizable()) flags |= SDL_RESIZABLE;
+            if (videoOpts.noFrame()) flags |= SDL_NOFRAME;
+            w = videoOpts.windowW;
+            h = videoOpts.windowH;
         }
         
         // OpenGL attributes
@@ -155,12 +155,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 (vidOpts.fullscreen) {       // probably resizeEvent only called when not fullscreen
-            vidOpts.set!(int) ("screenW", w);
-            vidOpts.set!(int) ("screenH", h);
+        if (videoOpts.fullscreen()) {       // probably resizeEvent only called when not fullscreen
+            videoOpts.set!(int) ("screenW", w);
+            videoOpts.set!(int) ("screenH", h);
         } else {
-            vidOpts.set!(int) ("windowW", w);
-            vidOpts.set!(int) ("windowH", h);
+            videoOpts.set!(int) ("windowW", w);
+            videoOpts.set!(int) ("windowH", h);
         }
         
         if (setWindow (w,h))
@@ -262,8 +262,8 @@
     static this() {
         logger = Log.getLogger ("mde.setup.Screen");
         
-        vidOpts = new OptionsVideo;
-        Options.addOptionsClass (vidOpts, "video");
+        videoOpts = new VideoOptions;
+        Options.addOptionsClass (videoOpts, "VideoOptions");
     }
     
     // DATA:
@@ -271,5 +271,5 @@
     uint flags = 0;
     IDrawable[] drawables;
     Logger logger;
-    OptionsVideo vidOpts;
+    VideoOptions videoOpts;
 }