mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 20:09:41 +00:00
Support for per-type sound blockers
This commit is contained in:
parent
bb7c2ac630
commit
3d6fd2818f
4 changed files with 23 additions and 14 deletions
|
@ -168,10 +168,10 @@ namespace MWBase
|
|||
///< Is the given sound currently playing on the given object?
|
||||
/// If you want to check if sound played with playSound is playing, use empty Ptr
|
||||
|
||||
virtual void pauseSounds(int types=static_cast<int>(Type::Mask)) = 0;
|
||||
virtual void pauseSounds(const std::string& blockerId, int types=int(Type::Mask)) = 0;
|
||||
///< Pauses all currently playing sounds, including music.
|
||||
|
||||
virtual void resumeSounds(int types=static_cast<int>(Type::Mask)) = 0;
|
||||
virtual void resumeSounds(const std::string& blockerId) = 0;
|
||||
///< Resumes all previously paused sounds.
|
||||
|
||||
virtual void update(float duration) = 0;
|
||||
|
|
|
@ -1893,7 +1893,7 @@ namespace MWGui
|
|||
setCursorVisible(false);
|
||||
|
||||
if (mVideoWidget->hasAudioStream())
|
||||
MWBase::Environment::get().getSoundManager()->pauseSounds(
|
||||
MWBase::Environment::get().getSoundManager()->pauseSounds("Video",
|
||||
~MWSound::Type::Movie & MWSound::Type::Mask
|
||||
);
|
||||
osg::Timer frameTimer;
|
||||
|
@ -1921,7 +1921,7 @@ namespace MWGui
|
|||
}
|
||||
mVideoWidget->stop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->resumeSounds();
|
||||
MWBase::Environment::get().getSoundManager()->resumeSounds("Video");
|
||||
|
||||
setKeyFocusWidget(oldKeyFocus);
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace MWSound
|
|||
, mListenerPos(0,0,0)
|
||||
, mListenerDir(1,0,0)
|
||||
, mListenerUp(0,0,1)
|
||||
, mPausedSoundTypes(0)
|
||||
, mUnderwaterSound(nullptr)
|
||||
, mNearWaterSound(nullptr)
|
||||
{
|
||||
|
@ -858,27 +857,36 @@ namespace MWSound
|
|||
}
|
||||
|
||||
|
||||
void SoundManager::pauseSounds(int types)
|
||||
void SoundManager::pauseSounds(const std::string& blockerId, int types)
|
||||
{
|
||||
if(mOutput->isInitialized())
|
||||
{
|
||||
auto found = mPausedSoundTypes.find(blockerId);
|
||||
if (found != mPausedSoundTypes.end() && found->second != types)
|
||||
resumeSounds(blockerId);
|
||||
|
||||
types = types & Type::Mask;
|
||||
mOutput->pauseSounds(types);
|
||||
mPausedSoundTypes |= types;
|
||||
mPausedSoundTypes[blockerId] = types;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::resumeSounds(int types)
|
||||
void SoundManager::resumeSounds(const std::string& blockerId)
|
||||
{
|
||||
if(mOutput->isInitialized())
|
||||
{
|
||||
types = types & Type::Mask & mPausedSoundTypes;
|
||||
mPausedSoundTypes.erase(blockerId);
|
||||
int types = int(Type::Mask);
|
||||
for (auto& blocker : mPausedSoundTypes)
|
||||
{
|
||||
if (blocker.first != blockerId)
|
||||
types &= ~blocker.second;
|
||||
}
|
||||
|
||||
mOutput->resumeSounds(types);
|
||||
mPausedSoundTypes &= ~types;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SoundManager::updateRegionSound(float duration)
|
||||
{
|
||||
static float sTimeToNextEnvSound = 0.0f;
|
||||
|
@ -1399,5 +1407,6 @@ namespace MWSound
|
|||
mUnusedStreams.push_back(sound);
|
||||
}
|
||||
mActiveTracks.clear();
|
||||
mPausedSoundTypes.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace MWSound
|
|||
osg::Vec3f mListenerDir;
|
||||
osg::Vec3f mListenerUp;
|
||||
|
||||
int mPausedSoundTypes;
|
||||
std::unordered_map<std::string, int> mPausedSoundTypes;
|
||||
|
||||
Sound *mUnderwaterSound;
|
||||
Sound *mNearWaterSound;
|
||||
|
@ -244,10 +244,10 @@ namespace MWSound
|
|||
virtual bool getSoundPlaying(const MWWorld::ConstPtr &reference, const std::string& soundId) const;
|
||||
///< Is the given sound currently playing on the given object?
|
||||
|
||||
virtual void pauseSounds(int types);
|
||||
virtual void pauseSounds(const std::string& blockerId, int types=int(Type::Mask));
|
||||
///< Pauses all currently playing sounds, including music.
|
||||
|
||||
virtual void resumeSounds(int types);
|
||||
virtual void resumeSounds(const std::string& blockerId);
|
||||
///< Resumes all previously paused sounds.
|
||||
|
||||
virtual void update(float duration);
|
||||
|
|
Loading…
Reference in a new issue