diff options
author | Piotr Dziwinski <piotrdz@gmail.com> | 2012-09-22 14:40:13 +0200 |
---|---|---|
committer | Piotr Dziwinski <piotrdz@gmail.com> | 2012-09-22 14:40:13 +0200 |
commit | fd09071c29452bdfea2c519f0defbffebee42f4c (patch) | |
tree | 44d2d9d59d4c98204cb1d60bf101414bfc45b708 /src/app | |
parent | 37e7c73f439c0d8cbfd0f1c02b7ef5916fd748ae (diff) | |
download | colobot-fd09071c29452bdfea2c519f0defbffebee42f4c.tar.gz colobot-fd09071c29452bdfea2c519f0defbffebee42f4c.tar.bz2 colobot-fd09071c29452bdfea2c519f0defbffebee42f4c.zip |
Data dir paths
- changed access to paths in data directory in CApplication
- models now load from data directory
Diffstat (limited to 'src/app')
-rw-r--r-- | src/app/app.cpp | 42 | ||||
-rw-r--r-- | src/app/app.h | 12 |
2 files changed, 49 insertions, 5 deletions
diff --git a/src/app/app.cpp b/src/app/app.cpp index c787927..1d67745 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -132,6 +132,20 @@ CApplication::CApplication() m_language = LANG_ENGLISH; m_lowCPU = true; + + for (int i = 0; i < DIR_MAX; ++i) + m_dataDirs[i] = nullptr; + + m_dataDirs[DIR_AI] = "ai"; + m_dataDirs[DIR_FONT] = "fonts"; + m_dataDirs[DIR_HELP] = "help"; + m_dataDirs[DIR_I18N] = "i18n"; + m_dataDirs[DIR_ICON] = "icons"; + m_dataDirs[DIR_LEVEL] = "levels"; + m_dataDirs[DIR_MODEL] = "models"; + m_dataDirs[DIR_MUSIC] = "music"; + m_dataDirs[DIR_SOUND] = "sounds"; + m_dataDirs[DIR_TEXTURE] = "textures"; } CApplication::~CApplication() @@ -299,7 +313,7 @@ bool CApplication::Create() putenv(S_LANGUAGE); setlocale(LC_ALL, locale.c_str()); - std::string trPath = m_dataPath + std::string("/i18n"); + std::string trPath = m_dataPath + "/" + m_dataDirs[DIR_I18N]; bindtextdomain("colobot", trPath.c_str()); bind_textdomain_codeset("colobot", "UTF-8"); textdomain("colobot"); @@ -1345,9 +1359,31 @@ bool CApplication::GetJoystickEnabled() return m_joystickEnabled; } -std::string CApplication::GetDataFilePath(const std::string& dirName, const std::string& fileName) +std::string CApplication::GetDataDirPath() +{ + return m_dataPath; +} + +std::string CApplication::GetDataFilePath(DataDir dataDir, const std::string& subpath) +{ + int index = static_cast<int>(dataDir); + assert(index >= 0 && index < DIR_MAX); + std::stringstream str; + str << m_dataPath; + str << "/"; + str << m_dataDirs[index]; + str << "/"; + str << subpath; + return str.str(); +} + +std::string CApplication::GetDataFilePath(const std::string& subpath) { - return m_dataPath + "/" + dirName + "/" + fileName; + std::stringstream str; + str << m_dataPath; + str << "/"; + str << subpath; + return str.str(); } Language CApplication::GetLanguage() diff --git a/src/app/app.h b/src/app/app.h index f5383ce..f1e2c7f 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -283,8 +283,14 @@ public: bool GetDebugMode(); //@} - //! Returns the full path to a file in data directory - std::string GetDataFilePath(const std::string &dirName, const std::string &fileName); + //! Returns the full path to data directory + std::string GetDataDirPath(); + + //! Returns the full path to a file in data directory given standard dir and subpath + std::string GetDataFilePath(DataDir dir, const std::string &subpath); + + //! Returns the full path to a file in data directory given custom subpath in data dir + std::string GetDataFilePath(const std::string &subpath); //! Management of language //@{ @@ -397,6 +403,8 @@ protected: //! Path to directory with data files std::string m_dataPath; + const char* m_dataDirs[DIR_MAX]; + //! Application language Language m_language; |