void CSettings::SaveSettings() { CApplication* app = CApplication::GetInstancePointer(); CRobotMain* main = CRobotMain::GetInstancePointer(); Gfx::CEngine* engine = Gfx::CEngine::GetInstancePointer(); Gfx::CCamera* camera = main->GetCamera(); CSoundInterface* sound = app->GetSound(); GetConfigFile().SetBoolProperty("Setup", "Tooltips", m_tooltips); GetConfigFile().SetBoolProperty("Setup", "InterfaceGlint", m_interfaceGlint); GetConfigFile().SetBoolProperty("Setup", "InterfaceRain", m_interfaceRain); GetConfigFile().SetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().SetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().SetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); GetConfigFile().SetBoolProperty("Setup", "OldCameraScroll", camera->GetOldCameraScroll()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertX", camera->GetCameraInvertX()); GetConfigFile().SetBoolProperty("Setup", "CameraInvertY", camera->GetCameraInvertY()); GetConfigFile().SetBoolProperty("Setup", "InterfaceEffect", camera->GetEffect()); GetConfigFile().SetBoolProperty("Setup", "Blood", camera->GetBlood()); GetConfigFile().SetBoolProperty("Setup", "Autosave", main->GetAutosave()); GetConfigFile().SetIntProperty("Setup", "AutosaveInterval", main->GetAutosaveInterval()); GetConfigFile().SetIntProperty("Setup", "AutosaveSlots", main->GetAutosaveSlots()); GetConfigFile().SetBoolProperty("Setup", "ObjectDirty", engine->GetDirty()); GetConfigFile().SetBoolProperty("Setup", "FogMode", engine->GetFog()); GetConfigFile().SetBoolProperty("Setup", "LightMode", engine->GetLightMode()); GetConfigFile().SetIntProperty("Setup", "JoystickIndex", app->GetJoystickEnabled() ? app->GetJoystick().index : -1); GetConfigFile().SetFloatProperty("Setup", "ParticleDensity", engine->GetParticleDensity()); GetConfigFile().SetFloatProperty("Setup", "ClippingDistance", engine->GetClippingDistance()); GetConfigFile().SetIntProperty("Setup", "AudioVolume", sound->GetAudioVolume()); GetConfigFile().SetIntProperty("Setup", "MusicVolume", sound->GetMusicVolume()); GetConfigFile().SetBoolProperty("Setup", "EditIndentMode", engine->GetEditIndentMode()); GetConfigFile().SetIntProperty("Setup", "EditIndentValue", engine->GetEditIndentValue()); GetConfigFile().SetIntProperty("Setup", "MipmapLevel", engine->GetTextureMipmapLevel()); GetConfigFile().SetIntProperty("Setup", "Anisotropy", engine->GetTextureAnisotropyLevel()); GetConfigFile().SetFloatProperty("Setup", "ShadowColor", engine->GetShadowColor()); GetConfigFile().SetFloatProperty("Setup", "ShadowRange", engine->GetShadowRange()); GetConfigFile().SetIntProperty("Setup", "MSAA", engine->GetMultiSample()); GetConfigFile().SetIntProperty("Setup", "FilterMode", engine->GetTextureFilterMode()); GetConfigFile().SetBoolProperty("Setup", "ShadowMapping", engine->GetShadowMapping()); GetConfigFile().SetBoolProperty("Setup", "ShadowMappingQuality", engine->GetShadowMappingQuality()); GetConfigFile().SetIntProperty("Setup", "ShadowMappingResolution", engine->GetShadowMappingOffscreen() ? engine->GetShadowMappingOffscreenResolution() : 0); // Experimental settings GetConfigFile().SetBoolProperty("Experimental", "TerrainShadows", engine->GetTerrainShadows()); CInput::GetInstancePointer()->SaveKeyBindings(); GetConfigFile().SetFloatProperty("Edit", "FontSize", m_fontSize); GetConfigFile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); GetConfigFile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); GetConfigFile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); GetConfigFile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); GetConfigFile().SetBoolProperty("Edit", "IOPublic", m_IOPublic); GetConfigFile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); GetConfigFile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); GetConfigFile().SetFloatProperty("Edit", "IODimX", m_IODim.x); GetConfigFile().SetFloatProperty("Edit", "IODimY", m_IODim.y); std::string lang = ""; LanguageToString(m_language, lang); GetConfigFile().SetStringProperty("Language", "Lang", lang); GetConfigFile().Save(); }
void CSettings::LoadSettings() { CApplication* app = CApplication::GetInstancePointer(); CRobotMain* main = CRobotMain::GetInstancePointer(); Gfx::CEngine* engine = Gfx::CEngine::GetInstancePointer(); Gfx::CCamera* camera = main->GetCamera(); CSoundInterface* sound = app->GetSound(); int iValue = 0; float fValue = 0.0f; bool bValue = false; std::string sValue = ""; GetConfigFile().GetBoolProperty("Setup", "Tooltips", m_tooltips); GetConfigFile().GetBoolProperty("Setup", "InterfaceGlint", m_interfaceGlint); GetConfigFile().GetBoolProperty("Setup", "InterfaceRain", m_interfaceRain); GetConfigFile().GetBoolProperty("Setup", "Soluce4", m_soluce4); GetConfigFile().GetBoolProperty("Setup", "Movies", m_movies); GetConfigFile().GetBoolProperty("Setup", "FocusLostPause", m_focusLostPause); if (GetConfigFile().GetBoolProperty("Setup", "OldCameraScroll", bValue)) camera->SetOldCameraScroll(bValue); if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertX", bValue)) camera->SetCameraInvertX(bValue); if (GetConfigFile().GetBoolProperty("Setup", "CameraInvertY", bValue)) camera->SetCameraInvertY(bValue); if (GetConfigFile().GetBoolProperty("Setup", "InterfaceEffect", bValue)) camera->SetEffect(bValue); if (GetConfigFile().GetBoolProperty("Setup", "Blood", bValue)) camera->SetBlood(bValue); if (GetConfigFile().GetBoolProperty("Setup", "Autosave", bValue)) main->SetAutosave(bValue); if (GetConfigFile().GetIntProperty("Setup", "AutosaveInterval", iValue)) main->SetAutosaveInterval(iValue); if (GetConfigFile().GetIntProperty("Setup", "AutosaveSlots", iValue)) main->SetAutosaveSlots(iValue); if (GetConfigFile().GetBoolProperty("Setup", "ObjectDirty", bValue)) engine->SetDirty(bValue); if (GetConfigFile().GetBoolProperty("Setup", "FogMode", bValue)) { engine->SetFog(bValue); camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok? } if (GetConfigFile().GetBoolProperty("Setup", "LightMode", bValue)) engine->SetLightMode(bValue); if (GetConfigFile().GetIntProperty("Setup", "JoystickIndex", iValue)) { if (iValue >= 0) { auto joysticks = app->GetJoystickList(); for(const auto& joystick : joysticks) { if (joystick.index == iValue) { app->ChangeJoystick(joystick); app->SetJoystickEnabled(true); } } } else { app->SetJoystickEnabled(false); } } if (GetConfigFile().GetFloatProperty("Setup", "ParticleDensity", fValue)) engine->SetParticleDensity(fValue); if (GetConfigFile().GetFloatProperty("Setup", "ClippingDistance", fValue)) engine->SetClippingDistance(fValue); if (GetConfigFile().GetIntProperty("Setup", "AudioVolume", iValue)) sound->SetAudioVolume(iValue); if (GetConfigFile().GetIntProperty("Setup", "MusicVolume", iValue)) sound->SetMusicVolume(iValue); if (GetConfigFile().GetBoolProperty("Setup", "EditIndentMode", bValue)) engine->SetEditIndentMode(bValue); if (GetConfigFile().GetIntProperty("Setup", "EditIndentValue", iValue)) engine->SetEditIndentValue(iValue); if (GetConfigFile().GetIntProperty("Setup", "MipmapLevel", iValue)) engine->SetTextureMipmapLevel(iValue); if (GetConfigFile().GetIntProperty("Setup", "Anisotropy", iValue)) engine->SetTextureAnisotropyLevel(iValue); if (GetConfigFile().GetFloatProperty("Setup", "ShadowColor", fValue)) engine->SetShadowColor(fValue); if (GetConfigFile().GetFloatProperty("Setup", "ShadowRange", fValue)) engine->SetShadowRange(fValue); if (GetConfigFile().GetIntProperty("Setup", "MSAA", iValue)) engine->SetMultiSample(iValue); if (GetConfigFile().GetIntProperty("Setup", "FilterMode", iValue)) engine->SetTextureFilterMode(static_cast<Gfx::TexFilter>(iValue)); if (GetConfigFile().GetBoolProperty("Setup", "ShadowMapping", bValue)) engine->SetShadowMapping(bValue); if (GetConfigFile().GetBoolProperty("Setup", "ShadowMappingQuality", bValue)) engine->SetShadowMappingQuality(bValue); if (GetConfigFile().GetIntProperty("Setup", "ShadowMappingResolution", iValue)) { if (iValue == 0) { engine->SetShadowMappingOffscreen(false); } else { engine->SetShadowMappingOffscreen(true); engine->SetShadowMappingOffscreenResolution(iValue); } } if (GetConfigFile().GetBoolProperty("Experimental", "TerrainShadows", bValue)) engine->SetTerrainShadows(bValue); CInput::GetInstancePointer()->LoadKeyBindings(); GetConfigFile().GetFloatProperty("Edit", "FontSize", m_fontSize); GetConfigFile().GetFloatProperty("Edit", "WindowPosX", m_windowPos.x); GetConfigFile().GetFloatProperty("Edit", "WindowPosY", m_windowPos.y); GetConfigFile().GetFloatProperty("Edit", "WindowDimX", m_windowDim.x); GetConfigFile().GetFloatProperty("Edit", "WindowDimY", m_windowDim.y); GetConfigFile().GetBoolProperty ("Edit", "IOPublic", m_IOPublic); GetConfigFile().GetFloatProperty("Edit", "IOPosX", m_IOPos.x); GetConfigFile().GetFloatProperty("Edit", "IOPosY", m_IOPos.y); GetConfigFile().GetFloatProperty("Edit", "IODimX", m_IODim.x); GetConfigFile().GetFloatProperty("Edit", "IODimY", m_IODim.y); m_language = LANGUAGE_ENV; if (GetConfigFile().GetStringProperty("Language", "Lang", sValue)) { if (!sValue.empty() && !ParseLanguage(sValue, m_language)) { GetLogger()->Error("Failed to parse language '%s' from config file. Default language will be used.\n", sValue.c_str()); } } app->SetLanguage(m_language); }