From 74312b0405d6fb5ed75c675ceed471e1e5086f00 Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Tue, 12 Aug 2014 20:03:56 +0200 Subject: Better CMake organization and unit test cleanups * created a static library containing most source modules to avoid compiling source modules twice in code and unit tests * moved profile_test to main unit tests executable * removed image_test and edit_test as not really useful --- src/common/profile.cpp | 26 ++++++++++++++------------ src/common/profile.h | 7 +++++++ 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src/common') diff --git a/src/common/profile.cpp b/src/common/profile.cpp index ee3e873..a63a772 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -31,8 +31,9 @@ template<> CProfile* CSingleton::m_instance = nullptr; namespace bp = boost::property_tree; -CProfile::CProfile() : - m_profileNeedSave(false) +CProfile::CProfile() + : m_profileNeedSave(false) + , m_useLocalDirectory(false) { } @@ -42,16 +43,21 @@ CProfile::~CProfile() SaveCurrentDirectory(); } +void CProfile::SetUseLocalDirectory(bool useLocalDirectory) +{ + m_useLocalDirectory = useLocalDirectory; +} + +std::string CProfile::GetIniFileLocation() +{ + return m_useLocalDirectory ? "colobot.ini" : GetSystemUtils()->GetProfileFileLocation(); +} bool CProfile::InitCurrentDirectory() { try { - #if DEV_BUILD - bp::ini_parser::read_ini("colobot.ini", m_propertyTree); - #else - bp::ini_parser::read_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #endif + bp::ini_parser::read_ini(GetIniFileLocation(), m_propertyTree); } catch (std::exception & e) { @@ -67,11 +73,7 @@ bool CProfile::SaveCurrentDirectory() { try { - #if DEV_BUILD - bp::ini_parser::write_ini("colobot.ini", m_propertyTree); - #else - bp::ini_parser::write_ini(GetSystemUtils()->GetProfileFileLocation(), m_propertyTree); - #endif + bp::ini_parser::write_ini(GetIniFileLocation(), m_propertyTree); } catch (std::exception & e) { diff --git a/src/common/profile.h b/src/common/profile.h index f084ece..52f9f15 100644 --- a/src/common/profile.h +++ b/src/common/profile.h @@ -45,6 +45,9 @@ public: CProfile(); virtual ~CProfile(); + /** Set flag to force using ini file from local directory */ + void SetUseLocalDirectory(bool useLocalDirectory); + /** Loads colobot.ini from current directory * \return return true on success */ @@ -129,10 +132,14 @@ public: */ bool CopyFileToTemp(std::string filename); +private: + std::string GetIniFileLocation(); + private: boost::property_tree::ptree m_propertyTree; bool m_profileNeedSave; std::string m_userDirectory; + bool m_useLocalDirectory; }; //! Global function to get profile instance -- cgit v1.2.3-1-g7c22