Make per-material sounds always positional

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8428 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-04-23 16:09:23 +00:00
parent 4229c14341
commit 16158e434f
4 changed files with 33 additions and 24 deletions

View File

@ -93,9 +93,11 @@ public:
bool isPositional() const { return m_positional; }
float getRolloff() const { return m_rolloff; }
float getGain() const { return m_gain; }
std::string getFileName() const { return m_file; }
void setPositional(bool positional) { m_positional = positional; }
};

View File

@ -178,7 +178,7 @@ void SFXManager::loadSfx()
* \return whether loading this sound effect was successful
*/
bool SFXManager::addSingleSfx(const std::string &sfx_name,
SFXBuffer* SFXManager::addSingleSfx(const std::string &sfx_name,
const std::string &sfx_file,
bool positional,
float rolloff,
@ -193,21 +193,22 @@ bool SFXManager::addSingleSfx(const std::string &sfx_name,
{
// Keep the buffer even if SFX is disabled, in case
// SFX is enabled back later
return false;
return NULL;
}
if (UserConfigParams::m_verbosity>=5)
printf("Loading SFX %s\n", sfx_file.c_str());
return buffer->load();
if (buffer->load()) return buffer;
return NULL;
} // addSingleSFX
//----------------------------------------------------------------------------
/** Loads a single sfx from the XML specification.
* \param node The XML node with the data for this sfx.
*/
void SFXManager::loadSingleSfx(const XMLNode* node,
SFXBuffer* SFXManager::loadSingleSfx(const XMLNode* node,
const std::string &path)
{
std::string filename;
@ -216,7 +217,7 @@ void SFXManager::loadSingleSfx(const XMLNode* node,
{
fprintf(stderr,
"/!\\ The 'filename' attribute is mandatory in the SFX XML file!\n");
return;
return NULL;
}
std::string sfx_name = StringUtils::removeExtension(filename);
@ -233,7 +234,7 @@ void SFXManager::loadSingleSfx(const XMLNode* node,
fprintf(stderr,
"There is already a sfx named '%s' installed - new one is ignored.\n",
sfx_name.c_str());
return;
return NULL;
}
// Only use the filename if no full path is specified. This is used
@ -243,7 +244,7 @@ void SFXManager::loadSingleSfx(const XMLNode* node,
SFXBuffer tmpbuffer(full_path, node);
addSingleSfx(sfx_name, full_path,
return addSingleSfx(sfx_name, full_path,
tmpbuffer.isPositional(),
tmpbuffer.getRolloff(),
tmpbuffer.getGain());

View File

@ -100,9 +100,9 @@ public:
SFXManager();
virtual ~SFXManager();
bool sfxAllowed();
void loadSingleSfx(const XMLNode* node,
SFXBuffer* loadSingleSfx(const XMLNode* node,
const std::string &path=std::string(""));
bool addSingleSfx(const std::string &sfx_name,
SFXBuffer* addSingleSfx(const std::string &sfx_name,
const std::string &filename,
bool positional,
float rolloff,

View File

@ -23,6 +23,7 @@
#include <stdexcept>
#include "audio/sfx_base.hpp"
#include "audio/sfx_buffer.hpp"
#include "config/user_config.hpp"
#include "config/stk_config.hpp"
#include "graphics/irr_driver.hpp"
@ -312,7 +313,12 @@ void Material::initCustomSFX(const XMLNode *sfx)
// 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->getModelFile(filename);
sfx_manager->loadSingleSfx(sfx, full_path);
SFXBuffer* buffer = sfx_manager->loadSingleSfx(sfx, full_path);
if (buffer != NULL)
{
buffer->setPositional(true);
}
}
} // initCustomSFX