Changed: Used write* methods to write variables

This commit is contained in:
kervala 2010-11-02 21:21:45 +01:00
parent dbaf740e76
commit b744f44c67

View file

@ -1972,6 +1972,11 @@ void CClientConfig::release ()
// Do we have to save the cfg file ? // Do we have to save the cfg file ?
if (ClientCfg.SaveConfig) if (ClientCfg.SaveConfig)
{ {
// Save values
try
{
CConfigFile::CVar *varPtr = NULL;
// Driver still alive ? // Driver still alive ?
if (Driver && Driver->isActive ()) if (Driver && Driver->isActive ())
{ {
@ -1981,46 +1986,29 @@ void CClientConfig::release ()
Driver->getWindowPos(x, y); Driver->getWindowPos(x, y);
Driver->getWindowSize(width, height); Driver->getWindowSize(width, height);
// Save values
try
{
CConfigFile::CVar *varPtr = NULL;
// Are we in window mode ? // Are we in window mode ?
if (ClientCfg.Windowed /* && !isWindowMaximized() */) if (ClientCfg.Windowed /* && !isWindowMaximized() */)
{ {
// Save windows position // Save windows position
varPtr = ClientCfg.ConfigFile.getVarPtr ("PositionX"); writeInt("PositionX", x);
if (varPtr) writeInt("PositionY", y);
varPtr->forceAsInt (x);
varPtr = ClientCfg.ConfigFile.getVarPtr ("PositionY");
if (varPtr)
varPtr->forceAsInt (y);
// Save windows size // Save windows size
varPtr = ClientCfg.ConfigFile.getVarPtr ("Width"); writeInt("Width", std::max((sint)width, 800));
if (varPtr) writeInt("Height", std::max((sint)height, 600));
varPtr->forceAsInt (std::max((int)width, 800)); }
varPtr = ClientCfg.ConfigFile.getVarPtr ("Height");
if (varPtr)
varPtr->forceAsInt (std::max((int)height, 600));
} }
// Save if in FPV or TPV. // Save if in FPV or TPV.
varPtr = ClientCfg.ConfigFile.getVarPtr("FPV"); writeBool("FPV", ClientCfg.FPV);
if(varPtr)
varPtr->forceAsInt((sint)ClientCfg.FPV);
// Save the camera distance // Save the camera distance
varPtr = ClientCfg.ConfigFile.getVarPtr("CameraDistance"); writeDouble("CameraDistance", ClientCfg.CameraDistance);
if(varPtr)
varPtr->forceAsDouble(ClientCfg.CameraDistance);
} }
catch (Exception &e) catch (Exception &e)
{ {
nlwarning ("Error while set config file variables : %s", e.what ()); nlwarning ("Error while set config file variables : %s", e.what ());
} }
}
// Save it // Save it
ClientCfg.ConfigFile.save (); ClientCfg.ConfigFile.save ();