More work on audio : enabling SFX in-game now works significantly better, cakes and zippers now work properly. Disabling SFX in-game still not checked; when when enabling SFX in-game, looping sounds like kart engines are not started

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6245 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2010-10-11 02:13:45 +00:00
parent 65fdc2f2ee
commit 3f0f1d4b57
5 changed files with 25 additions and 1 deletions

View File

@ -73,6 +73,8 @@ SFXBuffer::SFXBuffer(const std::string& file,
bool SFXBuffer::load()
{
if (m_loaded) return false;
alGetError(); // clear errors from previously
alGenBuffers(1, &m_buffer);

View File

@ -71,7 +71,8 @@ public:
}
/**
* \brief load the buffer from file into OpenAL
* \brief load the buffer from file into OpenAL.
* \note If this buffer is already loaded, this call does nothing and returns false
* \return whether loading was successful
*/
bool load();

View File

@ -99,6 +99,23 @@ SFXManager::~SFXManager()
} // ~SFXManager
//----------------------------------------------------------------------------
void SFXManager::soundToggled(const bool on)
{
// When activating SFX, load all buffers
if (on)
{
std::map<std::string, SFXBuffer*>::iterator i = m_all_sfx_types.begin();
for (; i != m_all_sfx_types.end(); i++)
{
SFXBuffer* buffer = (*i).second;
buffer->load();
}
}
}
//----------------------------------------------------------------------------
bool SFXManager::sfxAllowed()
{
if(!UserConfigParams::m_sfx || !m_initialized)

View File

@ -126,6 +126,9 @@ public:
void positionListener(const Vec3 &position, const Vec3 &front);
void quickSound(const std::string &soundName);
/** Called when sound was muted/unmuted */
void soundToggled(const bool newValue);
};

View File

@ -144,6 +144,7 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
CheckBoxWidget* w = dynamic_cast<CheckBoxWidget*>(widget);
UserConfigParams::m_sfx = w->getState();
sfx_manager->soundToggled(UserConfigParams::m_sfx);
}
} // eventCallback