1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00

Reimplement background noise things

This commit is contained in:
Timmy Sjöstedt 2016-05-24 23:26:17 +02:00
parent 2bf0500a34
commit 9a2bb1b156
2 changed files with 10 additions and 27 deletions

View File

@ -62,7 +62,5 @@ private:
ALCdevice* alDevice;
std::map<std::string, Sound> sounds;
sf::SoundStream* backgroundNoise;
std::string backgroundNoise;
};

View File

@ -56,7 +56,6 @@ bool SoundManager::SoundBuffer::bufferData(SoundSource& soundSource)
}
SoundManager::SoundManager()
: backgroundNoise(nullptr)
{
initializeOpenAL();
}
@ -124,36 +123,22 @@ bool SoundManager::isPlaying(const std::string& name)
bool SoundManager::playBackground(const std::string& fileName)
{
if( backgroundNoise )
{
delete backgroundNoise;
}
sf::Music* bg = new sf::Music;
if( bg->openFromFile( fileName ) )
{
backgroundNoise = bg;
backgroundNoise->setLoop(true);
bg->play();
if (this->loadSound(fileName, fileName)) {
backgroundNoise = fileName;
this->playSound(fileName);
return true;
}
delete bg;
return false;
}
void SoundManager::pause(bool p)
{
if( backgroundNoise )
{
if( p )
{
backgroundNoise->pause();
}
else
{
backgroundNoise->play();
if (backgroundNoise.length() > 0) {
if (p) {
pauseSound(backgroundNoise);
} else {
playSound(backgroundNoise);
}
}
}