summaryrefslogtreecommitdiffstats
path: root/src/app
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-07-24 23:38:13 +0200
committerkrzys-h <krzys_h@interia.pl>2014-07-24 23:38:13 +0200
commit9a3cd67c3bb2f7d0d4b83f6a5ac8bbcfedf4207b (patch)
treefd6401e9192541dc59f6f8d2cb47b9e898974cb3 /src/app
parent17041e718b35b766df099dfaeaf4e7cc3cc63fa6 (diff)
downloadcolobot-9a3cd67c3bb2f7d0d4b83f6a5ac8bbcfedf4207b.tar.gz
colobot-9a3cd67c3bb2f7d0d4b83f6a5ac8bbcfedf4207b.tar.bz2
colobot-9a3cd67c3bb2f7d0d4b83f6a5ac8bbcfedf4207b.zip
Saving colobot.ini through physfs
Diffstat (limited to 'src/app')
-rw-r--r--src/app/main.cpp4
-rw-r--r--src/app/system.cpp4
-rw-r--r--src/app/system.h4
-rw-r--r--src/app/system_linux.cpp24
-rw-r--r--src/app/system_linux.h2
-rw-r--r--src/app/system_macosx.cpp11
-rw-r--r--src/app/system_macosx.h2
-rw-r--r--src/app/system_windows.cpp16
-rw-r--r--src/app/system_windows.h2
9 files changed, 37 insertions, 32 deletions
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 6ba8da2..294b306 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -102,6 +102,9 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
{
return app->GetExitCode();
}
+
+ manager.SetSaveLocation(systemUtils->GetSaveDir());
+ manager.AddLocation(systemUtils->GetSaveDir(), true);
int code = 0;
@@ -121,6 +124,7 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
delete app;
delete systemUtils;
+ //delete manager;
logger.Info("Exiting with code %d\n", code);
return code;
diff --git a/src/app/system.cpp b/src/app/system.cpp
index b2e6b47..66d08e5 100644
--- a/src/app/system.cpp
+++ b/src/app/system.cpp
@@ -192,7 +192,7 @@ float CSystemUtils::TimeStampDiff(SystemTimeStamp *before, SystemTimeStamp *afte
return result;
}
-std::string CSystemUtils::GetProfileFileLocation()
+std::string CSystemUtils::GetSaveDir()
{
- return std::string("colobot.ini");
+ return std::string("save");
}
diff --git a/src/app/system.h b/src/app/system.h
index 01f2672..6d2fe58 100644
--- a/src/app/system.h
+++ b/src/app/system.h
@@ -130,8 +130,8 @@ public:
/** 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 GetProfileFileLocation();
+ //! Returns the save dir location
+ virtual std::string GetSaveDir();
};
//! Global function to get CSystemUtils instance
diff --git a/src/app/system_linux.cpp b/src/app/system_linux.cpp
index e584cd1..485d7c2 100644
--- a/src/app/system_linux.cpp
+++ b/src/app/system_linux.cpp
@@ -95,29 +95,29 @@ long long CSystemUtilsLinux::TimeStampExactDiff(SystemTimeStamp *before, SystemT
(after->clockTime.tv_sec - before->clockTime.tv_sec) * 1000000000ll;
}
-std::string CSystemUtilsLinux::GetProfileFileLocation()
+std::string CSystemUtilsLinux::GetSaveDir()
{
- std::string profileFile;
-
- // Determine profileFile according to XDG Base Directory Specification
- char* envXDG_CONFIG_HOME = getenv("XDG_CONFIG_HOME");
- if (envXDG_CONFIG_HOME == NULL)
+ std::string savegameDir;
+
+ // Determine savegame dir according to XDG Base Directory Specification
+ char *envXDG_DATA_HOME = getenv("XDG_CONFIG_DATA");
+ if (envXDG_DATA_HOME == NULL)
{
char *envHOME = getenv("HOME");
if (envHOME == NULL)
{
- profileFile = "colobot.ini";
+ savegameDir = "/tmp/colobot-save";
}
else
{
- profileFile = std::string(envHOME) + "/.config/colobot.ini";
+ savegameDir = std::string(envHOME) + "/.local/share/colobot";
}
}
else
{
- profileFile = std::string(envXDG_CONFIG_HOME) + "/colobot.ini";
+ savegameDir = std::string(envXDG_DATA_HOME) + "/colobot";
}
- GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
-
- return profileFile;
+ GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
+
+ return savegameDir;
}
diff --git a/src/app/system_linux.h b/src/app/system_linux.h
index ad26454..f9cce05 100644
--- a/src/app/system_linux.h
+++ b/src/app/system_linux.h
@@ -46,7 +46,7 @@ public:
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
- virtual std::string GetProfileFileLocation() override;
+ virtual std::string GetSaveDir() override;
private:
bool m_zenityAvailable;
diff --git a/src/app/system_macosx.cpp b/src/app/system_macosx.cpp
index 38885eb..473a10c 100644
--- a/src/app/system_macosx.cpp
+++ b/src/app/system_macosx.cpp
@@ -87,10 +87,11 @@ void CSystemUtilsMacOSX::Init()
m_dataPath += "/Contents/Resources";
}
-std::string CSystemUtilsMacOSX::GetProfileFileLocation()
+std::string CSystemUtilsMacOSX::GetSaveDir()
{
- std::string profileFile = m_ASPath + "/colobot.ini";
-
- GetLogger()->Trace("Profile file is %s\n", profileFile.c_str());
- return profileFile;
+ std::string savegameDir = m_ASPath;
+ boost::filesystem::create_directories(savegameDir.c_str());
+ GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
+
+ return savegameDir;
}
diff --git a/src/app/system_macosx.h b/src/app/system_macosx.h
index 7360af1..6423320 100644
--- a/src/app/system_macosx.h
+++ b/src/app/system_macosx.h
@@ -28,7 +28,7 @@ class CSystemUtilsMacOSX : public CSystemUtilsOther
public:
virtual void Init() override;
- virtual std::string GetProfileFileLocation() override;
+ virtual std::string GetSaveDir() override;
private:
std::string m_ASPath;
std::string m_dataPath;
diff --git a/src/app/system_windows.cpp b/src/app/system_windows.cpp
index ffaa18a..e35f83f 100644
--- a/src/app/system_windows.cpp
+++ b/src/app/system_windows.cpp
@@ -111,20 +111,20 @@ std::wstring CSystemUtilsWindows::UTF8_Decode(const std::string& str)
}
-std::string CSystemUtilsWindows::GetProfileFileLocation()
+std::string CSystemUtilsWindows::GetSaveDir()
{
- std::string profileFile;
-
+ std::string savegameDir;
+
char* envUSERPROFILE = getenv("USERPROFILE");
if (envUSERPROFILE == NULL)
{
- profileFile = "colobot.ini";
+ savegameDir = "save";
}
else
{
- profileFile = std::string(envUSERPROFILE) + "\\colobot\\colobot.ini";
+ savegameDir = std::string(envUSERPROFILE) + "\\colobot";
}
- GetLogger()->Trace("Profile configuration is %s\n", profileFile.c_str());
-
- return profileFile;
+ GetLogger()->Trace("Saved game files are going to %s\n", savegameDir.c_str());
+
+ return savegameDir;
}
diff --git a/src/app/system_windows.h b/src/app/system_windows.h
index 0a41c1a..618caf9 100644
--- a/src/app/system_windows.h
+++ b/src/app/system_windows.h
@@ -44,7 +44,7 @@ public:
virtual long long GetTimeStampExactResolution() override;
virtual long long TimeStampExactDiff(SystemTimeStamp *before, SystemTimeStamp *after) override;
- virtual std::string GetProfileFileLocation() override;
+ virtual std::string GetSaveDir() override;
private:
std::string UTF8_Encode(const std::wstring &wstr);