Mercurial > hg > openttd
changeset 8171:df1e18335376 draft
(svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
-Fix[FS#1519]: When you can not use this resolution at full screen, now you'll know that it failed.
As for the reason it did not work, each computer/OS has its reason.
author | belugas <belugas@openttd.org> |
---|---|
date | Tue, 01 Jan 2008 14:20:48 +0000 |
parents | a8be61a5213c |
children | 465c2493606f |
files | src/gfx.cpp src/gfx_func.h src/lang/english.txt src/settings_gui.cpp src/video/cocoa/cocoa_v.h src/video/cocoa/cocoa_v.mm src/video/dedicated_v.cpp src/video/dedicated_v.h src/video/null_v.cpp src/video/null_v.h src/video/sdl_v.cpp src/video/sdl_v.h src/video/video_driver.hpp src/video/win32_v.cpp src/video/win32_v.h |
diffstat | 15 files changed, 30 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1275,12 +1275,13 @@ return (_screen.width == width && _screen.height == height) || _video_driver->ChangeResolution(width, height); } -void ToggleFullScreen(bool fs) +bool ToggleFullScreen(bool fs) { - _video_driver->ToggleFullscreen(fs); + bool result = _video_driver->ToggleFullscreen(fs); if (_fullscreen != fs && _num_resolutions == 0) { DEBUG(driver, 0, "Could not find a suitable fullscreen resolution"); } + return result; } static int CDECL compare_res(const void *pa, const void *pb)
--- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -151,7 +151,7 @@ void UndrawMouseCursor(); bool ChangeResInGame(int w, int h); void SortResolutions(int count); -void ToggleFullScreen(bool fs); +bool ToggleFullScreen(bool fs); /* gfx.cpp */ #define ASCII_LETTERSTART 32
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -941,6 +941,7 @@ STR_OPTIONS_FULLSCREEN :{BLACK}Fullscreen STR_OPTIONS_FULLSCREEN_TIP :{BLACK}Check this box to play OpenTTD fullscreen mode +STR_FULLSCREEN_FAILED :{WHITE}Fullscreen mode failed STR_OPTIONS_RES :{BLACK}Screen resolution STR_OPTIONS_RES_CBO :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
--- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -201,8 +201,11 @@ ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), 27, 0, 0); return; case 28: /* Click fullscreen on/off */ - w->SetWidgetLoweredState(28, !_fullscreen); - ToggleFullScreen(!_fullscreen); // toggle full-screen on/off + /* try to toggle full-screen on/off */ + if (!ToggleFullScreen(!_fullscreen)) { + ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0); + } + w->SetWidgetLoweredState(28, _fullscreen); SetWindowDirty(w); return; case 30: case 31: /* Setup screenshot format dropdown */
--- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -19,7 +19,7 @@ /* virtual */ bool ChangeResolution(int w, int h); - /* virtual */ void ToggleFullscreen(bool fullscreen); + /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
--- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -361,7 +361,7 @@ return ret; } -void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen) +bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen) { bool oldfs; @@ -386,6 +386,7 @@ QZ_GameSizeChanged(); QZ_UpdateVideoModes(); + return _cocoa_subdriver->IsFullscreen() == full_screen; }
--- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -168,7 +168,7 @@ void VideoDriver_Dedicated::MakeDirty(int left, int top, int width, int height) {} bool VideoDriver_Dedicated::ChangeResolution(int w, int h) { return false; } -void VideoDriver_Dedicated::ToggleFullscreen(bool fs) {} +bool VideoDriver_Dedicated::ToggleFullscreen(bool fs) { return false; } #if defined(UNIX) || defined(__OS2__) || defined(PSP) static bool InputWaiting()
--- a/src/video/dedicated_v.h +++ b/src/video/dedicated_v.h @@ -17,7 +17,7 @@ /* virtual */ bool ChangeResolution(int w, int h); - /* virtual */ void ToggleFullscreen(bool fullscreen); + /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
--- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -38,4 +38,4 @@ bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; } -void VideoDriver_Null::ToggleFullscreen(bool fs) {} +bool VideoDriver_Null::ToggleFullscreen(bool fs) { return false; }
--- a/src/video/null_v.h +++ b/src/video/null_v.h @@ -20,7 +20,7 @@ /* virtual */ bool ChangeResolution(int w, int h); - /* virtual */ void ToggleFullscreen(bool fullscreen); + /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
--- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -521,14 +521,16 @@ return CreateMainSurface(w, h); } -void VideoDriver_SDL::ToggleFullscreen(bool fullscreen) +bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen) { _fullscreen = fullscreen; GetVideoModes(); // get the list of available video modes if (_num_resolutions == 0 || !this->ChangeResolution(_cur_resolution[0], _cur_resolution[1])) { // switching resolution failed, put back full_screen to original status _fullscreen ^= true; + return false; } + return true; } #endif /* WITH_SDL */
--- a/src/video/sdl_v.h +++ b/src/video/sdl_v.h @@ -17,7 +17,7 @@ /* virtual */ bool ChangeResolution(int w, int h); - /* virtual */ void ToggleFullscreen(bool fullscreen); + /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
--- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -13,7 +13,7 @@ virtual bool ChangeResolution(int w, int h) = 0; - virtual void ToggleFullscreen(bool fullscreen) = 0; + virtual bool ToggleFullscreen(bool fullscreen) = 0; }; class VideoDriverFactoryBase: public DriverFactoryBase {
--- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -210,7 +210,7 @@ } } -static void MakeWindow(bool full_screen) +static bool MakeWindow(bool full_screen) { _fullscreen = full_screen; @@ -242,8 +242,8 @@ settings.dmDisplayFrequency = _display_hz; if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) { - MakeWindow(false); - return; + MakeWindow(false); // don't care about the result + return false; // the request failed } } else if (_wnd.fullscreen) { // restore display? @@ -291,6 +291,7 @@ } } GameSizeChanged(); // invalidate all windows, force redraw + return true; // the request succedded } static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -895,12 +896,10 @@ _wnd.width = _wnd.width_org = w; _wnd.height = _wnd.height_org = h; - MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching - - return true; + return MakeWindow(_fullscreen); // _wnd.fullscreen screws up ingame resolution switching } -void VideoDriver_Win32::ToggleFullscreen(bool full_screen) +bool VideoDriver_Win32::ToggleFullscreen(bool full_screen) { - MakeWindow(full_screen); + return MakeWindow(full_screen); }
--- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -17,7 +17,7 @@ /* virtual */ bool ChangeResolution(int w, int h); - /* virtual */ void ToggleFullscreen(bool fullscreen); + /* virtual */ bool ToggleFullscreen(bool fullscreen); }; class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {