[colobot] 52/390: CProfile refactoring

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:27 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit e4d52d9afbf6aeb090b225cc4852936dd3be5017
Author: Piotr Dziwinski <piotrdz at gmail.com>
Date:   Tue Aug 12 21:24:33 2014 +0200

    CProfile refactoring
---
 src/app/app.cpp                   |  10 +--
 src/common/profile.cpp            |  38 +++++-----
 src/common/profile.h              | 126 +++++++++++++++---------------
 src/object/robotmain.cpp          |  64 ++++++++--------
 src/ui/maindialog.cpp             | 156 +++++++++++++++++++-------------------
 test/unit/common/profile_test.cpp |  12 +--
 6 files changed, 203 insertions(+), 203 deletions(-)

diff --git a/src/app/app.cpp b/src/app/app.cpp
index 83a520a..42ebd39 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -386,14 +386,14 @@ bool CApplication::Create()
 
     GetLogger()->Info("Creating CApplication\n");
 
-    if (!GetProfile().InitCurrentDirectory())
+    if (!GetProfile().Init())
     {
         GetLogger()->Warn("Config not found. Default values will be used!\n");
         defaultValues = true;
     }
     else
     {
-        if (!m_customDataPath && GetProfile().GetLocalProfileString("Resources", "Data", path))
+        if (!m_customDataPath && GetProfile().GetStringProperty("Resources", "Data", path))
             m_dataPath = path;
     }
 
@@ -411,7 +411,7 @@ bool CApplication::Create()
     m_gameData->SetDataDir(std::string(m_dataPath));
     m_gameData->Init();
 
-    if (GetProfile().GetLocalProfileString("Language", "Lang", path)) {
+    if (GetProfile().GetStringProperty("Language", "Lang", path)) {
         Language language;
         if (ParseLanguage(path, language)) {
             m_language = language;
@@ -472,7 +472,7 @@ bool CApplication::Create()
 
     // load settings from profile
     int iValue;
-    if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Resolution", iValue) )
     {
         std::vector<Math::IntPoint> modes;
         GetVideoResolutionList(modes, true, true);
@@ -480,7 +480,7 @@ bool CApplication::Create()
             m_deviceConfig.size = modes.at(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) )
     {
         m_deviceConfig.fullScreen = (iValue == 1);
     }
diff --git a/src/common/profile.cpp b/src/common/profile.cpp
index a63a772..79d7152 100644
--- a/src/common/profile.cpp
+++ b/src/common/profile.cpp
@@ -17,10 +17,10 @@
 
 #include "common/profile.h"
 
-#include "common/logger.h"
-
 #include "app/system.h"
 
+#include "common/logger.h"
+
 #include <utility>
 #include <cstring>
 #include <boost/property_tree/ini_parser.hpp>
@@ -33,27 +33,27 @@ namespace bp = boost::property_tree;
 
 CProfile::CProfile()
    : m_profileNeedSave(false)
-   , m_useLocalDirectory(false)
+   , m_useCurrentDirectory(false)
 {
 }
 
 
 CProfile::~CProfile()
 {
-    SaveCurrentDirectory();
+    Save();
 }
 
-void CProfile::SetUseLocalDirectory(bool useLocalDirectory)
+void CProfile::SetUseCurrentDirectory(bool useCurrentDirectory)
 {
-    m_useLocalDirectory = useLocalDirectory;
+    m_useCurrentDirectory = useCurrentDirectory;
 }
 
 std::string CProfile::GetIniFileLocation()
 {
-    return m_useLocalDirectory ? "colobot.ini" : GetSystemUtils()->GetProfileFileLocation();
+    return m_useCurrentDirectory ? "colobot.ini" : GetSystemUtils()->GetProfileFileLocation();
 }
 
-bool CProfile::InitCurrentDirectory()
+bool CProfile::Init()
 {
     try
     {
@@ -67,7 +67,7 @@ bool CProfile::InitCurrentDirectory()
     return true;
 }
 
-bool CProfile::SaveCurrentDirectory()
+bool CProfile::Save()
 {
     if (m_profileNeedSave)
     {
@@ -84,7 +84,7 @@ bool CProfile::SaveCurrentDirectory()
     return true;
 }
 
-bool CProfile::SetLocalProfileString(std::string section, std::string key, std::string value)
+bool CProfile::SetStringProperty(std::string section, std::string key, std::string value)
 {
     try
     {
@@ -100,7 +100,7 @@ bool CProfile::SetLocalProfileString(std::string section, std::string key, std::
 }
 
 
-bool CProfile::GetLocalProfileString(std::string section, std::string key, std::string &buffer)
+bool CProfile::GetStringProperty(std::string section, std::string key, std::string &buffer)
 {
     try
     {
@@ -115,7 +115,7 @@ bool CProfile::GetLocalProfileString(std::string section, std::string key, std::
 }
 
 
-bool CProfile::SetLocalProfileInt(std::string section, std::string key, int value)
+bool CProfile::SetIntProperty(std::string section, std::string key, int value)
 {
     try
     {
@@ -131,7 +131,7 @@ bool CProfile::SetLocalProfileInt(std::string section, std::string key, int valu
 }
 
 
-bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &value)
+bool CProfile::GetIntProperty(std::string section, std::string key, int &value)
 {
     try
     {
@@ -146,7 +146,7 @@ bool CProfile::GetLocalProfileInt(std::string section, std::string key, int &val
 }
 
 
-bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float value)
+bool CProfile::SetFloatProperty(std::string section, std::string key, float value)
 {
     try
     {
@@ -162,7 +162,7 @@ bool CProfile::SetLocalProfileFloat(std::string section, std::string key, float
 }
 
 
-bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float &value)
+bool CProfile::GetFloatProperty(std::string section, std::string key, float &value)
 {
     try
     {
@@ -177,7 +177,7 @@ bool CProfile::GetLocalProfileFloat(std::string section, std::string key, float
 }
 
 
-std::vector< std::string > CProfile::GetLocalProfileSection(std::string section, std::string key)
+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
@@ -207,13 +207,13 @@ void CProfile::SetUserDir(std::string dir)
 }
 
 
-std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir)
+std::string CProfile::GetUserBasedPath(std::string dir, std::string defaultDir)
 {
     std::string path = dir;
     boost::replace_all(path, "\\", "/");
     if (dir.find("/") == std::string::npos)
     {
-        path = default_dir + "/" + dir;
+        path = defaultDir + "/" + dir;
     }
 
     if (m_userDirectory.length() > 0)
@@ -222,7 +222,7 @@ std::string CProfile::GetUserBasedPath(std::string dir, std::string default_dir)
     }
     else
     {
-        boost::replace_all(path, "%user%", default_dir);
+        boost::replace_all(path, "%user%", defaultDir);
     }
 
     return fs::path(path).make_preferred().string();
diff --git a/src/common/profile.h b/src/common/profile.h
index 52f9f15..ad0458e 100644
--- a/src/common/profile.h
+++ b/src/common/profile.h
@@ -45,91 +45,91 @@ public:
     CProfile();
     virtual ~CProfile();
 
-    /** Set flag to force using ini file from local directory */
-    void SetUseLocalDirectory(bool useLocalDirectory);
+    /** Set flag to force using ini file from current directory */
+    void SetUseCurrentDirectory(bool useCurrentDirectory);
 
     /** Loads colobot.ini from current directory
-        * \return return true on success
-        */
-    bool InitCurrentDirectory();
+     * \return return true on success
+     */
+    bool Init();
 
     /** Saves colobot.ini to current directory
-        * \return return true on success
-        */
-    bool SaveCurrentDirectory();
+     * \return return true on success
+     */
+    bool Save();
 
     /** Sets string value in section under specified key
-        * \param section
-        * \param key
-        * \param value
-        * \return return true on success
-        */
-    bool SetLocalProfileString(std::string section, std::string key, std::string value);
+     * \param section
+     * \param key
+     * \param value
+     * \return return true on success
+     */
+    bool SetStringProperty(std::string section, std::string key, std::string value);
 
     /** Gets string value in section under specified key
-        * \param section
-        * \param key
-        * \param buffer
-        * \return return true on success
-        */
-    bool GetLocalProfileString(std::string section, std::string key, std::string& buffer);
+     * \param section
+     * \param key
+     * \param buffer
+     * \return return true on success
+     */
+    bool GetStringProperty(std::string section, std::string key, std::string& buffer);
 
     /** Sets int value in section under specified key
-        * \param section
-        * \param key
-        * \param value
-        * \return return true on success
-        */
-    bool SetLocalProfileInt(std::string section, std::string key, int value);
+     * \param section
+     * \param key
+     * \param value
+     * \return return true on success
+     */
+    bool SetIntProperty(std::string section, std::string key, int value);
 
     /** Gets int value in section under specified key
-        * \param section
-        * \param key
-        * \param value
-        * \return return true on success
-        */
-    bool GetLocalProfileInt(std::string section, std::string key, int &value);
+     * \param section
+     * \param key
+     * \param value
+     * \return return true on success
+     */
+    bool GetIntProperty(std::string section, std::string key, int &value);
 
     /** Sets float value in section under specified key
-        * \param section
-        * \param key
-        * \param value
-        * \return return true on success
-        */
-    bool SetLocalProfileFloat(std::string section, std::string key, float value);
+     * \param section
+     * \param key
+     * \param value
+     * \return return true on success
+     */
+    bool SetFloatProperty(std::string section, std::string key, float value);
 
     /** Gets float value in section under specified key
-        * \param section
-        * \param key
-        * \param value
-        * \return return true on success
-        */
-    bool GetLocalProfileFloat(std::string section, std::string key, float &value);
+     * \param section
+     * \param key
+     * \param value
+     * \return return true on success
+     */
+    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
-        */
-    std::vector< std::string > GetLocalProfileSection(std::string section, std::string key);
+     * \param section
+     * \param key
+     * \return vector of values
+     */
+    std::vector< std::string > GetSection(std::string section, std::string key);
 
     /** Sets current user directory
-        * \param dir
-        */
+     * \param dir
+     */
     void SetUserDir(std::string dir);
 
     /** Returns path based on current user. Replaces %user% in path with current user dir or
-        * uses default_dir param if no user dir is specified
-        * \param dir
-        * \param default_dir
-        * \return path
-        */
-    std::string GetUserBasedPath(std::string dir, std::string default_dir);
-
-    /** opy a file into the temporary folder.
-        * \param filename
-        * \return true on success
-        */
+     * uses default_dir param if no user dir is specified
+     * \param dir
+     * \param default_dir
+     * \return path
+     */
+    std::string GetUserBasedPath(std::string dir, std::string defaultDir);
+
+    /** Copy a file into the temporary folder.
+     * \param filename
+     * \return true on success
+     */
     bool CopyFileToTemp(std::string filename);
 
 private:
@@ -139,7 +139,7 @@ private:
     boost::property_tree::ptree m_propertyTree;
     bool m_profileNeedSave;
     std::string m_userDirectory;
-    bool m_useLocalDirectory;
+    bool m_useCurrentDirectory;
 };
 
 //! Global function to get profile instance
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index fc15b26..d33ea27 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -721,11 +721,11 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
 
     if (loadProfile)
     {
-        if (GetProfile().GetLocalProfileFloat("Edit", "FontSize",    fValue)) m_fontSize    = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosX",  fValue)) m_windowPos.x = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "WindowPosY",  fValue)) m_windowPos.y = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimX",  fValue)) m_windowDim.x = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "WindowDimY",  fValue)) m_windowDim.y = fValue;
+        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;
     }
 
     m_IOPublic = false;
@@ -735,11 +735,11 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
 
     if (loadProfile)
     {
-        if (GetProfile().GetLocalProfileInt  ("Edit", "IOPublic", iValue)) m_IOPublic = iValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "IOPosX",   fValue)) m_IOPos.x  = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "IOPosY",   fValue)) m_IOPos.y  = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "IODimX",   fValue)) m_IODim.x  = fValue;
-        if (GetProfile().GetLocalProfileFloat("Edit", "IODimY",   fValue)) m_IODim.y  = fValue;
+        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;
     }
 
     m_short->FlushShortcuts();
@@ -757,7 +757,7 @@ CRobotMain::CRobotMain(CApplication* app, bool loadProfile)
     g_unit = UNIT;
 
     m_gamerName = "";
-    if (loadProfile) GetProfile().GetLocalProfileString("Gamer", "LastName", m_gamerName);
+    if (loadProfile) GetProfile().GetStringProperty("Gamer", "LastName", m_gamerName);
     SetGlobalGamerName(m_gamerName);
     ReadFreeParam();
     if (loadProfile) m_dialog->SetupRecall();
@@ -966,18 +966,18 @@ void CRobotMain::CreateIni()
 {
     m_dialog->SetupMemorize();
 
-    GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y);
-    GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
-    GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x);
-    GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y);
-    GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x);
-    GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y);
+    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().SaveCurrentDirectory();
+    GetProfile().Save();
 }
 
 void CRobotMain::SetDefaultInputBindings()
@@ -2258,7 +2258,7 @@ float CRobotMain::GetGameTime()
 void CRobotMain::SetFontSize(float size)
 {
     m_fontSize = size;
-    GetProfile().SetLocalProfileFloat("Edit", "FontSize", m_fontSize);
+    GetProfile().SetFloatProperty("Edit", "FontSize", m_fontSize);
 }
 
 float CRobotMain::GetFontSize()
@@ -2270,8 +2270,8 @@ float CRobotMain::GetFontSize()
 void CRobotMain::SetWindowPos(Math::Point pos)
 {
     m_windowPos = pos;
-    GetProfile().SetLocalProfileFloat("Edit", "WindowPosX", m_windowPos.x);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowPosY", m_windowPos.y);
+    GetProfile().SetFloatProperty("Edit", "WindowPosX", m_windowPos.x);
+    GetProfile().SetFloatProperty("Edit", "WindowPosY", m_windowPos.y);
 }
 
 Math::Point CRobotMain::GetWindowPos()
@@ -2282,8 +2282,8 @@ Math::Point CRobotMain::GetWindowPos()
 void CRobotMain::SetWindowDim(Math::Point dim)
 {
     m_windowDim = dim;
-    GetProfile().SetLocalProfileFloat("Edit", "WindowDimX", m_windowDim.x);
-    GetProfile().SetLocalProfileFloat("Edit", "WindowDimY", m_windowDim.y);
+    GetProfile().SetFloatProperty("Edit", "WindowDimX", m_windowDim.x);
+    GetProfile().SetFloatProperty("Edit", "WindowDimY", m_windowDim.y);
 }
 
 Math::Point CRobotMain::GetWindowDim()
@@ -2296,7 +2296,7 @@ Math::Point CRobotMain::GetWindowDim()
 void CRobotMain::SetIOPublic(bool mode)
 {
     m_IOPublic = mode;
-    GetProfile().SetLocalProfileInt("Edit", "IOPublic", m_IOPublic);
+    GetProfile().SetIntProperty("Edit", "IOPublic", m_IOPublic);
 }
 
 bool CRobotMain::GetIOPublic()
@@ -2307,8 +2307,8 @@ bool CRobotMain::GetIOPublic()
 void CRobotMain::SetIOPos(Math::Point pos)
 {
     m_IOPos = pos;
-    GetProfile().SetLocalProfileFloat("Edit", "IOPosX", m_IOPos.x);
-    GetProfile().SetLocalProfileFloat("Edit", "IOPosY", m_IOPos.y);
+    GetProfile().SetFloatProperty("Edit", "IOPosX", m_IOPos.x);
+    GetProfile().SetFloatProperty("Edit", "IOPosY", m_IOPos.y);
 }
 
 Math::Point CRobotMain::GetIOPos()
@@ -2319,8 +2319,8 @@ Math::Point CRobotMain::GetIOPos()
 void CRobotMain::SetIODim(Math::Point dim)
 {
     m_IODim = dim;
-    GetProfile().SetLocalProfileFloat("Edit", "IODimX", m_IODim.x);
-    GetProfile().SetLocalProfileFloat("Edit", "IODimY", m_IODim.y);
+    GetProfile().SetFloatProperty("Edit", "IODimX", m_IODim.x);
+    GetProfile().SetFloatProperty("Edit", "IODimY", m_IODim.y);
 }
 
 Math::Point CRobotMain::GetIODim()
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 39e7aa9..1b0facb 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -3541,7 +3541,7 @@ void CMainDialog::NameSelect()
 
     GetGamerFace(m_main->GetGamerName());
 
-    GetProfile().SetLocalProfileString("Gamer", "LastName", m_main->GetGamerName());
+    GetProfile().SetStringProperty("Gamer", "LastName", m_main->GetGamerName());
 }
 
 // Creates a new player.
@@ -5164,46 +5164,46 @@ void CMainDialog::ChangeSetupButtons()
 
 void CMainDialog::SetupMemorize()
 {
-    GetProfile().SetLocalProfileString("Directory", "scene",    m_sceneDir);
-    GetProfile().SetLocalProfileString("Directory", "savegame", m_savegameDir);
-    GetProfile().SetLocalProfileString("Directory", "public",   m_publicDir);
-    GetProfile().SetLocalProfileString("Directory", "user",     m_userDir);
-    GetProfile().SetLocalProfileString("Directory", "files",    m_filesDir);
-    GetProfile().SetLocalProfileInt("Setup", "Tooltips", m_bTooltip);
-    GetProfile().SetLocalProfileInt("Setup", "InterfaceGlint", m_bGlint);
-    GetProfile().SetLocalProfileInt("Setup", "InterfaceGlint", m_bRain);
-    GetProfile().SetLocalProfileInt("Setup", "Soluce4", m_bSoluce4);
-    GetProfile().SetLocalProfileInt("Setup", "Movies", m_bMovies);
-    GetProfile().SetLocalProfileInt("Setup", "NiceReset", m_bNiceReset);
-    GetProfile().SetLocalProfileInt("Setup", "HimselfDamage", m_bHimselfDamage);
-    GetProfile().SetLocalProfileInt("Setup", "CameraScroll", m_bCameraScroll);
-    GetProfile().SetLocalProfileInt("Setup", "CameraInvertX", m_bCameraInvertX);
-    GetProfile().SetLocalProfileInt("Setup", "CameraInvertY", m_bCameraInvertY);
-    GetProfile().SetLocalProfileInt("Setup", "InterfaceEffect", m_bEffect);
-    GetProfile().SetLocalProfileInt("Setup", "GroundShadow", m_engine->GetShadow());
-    GetProfile().SetLocalProfileInt("Setup", "GroundSpot", m_engine->GetGroundSpot());
-    GetProfile().SetLocalProfileInt("Setup", "ObjectDirty", m_engine->GetDirty());
-    GetProfile().SetLocalProfileInt("Setup", "FogMode", m_engine->GetFog());
-    GetProfile().SetLocalProfileInt("Setup", "LensMode", m_engine->GetLensMode());
-    GetProfile().SetLocalProfileInt("Setup", "SkyMode", m_engine->GetSkyMode());
-    GetProfile().SetLocalProfileInt("Setup", "PlanetMode", m_engine->GetPlanetMode());
-    GetProfile().SetLocalProfileInt("Setup", "LightMode", m_engine->GetLightMode());
-    GetProfile().SetLocalProfileFloat("Setup", "ParticleDensity", m_engine->GetParticleDensity());
-    GetProfile().SetLocalProfileFloat("Setup", "ClippingDistance", m_engine->GetClippingDistance());
-    GetProfile().SetLocalProfileFloat("Setup", "ObjectDetail", m_engine->GetObjectDetail());
-    GetProfile().SetLocalProfileFloat("Setup", "GadgetQuantity", m_engine->GetGadgetQuantity());
-    GetProfile().SetLocalProfileInt("Setup", "TextureQuality", m_engine->GetTextureQuality());
-    GetProfile().SetLocalProfileInt("Setup", "TotoMode", m_engine->GetTotoMode());
-    GetProfile().SetLocalProfileInt("Setup", "AudioVolume", m_sound->GetAudioVolume());
-    GetProfile().SetLocalProfileInt("Setup", "MusicVolume", m_sound->GetMusicVolume());
-    GetProfile().SetLocalProfileInt("Setup", "EditIndentMode", m_engine->GetEditIndentMode());
-    GetProfile().SetLocalProfileInt("Setup", "EditIndentValue", m_engine->GetEditIndentValue());
+    GetProfile().SetStringProperty("Directory", "scene",    m_sceneDir);
+    GetProfile().SetStringProperty("Directory", "savegame", m_savegameDir);
+    GetProfile().SetStringProperty("Directory", "public",   m_publicDir);
+    GetProfile().SetStringProperty("Directory", "user",     m_userDir);
+    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", "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().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());
 
     /* screen setup */
     if (m_setupFull)
-        GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 1);
+        GetProfile().SetIntProperty("Setup", "Fullscreen", 1);
     else
-        GetProfile().SetLocalProfileInt("Setup", "Fullscreen", 0);
+        GetProfile().SetIntProperty("Setup", "Fullscreen", 0);
 
     CList *pl;
     CWindow *pw;
@@ -5213,7 +5213,7 @@ void CMainDialog::SetupMemorize()
         pl = static_cast<CList *>(pw->SearchControl(EVENT_LIST2));
         if ( pl != 0 )
         {
-            GetProfile().SetLocalProfileInt("Setup", "Resolution", pl->GetSelect());
+            GetProfile().SetIntProperty("Setup", "Resolution", pl->GetSelect());
         }
     }
     else
@@ -5230,9 +5230,9 @@ void CMainDialog::SetupMemorize()
         key << b.secondary << "  ";
     }
 
-    GetProfile().SetLocalProfileString("Setup", "KeyMap", key.str());
+    GetProfile().SetStringProperty("Setup", "KeyMap", key.str());
 
-    GetProfile().SetLocalProfileInt("Setup", "DeleteGamer", m_bDeleteGamer);
+    GetProfile().SetIntProperty("Setup", "DeleteGamer", m_bDeleteGamer);
 }
 
 // Remember all the settings.
@@ -5243,48 +5243,48 @@ void CMainDialog::SetupRecall()
     int         iValue;
     std::string key;
 
-    if ( GetProfile().GetLocalProfileString("Directory", "scene", key) )
+    if ( GetProfile().GetStringProperty("Directory", "scene", key) )
     {
         m_sceneDir = key;
     }
 
-    if ( GetProfile().GetLocalProfileString("Directory", "savegame", key) )
+    if ( GetProfile().GetStringProperty("Directory", "savegame", key) )
     {
         m_savegameDir = key;
     }
 
-    if ( GetProfile().GetLocalProfileString("Directory", "public", key) )
+    if ( GetProfile().GetStringProperty("Directory", "public", key) )
     {
         m_publicDir = key;
     }
 
-    if ( GetProfile().GetLocalProfileString("Directory", "user", key) )
+    if ( GetProfile().GetStringProperty("Directory", "user", key) )
     {
         m_userDir = key;
     }
 
-    if ( GetProfile().GetLocalProfileString("Directory", "files", key) )
+    if ( GetProfile().GetStringProperty("Directory", "files", key) )
     {
         m_filesDir = key;
     }
 
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "TotoMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "TotoMode", iValue) )
     {
         m_engine->SetTotoMode(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Tooltips", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Tooltips", iValue) )
     {
         m_bTooltip = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "InterfaceGlint", iValue) )
     {
         m_bGlint = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "InterfaceGlint", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "InterfaceGlint", iValue) )
     {
         m_bRain = iValue;
     }
@@ -5295,86 +5295,86 @@ void CMainDialog::SetupRecall()
     //     m_engine->SetNiceMouse(iValue);
     // }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Soluce4", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Soluce4", iValue) )
     {
         m_bSoluce4 = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Movies", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Movies", iValue) )
     {
         m_bMovies = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "NiceReset", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "NiceReset", iValue) )
     {
         m_bNiceReset = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "HimselfDamage", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "HimselfDamage", iValue) )
     {
         m_bHimselfDamage = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "CameraScroll", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "CameraScroll", iValue) )
     {
         m_bCameraScroll = iValue;
         m_camera->SetCameraScroll(m_bCameraScroll);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "CameraInvertX", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "CameraInvertX", iValue) )
     {
         m_bCameraInvertX = iValue;
         m_camera->SetCameraInvertX(m_bCameraInvertX);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "CameraInvertY", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "CameraInvertY", iValue) )
     {
         m_bCameraInvertY = iValue;
         m_camera->SetCameraInvertY(m_bCameraInvertY);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "InterfaceEffect", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "InterfaceEffect", iValue) )
     {
         m_bEffect = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "GroundShadow", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "GroundShadow", iValue) )
     {
         m_engine->SetShadow(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "GroundSpot", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "GroundSpot", iValue) )
     {
         m_engine->SetGroundSpot(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "ObjectDirty", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "ObjectDirty", iValue) )
     {
         m_engine->SetDirty(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "FogMode", iValue) )
+    if ( GetProfile().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().GetLocalProfileInt("Setup", "LensMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "LensMode", iValue) )
     {
         m_engine->SetLensMode(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "SkyMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "SkyMode", iValue) )
     {
         m_engine->SetSkyMode(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "PlanetMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "PlanetMode", iValue) )
     {
         m_engine->SetPlanetMode(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "LightMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "LightMode", iValue) )
     {
         m_engine->SetLightMode(iValue);
     }
@@ -5384,52 +5384,52 @@ void CMainDialog::SetupRecall()
     //     m_engine->SetJoystick(iValue);
     // }
 
-    if ( GetProfile().GetLocalProfileFloat("Setup", "ParticleDensity", fValue) )
+    if ( GetProfile().GetFloatProperty("Setup", "ParticleDensity", fValue) )
     {
         m_engine->SetParticleDensity(fValue);
     }
 
-    if ( GetProfile().GetLocalProfileFloat("Setup", "ClippingDistance", fValue) )
+    if ( GetProfile().GetFloatProperty("Setup", "ClippingDistance", fValue) )
     {
         m_engine->SetClippingDistance(fValue);
     }
 
-    if ( GetProfile().GetLocalProfileFloat("Setup", "ObjectDetail", fValue) )
+    if ( GetProfile().GetFloatProperty("Setup", "ObjectDetail", fValue) )
     {
         m_engine->SetObjectDetail(fValue);
     }
 
-    if ( GetProfile().GetLocalProfileFloat("Setup", "GadgetQuantity", fValue) )
+    if ( GetProfile().GetFloatProperty("Setup", "GadgetQuantity", fValue) )
     {
         m_engine->SetGadgetQuantity(fValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "TextureQuality", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "TextureQuality", iValue) )
     {
         m_engine->SetTextureQuality(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "AudioVolume", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "AudioVolume", iValue) )
     {
         m_sound->SetAudioVolume(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "MusicVolume", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "MusicVolume", iValue) )
     {
         m_sound->SetMusicVolume(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentMode", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "EditIndentMode", iValue) )
     {
         m_engine->SetEditIndentMode(iValue);
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "EditIndentValue", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "EditIndentValue", iValue) )
     {
         m_engine->SetEditIndentValue(iValue);
     }
 
-    if (GetProfile().GetLocalProfileString("Setup", "KeyMap", key))
+    if (GetProfile().GetStringProperty("Setup", "KeyMap", key))
     {
         std::stringstream skey;
         skey.str(key);
@@ -5442,17 +5442,17 @@ void CMainDialog::SetupRecall()
          }
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "DeleteGamer", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "DeleteGamer", iValue) )
     {
         m_bDeleteGamer = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Resolution", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Resolution", iValue) )
     {
         m_setupSelMode = iValue;
     }
 
-    if ( GetProfile().GetLocalProfileInt("Setup", "Fullscreen", iValue) )
+    if ( GetProfile().GetIntProperty("Setup", "Fullscreen", iValue) )
     {
         m_setupFull = (iValue == 1);
     }
diff --git a/test/unit/common/profile_test.cpp b/test/unit/common/profile_test.cpp
index 1a4f239..2d21a90 100644
--- a/test/unit/common/profile_test.cpp
+++ b/test/unit/common/profile_test.cpp
@@ -17,23 +17,23 @@ protected:
 
 TEST_F(CProfileTest, ReadTest)
 {
-    m_profile.SetUseLocalDirectory(true);
+    m_profile.SetUseCurrentDirectory(true);
 
-    ASSERT_TRUE(m_profile.InitCurrentDirectory()); // load colobot.ini file
+    ASSERT_TRUE(m_profile.Init()); // load colobot.ini file
 
     std::string result;
-    ASSERT_TRUE(m_profile.GetLocalProfileString("test_string", "string_value", result));
+    ASSERT_TRUE(m_profile.GetStringProperty("test_string", "string_value", result));
     ASSERT_STREQ("Hello world", result.c_str());
 
     int int_value;
-    ASSERT_TRUE(m_profile.GetLocalProfileInt("test_int", "int_value", int_value));
+    ASSERT_TRUE(m_profile.GetIntProperty("test_int", "int_value", int_value));
     ASSERT_EQ(42, int_value);
 
     float float_value;
-    ASSERT_TRUE(m_profile.GetLocalProfileFloat("test_float", "float_value", float_value));
+    ASSERT_TRUE(m_profile.GetFloatProperty("test_float", "float_value", float_value));
     ASSERT_FLOAT_EQ(1.5, float_value);
 
     std::vector<std::string> list;
-    list = m_profile.GetLocalProfileSection("test_multi", "entry");
+    list = m_profile.GetSection("test_multi", "entry");
     ASSERT_EQ(5u, list.size());
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list