mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 03:40:24 +00:00
Merge branch 'soundfixes' into 'master'
Follow-up work for Lua-based music See merge request OpenMW/openmw!4146
This commit is contained in:
commit
56b31d87e3
7 changed files with 19 additions and 22 deletions
|
@ -27,11 +27,6 @@ namespace ESM
|
||||||
class ESMWriter;
|
class ESMWriter;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWSound
|
|
||||||
{
|
|
||||||
enum class MusicType;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
class Ptr;
|
class Ptr;
|
||||||
|
@ -312,9 +307,6 @@ namespace MWBase
|
||||||
virtual float getAngleToPlayer(const MWWorld::Ptr& ptr) const = 0;
|
virtual float getAngleToPlayer(const MWWorld::Ptr& ptr) const = 0;
|
||||||
virtual MWMechanics::GreetingState getGreetingState(const MWWorld::Ptr& ptr) const = 0;
|
virtual MWMechanics::GreetingState getGreetingState(const MWWorld::Ptr& ptr) const = 0;
|
||||||
virtual bool isTurningToPlayer(const MWWorld::Ptr& ptr) const = 0;
|
virtual bool isTurningToPlayer(const MWWorld::Ptr& ptr) const = 0;
|
||||||
|
|
||||||
virtual MWSound::MusicType getMusicType() const = 0;
|
|
||||||
virtual void setMusicType(MWSound::MusicType type) = 0;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,8 @@ namespace MWBase
|
||||||
virtual void stopMusic() = 0;
|
virtual void stopMusic() = 0;
|
||||||
///< Stops music if it's playing
|
///< 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;
|
virtual void streamMusic(VFS::Path::NormalizedView filename, MWSound::MusicType type, float fade = 1.f) = 0;
|
||||||
///< Play a soundifle
|
///< Play a soundifle
|
||||||
/// \param filename name of a sound file in the data directory.
|
/// \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["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);
|
lua["openmw_ambient"] = LuaUtil::makeReadOnly(api);
|
||||||
return lua["openmw_ambient"];
|
return lua["openmw_ambient"];
|
||||||
|
|
|
@ -250,7 +250,6 @@ namespace MWMechanics
|
||||||
, mClassSelected(false)
|
, mClassSelected(false)
|
||||||
, mRaceSelected(false)
|
, mRaceSelected(false)
|
||||||
, mAI(true)
|
, mAI(true)
|
||||||
, mMusicType(MWSound::MusicType::Normal)
|
|
||||||
{
|
{
|
||||||
// buildPlayer no longer here, needs to be done explicitly after all subsystems are up and running
|
// buildPlayer no longer here, needs to be done explicitly after all subsystems are up and running
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,6 @@ namespace MWMechanics
|
||||||
typedef std::map<ESM::RefId, OwnerMap> StolenItemsMap;
|
typedef std::map<ESM::RefId, OwnerMap> StolenItemsMap;
|
||||||
StolenItemsMap mStolenItems;
|
StolenItemsMap mStolenItems;
|
||||||
|
|
||||||
MWSound::MusicType mMusicType;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void buildPlayer();
|
void buildPlayer();
|
||||||
///< build player according to stored class/race/birthsign information. Will
|
///< build player according to stored class/race/birthsign information. Will
|
||||||
|
@ -245,9 +243,6 @@ namespace MWMechanics
|
||||||
GreetingState getGreetingState(const MWWorld::Ptr& ptr) const override;
|
GreetingState getGreetingState(const MWWorld::Ptr& ptr) const override;
|
||||||
bool isTurningToPlayer(const MWWorld::Ptr& ptr) const override;
|
bool isTurningToPlayer(const MWWorld::Ptr& ptr) const override;
|
||||||
|
|
||||||
MWSound::MusicType getMusicType() const override { return mMusicType; }
|
|
||||||
void setMusicType(MWSound::MusicType type) override { mMusicType = type; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool canCommitCrimeAgainst(const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
|
bool canCommitCrimeAgainst(const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker);
|
||||||
bool canReportCrime(
|
bool canReportCrime(
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include <components/vfs/recursivedirectoryiterator.hpp>
|
#include <components/vfs/recursivedirectoryiterator.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/mechanicsmanager.hpp"
|
|
||||||
#include "../mwbase/statemanager.hpp"
|
#include "../mwbase/statemanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
@ -115,6 +114,7 @@ namespace MWSound
|
||||||
, mOutput(std::make_unique<OpenAL_Output>(*this))
|
, mOutput(std::make_unique<OpenAL_Output>(*this))
|
||||||
, mWaterSoundUpdater(makeWaterSoundUpdaterSettings())
|
, mWaterSoundUpdater(makeWaterSoundUpdaterSettings())
|
||||||
, mSoundBuffers(*mOutput)
|
, mSoundBuffers(*mOutput)
|
||||||
|
, mMusicType(MWSound::MusicType::Normal)
|
||||||
, mListenerUnderwater(false)
|
, mListenerUnderwater(false)
|
||||||
, mListenerPos(0, 0, 0)
|
, mListenerPos(0, 0, 0)
|
||||||
, mListenerDir(1, 0, 0)
|
, mListenerDir(1, 0, 0)
|
||||||
|
@ -304,13 +304,11 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::streamMusic(VFS::Path::NormalizedView filename, MusicType type, float fade)
|
void SoundManager::streamMusic(VFS::Path::NormalizedView filename, MusicType type, float fade)
|
||||||
{
|
{
|
||||||
const auto mechanicsManager = MWBase::Environment::get().getMechanicsManager();
|
|
||||||
|
|
||||||
// Can not interrupt scripted music by built-in playlists
|
// Can not interrupt scripted music by built-in playlists
|
||||||
if (mechanicsManager->getMusicType() == MusicType::MWScript && type != MusicType::MWScript)
|
if (mMusicType == MusicType::MWScript && type != MusicType::MWScript)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mechanicsManager->setMusicType(type);
|
mMusicType = type;
|
||||||
advanceMusic(filename, fade);
|
advanceMusic(filename, fade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1072,6 +1070,8 @@ namespace MWSound
|
||||||
streamMusicFull(mNextMusic);
|
streamMusicFull(mNextMusic);
|
||||||
mNextMusic = VFS::Path::Normalized();
|
mNextMusic = VFS::Path::Normalized();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
mMusicType = MusicType::Normal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1256,7 +1256,8 @@ namespace MWSound
|
||||||
|
|
||||||
void SoundManager::clear()
|
void SoundManager::clear()
|
||||||
{
|
{
|
||||||
SoundManager::stopMusic();
|
stopMusic();
|
||||||
|
mMusicType = MusicType::Normal;
|
||||||
|
|
||||||
for (SoundMap::value_type& snd : mActiveSounds)
|
for (SoundMap::value_type& snd : mActiveSounds)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace MWSound
|
||||||
TrackList mActiveTracks;
|
TrackList mActiveTracks;
|
||||||
|
|
||||||
StreamPtr mMusic;
|
StreamPtr mMusic;
|
||||||
VFS::Path::Normalized mCurrentPlaylist;
|
MusicType mMusicType;
|
||||||
|
|
||||||
bool mListenerUnderwater;
|
bool mListenerUnderwater;
|
||||||
osg::Vec3f mListenerPos;
|
osg::Vec3f mListenerPos;
|
||||||
|
@ -169,6 +169,8 @@ namespace MWSound
|
||||||
void stopMusic() override;
|
void stopMusic() override;
|
||||||
///< Stops music if it's playing
|
///< 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;
|
void streamMusic(VFS::Path::NormalizedView filename, MWSound::MusicType type, float fade = 1.f) override;
|
||||||
///< Play a soundifle
|
///< Play a soundifle
|
||||||
/// \param filename name of a sound file in the data directory.
|
/// \param filename name of a sound file in the data directory.
|
||||||
|
|
Loading…
Reference in a new issue