summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2008-01-01 14:20:48 +0000
committerbelugas <belugas@openttd.org>2008-01-01 14:20:48 +0000
commit3dd61f423ad6c79f319388625f2223d0e46a2f16 (patch)
tree4649001ed8ff619fb2275a558ad17a1e8a942a9c /src/video
parenta8611311ac842618f0be9e20b8339e7adbf86738 (diff)
downloadopenttd-3dd61f423ad6c79f319388625f2223d0e46a2f16.tar.xz
(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.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/cocoa/cocoa_v.h2
-rw-r--r--src/video/cocoa/cocoa_v.mm3
-rw-r--r--src/video/dedicated_v.cpp2
-rw-r--r--src/video/dedicated_v.h2
-rw-r--r--src/video/null_v.cpp2
-rw-r--r--src/video/null_v.h2
-rw-r--r--src/video/sdl_v.cpp4
-rw-r--r--src/video/sdl_v.h2
-rw-r--r--src/video/video_driver.hpp2
-rw-r--r--src/video/win32_v.cpp15
-rw-r--r--src/video/win32_v.h2
11 files changed, 20 insertions, 18 deletions
diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h
index 3a7276bb2..10c408f0a 100644
--- a/src/video/cocoa/cocoa_v.h
+++ b/src/video/cocoa/cocoa_v.h
@@ -19,7 +19,7 @@ public:
/* virtual */ bool ChangeResolution(int w, int h);
- /* virtual */ void ToggleFullscreen(bool fullscreen);
+ /* virtual */ bool ToggleFullscreen(bool fullscreen);
};
class FVideoDriver_Cocoa: public VideoDriverFactory<FVideoDriver_Cocoa> {
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm
index 3ca9f8113..2a5eea7be 100644
--- a/src/video/cocoa/cocoa_v.mm
+++ b/src/video/cocoa/cocoa_v.mm
@@ -361,7 +361,7 @@ bool VideoDriver_Cocoa::ChangeResolution(int w, int h)
return ret;
}
-void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
+bool VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
{
bool oldfs;
@@ -386,6 +386,7 @@ void VideoDriver_Cocoa::ToggleFullscreen(bool full_screen)
QZ_GameSizeChanged();
QZ_UpdateVideoModes();
+ return _cocoa_subdriver->IsFullscreen() == full_screen;
}
diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp
index 7ca1db6ea..97b53e87f 100644
--- a/src/video/dedicated_v.cpp
+++ b/src/video/dedicated_v.cpp
@@ -168,7 +168,7 @@ void VideoDriver_Dedicated::Stop()
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()
diff --git a/src/video/dedicated_v.h b/src/video/dedicated_v.h
index a2de1c275..0ade00f92 100644
--- a/src/video/dedicated_v.h
+++ b/src/video/dedicated_v.h
@@ -17,7 +17,7 @@ public:
/* virtual */ bool ChangeResolution(int w, int h);
- /* virtual */ void ToggleFullscreen(bool fullscreen);
+ /* virtual */ bool ToggleFullscreen(bool fullscreen);
};
class FVideoDriver_Dedicated: public VideoDriverFactory<FVideoDriver_Dedicated> {
diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp
index 7d2fa512d..f1942a8ae 100644
--- a/src/video/null_v.cpp
+++ b/src/video/null_v.cpp
@@ -38,4 +38,4 @@ void VideoDriver_Null::MainLoop()
bool VideoDriver_Null::ChangeResolution(int w, int h) { return false; }
-void VideoDriver_Null::ToggleFullscreen(bool fs) {}
+bool VideoDriver_Null::ToggleFullscreen(bool fs) { return false; }
diff --git a/src/video/null_v.h b/src/video/null_v.h
index d2e8b4b18..e32a88536 100644
--- a/src/video/null_v.h
+++ b/src/video/null_v.h
@@ -20,7 +20,7 @@ public:
/* virtual */ bool ChangeResolution(int w, int h);
- /* virtual */ void ToggleFullscreen(bool fullscreen);
+ /* virtual */ bool ToggleFullscreen(bool fullscreen);
};
class FVideoDriver_Null: public VideoDriverFactory<FVideoDriver_Null> {
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index 4461fbf32..cf0e9971d 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -521,14 +521,16 @@ bool VideoDriver_SDL::ChangeResolution(int w, int h)
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 */
diff --git a/src/video/sdl_v.h b/src/video/sdl_v.h
index fdfded49c..ab56f99c3 100644
--- a/src/video/sdl_v.h
+++ b/src/video/sdl_v.h
@@ -17,7 +17,7 @@ public:
/* virtual */ bool ChangeResolution(int w, int h);
- /* virtual */ void ToggleFullscreen(bool fullscreen);
+ /* virtual */ bool ToggleFullscreen(bool fullscreen);
};
class FVideoDriver_SDL: public VideoDriverFactory<FVideoDriver_SDL> {
diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp
index 048c233b9..423ab92e1 100644
--- a/src/video/video_driver.hpp
+++ b/src/video/video_driver.hpp
@@ -13,7 +13,7 @@ public:
virtual bool ChangeResolution(int w, int h) = 0;
- virtual void ToggleFullscreen(bool fullscreen) = 0;
+ virtual bool ToggleFullscreen(bool fullscreen) = 0;
};
class VideoDriverFactoryBase: public DriverFactoryBase {
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 5fb4a4c60..ceac2b3b6 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -210,7 +210,7 @@ static void CALLBACK TrackMouseTimerProc(HWND hwnd, UINT msg, UINT event, DWORD
}
}
-static void MakeWindow(bool full_screen)
+static bool MakeWindow(bool full_screen)
{
_fullscreen = full_screen;
@@ -242,8 +242,8 @@ static void MakeWindow(bool full_screen)
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 @@ static void MakeWindow(bool full_screen)
}
}
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 @@ bool VideoDriver_Win32::ChangeResolution(int w, int h)
_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);
}
diff --git a/src/video/win32_v.h b/src/video/win32_v.h
index 11ee523ef..223772d75 100644
--- a/src/video/win32_v.h
+++ b/src/video/win32_v.h
@@ -17,7 +17,7 @@ public:
/* virtual */ bool ChangeResolution(int w, int h);
- /* virtual */ void ToggleFullscreen(bool fullscreen);
+ /* virtual */ bool ToggleFullscreen(bool fullscreen);
};
class FVideoDriver_Win32: public VideoDriverFactory<FVideoDriver_Win32> {