From 02c24fbf27a1f36ad02310a908301ae8c2af622b Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 19 Jul 2015 15:30:30 +0200 Subject: [PATCH] CProfile -> CConfigFile --- src/CMakeLists.txt | 2 +- src/app/app.cpp | 10 +- src/app/app.h | 4 +- src/app/controller.cpp | 10 +- src/app/controller.h | 2 +- src/app/input.cpp | 18 +- src/common/{profile.cpp => config_file.cpp} | 149 +++++++------- src/common/{profile.h => config_file.h} | 35 ++-- src/graphics/engine/engine.cpp | 6 +- src/graphics/opengl/gl21device.cpp | 4 +- src/graphics/opengl/gl33device.cpp | 4 +- src/object/player_progress.cpp | 6 +- src/object/robotmain.cpp | 76 ++++--- src/object/robotmain.h | 7 +- src/ui/maindialog.cpp | 186 +++++++++--------- test/unit/CMakeLists.txt | 2 +- test/unit/common/colobot.ini | 7 - ...{profile_test.cpp => config_file_test.cpp} | 22 +-- 18 files changed, 258 insertions(+), 292 deletions(-) rename src/common/{profile.cpp => config_file.cpp} (53%) rename src/common/{profile.h => config_file.h} (83%) rename test/unit/common/{profile_test.cpp => config_file_test.cpp} (66%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 60403812..56002ea6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,7 +86,7 @@ set(BASE_SOURCES common/logger.cpp common/misc.cpp common/pathman.cpp - common/profile.cpp + common/config_file.cpp common/regex_utils.cpp common/resources/inputstream.cpp common/resources/inputstreambuffer.cpp diff --git a/src/app/app.cpp b/src/app/app.cpp index 55323c0e..955e8827 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -102,7 +102,7 @@ struct ApplicationPrivate CApplication::CApplication() : m_private(MakeUnique()) , m_eventQueue(MakeUnique()) - , m_profile(MakeUnique()) + , m_configFile(MakeUnique()) , m_input(MakeUnique()) , m_pathManager(MakeUnique()) { @@ -395,13 +395,13 @@ bool CApplication::Create() } m_pathManager->InitPaths(); - if (!GetProfile().Init()) + if (!GetConfigFile().Init()) { GetLogger()->Warn("Config not found. Default values will be used!\n"); defaultValues = true; } - if (GetProfile().GetStringProperty("Language", "Lang", path)) { + if (GetConfigFile().GetStringProperty("Language", "Lang", path)) { Language language; if (ParseLanguage(path, language)) { m_language = language; @@ -478,7 +478,7 @@ bool CApplication::Create() std::vector modes; GetVideoResolutionList(modes, true, true); - if ( GetProfile().GetStringProperty("Setup", "Resolution", sValue) && !m_resolutionOverride ) + if ( GetConfigFile().GetStringProperty("Setup", "Resolution", sValue) && !m_resolutionOverride ) { std::istringstream resolution(sValue); std::string ws, hs; @@ -499,7 +499,7 @@ bool CApplication::Create() } } - if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) && !m_resolutionOverride ) + if ( GetConfigFile().GetIntProperty("Setup", "Fullscreen", iValue) && !m_resolutionOverride ) { m_deviceConfig.fullScreen = (iValue == 1); } diff --git a/src/app/app.h b/src/app/app.h index d4ad303c..650513c3 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -27,7 +27,7 @@ #include "common/event.h" #include "common/global.h" #include "common/singleton.h" -#include "common/profile.h" +#include "common/config_file.h" #include "graphics/core/device.h" #include "graphics/engine/engine.h" @@ -368,7 +368,7 @@ protected: //! Game controller - game engine and UI std::unique_ptr m_controller; //! Profile (INI) reader/writer - std::unique_ptr m_profile; + std::unique_ptr m_configFile; //! Input manager std::unique_ptr m_input; //! Path manager diff --git a/src/app/controller.cpp b/src/app/controller.cpp index f1164ab5..00179f2a 100644 --- a/src/app/controller.cpp +++ b/src/app/controller.cpp @@ -26,17 +26,17 @@ -CController::CController(CApplication* app, bool loadProfile) +CController::CController(CApplication* app, bool configLoaded) : m_app(app) , m_main(new CRobotMain(this)) , m_dialog(new Ui::CMainDialog()) { - m_main->Create(loadProfile); + m_main->Create(); m_dialog->Create(); - if (!loadProfile) - m_main->CreateIni(); + if (configLoaded) + m_main->LoadConfigFile(); else - m_main->LoadIni(); + m_main->CreateConfigFile(); } CController::~CController() diff --git a/src/app/controller.h b/src/app/controller.h index 6384c0f4..5bc42090 100644 --- a/src/app/controller.h +++ b/src/app/controller.h @@ -43,7 +43,7 @@ class CMainDialog; class CController { public: - CController(CApplication* app, bool loadProfile = true); + CController(CApplication* app, bool configLoaded = true); ~CController(); //! Return CApplication instance diff --git a/src/app/input.cpp b/src/app/input.cpp index 23220b9d..9cce70e6 100644 --- a/src/app/input.cpp +++ b/src/app/input.cpp @@ -21,7 +21,7 @@ #include "common/logger.h" -#include "common/profile.h" +#include "common/config_file.h" #include "common/restext.h" #include "graphics/engine/engine.h" @@ -314,17 +314,17 @@ void CInput::SaveKeyBindings() key.str(""); key << b.primary << " " << b.secondary; - CProfile::GetInstancePointer()->SetStringProperty("Keybindings", keyTable[static_cast(i)], key.str()); + CConfigFile::GetInstancePointer()->SetStringProperty("Keybindings", keyTable[static_cast(i)], key.str()); } for (int i = 0; i < JOY_AXIS_SLOT_MAX; i++) { JoyAxisBinding b = GetJoyAxisBinding(static_cast(i)); - CProfile::GetInstancePointer()->SetIntProperty("Setup", "JoystickAxisBinding"+boost::lexical_cast(i), b.axis); - CProfile::GetInstancePointer()->SetIntProperty("Setup", "JoystickAxisInvert"+boost::lexical_cast(i), b.invert); + CConfigFile::GetInstancePointer()->SetIntProperty("Setup", "JoystickAxisBinding"+boost::lexical_cast(i), b.axis); + CConfigFile::GetInstancePointer()->SetIntProperty("Setup", "JoystickAxisInvert"+boost::lexical_cast(i), b.invert); } - CProfile::GetInstancePointer()->SetFloatProperty("Setup", "JoystickDeadzone", GetJoystickDeadzone()); + CConfigFile::GetInstancePointer()->SetFloatProperty("Setup", "JoystickDeadzone", GetJoystickDeadzone()); } void CInput::LoadKeyBindings() @@ -335,7 +335,7 @@ void CInput::LoadKeyBindings() { InputBinding b; - if (!CProfile::GetInstancePointer()->GetStringProperty("Keybindings", keyTable[static_cast(i)], keys)) + if (!CConfigFile::GetInstancePointer()->GetStringProperty("Keybindings", keyTable[static_cast(i)], keys)) continue; skey.clear(); skey.str(keys); @@ -350,17 +350,17 @@ void CInput::LoadKeyBindings() { JoyAxisBinding b; - if (!CProfile::GetInstancePointer()->GetIntProperty("Setup", "JoystickAxisBinding"+boost::lexical_cast(i), b.axis)) + if (!CConfigFile::GetInstancePointer()->GetIntProperty("Setup", "JoystickAxisBinding"+boost::lexical_cast(i), b.axis)) continue; int x = 0; - CProfile::GetInstancePointer()->GetIntProperty("Setup", "JoystickAxisInvert"+boost::lexical_cast(i), x); // If doesn't exist, use default (0) + CConfigFile::GetInstancePointer()->GetIntProperty("Setup", "JoystickAxisInvert"+boost::lexical_cast(i), x); // If doesn't exist, use default (0) b.invert = (x != 0); SetJoyAxisBinding(static_cast(i), b); } float deadzone; - if (CProfile::GetInstancePointer()->GetFloatProperty("Setup", "JoystickDeadzone", deadzone)) + if (CConfigFile::GetInstancePointer()->GetFloatProperty("Setup", "JoystickDeadzone", deadzone)) SetJoystickDeadzone(deadzone); } diff --git a/src/common/profile.cpp b/src/common/config_file.cpp similarity index 53% rename from src/common/profile.cpp rename to src/common/config_file.cpp index 75ab1355..0f394448 100644 --- a/src/common/profile.cpp +++ b/src/common/config_file.cpp @@ -18,7 +18,7 @@ */ -#include "common/profile.h" +#include "common/config_file.h" #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" @@ -33,28 +33,27 @@ #include -template<> CProfile* CSingleton::m_instance = nullptr; +template<> CConfigFile* CSingleton::m_instance = nullptr; namespace bp = boost::property_tree; -CProfile::CProfile() - : m_profileNeedSave(false) - , m_useCurrentDirectory(false) +CConfigFile::CConfigFile() + : m_useCurrentDirectory(false) + , m_loaded(false) { } -CProfile::~CProfile() +CConfigFile::~CConfigFile() { - Save(); } -void CProfile::SetUseCurrentDirectory(bool useCurrentDirectory) +void CConfigFile::SetUseCurrentDirectory(bool useCurrentDirectory) { m_useCurrentDirectory = useCurrentDirectory; } -bool CProfile::Init() +bool CConfigFile::Init() { try { @@ -76,6 +75,7 @@ bool CProfile::Init() if (good) { bp::ini_parser::read_ini(*stream, m_propertyTree); + m_loaded = true; } else { @@ -91,63 +91,60 @@ bool CProfile::Init() return true; } -bool CProfile::Save() +bool CConfigFile::Save() { - if (m_profileNeedSave) + try { - try + std::unique_ptr stream; + bool good; + if (m_useCurrentDirectory) { - std::unique_ptr stream; - bool good; - if (m_useCurrentDirectory) - { - std::ofstream* outputStream = new std::ofstream("./colobot.ini"); - stream = std::unique_ptr(outputStream); - good = outputStream->good(); - } - else - { - COutputStream* outputStream = new COutputStream("colobot.ini"); - stream = std::unique_ptr(outputStream); - good = outputStream->is_open(); - } - - if (good) - { - bp::ini_parser::write_ini(*stream, m_propertyTree); - } - else - { - GetLogger()->Error("Error on storing profile: failed to open file\n"); - return false; - } + std::ofstream* outputStream = new std::ofstream("./colobot.ini"); + stream = std::unique_ptr(outputStream); + good = outputStream->good(); } - catch (std::exception & e) + else { - GetLogger()->Error("Error on storing profile: %s\n", e.what()); + COutputStream* outputStream = new COutputStream("colobot.ini"); + stream = std::unique_ptr(outputStream); + good = outputStream->is_open(); + } + + if (good) + { + bp::ini_parser::write_ini(*stream, m_propertyTree); + } + else + { + GetLogger()->Error("Error on storing profile: failed to open file\n"); return false; } } + catch (std::exception & e) + { + GetLogger()->Error("Error on storing profile: %s\n", e.what()); + return false; + } return true; } -bool CProfile::SetStringProperty(std::string section, std::string key, std::string value) +bool CConfigFile::SetStringProperty(std::string section, std::string key, std::string value) { try { m_propertyTree.put(section + "." + key, value); - m_profileNeedSave = true; + Save(); } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on editing config file: %s\n", e.what()); return false; } return true; } -bool CProfile::GetStringProperty(std::string section, std::string key, std::string &buffer) +bool CConfigFile::GetStringProperty(std::string section, std::string key, std::string &buffer) { try { @@ -155,30 +152,37 @@ bool CProfile::GetStringProperty(std::string section, std::string key, std::stri } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + if (m_loaded) + { + GetLogger()->Info("Error on parsing config file: %s\n", e.what()); + } + else + { + GetLogger()->Trace("Error on parsing config file: %s\n", e.what()); + } return false; } return true; } -bool CProfile::SetIntProperty(std::string section, std::string key, int value) +bool CConfigFile::SetIntProperty(std::string section, std::string key, int value) { try { m_propertyTree.put(section + "." + key, value); - m_profileNeedSave = true; + Save(); } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on editing config file: %s\n", e.what()); return false; } return true; } -bool CProfile::GetIntProperty(std::string section, std::string key, int &value) +bool CConfigFile::GetIntProperty(std::string section, std::string key, int &value) { try { @@ -186,30 +190,37 @@ bool CProfile::GetIntProperty(std::string section, std::string key, int &value) } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + if (m_loaded) + { + GetLogger()->Info("Error on parsing config file: %s\n", e.what()); + } + else + { + GetLogger()->Trace("Error on parsing config file: %s\n", e.what()); + } return false; } return true; } -bool CProfile::SetFloatProperty(std::string section, std::string key, float value) +bool CConfigFile::SetFloatProperty(std::string section, std::string key, float value) { try { m_propertyTree.put(section + "." + key, value); - m_profileNeedSave = true; + Save(); } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + GetLogger()->Info("Error on editing config file: %s\n", e.what()); return false; } return true; } -bool CProfile::GetFloatProperty(std::string section, std::string key, float &value) +bool CConfigFile::GetFloatProperty(std::string section, std::string key, float &value) { try { @@ -217,33 +228,15 @@ bool CProfile::GetFloatProperty(std::string section, std::string key, float &val } catch (std::exception & e) { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); + if (m_loaded) + { + GetLogger()->Info("Error on parsing config file: %s\n", e.what()); + } + else + { + GetLogger()->Trace("Error on parsing config file: %s\n", e.what()); + } return false; } return true; } - - -std::vector< std::string > CProfile::GetSection(std::string section, std::string key) -{ - std::vector< std::string > ret_list; - boost::regex re(key + "[0-9]*"); //we want to match all key followed by any number - - try - { - for(bp::ptree::value_type const & v : m_propertyTree.get_child(section)) - { - if (boost::regex_search(v.first, re)) - { - ret_list.push_back(v.second.get_value()); - } - } - } - catch (std::exception & e) - { - GetLogger()->Info("Error on parsing profile: %s\n", e.what()); - } - - return ret_list; -} - diff --git a/src/common/profile.h b/src/common/config_file.h similarity index 83% rename from src/common/profile.h rename to src/common/config_file.h index d89c5d15..c1e2c260 100644 --- a/src/common/profile.h +++ b/src/common/config_file.h @@ -18,7 +18,7 @@ */ /** - * \file common/profile.h + * \file common/config_file.h * \brief Class for loading profile (currently for loading ini config file) */ @@ -37,30 +37,25 @@ namespace fs = boost::filesystem; /** -* \class CProfile +* \class CConfigFile * -* \brief Class for loading profile (currently for loading ini config file) +* \brief Class for loading config file * */ -class CProfile : public CSingleton +class CConfigFile : public CSingleton { public: - CProfile(); - virtual ~CProfile(); + CConfigFile(); + virtual ~CConfigFile(); /** Set flag to force using ini file from current directory */ void SetUseCurrentDirectory(bool useCurrentDirectory); - /** Loads colobot.ini from current directory + /** Loads colobot.ini * \return return true on success */ bool Init(); - /** Saves colobot.ini to current directory - * \return return true on success - */ - bool Save(); - /** Sets string value in section under specified key * \param section * \param key @@ -109,22 +104,20 @@ public: */ bool GetFloatProperty(std::string section, std::string key, float &value); - /** Gets all values in section under specified key - * \param section - * \param key - * \return vector of values +private: + /** Saves colobot.ini + * \return return true on success */ - std::vector< std::string > GetSection(std::string section, std::string key); + bool Save(); private: boost::property_tree::ptree m_propertyTree; - bool m_profileNeedSave; bool m_useCurrentDirectory; + bool m_loaded; }; //! Global function to get profile instance -inline CProfile & GetProfile() +inline CConfigFile & GetConfigFile() { - return *CProfile::GetInstancePointer(); + return *CConfigFile::GetInstancePointer(); } - diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 5661e2e2..d377bdde 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -174,14 +174,14 @@ CEngine::CEngine(CApplication *app) bool mipmaps = false; int value; - if (CProfile::GetInstance().GetIntProperty("Setup", "FilterMode", value)) + if (GetConfigFile().GetIntProperty("Setup", "FilterMode", value)) { if (value == 1) filter = TEX_FILTER_NEAREST; else if (value == 2) filter = TEX_FILTER_BILINEAR; else if (value == 3) filter = TEX_FILTER_TRILINEAR, mipmaps = true; } - if (CProfile::GetInstance().GetIntProperty("Setup", "ShadowMapping", value)) + if (GetConfigFile().GetIntProperty("Setup", "ShadowMapping", value)) { m_shadowMapping = (value > 0); m_offscreenShadowRendering = (value > 1); @@ -3390,7 +3390,7 @@ void CEngine::RenderShadowMap() { int size; - if (CProfile::GetInstance().GetIntProperty("Setup", "OffscreenBuffer", size)) + if (CConfigFile::GetInstance().GetIntProperty("Setup", "OffscreenBuffer", size)) { width = height = size; } diff --git a/src/graphics/opengl/gl21device.cpp b/src/graphics/opengl/gl21device.cpp index 0dfca93f..22abc23f 100644 --- a/src/graphics/opengl/gl21device.cpp +++ b/src/graphics/opengl/gl21device.cpp @@ -25,7 +25,7 @@ #include "common/config.h" #include "common/image.h" #include "common/logger.h" -#include "common/profile.h" +#include "common/config_file.h" #include "math/geometry.h" @@ -238,7 +238,7 @@ bool CGL21Device::Create() m_textureStageParams = std::vector(maxTextures, TextureStageParams()); int value; - if (CProfile::GetInstance().GetIntProperty("Setup", "PerPixelLighting", value)) + if (CConfigFile::GetInstance().GetIntProperty("Setup", "PerPixelLighting", value)) { m_perPixelLighting = value > 0; } diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp index e2f0e7d8..4f81e9ff 100644 --- a/src/graphics/opengl/gl33device.cpp +++ b/src/graphics/opengl/gl33device.cpp @@ -24,7 +24,7 @@ #include "common/config.h" #include "common/image.h" #include "common/logger.h" -#include "common/profile.h" +#include "common/config_file.h" #include "math/geometry.h" @@ -243,7 +243,7 @@ bool CGL33Device::Create() m_vertexCol = CreateStaticBuffer(PRIMITIVE_POINTS, static_cast(nullptr), 1); int value; - if (CProfile::GetInstance().GetIntProperty("Setup", "PerPixelLighting", value)) + if (CConfigFile::GetInstance().GetIntProperty("Setup", "PerPixelLighting", value)) { m_perPixelLighting = value > 0; } diff --git a/src/object/player_progress.cpp b/src/object/player_progress.cpp index 90c1c0c8..ed3b5bb2 100644 --- a/src/object/player_progress.cpp +++ b/src/object/player_progress.cpp @@ -20,7 +20,7 @@ #include "common/logger.h" #include "common/make_unique.h" -#include "common/profile.h" +#include "common/config_file.h" #include "common/resources/resourcemanager.h" #include "common/resources/inputstream.h" #include "common/resources/outputstream.h" @@ -75,7 +75,7 @@ void PlayerApperance::DefPerso() CPlayerProgress::CPlayerProgress(std::string playerName) { m_playerName = playerName; - GetProfile().SetStringProperty("Gamer", "LastName", m_playerName); + GetConfigFile().SetStringProperty("Gamer", "LastName", m_playerName); if (!CResourceManager::DirectoryExists(GetSaveDir())) { @@ -96,7 +96,7 @@ std::string CPlayerProgress::GetLastName() { std::string name; - if(!GetProfile().GetStringProperty("Gamer", "LastName", name)) + if(!GetConfigFile().GetStringProperty("Gamer", "LastName", name)) GetResource(RES_TEXT, RT_NAME_DEFAULT, name); return name; diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 294e7abf..8a888d98 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -33,7 +33,7 @@ #include "common/logger.h" #include "common/make_unique.h" #include "common/misc.h" -#include "common/profile.h" +#include "common/config_file.h" #include "common/restext.h" #include "common/resources/resourcemanager.h" @@ -247,7 +247,7 @@ CRobotMain::CRobotMain(CController* controller) } } -void CRobotMain::Create(bool loadProfile) +void CRobotMain::Create() { m_app = m_ctrl->GetApplication(); @@ -296,28 +296,22 @@ void CRobotMain::Create(bool loadProfile) float fValue; int iValue; - if (loadProfile) - { - if (GetProfile().GetFloatProperty("Edit", "FontSize", fValue)) m_fontSize = fValue; - if (GetProfile().GetFloatProperty("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; - if (GetProfile().GetFloatProperty("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; - if (GetProfile().GetFloatProperty("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; - if (GetProfile().GetFloatProperty("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; - } + if (GetConfigFile().GetFloatProperty("Edit", "FontSize", fValue)) m_fontSize = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "WindowPosX", fValue)) m_windowPos.x = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "WindowPosY", fValue)) m_windowPos.y = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "WindowDimX", fValue)) m_windowDim.x = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "WindowDimY", fValue)) m_windowDim.y = fValue; m_IOPublic = false; m_IODim = Math::Point(320.0f/640.0f, (121.0f+18.0f*8)/480.0f); m_IOPos.x = (1.0f-m_IODim.x)/2.0f; // in the middle m_IOPos.y = (1.0f-m_IODim.y)/2.0f; - if (loadProfile) - { - if (GetProfile().GetIntProperty ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; - if (GetProfile().GetFloatProperty("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; - if (GetProfile().GetFloatProperty("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; - if (GetProfile().GetFloatProperty("Edit", "IODimX", fValue)) m_IODim.x = fValue; - if (GetProfile().GetFloatProperty("Edit", "IODimY", fValue)) m_IODim.y = fValue; - } + if (GetConfigFile().GetIntProperty ("Edit", "IOPublic", iValue)) m_IOPublic = iValue; + if (GetConfigFile().GetFloatProperty("Edit", "IOPosX", fValue)) m_IOPos.x = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "IOPosY", fValue)) m_IOPos.y = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "IODimX", fValue)) m_IODim.x = fValue; + if (GetConfigFile().GetFloatProperty("Edit", "IODimY", fValue)) m_IODim.y = fValue; InitEye(); @@ -402,25 +396,23 @@ void CRobotMain::ResetAfterDeviceChanged() //! Creates the file colobot.ini at the first time -void CRobotMain::CreateIni() +void CRobotMain::CreateConfigFile() { m_dialog->SetupMemorize(); - GetProfile().SetFloatProperty("Edit", "FontSize", m_fontSize); - GetProfile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); - GetProfile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); - GetProfile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); - GetProfile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); - GetProfile().SetIntProperty("Edit", "IOPublic", m_IOPublic); - GetProfile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); - GetProfile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); - GetProfile().SetFloatProperty("Edit", "IODimX", m_IODim.x); - GetProfile().SetFloatProperty("Edit", "IODimY", m_IODim.y); - - GetProfile().Save(); + 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().SetIntProperty("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); } -void CRobotMain::LoadIni() +void CRobotMain::LoadConfigFile() { m_dialog->SetupRecall(); } @@ -1556,7 +1548,7 @@ float CRobotMain::GetGameTime() void CRobotMain::SetFontSize(float size) { m_fontSize = size; - GetProfile().SetFloatProperty("Edit", "FontSize", m_fontSize); + GetConfigFile().SetFloatProperty("Edit", "FontSize", m_fontSize); } float CRobotMain::GetFontSize() @@ -1568,8 +1560,8 @@ float CRobotMain::GetFontSize() void CRobotMain::SetWindowPos(Math::Point pos) { m_windowPos = pos; - GetProfile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); - GetProfile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); + GetConfigFile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x); + GetConfigFile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y); } Math::Point CRobotMain::GetWindowPos() @@ -1580,8 +1572,8 @@ Math::Point CRobotMain::GetWindowPos() void CRobotMain::SetWindowDim(Math::Point dim) { m_windowDim = dim; - GetProfile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); - GetProfile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); + GetConfigFile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x); + GetConfigFile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y); } Math::Point CRobotMain::GetWindowDim() @@ -1594,7 +1586,7 @@ Math::Point CRobotMain::GetWindowDim() void CRobotMain::SetIOPublic(bool mode) { m_IOPublic = mode; - GetProfile().SetIntProperty("Edit", "IOPublic", m_IOPublic); + GetConfigFile().SetIntProperty("Edit", "IOPublic", m_IOPublic); } bool CRobotMain::GetIOPublic() @@ -1605,8 +1597,8 @@ bool CRobotMain::GetIOPublic() void CRobotMain::SetIOPos(Math::Point pos) { m_IOPos = pos; - GetProfile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); - GetProfile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); + GetConfigFile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x); + GetConfigFile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y); } Math::Point CRobotMain::GetIOPos() @@ -1617,8 +1609,8 @@ Math::Point CRobotMain::GetIOPos() void CRobotMain::SetIODim(Math::Point dim) { m_IODim = dim; - GetProfile().SetFloatProperty("Edit", "IODimX", m_IODim.x); - GetProfile().SetFloatProperty("Edit", "IODimY", m_IODim.y); + GetConfigFile().SetFloatProperty("Edit", "IODimX", m_IODim.x); + GetConfigFile().SetFloatProperty("Edit", "IODimY", m_IODim.y); } Math::Point CRobotMain::GetIODim() diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 3f33114f..afc3d9ff 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -150,16 +150,15 @@ class CRobotMain : public CSingleton public: CRobotMain(CController* controller); virtual ~CRobotMain(); - - void Create(bool loadProfile = true); + void Create(); Gfx::CCamera* GetCamera(); Gfx::CTerrain* GetTerrain(); Ui::CInterface* GetInterface(); Ui::CDisplayText* GetDisplayText(); - void CreateIni(); - void LoadIni(); + void CreateConfigFile(); + void LoadConfigFile(); void ResetAfterDeviceChanged(); diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 5cf6cf02..9ed31e54 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -30,7 +30,7 @@ #include "common/logger.h" #include "common/make_unique.h" #include "common/misc.h" -#include "common/profile.h" +#include "common/config_file.h" #include "common/restext.h" #include "common/stringutils.h" @@ -4861,53 +4861,53 @@ void CMainDialog::ChangeSetupButtons() void CMainDialog::SetupMemorize() { - GetProfile().SetStringProperty("Directory", "savegame", m_savegameDir); - GetProfile().SetStringProperty("Directory", "public", m_publicDir); - GetProfile().SetStringProperty("Directory", "files", m_filesDir); - GetProfile().SetIntProperty("Setup", "Tooltips", m_bTooltip); - GetProfile().SetIntProperty("Setup", "InterfaceGlint", m_bGlint); - GetProfile().SetIntProperty("Setup", "InterfaceGlint", m_bRain); - GetProfile().SetIntProperty("Setup", "Soluce4", m_bSoluce4); - GetProfile().SetIntProperty("Setup", "Movies", m_bMovies); - GetProfile().SetIntProperty("Setup", "NiceReset", m_bNiceReset); - GetProfile().SetIntProperty("Setup", "HimselfDamage", m_bHimselfDamage); - GetProfile().SetIntProperty("Setup", "CameraScroll", m_bCameraScroll); - GetProfile().SetIntProperty("Setup", "CameraInvertX", m_bCameraInvertX); - GetProfile().SetIntProperty("Setup", "CameraInvertY", m_bCameraInvertY); - GetProfile().SetIntProperty("Setup", "InterfaceEffect", m_bEffect); - GetProfile().SetIntProperty("Setup", "Blood", m_bBlood); - GetProfile().SetIntProperty("Setup", "Autosave", m_bAutosave); - GetProfile().SetIntProperty("Setup", "AutosaveInterval", m_main->GetAutosaveInterval()); - GetProfile().SetIntProperty("Setup", "AutosaveSlots", m_main->GetAutosaveSlots()); - GetProfile().SetIntProperty("Setup", "GroundShadow", m_engine->GetShadow()); - GetProfile().SetIntProperty("Setup", "GroundSpot", m_engine->GetGroundSpot()); - GetProfile().SetIntProperty("Setup", "ObjectDirty", m_engine->GetDirty()); - GetProfile().SetIntProperty("Setup", "FogMode", m_engine->GetFog()); - GetProfile().SetIntProperty("Setup", "LensMode", m_engine->GetLensMode()); - GetProfile().SetIntProperty("Setup", "SkyMode", m_engine->GetSkyMode()); - GetProfile().SetIntProperty("Setup", "PlanetMode", m_engine->GetPlanetMode()); - GetProfile().SetIntProperty("Setup", "LightMode", m_engine->GetLightMode()); - GetProfile().SetIntProperty("Setup", "UseJoystick", m_app->GetJoystickEnabled() ? m_app->GetJoystick().index : -1); - GetProfile().SetFloatProperty("Setup", "ParticleDensity", m_engine->GetParticleDensity()); - GetProfile().SetFloatProperty("Setup", "ClippingDistance", m_engine->GetClippingDistance()); - GetProfile().SetFloatProperty("Setup", "ObjectDetail", m_engine->GetObjectDetail()); - GetProfile().SetFloatProperty("Setup", "GadgetQuantity", m_engine->GetGadgetQuantity()); - GetProfile().SetIntProperty("Setup", "TextureQuality", m_engine->GetTextureQuality()); - GetProfile().SetIntProperty("Setup", "TotoMode", m_engine->GetTotoMode()); - GetProfile().SetIntProperty("Setup", "AudioVolume", m_sound->GetAudioVolume()); - GetProfile().SetIntProperty("Setup", "MusicVolume", m_sound->GetMusicVolume()); - GetProfile().SetIntProperty("Setup", "EditIndentMode", m_engine->GetEditIndentMode()); - GetProfile().SetIntProperty("Setup", "EditIndentValue", m_engine->GetEditIndentValue()); - GetProfile().SetIntProperty("Setup", "SystemMouse", m_app->GetMouseMode() == MOUSE_SYSTEM); + GetConfigFile().SetStringProperty("Directory", "savegame", m_savegameDir); + GetConfigFile().SetStringProperty("Directory", "public", m_publicDir); + GetConfigFile().SetStringProperty("Directory", "files", m_filesDir); + GetConfigFile().SetIntProperty("Setup", "Tooltips", m_bTooltip); + GetConfigFile().SetIntProperty("Setup", "InterfaceGlint", m_bGlint); + GetConfigFile().SetIntProperty("Setup", "InterfaceGlint", m_bRain); + GetConfigFile().SetIntProperty("Setup", "Soluce4", m_bSoluce4); + GetConfigFile().SetIntProperty("Setup", "Movies", m_bMovies); + GetConfigFile().SetIntProperty("Setup", "NiceReset", m_bNiceReset); + GetConfigFile().SetIntProperty("Setup", "HimselfDamage", m_bHimselfDamage); + GetConfigFile().SetIntProperty("Setup", "CameraScroll", m_bCameraScroll); + GetConfigFile().SetIntProperty("Setup", "CameraInvertX", m_bCameraInvertX); + GetConfigFile().SetIntProperty("Setup", "CameraInvertY", m_bCameraInvertY); + GetConfigFile().SetIntProperty("Setup", "InterfaceEffect", m_bEffect); + GetConfigFile().SetIntProperty("Setup", "Blood", m_bBlood); + GetConfigFile().SetIntProperty("Setup", "Autosave", m_bAutosave); + GetConfigFile().SetIntProperty("Setup", "AutosaveInterval", m_main->GetAutosaveInterval()); + GetConfigFile().SetIntProperty("Setup", "AutosaveSlots", m_main->GetAutosaveSlots()); + GetConfigFile().SetIntProperty("Setup", "GroundShadow", m_engine->GetShadow()); + GetConfigFile().SetIntProperty("Setup", "GroundSpot", m_engine->GetGroundSpot()); + GetConfigFile().SetIntProperty("Setup", "ObjectDirty", m_engine->GetDirty()); + GetConfigFile().SetIntProperty("Setup", "FogMode", m_engine->GetFog()); + GetConfigFile().SetIntProperty("Setup", "LensMode", m_engine->GetLensMode()); + GetConfigFile().SetIntProperty("Setup", "SkyMode", m_engine->GetSkyMode()); + GetConfigFile().SetIntProperty("Setup", "PlanetMode", m_engine->GetPlanetMode()); + GetConfigFile().SetIntProperty("Setup", "LightMode", m_engine->GetLightMode()); + GetConfigFile().SetIntProperty("Setup", "UseJoystick", m_app->GetJoystickEnabled() ? m_app->GetJoystick().index : -1); + GetConfigFile().SetFloatProperty("Setup", "ParticleDensity", m_engine->GetParticleDensity()); + GetConfigFile().SetFloatProperty("Setup", "ClippingDistance", m_engine->GetClippingDistance()); + GetConfigFile().SetFloatProperty("Setup", "ObjectDetail", m_engine->GetObjectDetail()); + GetConfigFile().SetFloatProperty("Setup", "GadgetQuantity", m_engine->GetGadgetQuantity()); + GetConfigFile().SetIntProperty("Setup", "TextureQuality", m_engine->GetTextureQuality()); + GetConfigFile().SetIntProperty("Setup", "TotoMode", m_engine->GetTotoMode()); + GetConfigFile().SetIntProperty("Setup", "AudioVolume", m_sound->GetAudioVolume()); + GetConfigFile().SetIntProperty("Setup", "MusicVolume", m_sound->GetMusicVolume()); + GetConfigFile().SetIntProperty("Setup", "EditIndentMode", m_engine->GetEditIndentMode()); + GetConfigFile().SetIntProperty("Setup", "EditIndentValue", m_engine->GetEditIndentValue()); + GetConfigFile().SetIntProperty("Setup", "SystemMouse", m_app->GetMouseMode() == MOUSE_SYSTEM); - GetProfile().SetIntProperty("Setup", "MipmapLevel", m_engine->GetTextureMipmapLevel()); - GetProfile().SetIntProperty("Setup", "Anisotropy", m_engine->GetTextureAnisotropyLevel()); - GetProfile().SetFloatProperty("Setup", "ShadowColor", m_engine->GetShadowColor()); - GetProfile().SetFloatProperty("Setup", "ShadowRange", m_engine->GetShadowRange()); - GetProfile().SetIntProperty("Setup", "MSAA", m_engine->GetMultiSample()); + GetConfigFile().SetIntProperty("Setup", "MipmapLevel", m_engine->GetTextureMipmapLevel()); + GetConfigFile().SetIntProperty("Setup", "Anisotropy", m_engine->GetTextureAnisotropyLevel()); + GetConfigFile().SetFloatProperty("Setup", "ShadowColor", m_engine->GetShadowColor()); + GetConfigFile().SetFloatProperty("Setup", "ShadowRange", m_engine->GetShadowRange()); + GetConfigFile().SetIntProperty("Setup", "MSAA", m_engine->GetMultiSample()); /* screen setup */ - GetProfile().SetIntProperty("Setup", "Fullscreen", m_setupFull ? 1 : 0); + GetConfigFile().SetIntProperty("Setup", "Fullscreen", m_setupFull ? 1 : 0); CList *pl; CWindow *pw; @@ -4921,13 +4921,13 @@ void CMainDialog::SetupMemorize() m_app->GetVideoResolutionList(modes, true, true); std::ostringstream ss; ss << modes[m_setupSelMode].x << "x" << modes[m_setupSelMode].y; - GetProfile().SetStringProperty("Setup", "Resolution", ss.str()); + GetConfigFile().SetStringProperty("Setup", "Resolution", ss.str()); } } CInput::GetInstancePointer()->SaveKeyBindings(); - GetProfile().SetIntProperty("Setup", "DeleteGamer", m_bDeleteGamer); + GetConfigFile().SetIntProperty("Setup", "DeleteGamer", m_bDeleteGamer); } // Remember all the settings. @@ -4938,152 +4938,152 @@ void CMainDialog::SetupRecall() int iValue; std::string key; - if ( GetProfile().GetStringProperty("Directory", "savegame", key) ) + if ( GetConfigFile().GetStringProperty("Directory", "savegame", key) ) { m_savegameDir = key; } - if ( GetProfile().GetStringProperty("Directory", "public", key) ) + if ( GetConfigFile().GetStringProperty("Directory", "public", key) ) { m_publicDir = key; } - if ( GetProfile().GetStringProperty("Directory", "files", key) ) + if ( GetConfigFile().GetStringProperty("Directory", "files", key) ) { m_filesDir = key; } - if ( GetProfile().GetIntProperty("Setup", "TotoMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "TotoMode", iValue) ) { m_engine->SetTotoMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "Tooltips", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Tooltips", iValue) ) { m_bTooltip = iValue; } - if ( GetProfile().GetIntProperty("Setup", "InterfaceGlint", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "InterfaceGlint", iValue) ) { m_bGlint = iValue; } - if ( GetProfile().GetIntProperty("Setup", "InterfaceGlint", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "InterfaceGlint", iValue) ) { m_bRain = iValue; } - if ( GetProfile().GetIntProperty("Setup", "SystemMouse", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "SystemMouse", iValue) ) { m_app->SetMouseMode(iValue ? MOUSE_SYSTEM : MOUSE_ENGINE); } - if ( GetProfile().GetIntProperty("Setup", "Soluce4", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Soluce4", iValue) ) { m_bSoluce4 = iValue; } - if ( GetProfile().GetIntProperty("Setup", "Movies", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Movies", iValue) ) { m_bMovies = iValue; } - if ( GetProfile().GetIntProperty("Setup", "NiceReset", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "NiceReset", iValue) ) { m_bNiceReset = iValue; } - if ( GetProfile().GetIntProperty("Setup", "HimselfDamage", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "HimselfDamage", iValue) ) { m_bHimselfDamage = iValue; } - if ( GetProfile().GetIntProperty("Setup", "CameraScroll", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "CameraScroll", iValue) ) { m_bCameraScroll = iValue; m_camera->SetCameraScroll(m_bCameraScroll); } - if ( GetProfile().GetIntProperty("Setup", "CameraInvertX", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "CameraInvertX", iValue) ) { m_bCameraInvertX = iValue; m_camera->SetCameraInvertX(m_bCameraInvertX); } - if ( GetProfile().GetIntProperty("Setup", "CameraInvertY", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "CameraInvertY", iValue) ) { m_bCameraInvertY = iValue; m_camera->SetCameraInvertY(m_bCameraInvertY); } - if ( GetProfile().GetIntProperty("Setup", "InterfaceEffect", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "InterfaceEffect", iValue) ) { m_bEffect = iValue; } - if ( GetProfile().GetIntProperty("Setup", "Blood", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Blood", iValue) ) { m_bBlood = iValue; } - if ( GetProfile().GetIntProperty("Setup", "Autosave", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Autosave", iValue) ) { m_bAutosave = iValue; } - if ( GetProfile().GetIntProperty("Setup", "AutosaveInterval", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "AutosaveInterval", iValue) ) { m_main->SetAutosaveInterval(iValue); } - if ( GetProfile().GetIntProperty("Setup", "AutosaveSlots", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "AutosaveSlots", iValue) ) { m_main->SetAutosaveSlots(iValue); } - if ( GetProfile().GetIntProperty("Setup", "GroundShadow", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "GroundShadow", iValue) ) { m_engine->SetShadow(iValue); } - if ( GetProfile().GetIntProperty("Setup", "GroundSpot", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "GroundSpot", iValue) ) { m_engine->SetGroundSpot(iValue); } - if ( GetProfile().GetIntProperty("Setup", "ObjectDirty", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "ObjectDirty", iValue) ) { m_engine->SetDirty(iValue); } - if ( GetProfile().GetIntProperty("Setup", "FogMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "FogMode", iValue) ) { m_engine->SetFog(iValue); m_camera->SetOverBaseColor(Gfx::Color(0.0f, 0.0f, 0.0f, 0.0f)); // TODO: color ok? } - if ( GetProfile().GetIntProperty("Setup", "LensMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "LensMode", iValue) ) { m_engine->SetLensMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "SkyMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "SkyMode", iValue) ) { m_engine->SetSkyMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "PlanetMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "PlanetMode", iValue) ) { m_engine->SetPlanetMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "LightMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "LightMode", iValue) ) { m_engine->SetLightMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "UseJoystick", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "UseJoystick", iValue) ) { if(iValue >= 0) { @@ -5103,59 +5103,59 @@ void CMainDialog::SetupRecall() } } - if ( GetProfile().GetFloatProperty("Setup", "ParticleDensity", fValue) ) + if ( GetConfigFile().GetFloatProperty("Setup", "ParticleDensity", fValue) ) { m_engine->SetParticleDensity(fValue); } - if ( GetProfile().GetFloatProperty("Setup", "ClippingDistance", fValue) ) + if ( GetConfigFile().GetFloatProperty("Setup", "ClippingDistance", fValue) ) { m_engine->SetClippingDistance(fValue); } - if ( GetProfile().GetFloatProperty("Setup", "ObjectDetail", fValue) ) + if ( GetConfigFile().GetFloatProperty("Setup", "ObjectDetail", fValue) ) { m_engine->SetObjectDetail(fValue); } - if ( GetProfile().GetFloatProperty("Setup", "GadgetQuantity", fValue) ) + if ( GetConfigFile().GetFloatProperty("Setup", "GadgetQuantity", fValue) ) { m_engine->SetGadgetQuantity(fValue); } - if ( GetProfile().GetIntProperty("Setup", "TextureQuality", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "TextureQuality", iValue) ) { m_engine->SetTextureQuality(iValue); } - if ( GetProfile().GetIntProperty("Setup", "AudioVolume", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "AudioVolume", iValue) ) { m_sound->SetAudioVolume(iValue); } - if ( GetProfile().GetIntProperty("Setup", "MusicVolume", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "MusicVolume", iValue) ) { m_sound->SetMusicVolume(iValue); } - if ( GetProfile().GetIntProperty("Setup", "EditIndentMode", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "EditIndentMode", iValue) ) { m_engine->SetEditIndentMode(iValue); } - if ( GetProfile().GetIntProperty("Setup", "EditIndentValue", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "EditIndentValue", iValue) ) { m_engine->SetEditIndentValue(iValue); } CInput::GetInstancePointer()->LoadKeyBindings(); - if ( GetProfile().GetIntProperty("Setup", "DeleteGamer", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "DeleteGamer", iValue) ) { m_bDeleteGamer = iValue; } - if ( GetProfile().GetStringProperty("Setup", "Resolution", key) ) + if ( GetConfigFile().GetStringProperty("Setup", "Resolution", key) ) { std::istringstream resolution(key); std::string ws, hs; @@ -5180,32 +5180,32 @@ void CMainDialog::SetupRecall() } } - if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) ) + if ( GetConfigFile().GetIntProperty("Setup", "Fullscreen", iValue) ) { m_setupFull = (iValue == 1); } - if ( GetProfile().GetIntProperty("Setup", "MipmapLevel", iValue)) + if ( GetConfigFile().GetIntProperty("Setup", "MipmapLevel", iValue)) { m_engine->SetTextureMipmapLevel(iValue); } - if (GetProfile().GetIntProperty("Setup", "Anisotropy", iValue)) + if (GetConfigFile().GetIntProperty("Setup", "Anisotropy", iValue)) { m_engine->SetTextureAnisotropyLevel(iValue); } - if (GetProfile().GetFloatProperty("Setup", "ShadowColor", fValue)) + if (GetConfigFile().GetFloatProperty("Setup", "ShadowColor", fValue)) { m_engine->SetShadowColor(fValue); } - if (GetProfile().GetFloatProperty("Setup", "ShadowRange", fValue)) + if (GetConfigFile().GetFloatProperty("Setup", "ShadowRange", fValue)) { m_engine->SetShadowRange(fValue); } - if (GetProfile().GetIntProperty("Setup", "MSAA", iValue)) + if (GetConfigFile().GetIntProperty("Setup", "MSAA", iValue)) { m_engine->SetMultiSample(iValue); } diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index c121f04b..b38e7b28 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -9,7 +9,7 @@ endif() set(UT_SOURCES main.cpp app/app_test.cpp - common/profile_test.cpp + common/config_file_test.cpp graphics/engine/lightman_test.cpp math/func_test.cpp math/geometry_test.cpp diff --git a/test/unit/common/colobot.ini b/test/unit/common/colobot.ini index 2ca37eef..c4d21623 100644 --- a/test/unit/common/colobot.ini +++ b/test/unit/common/colobot.ini @@ -6,10 +6,3 @@ string_value=Hello world [test_int] int_value=42 - -[test_multi] -entry1=1 -entry2=2 -entry3=3 -entry4=4 -entry5=5 diff --git a/test/unit/common/profile_test.cpp b/test/unit/common/config_file_test.cpp similarity index 66% rename from test/unit/common/profile_test.cpp rename to test/unit/common/config_file_test.cpp index d85017be..fa6ebc42 100644 --- a/test/unit/common/profile_test.cpp +++ b/test/unit/common/config_file_test.cpp @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see http://gnu.org/licenses */ -#include "common/profile.h" +#include "common/config_file.h" #include "common/logger.h" #include "app/system.h" @@ -26,31 +26,27 @@ #include -class CProfileTest : public testing::Test +class CConfigFileTest : public testing::Test { protected: - CProfile m_profile; + CConfigFile m_configFile; }; -TEST_F(CProfileTest, ReadTest) +TEST_F(CConfigFileTest, ReadTest) { - m_profile.SetUseCurrentDirectory(true); + m_configFile.SetUseCurrentDirectory(true); - ASSERT_TRUE(m_profile.Init()); // load colobot.ini file + ASSERT_TRUE(m_configFile.Init()); // load colobot.ini file std::string result; - ASSERT_TRUE(m_profile.GetStringProperty("test_string", "string_value", result)); + ASSERT_TRUE(m_configFile.GetStringProperty("test_string", "string_value", result)); ASSERT_STREQ("Hello world", result.c_str()); int int_value; - ASSERT_TRUE(m_profile.GetIntProperty("test_int", "int_value", int_value)); + ASSERT_TRUE(m_configFile.GetIntProperty("test_int", "int_value", int_value)); ASSERT_EQ(42, int_value); float float_value; - ASSERT_TRUE(m_profile.GetFloatProperty("test_float", "float_value", float_value)); + ASSERT_TRUE(m_configFile.GetFloatProperty("test_float", "float_value", float_value)); ASSERT_FLOAT_EQ(1.5, float_value); - - std::vector list; - list = m_profile.GetSection("test_multi", "entry"); - ASSERT_EQ(5u, list.size()); }