Fixed race over music not playing when sfx are disabled.
This commit is contained in:
@@ -62,6 +62,10 @@ DEFINE_SCREEN_SINGLETON( RaceResultGUI );
|
||||
RaceResultGUI::RaceResultGUI() : Screen("race_result.stkgui",
|
||||
/*pause race*/ false)
|
||||
{
|
||||
std::string path = file_manager->getAsset(FileManager::MUSIC,
|
||||
"race_summary.music");
|
||||
m_race_over_music = music_manager->getMusicInformation(path);
|
||||
|
||||
} // RaceResultGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -83,6 +87,13 @@ void RaceResultGUI::init()
|
||||
|
||||
music_manager->stopMusic();
|
||||
m_finish_sound = SFXManager::get()->quickSound("race_finish");
|
||||
if (!m_finish_sound)
|
||||
{
|
||||
// If there is no finish sound (because sfx are disabled), start
|
||||
// the race over music here (since the race over music is only started
|
||||
// when the finish sound has been played).
|
||||
music_manager->startMusic(m_race_over_music);
|
||||
}
|
||||
|
||||
// Calculate how many track screenshots can fit into the "result-table" widget
|
||||
GUIEngine::Widget* result_table = getWidget("result-table");
|
||||
@@ -600,14 +611,14 @@ void RaceResultGUI::onUpdate(float dt)
|
||||
{
|
||||
renderGlobal(dt);
|
||||
|
||||
if (m_finish_sound != NULL &&
|
||||
m_finish_sound->getStatus() != SFXBase::SFX_PLAYING)
|
||||
// When the finish sound has been played, start the race over music.
|
||||
if(m_finish_sound && m_finish_sound->getStatus() != SFXBase::SFX_PLAYING)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string path = file_manager->getAsset(FileManager::MUSIC,
|
||||
"race_summary.music");
|
||||
music_manager->startMusic(music_manager->getMusicInformation(path));
|
||||
// This call is done once each frame, but startMusic() is cheap
|
||||
// if the music is already playing.
|
||||
music_manager->startMusic(m_race_over_music);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
#ifndef HEADER_RACE_RESULT_GUI_HPP
|
||||
#define HEADER_RACE_RESULT_GUI_HPP
|
||||
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
#include "states_screens/race_gui_base.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "states_screens/dialogs/message_dialog.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
@@ -36,6 +37,7 @@ namespace irr
|
||||
}
|
||||
}
|
||||
|
||||
class MusicInformation;
|
||||
class SFXBase;
|
||||
|
||||
/**
|
||||
@@ -162,13 +164,17 @@ private:
|
||||
/** The previous monospace state of the font. */
|
||||
bool m_was_monospace;
|
||||
|
||||
SFXBase* m_finish_sound;
|
||||
/** Sound effect at end of race. */
|
||||
SFXBase *m_finish_sound;
|
||||
|
||||
/** Music to be played after race ended. */
|
||||
MusicInformation *m_race_over_music;
|
||||
|
||||
/** For highscores */
|
||||
std::string m_highscore_who;
|
||||
|
||||
/** For highscores */
|
||||
StateManager::ActivePlayer* m_highscore_player;
|
||||
StateManager::ActivePlayer *m_highscore_player;
|
||||
|
||||
/** For highscores */
|
||||
int m_highscore_rank;
|
||||
|
||||
Reference in New Issue
Block a user