Turn sfx_manager into a singleton.

This commit is contained in:
hiker 2014-09-17 21:38:21 +10:00
parent 04dd7869cb
commit 86b351fbf4
46 changed files with 201 additions and 172 deletions

View File

@ -45,9 +45,28 @@
#include "race/race_manager.hpp"
#include "utils/constants.hpp"
SFXManager* sfx_manager= NULL;
std::map<std::string, SFXBase*> SFXManager::m_quick_sounds;
SFXManager *SFXManager::m_sfx_manager;
/** Static function to create the singleton sfx manager.
*/
void SFXManager::create()
{
assert(!m_sfx_manager);
m_sfx_manager = new SFXManager();
} // create
// ------------------------------------------------------------------------
/** Static function to delete the singleton sfx manager.
*/
void SFXManager::destroy()
{
assert(m_sfx_manager);
delete m_sfx_manager;
m_sfx_manager = NULL;
} // destroy
// ----------------------------------------------------------------------------
/** Initialises the SFX manager and loads the sfx from a config file.
*/
SFXManager::SFXManager()
@ -99,7 +118,6 @@ SFXManager::~SFXManager()
}
m_all_sfx_types.clear();
sfx_manager = NULL;
} // ~SFXManager
//----------------------------------------------------------------------------
@ -524,7 +542,7 @@ SFXBase* SFXManager::quickSound(const std::string &sound_type)
if (sound == m_quick_sounds.end())
{
// sound not yet in our local list of quick sounds
SFXBase* newSound = sfx_manager->createSoundSource(sound_type, false);
SFXBase* newSound = SFXManager::get()->createSoundSource(sound_type, false);
if (newSound == NULL) return NULL;
newSound->play();
m_quick_sounds[sound_type] = newSound;
@ -535,9 +553,6 @@ SFXBase* SFXManager::quickSound(const std::string &sound_type)
(*sound).second->play();
return (*sound).second;
}
// m_locked_sound = sfx_manager->newSFX(SFXManager::SOUND_LOCKED);
// m_locked_sound->play();
}
} // quickSound

View File

@ -50,6 +50,10 @@ class XMLNode;
*/
class SFXManager : public NoCopy
{
private:
/** Singleton pointer. */
static SFXManager *m_sfx_manager;
public:
/**
@ -100,10 +104,21 @@ private:
float m_master_gain;
void loadSfx();
public:
SFXManager();
virtual ~SFXManager();
public:
static void create();
static void destroy();
// ------------------------------------------------------------------------
/** Static function to get the singleton sfx manager. */
static SFXManager *get()
{
assert(m_sfx_manager);
return m_sfx_manager;
} // get
// ------------------------------------------------------------------------
bool sfxAllowed();
SFXBuffer* loadSingleSfx(const XMLNode* node,
const std::string &path=std::string(""),

View File

@ -53,7 +53,7 @@ SFXOpenAL::SFXOpenAL(SFXBuffer* buffer, bool positional, float gain, bool ownsBu
// Don't initialise anything else if the sfx manager was not correctly
// initialised. First of all the initialisation will not work, and it
// will not be used anyway.
if (sfx_manager->sfxAllowed())
if (SFXManager::get()->sfxAllowed())
{
init();
}
@ -226,7 +226,7 @@ void SFXOpenAL::resume()
*/
void SFXOpenAL::play()
{
if (!sfx_manager->sfxAllowed()) return;
if (!SFXManager::get()->sfxAllowed()) return;
if (!m_ok)
{
// lazily create OpenAL source when needed
@ -268,7 +268,7 @@ void SFXOpenAL::position(const Vec3 &position)
alSource3f(m_soundSource, AL_POSITION,
(float)position.getX(), (float)position.getY(), (float)position.getZ());
if (sfx_manager->getListenerPos().distance(position) > m_soundBuffer->getMaxDist())
if (SFXManager::get()->getListenerPos().distance(position) > m_soundBuffer->getMaxDist())
{
alSourcef(m_soundSource, AL_GAIN, 0);
}

View File

@ -49,7 +49,7 @@ UnlockManager::UnlockManager()
// in main).
unlock_manager = this;
m_locked_sound = sfx_manager->createSoundSource("locked");
m_locked_sound = SFXManager::get()->createSoundSource("locked");
// Read challenges from .../data/challenges

View File

@ -360,7 +360,7 @@ void Camera::smoothMoveCamera(float dt)
if (race_manager->getNumLocalPlayers() < 2)
{
sfx_manager->positionListener(current_position, current_target - current_position);
SFXManager::get()->positionListener(current_position, current_target - current_position);
}
} // smoothMoveCamera
@ -565,7 +565,7 @@ void Camera::positionCamera(float dt, float above_kart, float cam_angle,
if (race_manager->getNumLocalPlayers() < 2)
{
sfx_manager->positionListener(m_camera->getPosition(),
SFXManager::get()->positionListener(m_camera->getPosition(),
wanted_target - m_camera->getPosition());
}
}

View File

@ -26,7 +26,7 @@
HitSFX::HitSFX(const Vec3& coord, const char* explosion_sound)
: HitEffect()
{
m_sfx = sfx_manager->createSoundSource( explosion_sound );
m_sfx = SFXManager::get()->createSoundSource( explosion_sound );
m_sfx->position(coord);
// in multiplayer mode, sounds are NOT positional (because we have
@ -45,7 +45,7 @@ HitSFX::~HitSFX()
if (m_sfx->getStatus() == SFXManager::SFX_PLAYING)
m_sfx->stop();
sfx_manager->deleteSFX(m_sfx);
SFXManager::get()->deleteSFX(m_sfx);
} // ~HitEffect
//-----------------------------------------------------------------------------

View File

@ -513,7 +513,7 @@ Material::~Material()
// tracks might use the same name.
if(m_sfx_name!="" && m_sfx_name==m_texname)
{
sfx_manager->deleteSFXMapping(m_sfx_name);
SFXManager::get()->deleteSFXMapping(m_sfx_name);
}
} // ~Material
@ -551,14 +551,14 @@ void Material::initCustomSFX(const XMLNode *sfx)
m_sfx_pitch_per_speed = (m_sfx_max_pitch - m_sfx_min_pitch)
/ (m_sfx_max_speed - m_sfx_min_speed);
if(!sfx_manager->soundExist(m_sfx_name))
if(!SFXManager::get()->soundExist(m_sfx_name))
{
// The directory for the track was added to the model search path
// so just misuse the getModelFile function
const std::string full_path = file_manager->getAsset(FileManager::MODEL,
filename);
SFXBuffer* buffer = sfx_manager->loadSingleSfx(sfx, full_path);
SFXBuffer* buffer = SFXManager::get()->loadSingleSfx(sfx, full_path);
if (buffer != NULL)
{

View File

@ -34,12 +34,12 @@ Weather::Weather(bool lightning, std::string sound)
if (m_lightning)
{
m_thunder_sound = sfx_manager->createSoundSource("thunder");
m_thunder_sound = SFXManager::get()->createSoundSource("thunder");
}
if (sound != "")
{
m_weather_sound = sfx_manager->createSoundSource(sound);
m_weather_sound = SFXManager::get()->createSoundSource(sound);
}
RandomGenerator g;
@ -51,10 +51,10 @@ Weather::Weather(bool lightning, std::string sound)
Weather::~Weather()
{
if (m_thunder_sound != NULL)
sfx_manager->deleteSFX(m_thunder_sound);
SFXManager::get()->deleteSFX(m_thunder_sound);
if (m_weather_sound != NULL)
sfx_manager->deleteSFX(m_weather_sound);
SFXManager::get()->deleteSFX(m_weather_sound);
}
// ----------------------------------------------------------------------------

View File

@ -80,13 +80,13 @@ Attachment::~Attachment()
if (m_bomb_sound)
{
sfx_manager->deleteSFX(m_bomb_sound);
SFXManager::get()->deleteSFX(m_bomb_sound);
m_bomb_sound = NULL;
}
if (m_bubble_explode_sound)
{
sfx_manager->deleteSFX(m_bubble_explode_sound);
SFXManager::get()->deleteSFX(m_bubble_explode_sound);
m_bubble_explode_sound = NULL;
}
} // ~Attachment
@ -139,8 +139,8 @@ void Attachment::set(AttachmentType type, float time,
break;
case ATTACH_BOMB:
m_node->setMesh(attachment_manager->getMesh(type));
if (m_bomb_sound) sfx_manager->deleteSFX(m_bomb_sound);
m_bomb_sound = sfx_manager->createSoundSource("clock");
if (m_bomb_sound) SFXManager::get()->deleteSFX(m_bomb_sound);
m_bomb_sound = SFXManager::get()->createSoundSource("clock");
m_bomb_sound->setLoop(true);
m_bomb_sound->position(m_kart->getXYZ());
m_bomb_sound->play();
@ -199,7 +199,7 @@ void Attachment::clear()
if (m_bomb_sound)
{
m_bomb_sound->stop();
sfx_manager->deleteSFX(m_bomb_sound);
SFXManager::get()->deleteSFX(m_bomb_sound);
m_bomb_sound = NULL;
}
@ -461,7 +461,7 @@ void Attachment::update(float dt)
if (m_bomb_sound)
{
m_bomb_sound->stop();
sfx_manager->deleteSFX(m_bomb_sound);
SFXManager::get()->deleteSFX(m_bomb_sound);
m_bomb_sound = NULL;
}
}
@ -474,8 +474,8 @@ void Attachment::update(float dt)
if (m_time_left < 0)
{
m_time_left = 0.0f;
if (m_bubble_explode_sound) sfx_manager->deleteSFX(m_bubble_explode_sound);
m_bubble_explode_sound = sfx_manager->createSoundSource("bubblegum_explode");
if (m_bubble_explode_sound) SFXManager::get()->deleteSFX(m_bubble_explode_sound);
m_bubble_explode_sound = SFXManager::get()->createSoundSource("bubblegum_explode");
m_bubble_explode_sound->position(m_kart->getXYZ());
m_bubble_explode_sound->play();

View File

@ -76,7 +76,7 @@ Bowling::Bowling(AbstractKart *kart)
// should not live forever, auto-destruct after 20 seconds
m_max_lifespan = 20;
m_roll_sfx = sfx_manager->createSoundSource("bowling_roll");
m_roll_sfx = SFXManager::get()->createSoundSource("bowling_roll");
m_roll_sfx->play();
m_roll_sfx->setLoop(true);
@ -89,7 +89,7 @@ Bowling::~Bowling()
{
if(m_roll_sfx->getStatus()==SFXManager::SFX_PLAYING)
m_roll_sfx->stop();
sfx_manager->deleteSFX(m_roll_sfx);
SFXManager::get()->deleteSFX(m_roll_sfx);
} // ~RubberBall
// -----------------------------------------------------------------------------

View File

@ -21,6 +21,7 @@
#include "items/plunger.hpp"
#include "audio/sfx_manager.hpp"
#include "io/xml_node.hpp"
#include "items/rubber_band.hpp"
#include "items/projectile_manager.hpp"
@ -167,7 +168,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
{
kart->blockViewWithPlunger();
if (kart->getController()->isPlayerController())
sfx_manager->quickSound("plunger");
SFXManager::get()->quickSound("plunger");
}
m_keep_alive = 0;

View File

@ -53,7 +53,7 @@ Powerup::Powerup(AbstractKart* kart)
*/
Powerup::~Powerup()
{
if(m_sound_use) sfx_manager->deleteSFX(m_sound_use);
if(m_sound_use) SFXManager::get()->deleteSFX(m_sound_use);
} // ~Powerup
//-----------------------------------------------------------------------------
@ -88,7 +88,7 @@ void Powerup::set(PowerupManager::PowerupType type, int n)
if(m_sound_use != NULL)
{
sfx_manager->deleteSFX(m_sound_use);
SFXManager::get()->deleteSFX(m_sound_use);
m_sound_use = NULL;
}
@ -102,30 +102,30 @@ void Powerup::set(PowerupManager::PowerupType type, int n)
break ;
case PowerupManager::POWERUP_BOWLING:
m_sound_use = sfx_manager->createSoundSource("bowling_shoot");
m_sound_use = SFXManager::get()->createSoundSource("bowling_shoot");
break ;
case PowerupManager::POWERUP_ANVIL:
m_sound_use = sfx_manager->createSoundSource("anvil");
m_sound_use = SFXManager::get()->createSoundSource("anvil");
break;
case PowerupManager::POWERUP_PARACHUTE:
m_sound_use = sfx_manager->createSoundSource("parachute");
m_sound_use = SFXManager::get()->createSoundSource("parachute");
break;
case PowerupManager::POWERUP_BUBBLEGUM:
m_sound_use = sfx_manager->createSoundSource("goo");
m_sound_use = SFXManager::get()->createSoundSource("goo");
break ;
case PowerupManager::POWERUP_SWITCH:
m_sound_use = sfx_manager->createSoundSource("swap");
m_sound_use = SFXManager::get()->createSoundSource("swap");
break;
case PowerupManager::POWERUP_NOTHING:
case PowerupManager::POWERUP_CAKE:
case PowerupManager::POWERUP_PLUNGER:
default :
m_sound_use = sfx_manager->createSoundSource("shoot");
m_sound_use = SFXManager::get()->createSoundSource("shoot");
break ;
}
@ -190,9 +190,9 @@ void Powerup::use()
// FIXME - for some collectibles, set() is never called
if(m_sound_use == NULL)
{
//if (m_type == POWERUP_SWITCH) m_sound_use = sfx_manager->newSFX(SFXManager::SOUND_SWAP);
//if (m_type == POWERUP_SWITCH) m_sound_use = SFXManager::get()->newSFX(SFXManager::SOUND_SWAP);
//else
m_sound_use = sfx_manager->createSoundSource("shoot");
m_sound_use = SFXManager::get()->createSoundSource("shoot");
}
m_number--;
@ -281,7 +281,7 @@ void Powerup::use()
}
}
m_sound_use = sfx_manager->createSoundSource("inflate");//Extraordinary. Usually sounds are set in Powerup::set()
m_sound_use = SFXManager::get()->createSoundSource("inflate");//Extraordinary. Usually sounds are set in Powerup::set()
//In this case this is a workaround, since the bubblegum item has two different sounds.
Powerup::adjustSound();

View File

@ -81,7 +81,7 @@ RubberBall::RubberBall(AbstractKart *kart)
m_height_timer = 0.0f;
m_interval = m_st_interval;
m_current_max_height = m_max_height;
m_ping_sfx = sfx_manager->createSoundSource("ball_bounce");
m_ping_sfx = SFXManager::get()->createSoundSource("ball_bounce");
// Just init the previoux coordinates with some value that's not getXYZ()
m_previous_xyz = m_owner->getXYZ();
m_previous_height = 2.0f; //
@ -109,7 +109,7 @@ RubberBall::~RubberBall()
{
if(m_ping_sfx->getStatus()==SFXManager::SFX_PLAYING)
m_ping_sfx->stop();
sfx_manager->deleteSFX(m_ping_sfx);
SFXManager::get()->deleteSFX(m_ping_sfx);
} // ~RubberBall
// ----------------------------------------------------------------------------

View File

@ -83,9 +83,9 @@ Swatter::Swatter(AbstractKart *kart, bool was_bomb,
}
if (kart->getIdent() == "nolok")
m_swat_sound = sfx_manager->createSoundSource("hammer");
m_swat_sound = SFXManager::get()->createSoundSource("hammer");
else
m_swat_sound = sfx_manager->createSoundSource("swatter");
m_swat_sound = SFXManager::get()->createSoundSource("swatter");
} // Swatter
// ----------------------------------------------------------------------------
@ -100,7 +100,7 @@ Swatter::~Swatter()
}
if (m_swat_sound)
{
sfx_manager->deleteSFX(m_swat_sound);
SFXManager::get()->deleteSFX(m_swat_sound);
}
} // ~Swatter

View File

@ -20,7 +20,6 @@
#include "karts/controller/player_controller.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/camera.hpp"
@ -61,11 +60,11 @@ PlayerController::PlayerController(AbstractKart *kart,
// Keep a pointer to the camera to remove the need to search for
// the right camera once per frame later.
m_camera = Camera::createCamera(kart);
m_bzzt_sound = sfx_manager->createSoundSource( "bzzt" );
m_wee_sound = sfx_manager->createSoundSource( "wee" );
m_ugh_sound = sfx_manager->createSoundSource( "ugh" );
m_grab_sound = sfx_manager->createSoundSource( "grab_collectable" );
m_full_sound = sfx_manager->createSoundSource( "energy_bar_full" );
m_bzzt_sound = SFXManager::get()->createSoundSource( "bzzt" );
m_wee_sound = SFXManager::get()->createSoundSource( "wee" );
m_ugh_sound = SFXManager::get()->createSoundSource( "ugh" );
m_grab_sound = SFXManager::get()->createSoundSource( "grab_collectable" );
m_full_sound = SFXManager::get()->createSoundSource( "energy_bar_full" );
reset();
} // PlayerController
@ -75,11 +74,11 @@ PlayerController::PlayerController(AbstractKart *kart,
*/
PlayerController::~PlayerController()
{
sfx_manager->deleteSFX(m_bzzt_sound);
sfx_manager->deleteSFX(m_wee_sound );
sfx_manager->deleteSFX(m_ugh_sound );
sfx_manager->deleteSFX(m_grab_sound);
sfx_manager->deleteSFX(m_full_sound);
SFXManager::get()->deleteSFX(m_bzzt_sound);
SFXManager::get()->deleteSFX(m_wee_sound );
SFXManager::get()->deleteSFX(m_ugh_sound );
SFXManager::get()->deleteSFX(m_grab_sound);
SFXManager::get()->deleteSFX(m_full_sound);
} // ~PlayerController
//-----------------------------------------------------------------------------

View File

@ -153,16 +153,16 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
// If id == -1 the custom sound was not defined in the .irrkart config file
if (id != -1)
{
m_custom_sounds[n] = sfx_manager->newSFX(id);
m_custom_sounds[n] = SFXManager::get()->newSFX(id);
}
}*/
m_engine_sound = sfx_manager->createSoundSource(m_kart_properties->getEngineSfxType());
m_beep_sound = sfx_manager->createSoundSource( "horn" );
m_crash_sound = sfx_manager->createSoundSource( "crash" );
m_boing_sound = sfx_manager->createSoundSource( "boing" );
m_goo_sound = sfx_manager->createSoundSource( "goo" );
m_skid_sound = sfx_manager->createSoundSource( "skid" );
m_engine_sound = SFXManager::get()->createSoundSource(m_kart_properties->getEngineSfxType());
m_beep_sound = SFXManager::get()->createSoundSource( "horn" );
m_crash_sound = SFXManager::get()->createSoundSource( "crash" );
m_boing_sound = SFXManager::get()->createSoundSource( "boing" );
m_goo_sound = SFXManager::get()->createSoundSource( "goo" );
m_skid_sound = SFXManager::get()->createSoundSource( "skid" );
m_terrain_sound = NULL;
m_previous_terrain_sound = NULL;
@ -242,18 +242,18 @@ Kart::~Kart()
for (int n = 0; n < SFXManager::NUM_CUSTOMS; n++)
{
if (m_custom_sounds[n] != NULL)
sfx_manager->deleteSFX(m_custom_sounds[n]);
SFXManager::get()->deleteSFX(m_custom_sounds[n]);
}*/
sfx_manager->deleteSFX(m_engine_sound );
sfx_manager->deleteSFX(m_crash_sound );
sfx_manager->deleteSFX(m_skid_sound );
sfx_manager->deleteSFX(m_goo_sound );
sfx_manager->deleteSFX(m_beep_sound );
sfx_manager->deleteSFX(m_boing_sound );
SFXManager::get()->deleteSFX(m_engine_sound );
SFXManager::get()->deleteSFX(m_crash_sound );
SFXManager::get()->deleteSFX(m_skid_sound );
SFXManager::get()->deleteSFX(m_goo_sound );
SFXManager::get()->deleteSFX(m_beep_sound );
SFXManager::get()->deleteSFX(m_boing_sound );
delete m_kart_gfx;
if(m_terrain_sound) sfx_manager->deleteSFX(m_terrain_sound);
if(m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
if(m_terrain_sound) SFXManager::get()->deleteSFX(m_terrain_sound);
if(m_previous_terrain_sound) SFXManager::get()->deleteSFX(m_previous_terrain_sound);
if(m_collision_particles) delete m_collision_particles;
if(m_slipstream) delete m_slipstream;
if(m_sky_particles_emitter) delete m_sky_particles_emitter;
@ -362,11 +362,11 @@ void Kart::reset()
if(m_terrain_sound)
{
sfx_manager->deleteSFX(m_terrain_sound);
SFXManager::get()->deleteSFX(m_terrain_sound);
}
if(m_previous_terrain_sound)
{
sfx_manager->deleteSFX(m_previous_terrain_sound);
SFXManager::get()->deleteSFX(m_previous_terrain_sound);
}
m_terrain_sound = NULL;
@ -1429,7 +1429,7 @@ void Kart::handleMaterialSFX(const Material *material)
// can be used again.
if(m_previous_terrain_sound)
{
sfx_manager->deleteSFX(m_previous_terrain_sound);
SFXManager::get()->deleteSFX(m_previous_terrain_sound);
}
m_previous_terrain_sound = m_terrain_sound;
if(m_previous_terrain_sound)
@ -1438,7 +1438,7 @@ void Kart::handleMaterialSFX(const Material *material)
const std::string &s = material->getSFXName();
if (s != "")
{
m_terrain_sound = sfx_manager->createSoundSource(s);
m_terrain_sound = SFXManager::get()->createSoundSource(s);
// In multiplayer mode sounds are NOT positional, because we have
// multiple listeners. This would make the sounds of all AIs be
@ -1466,7 +1466,7 @@ void Kart::handleMaterialSFX(const Material *material)
// We don't modify the position of m_previous_terrain_sound
// anymore, so that it keeps on playing at the place where the
// kart left the material.
sfx_manager->deleteSFX(m_previous_terrain_sound);
SFXManager::get()->deleteSFX(m_previous_terrain_sound);
m_previous_terrain_sound = NULL;
}
@ -1591,12 +1591,12 @@ void Kart::handleMaterialGFX()
(m_terrain_sound == NULL ||
m_terrain_sound->getStatus() == SFXManager::SFX_STOPPED))
{
if (m_previous_terrain_sound) sfx_manager->deleteSFX(m_previous_terrain_sound);
if (m_previous_terrain_sound) SFXManager::get()->deleteSFX(m_previous_terrain_sound);
m_previous_terrain_sound = m_terrain_sound;
if(m_previous_terrain_sound)
m_previous_terrain_sound->setLoop(false);
m_terrain_sound = sfx_manager->createSoundSource(s);
m_terrain_sound = SFXManager::get()->createSoundSource(s);
m_terrain_sound->play();
m_terrain_sound->setLoop(false);
}
@ -1855,7 +1855,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
// For now, until we have scripting, special-case the overworld... (TODO)
if (dynamic_cast<OverWorld*>(World::getWorld()) != NULL)
{
sfx_manager->quickSound("forcefield");
SFXManager::get()->quickSound("forcefield");
for (unsigned int n = 0; n < parts.size(); n++)
{
@ -1927,7 +1927,7 @@ void Kart::beep()
event. If there is no voice sample, a default can be played instead.
Use entries from the CustomSFX enumeration as a parameter (see
sfx_manager.hpp). eg. playCustomSFX(SFXManager::CUSTOM_CRASH)
SFXManager::get().hpp). eg. playCustomSFX(SFXManager::CUSTOM_CRASH)
Obviously we don't want a certain character voicing multiple phrases
simultaneously. It just sounds bad. There are two ways of avoiding this:
@ -1970,7 +1970,7 @@ bool Kart::playCustomSFX(unsigned int type)
{
ret = true;
//printf("Kart SFX: playing %s for %s.\n",
// sfx_manager->getCustomTagName(type),
// SFXManager::get()->getCustomTagName(type),
// m_kart_properties->getIdent().c_str());
// If it's already playing, let it finish
if (m_custom_sounds[type]->getStatus() != SFXManager::SFX_PLAYING)
@ -2107,7 +2107,7 @@ void Kart::updatePhysics(float dt)
void Kart::updateEngineSFX()
{
// when going faster, use higher pitch for engine
if(!m_engine_sound || !sfx_manager->sfxAllowed())
if(!m_engine_sound || !SFXManager::get()->sfxAllowed())
return;
if(isOnGround())

View File

@ -432,7 +432,7 @@ void KartProperties::getAllData(const XMLNode * root)
else if (s == "small") m_engine_sfx_type = "engine_small";
else
{
if (sfx_manager->soundExist(s))
if (SFXManager::get()->soundExist(s))
{
m_engine_sfx_type = s;
}
@ -451,14 +451,14 @@ void KartProperties::getAllData(const XMLNode * root)
{
std::string tempFile;
// Get filename associated with each custom sfx tag in sfx config
if (sounds_node->get(sfx_manager->getCustomTagName(i), tempFile))
if (sounds_node->get(SFXManager::get()->getCustomTagName(i), tempFile))
{
// determine absolute filename
// FIXME: will not work with add-on packs (is data dir the same)?
tempFile = file_manager->getKartFile(tempFile, getIdent());
// Create sfx in sfx manager and store id
m_custom_sfx_id[i] = sfx_manager->addSingleSfx(tempFile, 1, 0.2f,1.0f);
m_custom_sfx_id[i] = SFXManager::get()->addSingleSfx(tempFile, 1, 0.2f,1.0f);
}
else
{

View File

@ -1074,7 +1074,7 @@ void initRest()
NewsManager::get(); // this will create the news manager
music_manager = new MusicManager();
sfx_manager = new SFXManager();
SFXManager::create();
// The order here can be important, e.g. KartPropertiesManager needs
// defaultKartProperties, which are defined in stk_config.
history = new History ();
@ -1457,7 +1457,7 @@ static void cleanSuperTuxKart()
if(material_manager) delete material_manager;
if(history) delete history;
ReplayRecorder::destroy();
if(sfx_manager) delete sfx_manager;
SFXManager::destroy();
if(music_manager) delete music_manager;
delete ParticleKindManager::get();
PlayerManager::destroy();

View File

@ -20,6 +20,7 @@
#include "animations/animation_base.hpp"
#include "animations/three_d_animation.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "graphics/camera.hpp"
@ -306,14 +307,11 @@ void CutsceneWorld::update(float dt)
rot2.setPitch(rot2.getPitch() + 90.0f);
m_camera->setRotation(rot2.toIrrVector());
sfx_manager->positionListener(m_camera->getAbsolutePosition(),
SFXManager::get()->positionListener(m_camera->getAbsolutePosition(),
m_camera->getTarget() -
m_camera->getAbsolutePosition());
break;
//printf("Camera %f %f %f\n", curr->getNode()->getPosition().X,
// curr->getNode()->getPosition().Y,
// curr->getNode()->getPosition().Z);
}
}
std::map<float, std::vector<TrackObject*> >::iterator it;

View File

@ -43,7 +43,7 @@
*/
LinearWorld::LinearWorld() : WorldWithRank()
{
m_last_lap_sfx = sfx_manager->createSoundSource("last_lap_fanfare");
m_last_lap_sfx = SFXManager::get()->createSoundSource("last_lap_fanfare");
m_last_lap_sfx_played = false;
m_last_lap_sfx_playing = false;
m_fastest_lap = 9999999.9f;
@ -73,7 +73,7 @@ void LinearWorld::init()
*/
LinearWorld::~LinearWorld()
{
sfx_manager->deleteSFX(m_last_lap_sfx);
SFXManager::get()->deleteSFX(m_last_lap_sfx);
} // ~LinearWorld
//-----------------------------------------------------------------------------

View File

@ -17,9 +17,6 @@
#include "modes/soccer_world.hpp"
#include <string>
#include <IMeshSceneNode.h>
#include "audio/music_manager.hpp"
#include "audio/sfx_base.hpp"
#include "io/file_manager.hpp"
@ -36,6 +33,10 @@
#include "tracks/track_object_manager.hpp"
#include "utils/constants.hpp"
#include <IMeshSceneNode.h>
#include <string>
//-----------------------------------------------------------------------------
/** Constructor. Sets up the clock mode etc.
*/
@ -59,7 +60,7 @@ SoccerWorld::SoccerWorld() : WorldWithRank()
*/
SoccerWorld::~SoccerWorld()
{
sfx_manager->deleteSFX(m_goal_sound);
SFXManager::get()->deleteSFX(m_goal_sound);
} // ~SoccerWorld
//-----------------------------------------------------------------------------
@ -80,7 +81,7 @@ void SoccerWorld::init()
exit(1);
}
m_goal_target = race_manager->getMaxGoal();
m_goal_sound = sfx_manager->createSoundSource("goal_scored");
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
} // init

View File

@ -256,7 +256,7 @@ void World::reset()
music_manager->stopMusic();
// Enable SFX again
sfx_manager->resumeAll();
SFXManager::get()->resumeAll();
projectile_manager->cleanup();
race_manager->reset();
@ -1183,7 +1183,7 @@ void World::pause(Phase phase)
{
if (m_stop_music_when_dialog_open)
music_manager->pauseMusic();
sfx_manager->pauseAll();
SFXManager::get()->pauseAll();
WorldStatus::pause(phase);
} // pause
@ -1193,7 +1193,7 @@ void World::unpause()
{
if (m_stop_music_when_dialog_open)
music_manager->resumeMusic();
sfx_manager->resumeAll();
SFXManager::get()->resumeAll();
WorldStatus::unpause();

View File

@ -18,8 +18,8 @@
#include "modes/world_status.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/stk_config.hpp"
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
@ -35,9 +35,9 @@ WorldStatus::WorldStatus()
{
m_clock_mode = CLOCK_CHRONO;
m_prestart_sound = sfx_manager->createSoundSource("pre_start_race");
m_start_sound = sfx_manager->createSoundSource("start_race");
m_track_intro_sound = sfx_manager->createSoundSource("track_intro");
m_prestart_sound = SFXManager::get()->createSoundSource("pre_start_race");
m_start_sound = SFXManager::get()->createSoundSource("start_race");
m_track_intro_sound = SFXManager::get()->createSoundSource("track_intro");
music_manager->stopMusic();
@ -74,9 +74,9 @@ void WorldStatus::reset()
*/
WorldStatus::~WorldStatus()
{
sfx_manager->deleteSFX(m_prestart_sound);
sfx_manager->deleteSFX(m_start_sound);
sfx_manager->deleteSFX(m_track_intro_sound);
SFXManager::get()->deleteSFX(m_prestart_sound);
SFXManager::get()->deleteSFX(m_start_sound);
SFXManager::get()->deleteSFX(m_track_intro_sound);
IrrlichtDevice *device = irr_driver->getDevice();
if (device->getTimer()->isStopped())
@ -157,7 +157,7 @@ void WorldStatus::update(const float dt)
}
// Work around a bug that occurred on linux once:
// the sfx_manager kept on reporting that it is playing,
// the SFXManager::get() kept on reporting that it is playing,
// while it was not - so STK would never reach the ready
// ... phase. Since the sound effect is about 3 seconds
// long, we use the aux timer to force the next phase

View File

@ -103,7 +103,7 @@ void CreateServerScreen::onUpdate(float delta)
}
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_server_creation_request->getInfo(), false);
}
@ -146,7 +146,7 @@ void CreateServerScreen::serverCreationRequest()
return;
}
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
}
// --------------------------------------------------------------------
void CreateServerScreen::ServerCreationRequest::callback()

View File

@ -129,20 +129,20 @@ void ChangePasswordDialog::submit()
if (current_password.size() < 8 || current_password.size() > 30)
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(_("Current password invalid."), false);
}
else if (new_password1.size() < 8 || new_password1.size() > 30)
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(_("Password has to be between 8 and 30 "
"characters long!"), false);
}
else if (new_password1 != new_password2)
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(_("Passwords don't match!"), false);
}
@ -217,7 +217,7 @@ void ChangePasswordDialog::success()
// ----------------------------------------------------------------------------
void ChangePasswordDialog::error(const irr::core::stringw & error)
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error, false);
m_options_widget->setActivated();

View File

@ -89,7 +89,7 @@ void EnterGPNameDialog::onEnterPressedInternal()
LabelWidget* label = getWidget<LabelWidget>("title");
assert(label != NULL);
label->setText(_("Another grand prix with this name already exists."), false);
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
return;
}
@ -102,7 +102,7 @@ void EnterGPNameDialog::onEnterPressedInternal()
LabelWidget* label = getWidget<LabelWidget>("title");
assert(label != NULL);
label->setText(_("Cannot add a grand prix with this name"), false);
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
}
}

View File

@ -17,7 +17,6 @@
#include "states_screens/dialogs/gp_info_dialog.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/saved_grand_prix.hpp"

View File

@ -19,7 +19,6 @@
#include <IGUIEnvironment.h>
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/engine.hpp"
#include "states_screens/state_manager.hpp"

View File

@ -116,7 +116,7 @@ void RecoveryDialog::processInput()
if (username.size() < 4 || username.size() > 30 ||
email.size() < 4 || email.size() > 50 )
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(_("Username and/or email address invalid."),
false);
@ -194,7 +194,7 @@ void RecoveryDialog::onUpdate(float dt)
}
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_recovery_request->getInfo(), false);
m_options_widget->setActivated();

View File

@ -17,7 +17,6 @@
#include "states_screens/dialogs/registration_dialog.hpp"
#include "audio/sfx_manager.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets.hpp"
#include "states_screens/state_manager.hpp"

View File

@ -141,7 +141,7 @@ void ServerInfoDialog::onUpdate(float dt)
}
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_server_join_request->getInfo(), false);
}

View File

@ -17,7 +17,6 @@
#include "states_screens/dialogs/user_info_dialog.hpp"
#include "audio/sfx_manager.hpp"
#include "config/player_manager.hpp"
#include "guiengine/dialog_queue.hpp"
#include "guiengine/engine.hpp"

View File

@ -201,7 +201,7 @@ void VoteDialog::updateFetchVote()
} // isSuccess
else
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(m_fetch_vote_request->getInfo(), false);
m_cancel_widget->setActivated();
@ -233,7 +233,7 @@ void VoteDialog::onUpdate(float dt)
} // isSuccess
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_info_widget->setErrorColor();
m_info_widget->setText(m_perform_vote_request->getInfo(), false);
m_cancel_widget->setActivated();

View File

@ -18,9 +18,6 @@
#include "states_screens/grand_prix_win.hpp"
#include <SColor.h>
#include <iostream>
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
@ -44,12 +41,16 @@
#include "tracks/track_object_manager.hpp"
#include "utils/translation.hpp"
#include <IGUIEnvironment.h>
#include <ICameraSceneNode.h>
#include <ISceneManager.h>
#include <ILightSceneNode.h>
#include <IGUIEnvironment.h>
#include <IGUIImage.h>
#include <ILightSceneNode.h>
#include <IMeshSceneNode.h>
#include <ISceneManager.h>
#include <SColor.h>
#include <iostream>
using namespace irr::core;
using namespace irr::gui;
@ -170,7 +171,7 @@ void GrandPrixWin::init()
m_global_time = 0.0f;
m_phase = 1;
sfx_manager->quickSound("gp_end");
SFXManager::get()->quickSound("gp_end");
} // init
// -------------------------------------------------------------------------------------

View File

@ -18,6 +18,7 @@
#include "states_screens/kart_selection.hpp"
#include "audio/sfx_manager.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
#include "config/player_profile.hpp"
@ -577,7 +578,7 @@ void PlayerKartWidget::markAsReady()
delete m_player_ident_spinner;
m_player_ident_spinner = NULL;
sfx_manager->quickSound( "wee" );
SFXManager::get()->quickSound( "wee" );
m_model_view->setRotateTo(30.0f, 1.0f);
@ -1152,7 +1153,7 @@ bool KartSelectionScreen::joinPlayer(InputDevice* device, bool first_player)
{
Log::error("[KartSelectionScreen]", "Maximum number of players "
"reached");
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return false;
}
@ -1299,7 +1300,7 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
// then they can't back out
if (m_kart_widgets[n].isReady())
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return true;
}
@ -1437,7 +1438,7 @@ void KartSelectionScreen::playerConfirm(const int playerID)
if (m_kart_widgets[playerID].getKartInternalName().size() == 0)
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return;
}
@ -1469,7 +1470,7 @@ void KartSelectionScreen::playerConfirm(const int playerID)
Log::warn("[KartSelectionScreen]", "You can't select this identity "
"or kart, someone already took it!!");
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return;
}

View File

@ -122,7 +122,7 @@ void NetworkKartSelectionScreen::playerConfirm(const int playerID)
if (m_kart_widgets[playerID].getKartInternalName().size() == 0)
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return;
}
if(playerID == PLAYER_ID_GAME_MASTER) // self

View File

@ -187,7 +187,7 @@ void OnlineScreen::doQuickPlay()
XMLRequest *join_request = new RequestConnection::ServerJoinRequest();
if (!join_request)
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
return;
}
@ -205,7 +205,7 @@ void OnlineScreen::doQuickPlay()
}
else
{
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
}
} // doQuickPlay

View File

@ -271,7 +271,7 @@ void OnlineUserSearch::onUpdate(float dt)
}
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
new MessageDialog(m_search_request->getInfo());
}

View File

@ -70,7 +70,7 @@ void OptionsScreenAudio::init()
SpinnerWidget* gauge = this->getWidget<SpinnerWidget>("sfx_volume");
assert(gauge != NULL);
gauge->setValue( (int)(sfx_manager->getMasterSFXVolume()*10.0f) );
gauge->setValue( (int)(SFXManager::get()->getMasterSFXVolume()*10.0f) );
gauge = this->getWidget<SpinnerWidget>("music_volume");
@ -137,10 +137,10 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name,
SpinnerWidget* w = dynamic_cast<SpinnerWidget*>(widget);
assert(w != NULL);
if (sample_sound == NULL) sample_sound = sfx_manager->createSoundSource( "pre_start_race" );
if (sample_sound == NULL) sample_sound = SFXManager::get()->createSoundSource( "pre_start_race" );
sample_sound->volume(1);
sfx_manager->setMasterSFXVolume( w->getValue()/10.0f );
SFXManager::get()->setMasterSFXVolume( w->getValue()/10.0f );
UserConfigParams::m_sfx_volume = w->getValue()/10.0f;
// play a sample sound to show the user what this volume is like
@ -163,11 +163,11 @@ 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);
SFXManager::get()->soundToggled(UserConfigParams::m_sfx);
if (UserConfigParams::m_sfx)
{
sfx_manager->quickSound("horn");
SFXManager::get()->quickSound("horn");
}
}
} // eventCallback

View File

@ -19,6 +19,7 @@
#include "states_screens/race_result_gui.hpp"
#include "audio/music_manager.hpp"
#include "audio/sfx_manager.hpp"
#include "audio/sfx_base.hpp"
#include "challenges/unlock_manager.hpp"
#include "config/player_manager.hpp"
@ -81,7 +82,7 @@ void RaceResultGUI::init()
getWidget("bottom")->setVisible(false);
music_manager->stopMusic();
m_finish_sound = sfx_manager->quickSound("race_finish");
m_finish_sound = SFXManager::get()->quickSound("race_finish");
// Calculate how many track screenshots can fit into the "result-table" widget
GUIEngine::Widget* result_table = getWidget("result-table");

View File

@ -256,7 +256,7 @@ void RegisterScreen::doRegister()
return;
}
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
} // doRegister
// -----------------------------------------------------------------------------

View File

@ -17,16 +17,16 @@
#include "states_screens/server_selection.hpp"
#include <iostream>
#include <assert.h>
#include "audio/sfx_manager.hpp"
#include "guiengine/modaldialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/dialogs/server_info_dialog.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "utils/string_utils.hpp"
#include "audio/sfx_manager.hpp"
#include <iostream>
#include <assert.h>
using namespace Online;
@ -197,7 +197,7 @@ void ServerSelection::onUpdate(float dt)
}
else
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
new MessageDialog(m_refresh_request->getInfo());
}
delete m_refresh_request;

View File

@ -17,6 +17,7 @@
#include "states_screens/soccer_setup_screen.hpp"
#include "audio/sfx_manager.hpp"
#include "config/user_config.hpp"
#include "guiengine/widgets/button_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
@ -74,7 +75,7 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
m_kart_view_info[i].view->setBadge(BAD_BADGE);
}
}
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
return;
}
else if(!areAllKartsConfirmed())
@ -88,7 +89,7 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
m_kart_view_info[i].view->setBadge(OK_BADGE);
}
}
sfx_manager->quickSound( "wee" );
SFXManager::get()->quickSound( "wee" );
m_schedule_continue = true;
}
else
@ -319,7 +320,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
(getNumKartsInTeam(SOCCER_TEAM_RED) == 0 ||
getNumKartsInTeam(SOCCER_TEAM_BLUE) == 0))
{
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_kart_view_info[playerId].view->setBadge(BAD_BADGE);
}
else
@ -329,7 +330,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
m_kart_view_info[playerId].view->setRotateTo( KART_CONFIRMATION_TARGET_ANGLE, KART_CONFIRMATION_ROTATION_SPEED );
m_kart_view_info[playerId].view->setBadge(OK_BADGE);
m_kart_view_info[playerId].view->unsetBadge(BAD_BADGE);
sfx_manager->quickSound( "wee" );
SFXManager::get()->quickSound( "wee" );
}
return EVENT_BLOCK;
}

View File

@ -201,7 +201,7 @@ void StateManager::onGameStateChange(GameState new_state)
{
irr_driver->showPointer();
input_manager->setMode(InputManager::MENU);
sfx_manager->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
SFXManager::get()->positionListener( Vec3(0,0,0), Vec3(0,1,0) );
if (new_state == MENU)
{

View File

@ -257,7 +257,7 @@ void BaseUserScreen::eventCallback(Widget* widget,
m_info_widget->setText(
_("Internet access is disabled, please enable it in the options"),
true);
sfx_manager->quickSound( "anvil" );
SFXManager::get()->quickSound( "anvil" );
m_online_cb->setState(false);
}
}
@ -396,7 +396,7 @@ void BaseUserScreen::login()
if (m_password_tb->getText() == "")
{
m_info_widget->setText(_("You need to enter a password."), true);
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_options_widget->setActivated();
return;
}
@ -464,7 +464,7 @@ void BaseUserScreen::loginError(const irr::core::stringw & error_message)
player->clearSession();
player->setLastOnlineName("");
makeEntryFieldsVisible();
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error_message, false);
m_options_widget->setActivated();
@ -494,7 +494,7 @@ void BaseUserScreen::logoutError(const irr::core::stringw & error_message)
if(player && player->hasSavedSession())
player->clearSession();
makeEntryFieldsVisible();
sfx_manager->quickSound("anvil");
SFXManager::get()->quickSound("anvil");
m_info_widget->setErrorColor();
m_info_widget->setText(error_message, false);
m_options_widget->setActivated();

View File

@ -431,7 +431,7 @@ TrackObjectPresentationSound::TrackObjectPresentationSound(const XMLNode& xml_no
volume);
buffer->load();
m_sound = sfx_manager->createSoundSource(buffer, true, true);
m_sound = SFXManager::get()->createSoundSource(buffer, true, true);
if (m_sound != NULL)
{
m_sound->position(m_init_xyz);
@ -488,7 +488,7 @@ TrackObjectPresentationSound::~TrackObjectPresentationSound()
if (m_sound)
{
//delete m_sound->getBuffer();
sfx_manager->deleteSFX(m_sound);
SFXManager::get()->deleteSFX(m_sound);
}
}