Use configured resolution for login/outgame/ingame

develop
Nimetu 3 years ago
parent 5064f0417b
commit 2efc16ce52

@ -195,38 +195,9 @@ bool hasPrivilegeEG() { return (UserPrivileges.find(":EG:") != std::string::npos
// Restore the video mode (fullscreen for example) after the connection (done in a window)
void connectionRestoreVideoMode ()
{
// Setup full screen if we have to
UDriver::CMode mode;
Driver->getCurrentScreenMode(mode);
if (mode.Windowed)
{
uint32 width, height;
Driver->getWindowSize(width, height);
mode.Width = width;
mode.Height = height;
}
// don't allow sizes smaller than 1024x768
if (ClientCfg.Width < 1024) ClientCfg.Width = 1024;
if (ClientCfg.Height < 768) ClientCfg.Height = 768;
if (StereoDisplay)
StereoDisplayAttached = StereoDisplay->attachToDisplay();
if (!StereoDisplayAttached && (
(ClientCfg.Windowed != mode.Windowed) ||
(ClientCfg.Width != mode.Width) ||
(ClientCfg.Height != mode.Height)))
{
mode.Windowed = ClientCfg.Windowed;
mode.Depth = uint8(ClientCfg.Depth);
mode.Width = ClientCfg.Width;
mode.Height = ClientCfg.Height;
mode.Frequency = ClientCfg.Frequency;
setVideoMode(mode);
}
// And setup hardware mouse if we have to
InitMouseWithCursor (ClientCfg.HardwareCursor && !StereoDisplayAttached);
SetMouseFreeLook ();

@ -1061,43 +1061,45 @@ void prelogInit()
return;
}
// used to determine screen default resolution
if (ClientCfg.Width < 800 || ClientCfg.Height < 600)
UDriver::CMode mode;
// first run (no client.cfg)
if (ClientCfg.Width == 0 || ClientCfg.Height == 0)
{
UDriver::CMode mode;
CConfigFile::CVar *varPtr = NULL;
if (!ClientCfg.Windowed && Driver->getCurrentScreenMode(mode))
if (Driver->getCurrentScreenMode(mode))
{
// fullscreen, using monitor resolution
mode.Windowed = false;
ClientCfg.Windowed = mode.Windowed;
ClientCfg.Width = mode.Width;
ClientCfg.Height = mode.Height;
ClientCfg.Depth = mode.Depth;
ClientCfg.Frequency = mode.Frequency;
// update client.cfg with detected depth and frequency
varPtr = ClientCfg.ConfigFile.getVarPtr("Depth");
if(varPtr)
varPtr->forceAsInt(ClientCfg.Depth);
varPtr = ClientCfg.ConfigFile.getVarPtr("Frequency");
if(varPtr)
varPtr->forceAsInt(ClientCfg.Frequency);
}
else
{
// fallback
ClientCfg.Windowed = true;
ClientCfg.Width = 1024;
ClientCfg.Height = 768;
}
// update client.cfg with detected resolution
varPtr = ClientCfg.ConfigFile.getVarPtr("Width");
if(varPtr)
varPtr->forceAsInt(ClientCfg.Width);
ClientCfg.writeBool("FullScreen", !ClientCfg.Windowed, true);
ClientCfg.writeInt("Width", ClientCfg.Width, true);
ClientCfg.writeInt("Height", ClientCfg.Height, true);
ClientCfg.writeInt("Depth", ClientCfg.Depth, true);
ClientCfg.writeInt("Frequency", ClientCfg.Frequency, true);
varPtr = ClientCfg.ConfigFile.getVarPtr("Height");
if(varPtr)
varPtr->forceAsInt(ClientCfg.Height);
ClientCfg.ConfigFile.save();
}
else
{
mode.Windowed = ClientCfg.Windowed;
mode.Width = ClientCfg.Width;
mode.Height = ClientCfg.Height;
mode.Depth = ClientCfg.Depth;
mode.Frequency = ClientCfg.Frequency;
}
CLoginProgressPostThread::getInstance().step(CLoginStep(LoginStep_VideoModeSetup, "login_step_video_mode_setup"));
@ -1107,25 +1109,6 @@ void prelogInit()
// Check the driver is not is 16 bits
checkDriverDepth ();
UDriver::CMode mode;
if (Driver->getCurrentScreenMode(mode))
{
// use current mode if its smaller than 1024x768
// mode should be windowed already, but incase its not, use the mode as is
if (mode.Windowed && (mode.Width > 1024 && mode.Height > 768))
{
mode.Width = 1024;
mode.Height = 768;
}
}
else
{
mode.Width = 1024;
mode.Height = 768;
mode.Windowed = true;
}
// Disable Hardware Vertex Program.
if(ClientCfg.DisableVtxProgram)
Driver->disableHardwareVertexProgram();
@ -1260,10 +1243,11 @@ void prelogInit()
else
{
// position is not saved in config so center the window
if (Driver->getCurrentScreenMode(mode))
UDriver::CMode tmp;
if (Driver->getCurrentScreenMode(tmp))
{
posX = (mode.Width - Driver->getWindowWidth())/2;
posY = (mode.Height - Driver->getWindowHeight())/2;
posX = (tmp.Width - Driver->getWindowWidth())/2;
posY = (tmp.Height - Driver->getWindowHeight())/2;
}
}

Loading…
Cancel
Save