Add nice little race end fanfare and race summary song by Dundersylt

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8648 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-05-21 01:07:06 +00:00
parent 47d03595de
commit c5ddfb1d6d
4 changed files with 21 additions and 5 deletions

View File

@ -482,25 +482,29 @@ void SFXManager::positionListener(const Vec3 &position, const Vec3 &front)
/** Positional sound is cool, but creating a new object just to play a simple /** 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. * menu sound is not. This function allows for 'quick sounds' in a single call.
* \param sound_type Internal name of the sfx to play. * \param sound_type Internal name of the sfx to play.
* \return a pointer to the sound, for instance to check when the sound finished.
* don't delete the returned pointer.
*/ */
SFXBase* SFXManager::quickSound(const std::string &sound_type)
void SFXManager::quickSound(const std::string &sound_type)
{ {
if(!sfxAllowed()) return; if (!sfxAllowed()) return NULL;
std::map<std::string, SFXBase*>::iterator sound = m_quick_sounds.find(sound_type); std::map<std::string, SFXBase*>::iterator sound = m_quick_sounds.find(sound_type);
if (sound == m_quick_sounds.end()) if (sound == m_quick_sounds.end())
{ {
// sound not yet in our local list of quick sounds // sound not yet in our local list of quick sounds
SFXBase* newSound = sfx_manager->createSoundSource(sound_type, false); SFXBase* newSound = sfx_manager->createSoundSource(sound_type, false);
if (newSound == NULL) return NULL;
newSound->play(); newSound->play();
m_quick_sounds[sound_type] = newSound; m_quick_sounds[sound_type] = newSound;
return newSound;
} }
else else
{ {
(*sound).second->play(); (*sound).second->play();
return (*sound).second;
} }
// m_locked_sound = sfx_manager->newSFX(SFXManager::SOUND_LOCKED); // m_locked_sound = sfx_manager->newSFX(SFXManager::SOUND_LOCKED);
// m_locked_sound->play(); // m_locked_sound->play();
} }

View File

@ -125,7 +125,7 @@ public:
static const std::string getErrorString(int err); static const std::string getErrorString(int err);
void positionListener(const Vec3 &position, const Vec3 &front); void positionListener(const Vec3 &position, const Vec3 &front);
void quickSound(const std::string &soundName); SFXBase* quickSound(const std::string &soundName);
/** Called when sound was muted/unmuted */ /** Called when sound was muted/unmuted */
void soundToggled(const bool newValue); void soundToggled(const bool newValue);

View File

@ -19,6 +19,8 @@
#include "states_screens/race_result_gui.hpp" #include "states_screens/race_result_gui.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_base.hpp"
#include "challenges/unlock_manager.hpp" #include "challenges/unlock_manager.hpp"
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/scalable_font.hpp" #include "guiengine/scalable_font.hpp"
@ -55,6 +57,9 @@ void RaceResultGUI::init()
getWidget("top")->setVisible(false); getWidget("top")->setVisible(false);
getWidget("middle")->setVisible(false); getWidget("middle")->setVisible(false);
getWidget("bottom")->setVisible(false); getWidget("bottom")->setVisible(false);
music_manager->stopMusic();
m_finish_sound = sfx_manager->quickSound("race_finish");
} // init } // init
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -374,6 +379,11 @@ GUIEngine::EventPropagation RaceResultGUI::filterActions(PlayerAction action,
void RaceResultGUI::onUpdate(float dt, irr::video::IVideoDriver*) void RaceResultGUI::onUpdate(float dt, irr::video::IVideoDriver*)
{ {
renderGlobal(dt); renderGlobal(dt);
if (m_finish_sound != NULL && m_finish_sound->getStatus() != SFXManager::SFX_PLAYING)
{
music_manager->startMusic( music_manager->getMusicInformation("race_summary.music") );
}
} // onUpdate } // onUpdate
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@ -160,6 +160,8 @@ private:
/** The previous monospace state of the font. */ /** The previous monospace state of the font. */
bool m_was_monospace; bool m_was_monospace;
SFXBase* m_finish_sound;
void displayOneEntry(unsigned int x, unsigned int y, void displayOneEntry(unsigned int x, unsigned int y,
unsigned int n, bool display_points); unsigned int n, bool display_points);
void determineTableLayout(); void determineTableLayout();