summaryrefslogtreecommitdiff
path: root/gfx.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-05-14 21:01:57 +0000
committerDarkvater <darkvater@openttd.org>2005-05-14 21:01:57 +0000
commit2aa94201dc19b86e2c1bb5e2c724b52332833ccc (patch)
tree8885092af8efe744ce5c147755c8d5a7d50c3438 /gfx.c
parentd99dddc704e265665b652681855435df66367ecd (diff)
downloadopenttd-2aa94201dc19b86e2c1bb5e2c724b52332833ccc.tar.xz
(svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
- Fix: There would be duplicate entries in the resolutions dropdown box. Copy SDL method or removing duplicates and sort the list. - Feature: in the settings menu, you don't have to click on the arrows anymore, clicking on the dropdown box itself has the same effect. Consistent with other dropdowns in the game
Diffstat (limited to 'gfx.c')
-rw-r--r--gfx.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gfx.c b/gfx.c
index 4bdf40441..6a306c3bc 100644
--- a/gfx.c
+++ b/gfx.c
@@ -1979,15 +1979,16 @@ bool ChangeResInGame(int w, int h)
return true;
}
-void ToggleFullScreen(const bool full_screen)
+static int CDECL compare_res(const void *pa, const void *pb)
{
- _fullscreen = full_screen;
- /* use preset resolutions, not _screen.height and _screen.width. On windows for example
- if Desktop-size is 1280x1024, and gamesize is also 1280x1024, _screen.height will be
- only 1000 because of possible start-bar. For this reason you cannot switch to
- fullscreen mode from this resolution. Use of preset resolution will fix this */
- if (!_video_driver->change_resolution(_cur_resolution[0], _cur_resolution[1]))
- _fullscreen ^= true; // switching resolution failed, put back full_screen to original status
+ int x = ((const uint16*)pa)[0] - ((const uint16*)pb)[0];
+ if (x != 0) return x;
+ return ((const uint16*)pa)[1] - ((const uint16*)pb)[1];
+}
+
+void SortResolutions(int count)
+{
+ qsort(_resolutions, count, sizeof(_resolutions[0]), compare_res);
}
uint16 GetDrawStringPlayerColor(byte player)