Added ear-candy to previous commit + made it easier to add sound effects in menus

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@4158 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2009-10-28 23:57:10 +00:00
parent 31a8987e26
commit 8158bc01b0
4 changed files with 31 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
#include <sstream>
#include <stdexcept>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <stdlib.h>
@@ -445,3 +446,26 @@ const std::string SFXManager::getErrorString(int err)
} // getErrorString
//-----------------------------------------------------------------------------
void SFXManager::quickSound(SFXType soundType)
{
static std::map<SFXType, SFXBase*> allSounds;
std::map<SFXType, SFXBase*>::iterator sound = allSounds.find(soundType);
if (sound == allSounds.end())
{
// sound not yet in our list
SFXBase* newSound = sfx_manager->newSFX(soundType);
newSound->play();
allSounds[soundType] = newSound;
}
else
{
(*sound).second->play();
}
// m_locked_sound = sfx_manager->newSFX(SFXManager::SOUND_LOCKED);
// m_locked_sound->play();
}

View File

@@ -117,6 +117,11 @@ public:
static bool checkError(const std::string &context);
static const std::string getErrorString(int err);
/** Positional sound is cool, but creating a new object just to play a simple
menu sound is not. This function allows for 'quick sounds' in a single call.*/
static void quickSound(SFXType soundType);
};
extern SFXManager* sfx_manager;

View File

@@ -222,4 +222,3 @@ void SoundManager::positionListener(const Vec3 &position, const Vec3 &front)
alListener3f(AL_POSITION, position.getX(), position.getY(), position.getZ());
alListenerfv(AL_ORIENTATION, m_listenerVec);
}

View File

@@ -287,6 +287,8 @@ ptr_vector<PlayerKartWidget, REF> g_player_karts;
playerName->getIrrlichtElement()->remove();
playerName->elementRemoved();
SFXManager::quickSound( SFXManager::SOUND_WEE );
modelView->setRotateTo(30.0f, 150.0f);
player_id_w *= 2;