Mercurial > projects > mde
comparison 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 |
comparison
equal
deleted
inserted
replaced
93:08a4ae11454b | 94:9520cc0448e5 |
---|---|
46 /** Called you guess when :-) */ | 46 /** Called you guess when :-) */ |
47 void draw (); | 47 void draw (); |
48 } | 48 } |
49 | 49 |
50 /** All video options. */ | 50 /** All video options. */ |
51 class OptionsVideo : Options { | 51 class VideoOptions : Options { |
52 mixin (impl!("bool fullscreen,hardware,resizable,noFrame; int screenW,screenH,windowW,windowH;")); | 52 mixin (impl!("bool fullscreen,hardware,resizable,noFrame; int screenW,screenH,windowW,windowH;")); |
53 } | 53 } |
54 | 54 |
55 static: | 55 static: |
56 /** Init function to initialize SDL. */ | 56 /** Init function to initialize SDL. */ |
73 /** Init function to set up a window with OpenGL support. */ | 73 /** Init function to set up a window with OpenGL support. */ |
74 StageState initWindow () { | 74 StageState initWindow () { |
75 //BEGIN Create window and initialize OpenGL | 75 //BEGIN Create window and initialize OpenGL |
76 // Window creation flags and size | 76 // Window creation flags and size |
77 flags = SDL_OPENGL; | 77 flags = SDL_OPENGL; |
78 if (vidOpts.hardware) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF; | 78 if (videoOpts.hardware()) flags |= SDL_HWSURFACE | SDL_DOUBLEBUF; |
79 else flags |= SDL_SWSURFACE; | 79 else flags |= SDL_SWSURFACE; |
80 int w, h; | 80 int w, h; |
81 if (vidOpts.fullscreen) { | 81 if (videoOpts.fullscreen()) { |
82 flags |= SDL_FULLSCREEN; | 82 flags |= SDL_FULLSCREEN; |
83 w = vidOpts.screenW; | 83 w = videoOpts.screenW; |
84 h = vidOpts.screenH; | 84 h = videoOpts.screenH; |
85 } | 85 } |
86 else { | 86 else { |
87 if (vidOpts.resizable) flags |= SDL_RESIZABLE; | 87 if (videoOpts.resizable()) flags |= SDL_RESIZABLE; |
88 if (vidOpts.noFrame) flags |= SDL_NOFRAME; | 88 if (videoOpts.noFrame()) flags |= SDL_NOFRAME; |
89 w = vidOpts.windowW; | 89 w = videoOpts.windowW; |
90 h = vidOpts.windowH; | 90 h = videoOpts.windowH; |
91 } | 91 } |
92 | 92 |
93 // OpenGL attributes | 93 // OpenGL attributes |
94 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); | 94 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); |
95 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); | 95 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); |
153 | 153 |
154 | 154 |
155 /** Called when a resize event occurs (when the window manager resizes the window). */ | 155 /** Called when a resize event occurs (when the window manager resizes the window). */ |
156 void resizeEvent (int w, int h) { | 156 void resizeEvent (int w, int h) { |
157 // Save new size to config | 157 // Save new size to config |
158 if (vidOpts.fullscreen) { // probably resizeEvent only called when not fullscreen | 158 if (videoOpts.fullscreen()) { // probably resizeEvent only called when not fullscreen |
159 vidOpts.set!(int) ("screenW", w); | 159 videoOpts.set!(int) ("screenW", w); |
160 vidOpts.set!(int) ("screenH", h); | 160 videoOpts.set!(int) ("screenH", h); |
161 } else { | 161 } else { |
162 vidOpts.set!(int) ("windowW", w); | 162 videoOpts.set!(int) ("windowW", w); |
163 vidOpts.set!(int) ("windowH", h); | 163 videoOpts.set!(int) ("windowH", h); |
164 } | 164 } |
165 | 165 |
166 if (setWindow (w,h)) | 166 if (setWindow (w,h)) |
167 imde.run = false; | 167 imde.run = false; |
168 } | 168 } |
260 } | 260 } |
261 | 261 |
262 static this() { | 262 static this() { |
263 logger = Log.getLogger ("mde.setup.Screen"); | 263 logger = Log.getLogger ("mde.setup.Screen"); |
264 | 264 |
265 vidOpts = new OptionsVideo; | 265 videoOpts = new VideoOptions; |
266 Options.addOptionsClass (vidOpts, "video"); | 266 Options.addOptionsClass (videoOpts, "VideoOptions"); |
267 } | 267 } |
268 | 268 |
269 // DATA: | 269 // DATA: |
270 private: | 270 private: |
271 uint flags = 0; | 271 uint flags = 0; |
272 IDrawable[] drawables; | 272 IDrawable[] drawables; |
273 Logger logger; | 273 Logger logger; |
274 OptionsVideo vidOpts; | 274 VideoOptions videoOpts; |
275 } | 275 } |