mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 13:15:35 +00:00
Prevent PlaySound overlapping
This commit is contained in:
parent
b995584ad2
commit
4872edc5ed
5 changed files with 9 additions and 10 deletions
|
@ -337,7 +337,7 @@ namespace MWBase
|
|||
/// Cycle to next or previous weapon
|
||||
virtual void cycleWeapon(bool next) = 0;
|
||||
|
||||
virtual void playSound(const std::string& soundId, bool preventOverlapping = false, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f) = 0;
|
||||
|
||||
// In WindowManager for now since there isn't a VFS singleton
|
||||
virtual std::string correctIconPath(const std::string& path) = 0;
|
||||
|
|
|
@ -200,7 +200,7 @@ namespace MWGui
|
|||
{
|
||||
if ((mCurrentPage+1)*2 < mPages.size())
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page2", true);
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page2");
|
||||
|
||||
++mCurrentPage;
|
||||
|
||||
|
@ -211,7 +211,7 @@ namespace MWGui
|
|||
{
|
||||
if (mCurrentPage > 0)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page", true);
|
||||
MWBase::Environment::get().getWindowManager()->playSound("book page");
|
||||
|
||||
--mCurrentPage;
|
||||
|
||||
|
|
|
@ -1919,16 +1919,12 @@ namespace MWGui
|
|||
mInventoryWindow->cycle(next);
|
||||
}
|
||||
|
||||
void WindowManager::playSound(const std::string& soundId, bool preventOverlapping, float volume, float pitch)
|
||||
void WindowManager::playSound(const std::string& soundId, float volume, float pitch)
|
||||
{
|
||||
if (soundId.empty())
|
||||
return;
|
||||
|
||||
MWBase::SoundManager *sndmgr = MWBase::Environment::get().getSoundManager();
|
||||
if (preventOverlapping && sndmgr->getSoundPlaying(MWWorld::Ptr(), soundId))
|
||||
return;
|
||||
|
||||
sndmgr->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv);
|
||||
MWBase::Environment::get().getSoundManager()->playSound(soundId, volume, pitch, MWSound::Type::Sfx, MWSound::PlayMode::NoEnv);
|
||||
}
|
||||
|
||||
void WindowManager::updateSpellWindow()
|
||||
|
|
|
@ -366,7 +366,7 @@ namespace MWGui
|
|||
/// Cycle to next or previous weapon
|
||||
virtual void cycleWeapon(bool next);
|
||||
|
||||
virtual void playSound(const std::string& soundId, bool preventOverlapping = false, float volume = 1.f, float pitch = 1.f);
|
||||
virtual void playSound(const std::string& soundId, float volume = 1.f, float pitch = 1.f);
|
||||
|
||||
// In WindowManager for now since there isn't a VFS singleton
|
||||
virtual std::string correctIconPath(const std::string& path);
|
||||
|
|
|
@ -577,6 +577,9 @@ namespace MWSound
|
|||
Sound_Buffer *sfx = loadSound(Misc::StringUtils::lowerCase(soundId));
|
||||
if(!sfx) return nullptr;
|
||||
|
||||
// Only one copy of given sound can be played at time, so stop previous copy
|
||||
stopSound(soundId);
|
||||
|
||||
Sound *sound = getSoundRef();
|
||||
sound->init(volume * sfx->mVolume, volumeFromType(type), pitch, mode|type|Play_2D);
|
||||
if(!mOutput->playSound(sound, sfx->mHandle, offset))
|
||||
|
|
Loading…
Reference in a new issue