Mercurial > projects > mde
comparison mde/options.d @ 22:249eb6620685
Changes to Options, particularly regarding window sizes.
Window sizes for fullscreen and windowed modes are now independant.
Window resizes by the WM are now persistant.
Options class contents are now generated by templates.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 25 Mar 2008 12:24:04 +0000 |
parents | a60cbb7359dd |
children | 47478557428d |
comparison
equal
deleted
inserted
replaced
21:a60cbb7359dd | 22:249eb6620685 |
---|---|
131 private static Logger logger; | 131 private static Logger logger; |
132 static this() { | 132 static this() { |
133 logger = Log.getLogger ("mde.options"); | 133 logger = Log.getLogger ("mde.options"); |
134 } | 134 } |
135 //END Static | 135 //END Static |
136 | |
137 //BEGIN Templates | |
138 template store(A...) { | |
139 alias A a; | |
140 } | |
141 template decRecurse(char[] A, B...) { | |
142 static if (B.length) const char[] decRecurse = A ~ ", " ~ decRecurse!(B); | |
143 else const char[] decRecurse = A; | |
144 } | |
145 template decBool(A...) { | |
146 const char[] decBool = "bool " ~ decRecurse!(A) ~ ";\n"; | |
147 } | |
148 template decCharA(A...) { | |
149 const char[] decCharA = "char[] " ~ decRecurse!(A) ~ ";\n"; | |
150 } | |
151 template decInt(A...) { | |
152 const char[] decInt = "int " ~ decRecurse!(A) ~ ";\n"; | |
153 } | |
154 template aaRecurse(char[] A, B...) { | |
155 static if (B.length) const char[] aaRecurse = "\""~A~"\"[]:&"~A ~ ", " ~ aaRecurse!(B); | |
156 else const char[] aaRecurse = "\""~A~"\"[]:&"~A; | |
157 } | |
158 template aaBool(A...) { | |
159 const char[] aaBool = "optsBool = [" ~ aaRecurse!(A) ~ "];\n"; | |
160 } | |
161 template aaInt(A...) { | |
162 const char[] aaInt = "optsInt = [" ~ aaRecurse!(A) ~ "];\n"; | |
163 } | |
164 template aaCharA(A...) { | |
165 const char[] aaCharA = "optsCharA = [" ~ aaRecurse!(A) ~ "];\n"; | |
166 } | |
167 //END Templates | |
136 } | 168 } |
169 | |
170 /* NOTE: These Options classes use templates to ease inserting contents. | |
171 * | |
172 * Each entry has an I18nTranslation entry; see data/L10n/ClassName.mtt for descriptions. | |
173 * | |
174 * To create a new class, copy and paste, and update Options. | |
175 */ | |
137 | 176 |
138 /** A home for all miscellaneous options, at least for now. */ | 177 /** A home for all miscellaneous options, at least for now. */ |
139 class OptionsMisc : Options { | 178 class OptionsMisc : Options { |
140 bool useThreads; // set 0 to disable threading | 179 alias store!("useThreads") BOOL; |
141 char[] L10n; // locale, e.g. en-GB | 180 alias store!("logLevel") INT; |
142 | 181 alias store!("L10n") CHARA; |
143 int logLevel; // tango logger level | 182 |
183 mixin (decBool!(BOOL.a)); | |
184 mixin (decInt!(INT.a)); | |
185 mixin (decCharA!(CHARA.a)); | |
144 | 186 |
145 this () { | 187 this () { |
146 optsBool = ["useThreads":&useThreads]; | 188 mixin (aaBool!(BOOL.a)); |
147 optsCharA = ["L10n":&L10n]; | 189 mixin (aaInt!(INT.a)); |
148 optsInt = ["logLevel":&logLevel]; | 190 mixin (aaCharA!(CHARA.a)); |
149 } | 191 } |
150 } | 192 } |
151 | 193 |
152 /** All video options. */ | 194 /** All video options. */ |
153 class OptionsVideo : Options { | 195 class OptionsVideo : Options { |
154 int width, height; // screen/window dimensions | 196 alias store!("fullscreen","hardware","resizable","noFrame") BOOL; |
155 bool fullscreen; | 197 alias store!("screenW","screenH","windowW","windowH") INT; |
156 bool resizable; // when not fullscreen, window can be resized | 198 //alias store!() CHARA; |
157 bool noFrame; // when not fullscreen, don't draw the window decorations | 199 |
158 bool hardware; // use a hardware surface. Relevant with OpenGL? | 200 mixin (decBool!(BOOL.a)); |
201 mixin (decInt!(INT.a)); | |
202 //mixin (decCharA!(CHARA.a)); | |
159 | 203 |
160 this () { | 204 this () { |
161 optsBool = ["fullscreen"[]:&fullscreen, "hardware":&hardware, "noFrame":&noFrame, "resizable":&resizable]; | 205 mixin (aaBool!(BOOL.a)); |
162 optsInt = ["height"[]:&height, "width":&width]; | 206 mixin (aaInt!(INT.a)); |
207 //mixin (aaCharA!(CHARA.a)); | |
163 } | 208 } |
164 } | 209 } |