Add profile and savegame fetchers in SystemUtils

This breaks the tests compilation. :/
dev-ui
Didier Raboud 2013-03-27 10:20:06 +01:00
parent df5edc703c
commit 991dbd1e37
4 changed files with 22 additions and 3 deletions

View File

@ -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");
}

View File

@ -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

View File

@ -19,6 +19,8 @@
#include "common/logger.h"
#include "app/system.h"
#include <utility>
#include <cstring>
#include <boost/property_tree/ini_parser.hpp>
@ -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)
{

View File

@ -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";