Changed: Fall back to windowed mode if we can't set a fullscreen mode

This commit is contained in:
kervala 2010-11-08 23:42:26 +01:00
parent fba159dbbd
commit 65f3cff7c5

View file

@ -1437,19 +1437,23 @@ void makeInstanceTransparent(UInstance &inst, uint8 opacity, bool disableZWrite)
void setVideoMode(const UDriver::CMode &mode) void setVideoMode(const UDriver::CMode &mode)
{ {
UDriver::CMode oldMode; UDriver::CMode oldMode, newMode = mode;
oldMode.Windowed = true; // getCurrentScreenMode may fail if first init ... oldMode.Windowed = true; // getCurrentScreenMode may fail if first init ...
Driver->getCurrentScreenMode(oldMode); Driver->getCurrentScreenMode(oldMode);
bool wasMaximized = isWindowMaximized(); bool wasMaximized = isWindowMaximized();
Driver->setMode(mode); if (!Driver->setMode(newMode) && !newMode.Windowed)
{
// failed to switch to mode, fall back to windowed
newMode.Windowed = true;
}
bool isMaximized = isWindowMaximized(); bool isMaximized = isWindowMaximized();
if (oldMode.Windowed && !mode.Windowed) // going to fullscreen ? if (oldMode.Windowed && !newMode.Windowed) // going to fullscreen ?
{ {
/*CInterfaceManager *pIM = CInterfaceManager::getInstance(); /*CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->movePointerAbs((sint32) mode.Width / 2, (sint32) mode.Height / 2); pIM->movePointerAbs((sint32) mode.Width / 2, (sint32) mode.Height / 2);
Driver->setMousePos(0.5f, 0.5f);*/ Driver->setMousePos(0.5f, 0.5f);*/
} }
else if ((!oldMode.Windowed || wasMaximized) && (mode.Windowed && !isMaximized)) // leaving fullscreen ? else if ((!oldMode.Windowed || wasMaximized) && (newMode.Windowed && !isMaximized)) // leaving fullscreen ?
{ {
UDriver::CMode screenMode; UDriver::CMode screenMode;
@ -1538,15 +1542,11 @@ sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<st
} }
} }
// If no modes are available, display a message and exit // If no modes are available, fallback to windowed mode
if (!ClientCfg.Windowed && (nFoundMode == -1 || stringModeList.empty())) if (nFoundMode == -1)
{ {
Driver->systemMessageBox("No Video Modes available!\n" nlwarning("Mode %ux%u not found, fall back to windowed", (uint)ClientCfg.Width, (uint)ClientCfg.Height);
"Minimum Video mode to play Ryzom is 800x600.\n", ClientCfg.Windowed = true;
"No Video Mode!",
NL3D::UDriver::okType,
NL3D::UDriver::exclamationIcon);
exit(EXIT_SUCCESS);
} }
return nFoundMode; return nFoundMode;