From 991dbd1e37366b43b790740beb2fef755c56dcba Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Wed, 27 Mar 2013 10:20:06 +0100 Subject: Add profile and savegame fetchers in SystemUtils This breaks the tests compilation. :/ --- src/app/system.cpp | 10 ++++++++++ src/app/system.h | 6 ++++++ src/common/profile.cpp | 6 ++++-- src/ui/maindialog.cpp | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/app/system.cpp b/src/app/system.cpp index 6927af8..743ed96 100644 --- a/src/app/system.cpp +++ b/src/app/system.cpp @@ -187,3 +187,13 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte return result; } + +std::string CSystemUtils::profileFileLocation() +{ + return std::string("colobot.ini"); +} + +std::string CSystemUtils::savegameDirectoryLocation() +{ + return std::string("savegame"); +} diff --git a/src/app/system.h b/src/app/system.h index 278a4bf..6ae05d6 100644 --- a/src/app/system.h +++ b/src/app/system.h @@ -129,6 +129,12 @@ public: //! Returns the exact (in nanosecond units) difference between two timestamps /** The difference is \a after - \a before. */ virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) = 0; + + //! Returns the profile (colobot.ini) file location + virtual std::string profileFileLocation(); + + //! Returns the savegame directory location + virtual std::string savegameDirectoryLocation(); }; //! Global function to get CSystemUtils instance diff --git a/src/common/profile.cpp b/src/common/profile.cpp index 2d11217..654648d 100644 --- a/src/common/profile.cpp +++ b/src/common/profile.cpp @@ -19,6 +19,8 @@ #include "common/logger.h" +#include "app/system.h" + #include #include #include @@ -41,7 +43,7 @@ CProfile::~CProfile() { try { - bp::ini_parser::write_ini("colobot.ini", m_propertyTree); + bp::ini_parser::write_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); } catch (std::exception & e) { @@ -55,7 +57,7 @@ bool CProfile::InitCurrentDirectory() { try { - bp::ini_parser::read_ini("colobot.ini", m_propertyTree); + bp::ini_parser::read_ini(GetSystemUtils()->profileFileLocation(), m_propertyTree); } catch (std::exception & e) { diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index a3670de..ced4324 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -18,6 +18,7 @@ #include "ui/maindialog.h" #include "app/app.h" +#include "app/system.h" #include "common/global.h" #include "common/event.h" @@ -173,7 +174,7 @@ CMainDialog::CMainDialog() m_sceneDir = "levels"; - m_savegameDir = "savegame"; + m_savegameDir = GetSystemUtils()->savegameDirectoryLocation(); m_publicDir = "program"; m_userDir = "user"; m_filesDir = "files"; -- cgit v1.2.3-1-g7c22