Do not allow Lua's "stopMusic" to interrupt MWScript's music

esm4-texture
Andrei Kortunov 7 months ago
parent 402e725d87
commit 7b5146e824

@ -115,6 +115,8 @@ namespace MWBase
virtual void stopMusic() = 0;
///< Stops music if it's playing
virtual MWSound::MusicType getMusicType() const = 0;
virtual void streamMusic(VFS::Path::NormalizedView filename, MWSound::MusicType type, float fade = 1.f) = 0;
///< Play a soundifle
/// \param filename name of a sound file in the data directory.

@ -157,7 +157,13 @@ namespace MWLua
api["isMusicPlaying"] = []() { return MWBase::Environment::get().getSoundManager()->isMusicPlaying(); };
api["stopMusic"] = []() { MWBase::Environment::get().getSoundManager()->stopMusic(); };
api["stopMusic"] = []() {
MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager();
if (sndMgr->getMusicType() == MWSound::MusicType::MWScript)
return;
sndMgr->stopMusic();
};
lua["openmw_ambient"] = LuaUtil::makeReadOnly(api);
return lua["openmw_ambient"];

@ -1257,6 +1257,7 @@ namespace MWSound
void SoundManager::clear()
{
stopMusic();
mMusicType = MusicType::Normal;
for (SoundMap::value_type& snd : mActiveSounds)
{

@ -169,6 +169,8 @@ namespace MWSound
void stopMusic() override;
///< Stops music if it's playing
MWSound::MusicType getMusicType() const override { return mMusicType; }
void streamMusic(VFS::Path::NormalizedView filename, MWSound::MusicType type, float fade = 1.f) override;
///< Play a soundifle
/// \param filename name of a sound file in the data directory.

Loading…
Cancel
Save