Changed: Added isWindowMaximized and getRyzomModes functions

This commit is contained in:
kervala 2010-10-18 13:11:28 +02:00
parent 7db03223fc
commit 24874b0356
2 changed files with 93 additions and 0 deletions

View file

@ -1440,13 +1440,31 @@ void setVideoMode(const UDriver::CMode &mode)
UDriver::CMode oldMode;
oldMode.Windowed = true; // getCurrentScreenMode may fail if first init ...
Driver->getCurrentScreenMode(oldMode);
bool wasMaximized = isWindowMaximized();
Driver->setMode(mode);
bool isMaximized = isWindowMaximized();
if (oldMode.Windowed && !mode.Windowed) // going to fullscreen ?
{
/*CInterfaceManager *pIM = CInterfaceManager::getInstance();
pIM->movePointerAbs((sint32) mode.Width / 2, (sint32) mode.Height / 2);
Driver->setMousePos(0.5f, 0.5f);*/
}
else if ((!oldMode.Windowed || wasMaximized) && (mode.Windowed && !isMaximized)) // leaving fullscreen ?
{
UDriver::CMode screenMode;
uint32 posX = 0;
uint32 posY = 0;
if (Driver->getCurrentScreenMode(screenMode))
{
// position is not saved in config so center the window
posX = (screenMode.Width - Driver->getWindowWidth())/2;
posY = (screenMode.Height - Driver->getWindowHeight())/2;
}
Driver->setWindowPos(posX, posY);
}
}
uint getCurrentColorDepth()
@ -1464,3 +1482,72 @@ uint getCurrentColorDepth()
return CSystemUtils::getCurrentColorDepth();
}
bool isWindowMaximized()
{
UDriver::CMode screenMode;
uint32 width, height;
Driver->getWindowSize(width, height);
return (Driver->getCurrentScreenMode(screenMode) && screenMode.Windowed &&
screenMode.Width == width && screenMode.Height == height);
}
sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList)
{
// **** Init Video Modes
Driver->getModes(videoModes);
// Remove modes under 800x600 and get the unique strings
sint i, j, nFoundMode = -1;
for (i=0; i < (sint)videoModes.size(); ++i)
{
if ((videoModes[i].Width < 800) || (videoModes[i].Height < 600))
{
videoModes.erase(videoModes.begin()+i);
--i;
}
else
{
bool bFound = false;
string tmp = toString(videoModes[i].Width)+" x "+toString(videoModes[i].Height);
for (j = 0; j < (sint)stringModeList.size(); ++j)
{
if (stringModeList[j] == tmp)
{
bFound = true;
break;
}
}
if (!bFound)
{
stringModeList.push_back(tmp);
if ((videoModes[i].Width <= ClientCfg.Width) && (videoModes[i].Height <= ClientCfg.Height))
{
if (nFoundMode == -1)
{
nFoundMode = j;
}
else
{
if ((videoModes[i].Width >= videoModes[nFoundMode].Width) &&
(videoModes[i].Height >= videoModes[nFoundMode].Height))
nFoundMode = j;
}
}
}
}
}
// If no modes are available, display a message and exit
if (!ClientCfg.Windowed && (nFoundMode == -1 || stringModeList.empty()))
{
Driver->systemMessageBox("No Video Modes available!\n"
"Minimum Video mode to play Ryzom is 800x600.\n",
"No Video Mode!",
NL3D::UDriver::okType,
NL3D::UDriver::exclamationIcon);
exit(EXIT_SUCCESS);
}
return nFoundMode;
}

View file

@ -29,6 +29,7 @@
#include "nel/misc/quat.h"
#include "nel/misc/rgba.h"
#include "nel/3d/u_instance.h"
#include "nel/3d/u_driver.h"
#include "game_share/slot_types.h"
#include "game_share/mode_and_behaviour.h"
@ -242,6 +243,11 @@ void setVideoMode(const NL3D::UDriver::CMode &mode);
// Get the current color depth (8, 16, or 32). In windowed mode, this will be the desktop color depth, in fullscreen mode, the color depth of the framebuffer.
uint getCurrentColorDepth();
// get maximized
bool isWindowMaximized();
sint getRyzomModes(std::vector<NL3D::UDriver::CMode> &videoModes, std::vector<std::string> &stringModeList);
#endif // CL_MISC_H
/* End of misc.h */