mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-19 17:39:44 +00:00
Use enums for blockers IDs instead of strings
This commit is contained in:
parent
2254256db9
commit
e444766901
4 changed files with 26 additions and 18 deletions
|
@ -14,6 +14,14 @@ namespace MWWorld
|
|||
|
||||
namespace MWSound
|
||||
{
|
||||
// Each entry excepts of MaxCount should be used only in one place
|
||||
enum BlockerType
|
||||
{
|
||||
VideoPlayback,
|
||||
|
||||
MaxCount
|
||||
};
|
||||
|
||||
class Sound;
|
||||
class Stream;
|
||||
struct Sound_Decoder;
|
||||
|
@ -168,10 +176,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(const std::string& blockerId, int types=int(Type::Mask)) = 0;
|
||||
virtual void pauseSounds(MWSound::BlockerType blocker, int types=int(Type::Mask)) = 0;
|
||||
///< Pauses all currently playing sounds, including music.
|
||||
|
||||
virtual void resumeSounds(const std::string& blockerId) = 0;
|
||||
virtual void resumeSounds(MWSound::BlockerType blocker) = 0;
|
||||
///< Resumes all previously paused sounds.
|
||||
|
||||
virtual void pausePlayback() = 0;
|
||||
|
|
|
@ -1893,9 +1893,10 @@ namespace MWGui
|
|||
setCursorVisible(false);
|
||||
|
||||
if (mVideoWidget->hasAudioStream())
|
||||
MWBase::Environment::get().getSoundManager()->pauseSounds("Video",
|
||||
MWBase::Environment::get().getSoundManager()->pauseSounds(MWSound::VideoPlayback,
|
||||
~MWSound::Type::Movie & MWSound::Type::Mask
|
||||
);
|
||||
|
||||
osg::Timer frameTimer;
|
||||
while (mVideoWidget->update() && !MWBase::Environment::get().getStateManager()->hasQuitRequest())
|
||||
{
|
||||
|
@ -1927,7 +1928,7 @@ namespace MWGui
|
|||
}
|
||||
mVideoWidget->stop();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->resumeSounds("Video");
|
||||
MWBase::Environment::get().getSoundManager()->resumeSounds(MWSound::VideoPlayback);
|
||||
|
||||
setKeyFocusWidget(oldKeyFocus);
|
||||
|
||||
|
|
|
@ -857,30 +857,29 @@ namespace MWSound
|
|||
return false;
|
||||
}
|
||||
|
||||
void SoundManager::pauseSounds(const std::string& blockerId, int types)
|
||||
void SoundManager::pauseSounds(BlockerType blocker, int types)
|
||||
{
|
||||
if(mOutput->isInitialized())
|
||||
{
|
||||
auto found = mPausedSoundTypes.find(blockerId);
|
||||
if (found != mPausedSoundTypes.end() && found->second != types)
|
||||
resumeSounds(blockerId);
|
||||
if (mPausedSoundTypes[blocker] != 0)
|
||||
resumeSounds(blocker);
|
||||
|
||||
types = types & Type::Mask;
|
||||
mOutput->pauseSounds(types);
|
||||
mPausedSoundTypes[blockerId] = types;
|
||||
mPausedSoundTypes[blocker] = types;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::resumeSounds(const std::string& blockerId)
|
||||
void SoundManager::resumeSounds(BlockerType blocker)
|
||||
{
|
||||
if(mOutput->isInitialized())
|
||||
{
|
||||
mPausedSoundTypes.erase(blockerId);
|
||||
mPausedSoundTypes[blocker] = 0;
|
||||
int types = int(Type::Mask);
|
||||
for (auto& blocker : mPausedSoundTypes)
|
||||
for (int currentBlocker = 0; currentBlocker < BlockerType::MaxCount; currentBlocker++)
|
||||
{
|
||||
if (blocker.first != blockerId)
|
||||
types &= ~blocker.second;
|
||||
if (currentBlocker != blocker)
|
||||
types &= ~mPausedSoundTypes[currentBlocker];
|
||||
}
|
||||
|
||||
mOutput->resumeSounds(types);
|
||||
|
@ -1425,7 +1424,7 @@ namespace MWSound
|
|||
mUnusedStreams.push_back(sound);
|
||||
}
|
||||
mActiveTracks.clear();
|
||||
mPausedSoundTypes.clear();
|
||||
mPlaybackPaused = false;
|
||||
std::fill(std::begin(mPausedSoundTypes), std::end(mPausedSoundTypes), 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace MWSound
|
|||
osg::Vec3f mListenerDir;
|
||||
osg::Vec3f mListenerUp;
|
||||
|
||||
std::unordered_map<std::string, int> mPausedSoundTypes;
|
||||
int mPausedSoundTypes[BlockerType::MaxCount] = {};
|
||||
|
||||
Sound *mUnderwaterSound;
|
||||
Sound *mNearWaterSound;
|
||||
|
@ -245,10 +245,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(const std::string& blockerId, int types=int(Type::Mask));
|
||||
virtual void pauseSounds(MWSound::BlockerType blocker, int types=int(Type::Mask));
|
||||
///< Pauses all currently playing sounds, including music.
|
||||
|
||||
virtual void resumeSounds(const std::string& blockerId);
|
||||
virtual void resumeSounds(MWSound::BlockerType blocker);
|
||||
///< Resumes all previously paused sounds.
|
||||
|
||||
virtual void pausePlayback();
|
||||
|
|
Loading…
Reference in a new issue