diff options
author | Darkvater <darkvater@openttd.org> | 2005-05-14 21:01:57 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2005-05-14 21:01:57 +0000 |
commit | 2aa94201dc19b86e2c1bb5e2c724b52332833ccc (patch) | |
tree | 8885092af8efe744ce5c147755c8d5a7d50c3438 /win32.c | |
parent | d99dddc704e265665b652681855435df66367ecd (diff) | |
download | openttd-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 'win32.c')
-rw-r--r-- | win32.c | 37 |
1 files changed, 23 insertions, 14 deletions
@@ -322,11 +322,10 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP } } break; - case WM_SYSKEYDOWN: /* user presses F10 or Alt, both activating the title-menu */ switch (wParam) { - case VK_RETURN: /* Full Screen */ - MakeWindow(!_wnd.fullscreen); + case VK_RETURN: case 0x46: /* Full Screen on ALT + ENTER/F(VK_F) */ + ToggleFullScreen(!_wnd.fullscreen); return 0; case VK_MENU: /* Just ALT */ return 0; // do nothing @@ -602,26 +601,34 @@ static void FindResolutions(void) int i = 0, n = 0; DEVMODE dm; - while (EnumDisplaySettings(NULL, i++, &dm)) { - if (dm.dmBitsPerPel == 8 && - IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) && - IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1) && ( - n == 0 || - _resolutions[n - 1][0] != dm.dmPelsWidth || - _resolutions[n - 1][1] != dm.dmPelsHeight - )) { - _resolutions[n][0] = dm.dmPelsWidth; - _resolutions[n][1] = dm.dmPelsHeight; - if (++n == lengthof(_resolutions)) break; + while (EnumDisplaySettings(NULL, i++, &dm) != 0) { + if (dm.dmBitsPerPel == 8 && IS_INT_INSIDE(dm.dmPelsWidth, 640, MAX_SCREEN_WIDTH + 1) && + IS_INT_INSIDE(dm.dmPelsHeight, 480, MAX_SCREEN_HEIGHT + 1)){ + int j; + for (j = 0; j < n; j++) { + if (_resolutions[j][0] == dm.dmPelsWidth && _resolutions[j][1] == dm.dmPelsHeight) break; + } + + /* In the previous loop we have checked already existing/added resolutions if + * they are the same as the new ones. If this is not the case (j == n); we have + * looped all and found none, add the new one to the list. If we have reached the + * maximum amount of resolutions, then quit querying the display */ + if (j == n) { + _resolutions[j][0] = dm.dmPelsWidth; + _resolutions[j][1] = dm.dmPelsHeight; + if (++n == lengthof(_resolutions)) break; + } } } + /* We have found no resolutions, show the default list */ if (n == 0) { memcpy(_resolutions, default_resolutions, sizeof(default_resolutions)); n = lengthof(default_resolutions); } _num_resolutions = n; + SortResolutions(_num_resolutions); } @@ -776,6 +783,8 @@ static bool Win32GdiChangeRes(int w, int h) return true; } +void ToggleFullScreen(bool full_screen) {MakeWindow(full_screen);} + const HalVideoDriver _win32_video_driver = { Win32GdiStart, Win32GdiStop, |