Fixed path for loading sounds

dev-ui
Piotr Dziwinski 2012-12-28 12:06:37 +01:00
parent b046c33206
commit 4cbb63f5b7
2 changed files with 23 additions and 18 deletions

View File

@ -329,26 +329,29 @@ bool CApplication::Create()
GetLogger()->Debug("Testing gettext translation: '%s'\n", gettext("Colobot rules!"));
//Create the sound instance.
if (!GetProfile().InitCurrentDirectory()) {
if (!GetProfile().InitCurrentDirectory())
{
GetLogger()->Warn("Config not found. Default values will be used!\n");
m_sound = new CSoundInterface();
} else {
}
else
{
std::string path;
if (GetProfile().GetLocalProfileString("Resources", "Data", path))
m_dataPath = path;
#ifdef OPENAL_SOUND
m_sound = static_cast<CSoundInterface *>(new ALSound());
#else
GetLogger()->Info("No sound support.\n");
m_sound = new CSoundInterface();
#endif
#ifdef OPENAL_SOUND
m_sound = static_cast<CSoundInterface *>(new ALSound());
#else
GetLogger()->Info("No sound support.\n");
m_sound = new CSoundInterface();
#endif
m_sound->Create(true);
if (GetProfile().GetLocalProfileString("Resources", "Sound", path))
m_sound->CacheAll(path);
else
m_sound->CacheAll(m_dataPath);
m_sound->CacheAll(GetDataSubdirPath(DIR_SOUND));
}
std::string standardInfoMessage =
@ -1421,24 +1424,26 @@ std::string CApplication::GetDataDirPath()
return m_dataPath;
}
std::string CApplication::GetDataFilePath(DataDir dataDir, const std::string& subpath)
std::string CApplication::GetDataSubdirPath(DataDir stdDir)
{
int index = static_cast<int>(dataDir);
int index = static_cast<int>(stdDir);
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)
std::string CApplication::GetDataFilePath(DataDir stdDir, const std::string& subpath)
{
int index = static_cast<int>(stdDir);
assert(index >= 0 && index < DIR_MAX);
std::stringstream str;
str << m_dataPath;
str << "/";
str << m_dataDirs[index];
str << "/";
str << subpath;
return str.str();
}

View File

@ -285,11 +285,11 @@ public:
//! 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 standard dir in data directory
std::string GetDataSubdirPath(DataDir stdDir);
//! Returns the full path to a file in data directory given custom subpath in data dir
std::string GetDataFilePath(const std::string &subpath);
//! Returns the full path to a file in data directory given standard dir and subpath
std::string GetDataFilePath(DataDir stdDir, const std::string &subpath);
//! Management of language
//@{