summaryrefslogtreecommitdiffstats
path: root/src/sound
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-05-18 12:12:47 +0200
committerkrzys-h <krzys_h@interia.pl>2014-05-18 12:12:47 +0200
commitf0d97bfdb91a2c0a17d1697b145d4df930280dbb (patch)
tree2d529428006e145b624108cce636b07867f566af /src/sound
parentf71658e38dbcfc5635a6b2a9c6c4168582728bb5 (diff)
downloadcolobot-f0d97bfdb91a2c0a17d1697b145d4df930280dbb.tar.gz
colobot-f0d97bfdb91a2c0a17d1697b145d4df930280dbb.tar.bz2
colobot-f0d97bfdb91a2c0a17d1697b145d4df930280dbb.zip
Better datadir mod support
Diffstat (limited to 'src/sound')
-rw-r--r--src/sound/oalsound/alsound.cpp15
-rw-r--r--src/sound/sound.cpp7
-rw-r--r--src/sound/sound.h7
3 files changed, 12 insertions, 17 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 23476d4..8afbdd2 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -18,6 +18,8 @@
#include "sound/oalsound/alsound.h"
+#include "app/gamedata.h"
+
#include <algorithm>
#include <iomanip>
@@ -163,7 +165,7 @@ int ALSound::GetMusicVolume()
bool ALSound::Cache(Sound sound, const std::string &filename)
{
Buffer *buffer = new Buffer();
- if (buffer->LoadFromFile(filename, sound))
+ if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_SOUND, filename), sound))
{
m_sounds[sound] = buffer;
return true;
@@ -176,9 +178,7 @@ bool ALSound::CacheMusic(const std::string &filename)
if (m_music.find(filename) == m_music.end())
{
Buffer *buffer = new Buffer();
- std::stringstream file;
- file << m_soundPath << "/" << filename;
- if (buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
+ if (buffer->LoadFromFile(CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename), static_cast<Sound>(-1)))
{
m_music[filename] = buffer;
return true;
@@ -635,22 +635,21 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
return false;
}
- std::stringstream file;
- file << m_soundPath << "/" << filename;
+ std::string file = CGameData::GetInstancePointer()->GetFilePath(DIR_MUSIC, filename);
Buffer *buffer;
// check if we have music in cache
if (m_music.find(filename) == m_music.end())
{
GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
- if (!boost::filesystem::exists(file.str()))
+ if (!boost::filesystem::exists(file))
{
GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
return false;
}
buffer = new Buffer();
- if (!buffer->LoadFromFile(file.str(), static_cast<Sound>(-1)))
+ if (!buffer->LoadFromFile(file, static_cast<Sound>(-1)))
{
return false;
}
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index c4b30b5..9cae1fd 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -41,20 +41,19 @@ bool CSoundInterface::Create()
return true;
}
-void CSoundInterface::CacheAll(const std::string &path)
+void CSoundInterface::CacheAll()
{
for ( int i = 1; i < SOUND_MAX; i++ )
{
std::stringstream filename;
- filename << path << "/sound" << std::setfill('0') << std::setw(3) << i << ".wav";
+ filename << "sound" << std::setfill('0') << std::setw(3) << i << ".wav";
if ( !Cache(static_cast<Sound>(i), filename.str()) )
GetLogger()->Warn("Unable to load audio: %s\n", filename.str().c_str());
}
}
-void CSoundInterface::AddMusicFiles(const std::string &path)
+void CSoundInterface::AddMusicFiles()
{
- m_soundPath = path;
CacheMusic("Intro1.ogg");
CacheMusic("Intro2.ogg");
CacheMusic("music010.ogg");
diff --git a/src/sound/sound.h b/src/sound/sound.h
index e86da2b..22a5ee2 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -159,10 +159,10 @@ public:
/** Function called to cache all sound effect files.
* Function calls \link CSoundInterface::Cache() \endlink for each file
*/
- void CacheAll(const std::string &path);
+ void CacheAll();
/** Function called to add all music files to list */
- void AddMusicFiles(const std::string &path);
+ void AddMusicFiles();
/** Function called to cache sound effect file.
* This function is called by plugin interface for each file.
@@ -327,8 +327,5 @@ public:
* \return nothing
*/
virtual void StopPauseMusic();
-
-protected:
- std::string m_soundPath;
};