From 4cbb63f5b7824dc48e999401c625adb50075fdca Mon Sep 17 00:00:00 2001 From: Piotr Dziwinski Date: Fri, 28 Dec 2012 12:06:37 +0100 Subject: Fixed path for loading sounds --- src/app/app.cpp | 33 +++++++++++++++++++-------------- src/app/app.h | 8 ++++---- 2 files changed, 23 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/app/app.cpp b/src/app/app.cpp index 27adcb1..4d32de3 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -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(new ALSound()); - #else - GetLogger()->Info("No sound support.\n"); - m_sound = new CSoundInterface(); - #endif + #ifdef OPENAL_SOUND + m_sound = static_cast(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(dataDir); + int index = static_cast(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(stdDir); + assert(index >= 0 && index < DIR_MAX); std::stringstream str; str << m_dataPath; str << "/"; + str << m_dataDirs[index]; + str << "/"; str << subpath; return str.str(); } diff --git a/src/app/app.h b/src/app/app.h index 5bf6867..20d07df 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -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 //@{ -- cgit v1.2.3-1-g7c22