summaryrefslogtreecommitdiffstats
path: root/src/app/app.cpp
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2012-09-22 14:40:13 +0200
committerPiotr Dziwinski <piotrdz@gmail.com>2012-09-22 14:40:13 +0200
commitfd09071c29452bdfea2c519f0defbffebee42f4c (patch)
tree44d2d9d59d4c98204cb1d60bf101414bfc45b708 /src/app/app.cpp
parent37e7c73f439c0d8cbfd0f1c02b7ef5916fd748ae (diff)
downloadcolobot-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/app.cpp')
-rw-r--r--src/app/app.cpp42
1 files changed, 39 insertions, 3 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()