Implemented ability to add custom horn sounds to each kart in order to test code that will support character voices. Adding a horn-sound
tag to the .irrkart file that specifies the filename of the sound effect will ensure that sound effect will act as a horn for that kart (see tux for an example). Added m_horn_sfx_file attribute to kart_properties class. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3892 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
6c0f94190b
commit
4f2f272d37
@ -230,7 +230,7 @@ int SFXManager::addSingleSfx(std::string sfxFile,
|
||||
int positional,
|
||||
float rolloff,
|
||||
float gain)
|
||||
/* Returns sfx ID */
|
||||
/* Returns sfx ID or -1 on error*/
|
||||
{
|
||||
int sfxID;
|
||||
|
||||
@ -246,11 +246,13 @@ int SFXManager::addSingleSfx(std::string sfxFile,
|
||||
alGenBuffers(1, &(m_sfx_buffers[sfxID]));
|
||||
if (!checkError("generating a buffer")) return -1;
|
||||
|
||||
if (!loadVorbisBuffer(sfxFile.c_str(), sfxID))
|
||||
if (!loadVorbisBuffer(sfxFile.c_str(), m_sfx_buffers[sfxID]))
|
||||
{
|
||||
printf("Failed to load sound effect %s\n", sfxFile.c_str());
|
||||
}
|
||||
|
||||
// debugging
|
||||
/*printf("addSingleSfx() id:%d sfxFile:%s\n", sfxID, sfxFile.c_str());*/
|
||||
return sfxID;
|
||||
}
|
||||
|
||||
@ -276,6 +278,7 @@ void SFXManager::loadSingleSfx(const lisp::Lisp* lisp,
|
||||
m_sfx_gain[item] = gain;
|
||||
|
||||
std::string path = file_manager->getSFXFile(wav);
|
||||
printf("Loading SFX %s\n", path.c_str());
|
||||
|
||||
alGenBuffers(1, &(m_sfx_buffers[item]));
|
||||
if (!checkError("generating a buffer")) return;
|
||||
@ -307,6 +310,8 @@ SFXBase *SFXManager::newSFX(int id)
|
||||
positional = m_sfx_positional[id]!=0;
|
||||
|
||||
SFXBase *p = new SFXOpenAL(m_sfx_buffers[id], positional, m_sfx_rolloff[id], m_sfx_gain[id]);
|
||||
// debugging
|
||||
/*printf("newSfx(): id:%d buffer:%p, rolloff:%f, gain:%f %p\n", id, m_sfx_buffers[id], m_sfx_rolloff[id], m_sfx_gain[id], p);*/
|
||||
p->volume(m_masterGain);
|
||||
m_all_sfx.push_back(p);
|
||||
return p;
|
||||
|
@ -74,14 +74,15 @@ private:
|
||||
const char *name,
|
||||
int type);
|
||||
|
||||
int addSingleSfx( std::string filename,
|
||||
int positional,
|
||||
float rolloff,
|
||||
float gain);
|
||||
public:
|
||||
SFXManager();
|
||||
virtual ~SFXManager();
|
||||
bool sfxAllowed();
|
||||
int addSingleSfx( std::string filename,
|
||||
int positional,
|
||||
float rolloff,
|
||||
float gain);
|
||||
|
||||
SFXBase *newSFX(int id);
|
||||
void deleteSFX(SFXBase *sfx);
|
||||
void pauseAll();
|
||||
|
@ -101,7 +101,16 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
m_wheel_rotation = 0;
|
||||
|
||||
m_engine_sound = sfx_manager->newSFX(m_kart_properties->getEngineSfxType());
|
||||
m_beep_sound = sfx_manager->newSFX( SFXManager::SOUND_BEEP );
|
||||
|
||||
// If horn sfx is defined, load it. Otherwise use default
|
||||
int sfxId;
|
||||
|
||||
if (m_kart_properties->getHornSfxFile() == "")
|
||||
sfxId = SFXManager::SOUND_BEEP;
|
||||
else
|
||||
sfxId = sfx_manager->addSingleSfx(m_kart_properties->getHornSfxFile(), 1, 0.2f,1.0f);
|
||||
|
||||
m_beep_sound = sfx_manager->newSFX( sfxId );
|
||||
m_crash_sound = sfx_manager->newSFX( SFXManager::SOUND_CRASH );
|
||||
m_skid_sound = sfx_manager->newSFX( SFXManager::SOUND_SKID );
|
||||
m_goo_sound = sfx_manager->newSFX( SFXManager::SOUND_GOO );
|
||||
|
@ -196,6 +196,20 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
|
||||
lisp->get("brake-factor", m_brake_factor);
|
||||
lisp->get("mass", m_mass);
|
||||
|
||||
// Load SFX filenames
|
||||
if (lisp->get("horn-sound", m_horn_sfx_file))
|
||||
{
|
||||
m_horn_sfx_file = file_manager->getDataDir() + "karts/" + getIdent() + "/" + m_horn_sfx_file;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Think of cleaner way to define when there
|
||||
is no sfx file (empty filename is hackish)
|
||||
*/
|
||||
m_horn_sfx_file = "";
|
||||
}
|
||||
|
||||
|
||||
std::string sfx_type_string;
|
||||
lisp->get("engine-sound", sfx_type_string);
|
||||
if(sfx_type_string == "large")
|
||||
|
@ -53,6 +53,10 @@ private:
|
||||
float m_speed_angle_increase; /**< Increase of turn angle with speed. */
|
||||
int m_version; /**< Version of the .kart file. */
|
||||
|
||||
// SFX files
|
||||
// ---------------
|
||||
std::string m_horn_sfx_file; /**< Absolute path name of horn SFX file */
|
||||
|
||||
// Display and gui
|
||||
// ---------------
|
||||
std::string m_name; /**< The human readable Name of the kart
|
||||
@ -175,6 +179,9 @@ public:
|
||||
const std::string& getIdent () const {return m_ident; }
|
||||
const std::string& getShadowFile() const {return m_shadow_file; }
|
||||
const std::string& getIconFile () const {return m_icon_file; }
|
||||
const
|
||||
std::string& getHornSfxFile() const {return m_horn_sfx_file; }
|
||||
|
||||
/** Returns the version of the .kart file. */
|
||||
int getVersion () const {return m_version; }
|
||||
/** Returns the dot color to use for this kart in the race gui. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user