diff --git a/apps/openmw/mwbase/soundmanager.hpp b/apps/openmw/mwbase/soundmanager.hpp index 9f1412dcbf..5f96a4e095 100644 --- a/apps/openmw/mwbase/soundmanager.hpp +++ b/apps/openmw/mwbase/soundmanager.hpp @@ -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. diff --git a/apps/openmw/mwlua/soundbindings.cpp b/apps/openmw/mwlua/soundbindings.cpp index fbae24ae1e..50b693fe32 100644 --- a/apps/openmw/mwlua/soundbindings.cpp +++ b/apps/openmw/mwlua/soundbindings.cpp @@ -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"]; diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index c741dce24e..8848948c1e 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -1257,6 +1257,7 @@ namespace MWSound void SoundManager::clear() { stopMusic(); + mMusicType = MusicType::Normal; for (SoundMap::value_type& snd : mActiveSounds) { diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index fab6489878..a5e5b2c45f 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -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.