Merge lp:~mxsscott/widelands/windowed-graphics into lp:widelands
- windowed-graphics
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 6484 | ||||||||
Proposed branch: | lp:~mxsscott/widelands/windowed-graphics | ||||||||
Merge into: | lp:widelands | ||||||||
Diff against target: |
414 lines (+138/-75) 8 files modified
src/sound/sound_handler.cc (+2/-2) src/ui_fsmenu/base.cc (+2/-2) src/ui_fsmenu/options.cc (+76/-24) src/ui_fsmenu/options.h (+19/-6) src/wlapplication.cc (+25/-4) src/wlapplication.h (+12/-2) src/wui/interactive_base.cc (+2/-32) src/wui/interactive_base.h (+0/-3) |
||||||||
To merge this branch: | bzr merge lp:~mxsscott/widelands/windowed-graphics | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email: mp+142048@code.launchpad.net |
Commit message
Description of the change
Fix resizing of the game window after the user chooses a new resolution bug 1096651.
- Also menus use the current graphics dimensions, not the dimensions in the options (not really a problem now!)
- Some graphics resolution tidyups.
- Support Enter/Escape for triggering the Apply or Cancel buttons within the Options menu. This allows the user to reselect a smaller window size if they get stuck due to bug 900784.
The screen resolution issue fix could possibly be improved if we display a window for 5-10 seconds asking the user to confirm they can see it. If they don't click OK, we revert the graphics mode back to the previous one. However, I believe the Enter/Escape solution is 'good enough' for now.
Mark Scott (mxsscott) wrote : | # |
Reading right to left, it's a pointer to a const pointer to a const SDL_Rect.
const SDL_Rect** should also work because that's what SDL_ListModes() returns (we declare our variable to be more consty to indicate we don't mess with it.
The reason I left the init out of the for loop was due to line-length, but this is a pretty poor reason to do so.
I'll make these changes and re-push the branch.
I'm happy having trunk rights - but I do see the benefit of having code reviewed, especially where it is an area people are touching significantly or haven't touched before. Even if the coding is fine, there may be opportunity to say "Why don't you do this too?", or point out something that was missed "You left a todo in for function X's documentation" - we all forget these in the haste to commit before going away to do something else (sleep?)
Mark Scott (mxsscott) wrote : | # |
Wasn't able to change the type
const SDL_Rect * const *
to
const SDL_Rect * *.
SDL_ListModes() returns a "SDL_Rect **" so we need to say we'll keep all but the final pointer variable constant (which is fine because that variable is ours), or nothing constant.
SirVer (sirver) wrote : | # |
Okay, Ack. Code LGTM, so feel free to push it.
I gave you push rights to trunk (by adding you to widelands dev). here comes the very important usual disclaimer: bzr is awefull in one regard that you can push your branch history to trunk without confirmation. that is, if you work in a branch and someone adds new revisions to trunk in the meantime, when you push your branch to trunk you will overwrite those changes!!!
so, the proper thing is to always keep a version of trunk around that you do not modify. I personally use this workflow: http://
you then always work in branches:
$ cd trunk && bzr switch -b bug123
hack hack, commit, commit
$ bzr switch trunk && bzr pull && bzr merge .bzr-repo/bug123
$ bzr push lp:widelands
especially never push to lp:widelands from a feature branch or before you pulled. bzr uncommit helps sometimes to undo errors.
feel free to ask for anything when you need help. this is really important to get right - though basically everybody gets it wrong once. this will result in mailbombs from bzr and "XXX revisions removed." mails which are confusing at best.
Hans Joachim Desserud (hjd) wrote : | # |
>I'd love to have code review for my own stuff as well in the future. .... this kinda went offtopic of this merge - I'd like to hear the comments of everybody though!
+1
Code reviews are really nice as they can often reveal and resolve issues before they hit trunk. And if something breaks in the future, both the author and reviewer should be familiar with the code as opposed to only a single person.
One potential issue I see is of shortage of reviewers. We currently have nine branches waiting for review, some of which are quite old. On the other hand, some of those have raised issues which authors haven't addressed yet.
I think this would be worth a try. We can always re-assess later if we end up with lots of unmerged reviews and a trunk gathering dust.
And since this is completely off-topic, we should find some better place to discuss it; a forum thread, meta bug?
SirVer (sirver) wrote : | # |
right, maybe we should take this to widelands-public which is still the goto place to discuss dev topics.
Preview Diff
1 | === modified file 'src/sound/sound_handler.cc' | |||
2 | --- src/sound/sound_handler.cc 2013-01-04 16:39:48 +0000 | |||
3 | +++ src/sound/sound_handler.cc 2013-01-07 20:42:25 +0000 | |||
4 | @@ -330,8 +330,8 @@ | |||
5 | 330 | Interactive_Base const & ibase = *m_egbase->get_ibase(); | 330 | Interactive_Base const & ibase = *m_egbase->get_ibase(); |
6 | 331 | Point const vp = ibase.get_viewpoint(); | 331 | Point const vp = ibase.get_viewpoint(); |
7 | 332 | 332 | ||
10 | 333 | int32_t const xres = ibase.get_xres(); | 333 | int32_t const xres = g_gr->get_xres(); |
11 | 334 | int32_t const yres = ibase.get_yres(); | 334 | int32_t const yres = g_gr->get_yres(); |
12 | 335 | 335 | ||
13 | 336 | MapviewPixelFunctions::get_pix(m_egbase->map(), position, sx, sy); | 336 | MapviewPixelFunctions::get_pix(m_egbase->map(), position, sx, sy); |
14 | 337 | sx -= vp.x; | 337 | sx -= vp.x; |
15 | 338 | 338 | ||
16 | === modified file 'src/ui_fsmenu/base.cc' | |||
17 | --- src/ui_fsmenu/base.cc 2013-01-05 21:03:10 +0000 | |||
18 | +++ src/ui_fsmenu/base.cc 2013-01-07 20:42:25 +0000 | |||
19 | @@ -86,11 +86,11 @@ | |||
20 | 86 | 86 | ||
21 | 87 | 87 | ||
22 | 88 | uint32_t Fullscreen_Menu_Base::gr_x() { | 88 | uint32_t Fullscreen_Menu_Base::gr_x() { |
24 | 89 | return g_options.pull_section("global").get_int("xres", XRES); | 89 | return g_gr->get_xres(); |
25 | 90 | } | 90 | } |
26 | 91 | 91 | ||
27 | 92 | uint32_t Fullscreen_Menu_Base::gr_y() { | 92 | uint32_t Fullscreen_Menu_Base::gr_y() { |
29 | 93 | return g_options.pull_section("global").get_int("yres", YRES); | 93 | return g_gr->get_yres(); |
30 | 94 | } | 94 | } |
31 | 95 | 95 | ||
32 | 96 | 96 | ||
33 | 97 | 97 | ||
34 | === modified file 'src/ui_fsmenu/options.cc' | |||
35 | --- src/ui_fsmenu/options.cc 2012-12-16 19:08:53 +0000 | |||
36 | +++ src/ui_fsmenu/options.cc 2013-01-07 20:42:25 +0000 | |||
37 | @@ -236,37 +236,47 @@ | |||
38 | 236 | 236 | ||
39 | 237 | // GRAPHIC_TODO: this shouldn't be here List all resolutions | 237 | // GRAPHIC_TODO: this shouldn't be here List all resolutions |
40 | 238 | // take a copy to not change real video info structure | 238 | // take a copy to not change real video info structure |
42 | 239 | SDL_PixelFormat fmt = *SDL_GetVideoInfo()->vfmt; | 239 | SDL_PixelFormat fmt = *SDL_GetVideoInfo()->vfmt; |
43 | 240 | |||
44 | 240 | fmt.BitsPerPixel = 16; | 241 | fmt.BitsPerPixel = 16; |
51 | 241 | if | 242 | for |
52 | 242 | (SDL_Rect const * const * const modes = | 243 | (const SDL_Rect * const * modes = SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN); |
53 | 243 | SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN)) | 244 | modes && *modes; |
54 | 244 | for (uint32_t i = 0; modes[i]; ++i) | 245 | ++modes) |
55 | 245 | if (640 <= modes[i]->w and 480 <= modes[i]->h) { | 246 | { |
56 | 246 | res const this_res = {modes[i]->w, modes[i]->h, 16}; | 247 | const SDL_Rect & mode = **modes; |
57 | 248 | if (640 <= mode.w and 480 <= mode.h) | ||
58 | 249 | { | ||
59 | 250 | const Resolution this_res = {mode.w, mode.h, fmt.BitsPerPixel}; | ||
60 | 247 | if | 251 | if |
61 | 248 | (m_resolutions.empty() | 252 | (m_resolutions.empty() |
66 | 249 | or | 253 | || this_res.xres != m_resolutions.rbegin()->xres |
67 | 250 | this_res.xres != m_resolutions.rbegin()->xres | 254 | || this_res.yres != m_resolutions.rbegin()->yres) |
68 | 251 | or | 255 | { |
65 | 252 | this_res.yres != m_resolutions.rbegin()->yres) | ||
69 | 253 | m_resolutions.push_back(this_res); | 256 | m_resolutions.push_back(this_res); |
70 | 254 | } | 257 | } |
71 | 258 | } | ||
72 | 259 | } | ||
73 | 260 | |||
74 | 255 | fmt.BitsPerPixel = 32; | 261 | fmt.BitsPerPixel = 32; |
88 | 256 | if | 262 | for |
89 | 257 | (SDL_Rect const * const * const modes = | 263 | (const SDL_Rect * const * modes = SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN); |
90 | 258 | SDL_ListModes(&fmt, SDL_SWSURFACE | SDL_FULLSCREEN)) | 264 | modes && *modes; |
91 | 259 | for (uint32_t i = 0; modes[i]; ++i) | 265 | ++modes) |
92 | 260 | if (640 <= modes[i]->w and 480 <= modes[i]->h) { | 266 | { |
93 | 261 | res const this_res = {modes[i]->w, modes[i]->h, 32}; | 267 | const SDL_Rect & mode = **modes; |
94 | 262 | if | 268 | if (640 <= mode.w and 480 <= mode.h) |
95 | 263 | (m_resolutions.empty() | 269 | { |
96 | 264 | or | 270 | const Resolution this_res = {mode.w, mode.h, fmt.BitsPerPixel}; |
97 | 265 | this_res.xres != m_resolutions.rbegin()->xres | 271 | if |
98 | 266 | or | 272 | (m_resolutions.empty() |
99 | 267 | this_res.yres != m_resolutions.rbegin()->yres) | 273 | || this_res.xres != m_resolutions.rbegin()->xres |
100 | 268 | m_resolutions.push_back(this_res); | 274 | || this_res.yres != m_resolutions.rbegin()->yres) |
101 | 275 | { | ||
102 | 276 | m_resolutions.push_back(this_res); | ||
103 | 269 | } | 277 | } |
104 | 278 | } | ||
105 | 279 | } | ||
106 | 270 | 280 | ||
107 | 271 | bool did_select_a_res = false; | 281 | bool did_select_a_res = false; |
108 | 272 | for (uint32_t i = 0; i < m_resolutions.size(); ++i) { | 282 | for (uint32_t i = 0; i < m_resolutions.size(); ++i) { |
109 | @@ -343,6 +353,26 @@ | |||
110 | 343 | } | 353 | } |
111 | 344 | } | 354 | } |
112 | 345 | 355 | ||
113 | 356 | bool Fullscreen_Menu_Options::handle_key(bool down, SDL_keysym code) | ||
114 | 357 | { | ||
115 | 358 | if (down) | ||
116 | 359 | { | ||
117 | 360 | switch (code.sym) | ||
118 | 361 | { | ||
119 | 362 | case SDLK_KP_ENTER: | ||
120 | 363 | case SDLK_RETURN: | ||
121 | 364 | end_modal(static_cast<int32_t>(om_ok)); | ||
122 | 365 | return true; | ||
123 | 366 | case SDLK_ESCAPE: | ||
124 | 367 | end_modal(static_cast<int32_t>(om_cancel)); | ||
125 | 368 | return true; | ||
126 | 369 | default: | ||
127 | 370 | break; // not handled | ||
128 | 371 | } | ||
129 | 372 | } | ||
130 | 373 | |||
131 | 374 | return Fullscreen_Menu_Base::handle_key(down, code); | ||
132 | 375 | } | ||
133 | 346 | 376 | ||
134 | 347 | Options_Ctrl::Options_Struct Fullscreen_Menu_Options::get_values() { | 377 | Options_Ctrl::Options_Struct Fullscreen_Menu_Options::get_values() { |
135 | 348 | const uint32_t res_index = m_reslist.selection_index(); | 378 | const uint32_t res_index = m_reslist.selection_index(); |
136 | @@ -561,6 +591,28 @@ | |||
137 | 561 | } | 591 | } |
138 | 562 | } | 592 | } |
139 | 563 | 593 | ||
140 | 594 | bool Fullscreen_Menu_Advanced_Options::handle_key(bool down, SDL_keysym code) | ||
141 | 595 | { | ||
142 | 596 | if (down) | ||
143 | 597 | { | ||
144 | 598 | switch (code.sym) | ||
145 | 599 | { | ||
146 | 600 | case SDLK_KP_ENTER: | ||
147 | 601 | case SDLK_RETURN: | ||
148 | 602 | end_modal(static_cast<int32_t>(om_ok)); | ||
149 | 603 | return true; | ||
150 | 604 | case SDLK_ESCAPE: | ||
151 | 605 | end_modal(static_cast<int32_t>(om_cancel)); | ||
152 | 606 | return true; | ||
153 | 607 | default: | ||
154 | 608 | break; // not handled | ||
155 | 609 | } | ||
156 | 610 | } | ||
157 | 611 | |||
158 | 612 | return Fullscreen_Menu_Base::handle_key(down, code); | ||
159 | 613 | } | ||
160 | 614 | |||
161 | 615 | |||
162 | 564 | Options_Ctrl::Options_Struct Fullscreen_Menu_Advanced_Options::get_values() { | 616 | Options_Ctrl::Options_Struct Fullscreen_Menu_Advanced_Options::get_values() { |
163 | 565 | // Write all remaining data from UI elements | 617 | // Write all remaining data from UI elements |
164 | 566 | os.message_sound = m_message_sound.get_state(); | 618 | os.message_sound = m_message_sound.get_state(); |
165 | 567 | 619 | ||
166 | === modified file 'src/ui_fsmenu/options.h' | |||
167 | --- src/ui_fsmenu/options.h 2012-02-15 21:25:34 +0000 | |||
168 | +++ src/ui_fsmenu/options.h 2013-01-07 20:42:25 +0000 | |||
169 | @@ -32,10 +32,11 @@ | |||
170 | 32 | #include <cstring> | 32 | #include <cstring> |
171 | 33 | #include <vector> | 33 | #include <vector> |
172 | 34 | 34 | ||
174 | 35 | struct Fullscreen_Menu_Options; | 35 | class Fullscreen_Menu_Options; |
175 | 36 | struct Section; | 36 | struct Section; |
176 | 37 | 37 | ||
178 | 38 | struct Options_Ctrl { | 38 | class Options_Ctrl { |
179 | 39 | public: | ||
180 | 39 | struct Options_Struct { | 40 | struct Options_Struct { |
181 | 40 | int32_t xres; | 41 | int32_t xres; |
182 | 41 | int32_t yres; | 42 | int32_t yres; |
183 | @@ -80,7 +81,8 @@ | |||
184 | 80 | * Fullscreen Optionsmenu. A modal optionsmenu | 81 | * Fullscreen Optionsmenu. A modal optionsmenu |
185 | 81 | */ | 82 | */ |
186 | 82 | 83 | ||
188 | 83 | struct Fullscreen_Menu_Options : public Fullscreen_Menu_Base { | 84 | class Fullscreen_Menu_Options : public Fullscreen_Menu_Base { |
189 | 85 | public: | ||
190 | 84 | Fullscreen_Menu_Options(Options_Ctrl::Options_Struct opt); | 86 | Fullscreen_Menu_Options(Options_Ctrl::Options_Struct opt); |
191 | 85 | Options_Ctrl::Options_Struct get_values(); | 87 | Options_Ctrl::Options_Struct get_values(); |
192 | 86 | enum { | 88 | enum { |
193 | @@ -89,6 +91,9 @@ | |||
194 | 89 | om_restart = 2 | 91 | om_restart = 2 |
195 | 90 | }; | 92 | }; |
196 | 91 | 93 | ||
197 | 94 | /// Handle keypresses | ||
198 | 95 | virtual bool handle_key(bool down, SDL_keysym code); | ||
199 | 96 | |||
200 | 92 | private: | 97 | private: |
201 | 93 | uint32_t m_vbutw; | 98 | uint32_t m_vbutw; |
202 | 94 | uint32_t m_butw; | 99 | uint32_t m_butw; |
203 | @@ -127,19 +132,24 @@ | |||
204 | 127 | 132 | ||
205 | 128 | void advanced_options(); | 133 | void advanced_options(); |
206 | 129 | 134 | ||
208 | 130 | struct res { | 135 | /// A screen resolution in terms of width, height and pixel depth. |
209 | 136 | class Resolution { | ||
210 | 137 | public: | ||
211 | 131 | int32_t xres; | 138 | int32_t xres; |
212 | 132 | int32_t yres; | 139 | int32_t yres; |
213 | 133 | int32_t depth; | 140 | int32_t depth; |
214 | 134 | }; | 141 | }; |
216 | 135 | std::vector<res> m_resolutions; | 142 | |
217 | 143 | /// All supported screen resolutions. | ||
218 | 144 | std::vector<Resolution> m_resolutions; | ||
219 | 136 | }; | 145 | }; |
220 | 137 | 146 | ||
221 | 138 | /** | 147 | /** |
222 | 139 | * Fullscreen Optionsmenu. A modal optionsmenu | 148 | * Fullscreen Optionsmenu. A modal optionsmenu |
223 | 140 | */ | 149 | */ |
224 | 141 | 150 | ||
226 | 142 | struct Fullscreen_Menu_Advanced_Options : public Fullscreen_Menu_Base { | 151 | class Fullscreen_Menu_Advanced_Options : public Fullscreen_Menu_Base { |
227 | 152 | public: | ||
228 | 143 | Fullscreen_Menu_Advanced_Options(Options_Ctrl::Options_Struct opt); | 153 | Fullscreen_Menu_Advanced_Options(Options_Ctrl::Options_Struct opt); |
229 | 144 | Options_Ctrl::Options_Struct get_values(); | 154 | Options_Ctrl::Options_Struct get_values(); |
230 | 145 | enum { | 155 | enum { |
231 | @@ -147,6 +157,9 @@ | |||
232 | 147 | om_ok = 1 | 157 | om_ok = 1 |
233 | 148 | }; | 158 | }; |
234 | 149 | 159 | ||
235 | 160 | /// Handle keypresses | ||
236 | 161 | virtual bool handle_key(bool down, SDL_keysym code); | ||
237 | 162 | |||
238 | 150 | private: | 163 | private: |
239 | 151 | uint32_t m_vbutw; | 164 | uint32_t m_vbutw; |
240 | 152 | uint32_t m_butw; | 165 | uint32_t m_butw; |
241 | 153 | 166 | ||
242 | === modified file 'src/wlapplication.cc' | |||
243 | --- src/wlapplication.cc 2013-01-04 15:24:56 +0000 | |||
244 | +++ src/wlapplication.cc 2013-01-07 20:42:25 +0000 | |||
245 | @@ -263,7 +263,7 @@ | |||
246 | 263 | m_mouse_locked (0), | 263 | m_mouse_locked (0), |
247 | 264 | m_mouse_compensate_warp(0, 0), | 264 | m_mouse_compensate_warp(0, 0), |
248 | 265 | m_should_die (false), | 265 | m_should_die (false), |
250 | 266 | m_gfx_w(0), m_gfx_h(0), | 266 | m_gfx_w(0), m_gfx_h(0), m_gfx_bpp(0), |
251 | 267 | m_gfx_fullscreen (false), | 267 | m_gfx_fullscreen (false), |
252 | 268 | m_gfx_opengl (true), | 268 | m_gfx_opengl (true), |
253 | 269 | m_default_datadirs (true), | 269 | m_default_datadirs (true), |
254 | @@ -790,11 +790,11 @@ | |||
255 | 790 | */ | 790 | */ |
256 | 791 | 791 | ||
257 | 792 | void WLApplication::init_graphics | 792 | void WLApplication::init_graphics |
260 | 793 | (int32_t const w, int32_t const h, int32_t const bpp, | 793 | (const int32_t w, const int32_t h, const int32_t bpp, |
261 | 794 | bool const fullscreen, bool const opengl) | 794 | const bool fullscreen, const bool opengl) |
262 | 795 | { | 795 | { |
263 | 796 | if | 796 | if |
265 | 797 | (w == m_gfx_w && h == m_gfx_h && | 797 | (w == m_gfx_w && h == m_gfx_h && bpp == m_gfx_bpp && |
266 | 798 | fullscreen == m_gfx_fullscreen && | 798 | fullscreen == m_gfx_fullscreen && |
267 | 799 | opengl == m_gfx_opengl) | 799 | opengl == m_gfx_opengl) |
268 | 800 | return; | 800 | return; |
269 | @@ -804,6 +804,7 @@ | |||
270 | 804 | 804 | ||
271 | 805 | m_gfx_w = w; | 805 | m_gfx_w = w; |
272 | 806 | m_gfx_h = h; | 806 | m_gfx_h = h; |
273 | 807 | m_gfx_bpp = bpp; | ||
274 | 807 | m_gfx_fullscreen = fullscreen; | 808 | m_gfx_fullscreen = fullscreen; |
275 | 808 | m_gfx_opengl = opengl; | 809 | m_gfx_opengl = opengl; |
276 | 809 | 810 | ||
277 | @@ -815,6 +816,23 @@ | |||
278 | 815 | } | 816 | } |
279 | 816 | } | 817 | } |
280 | 817 | 818 | ||
281 | 819 | void WLApplication::refresh_graphics() | ||
282 | 820 | { | ||
283 | 821 | Section & s = g_options.pull_section("global"); | ||
284 | 822 | |||
285 | 823 | // Switch to the new graphics system now, if necessary. | ||
286 | 824 | init_graphics | ||
287 | 825 | (s.get_int("xres", XRES), | ||
288 | 826 | s.get_int("yres", YRES), | ||
289 | 827 | s.get_int("depth", 16), | ||
290 | 828 | s.get_bool("fullscreen", false), | ||
291 | 829 | #if USE_OPENGL | ||
292 | 830 | s.get_bool("opengl", true)); | ||
293 | 831 | #else | ||
294 | 832 | false); | ||
295 | 833 | #endif | ||
296 | 834 | } | ||
297 | 835 | |||
298 | 818 | /** | 836 | /** |
299 | 819 | * Read the config file, parse the commandline and give all other internal | 837 | * Read the config file, parse the commandline and give all other internal |
300 | 820 | * parameters sensible default values | 838 | * parameters sensible default values |
301 | @@ -1515,6 +1533,9 @@ | |||
302 | 1515 | std::string message; | 1533 | std::string message; |
303 | 1516 | 1534 | ||
304 | 1517 | for (;;) { | 1535 | for (;;) { |
305 | 1536 | // Refresh graphics system in case we just changed resolution. | ||
306 | 1537 | refresh_graphics(); | ||
307 | 1538 | |||
308 | 1518 | Fullscreen_Menu_Main mm; | 1539 | Fullscreen_Menu_Main mm; |
309 | 1519 | 1540 | ||
310 | 1520 | if (message.size()) { | 1541 | if (message.size()) { |
311 | 1521 | 1542 | ||
312 | === modified file 'src/wlapplication.h' | |||
313 | --- src/wlapplication.h 2012-02-15 21:25:34 +0000 | |||
314 | +++ src/wlapplication.h 2013-01-07 20:42:25 +0000 | |||
315 | @@ -179,8 +179,15 @@ | |||
316 | 179 | //@} | 179 | //@} |
317 | 180 | 180 | ||
318 | 181 | void init_graphics | 181 | void init_graphics |
321 | 182 | (int32_t w, int32_t h, int32_t bpp, | 182 | (const int32_t w, const int32_t h, const int32_t bpp, |
322 | 183 | bool fullscreen, bool opengl); | 183 | const bool fullscreen, const bool opengl); |
323 | 184 | |||
324 | 185 | /** | ||
325 | 186 | * Refresh the graphics from the latest options. | ||
326 | 187 | * | ||
327 | 188 | * \note See caveats for \ref init_graphics() | ||
328 | 189 | */ | ||
329 | 190 | void refresh_graphics(); | ||
330 | 184 | 191 | ||
331 | 185 | void handle_input(InputCallback const *); | 192 | void handle_input(InputCallback const *); |
332 | 186 | 193 | ||
333 | @@ -282,6 +289,9 @@ | |||
334 | 282 | ///The Widelands window's height in pixels | 289 | ///The Widelands window's height in pixels |
335 | 283 | int32_t m_gfx_h; | 290 | int32_t m_gfx_h; |
336 | 284 | 291 | ||
337 | 292 | ///The Widelands window's bits per pixel | ||
338 | 293 | int32_t m_gfx_bpp; | ||
339 | 294 | |||
340 | 285 | ///If true Widelands is (should be, we never know ;-) running | 295 | ///If true Widelands is (should be, we never know ;-) running |
341 | 286 | ///in a fullscreen window | 296 | ///in a fullscreen window |
342 | 287 | bool m_gfx_fullscreen; | 297 | bool m_gfx_fullscreen; |
343 | 288 | 298 | ||
344 | === modified file 'src/wui/interactive_base.cc' | |||
345 | --- src/wui/interactive_base.cc 2012-12-16 14:29:46 +0000 | |||
346 | +++ src/wui/interactive_base.cc 2013-01-07 20:42:25 +0000 | |||
347 | @@ -71,7 +71,7 @@ | |||
348 | 71 | Interactive_Base::Interactive_Base | 71 | Interactive_Base::Interactive_Base |
349 | 72 | (Editor_Game_Base & the_egbase, Section & global_s) | 72 | (Editor_Game_Base & the_egbase, Section & global_s) |
350 | 73 | : | 73 | : |
352 | 74 | Map_View(0, 0, 0, get_xres(), get_yres(), *this), | 74 | Map_View(0, 0, 0, global_s.get_int("xres", XRES), global_s.get_int("yres", YRES), *this), |
353 | 75 | m_show_workarea_preview(global_s.get_bool("workareapreview", true)), | 75 | m_show_workarea_preview(global_s.get_bool("workareapreview", true)), |
354 | 76 | m | 76 | m |
355 | 77 | (new InteractiveBaseInternals | 77 | (new InteractiveBaseInternals |
356 | @@ -112,15 +112,7 @@ | |||
357 | 112 | (global_s.get_bool("dock_windows_to_edges", false)); | 112 | (global_s.get_bool("dock_windows_to_edges", false)); |
358 | 113 | 113 | ||
359 | 114 | // Switch to the new graphics system now, if necessary. | 114 | // Switch to the new graphics system now, if necessary. |
369 | 115 | WLApplication::get()->init_graphics | 115 | WLApplication::get()->refresh_graphics(); |
361 | 116 | (get_xres(), get_yres(), | ||
362 | 117 | global_s.get_int("depth", 16), | ||
363 | 118 | global_s.get_bool("fullscreen", false), | ||
364 | 119 | #if USE_OPENGL | ||
365 | 120 | global_s.get_bool("opengl", true)); | ||
366 | 121 | #else | ||
367 | 122 | false); | ||
368 | 123 | #endif | ||
370 | 124 | 116 | ||
371 | 125 | // Having this in the initializer list (before Sys_InitGraphics) will give | 117 | // Having this in the initializer list (before Sys_InitGraphics) will give |
372 | 126 | // funny results. | 118 | // funny results. |
373 | @@ -238,28 +230,6 @@ | |||
374 | 238 | 230 | ||
375 | 239 | 231 | ||
376 | 240 | /** | 232 | /** |
377 | 241 | * Retrieves the configured in-game resolution. | ||
378 | 242 | * | ||
379 | 243 | * \note For most purposes, you should use \ref Graphic::get_xres instead. | ||
380 | 244 | */ | ||
381 | 245 | int32_t Interactive_Base::get_xres() | ||
382 | 246 | { | ||
383 | 247 | return g_options.pull_section("global").get_int("xres", XRES); | ||
384 | 248 | } | ||
385 | 249 | |||
386 | 250 | |||
387 | 251 | /** | ||
388 | 252 | * Retrieves the configured in-game resolution. | ||
389 | 253 | * | ||
390 | 254 | * \note For most purposes, you should use \ref Graphic::get_yres instead. | ||
391 | 255 | */ | ||
392 | 256 | int32_t Interactive_Base::get_yres() | ||
393 | 257 | { | ||
394 | 258 | return g_options.pull_section("global").get_int("yres", YRES); | ||
395 | 259 | } | ||
396 | 260 | |||
397 | 261 | |||
398 | 262 | /** | ||
399 | 263 | * Called by \ref Game::postload at the end of the game loading | 233 | * Called by \ref Game::postload at the end of the game loading |
400 | 264 | * sequence. | 234 | * sequence. |
401 | 265 | * | 235 | * |
402 | 266 | 236 | ||
403 | === modified file 'src/wui/interactive_base.h' | |||
404 | --- src/wui/interactive_base.h 2012-12-13 10:41:22 +0000 | |||
405 | +++ src/wui/interactive_base.h 2013-01-07 20:42:25 +0000 | |||
406 | @@ -113,9 +113,6 @@ | |||
407 | 113 | virtual void cleanup_for_load() {}; | 113 | virtual void cleanup_for_load() {}; |
408 | 114 | 114 | ||
409 | 115 | private: | 115 | private: |
410 | 116 | static int32_t get_xres(); | ||
411 | 117 | static int32_t get_yres(); | ||
412 | 118 | |||
413 | 119 | void roadb_add_overlay (); | 116 | void roadb_add_overlay (); |
414 | 120 | void roadb_remove_overlay(); | 117 | void roadb_remove_overlay(); |
415 | 121 | 118 |
Nice change in total. The only issue I have is const SDL_Rect * const *. Maybe it's because i am a bad programmer, but i do not even know what type this is... a const pointer to pointer to constant SDL_Rects? does const SDL_Rect** compile without casting?
I also agree with the struct -> class changes and the simplifications concerning pulling the resolutions from the conf file periodically vs taking the real resolution.
I think here
for (/* init above */; modes && *modes; ++modes)
you could just pull the initialization into the for loop as you do not do anything with the variable anyways.
otherwise looks good to me. Btw, I really enjoy reviewing your code :-). In the past we have always granted push to trunk rights to developers who have made good contributions. Are you interested in this? Then, we also no longer did code reviews and devs just push whatever they think is appropriate - however i am interested in changing this because I'd love to have code review for my own stuff as well in the future. .... this kinda went offtopic of this merge - I'd like to hear the comments of everybody though!