mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
Added --nosound switch
This commit is contained in:
parent
304692dc8e
commit
31017447eb
5 changed files with 34 additions and 5 deletions
|
@ -106,6 +106,7 @@ OMW::Engine::Engine()
|
|||
: mDebug (false)
|
||||
, mVerboseScripts (false)
|
||||
, mNewGame (false)
|
||||
, mUseSound (true)
|
||||
, mScriptManager (0)
|
||||
, mScriptContext (0)
|
||||
{
|
||||
|
@ -239,7 +240,8 @@ void OMW::Engine::go()
|
|||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
|
||||
mOgre.getCamera(),
|
||||
mEnvironment.mWorld->getStore(),
|
||||
(mDataDir / "Sound").file_string());
|
||||
(mDataDir / "Sound").file_string(),
|
||||
mUseSound);
|
||||
|
||||
// Create script system
|
||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace OMW
|
|||
bool mDebug;
|
||||
bool mVerboseScripts;
|
||||
bool mNewGame;
|
||||
bool mUseSound;
|
||||
|
||||
MWWorld::Environment mEnvironment;
|
||||
MWScript::ScriptManager *mScriptManager;
|
||||
|
@ -115,6 +116,9 @@ namespace OMW
|
|||
/// Enable verbose script output
|
||||
void enableVerboseScripts();
|
||||
|
||||
/// Disable all sound
|
||||
void disableSound() { mUseSound = false; }
|
||||
|
||||
/// Start as a new game.
|
||||
void setNewGame();
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
|||
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
||||
"master file")
|
||||
( "debug", "debug mode" )
|
||||
( "nosound", "disable all sound" )
|
||||
( "script-verbose", "verbose script output" )
|
||||
( "new-game", "activate char gen/new game mechanics" )
|
||||
;
|
||||
|
@ -64,6 +65,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
|||
|
||||
if (variables.count ("debug"))
|
||||
engine.enableDebugMode();
|
||||
|
||||
if (variables.count ("nosound"))
|
||||
engine.disableSound();
|
||||
|
||||
if (variables.count ("script-verbose"))
|
||||
engine.enableVerboseScripts();
|
||||
|
|
|
@ -150,29 +150,37 @@ namespace MWSound
|
|||
|
||||
SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera,
|
||||
const ESMS::ESMStore &store,
|
||||
const std::string &soundDir)
|
||||
const std::string &soundDir,
|
||||
bool useSound)
|
||||
: mData(NULL)
|
||||
{
|
||||
mData = new SoundImpl(root, camera, store, soundDir);
|
||||
if(useSound)
|
||||
mData = new SoundImpl(root, camera, store, soundDir);
|
||||
}
|
||||
|
||||
SoundManager::~SoundManager()
|
||||
{
|
||||
delete mData;
|
||||
if(mData)
|
||||
delete mData;
|
||||
}
|
||||
|
||||
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
|
||||
{
|
||||
// The range values are not tested
|
||||
if(!mData) return;
|
||||
mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false);
|
||||
}
|
||||
|
||||
bool SoundManager::sayDone (MWWorld::Ptr ptr) const
|
||||
{
|
||||
if(!mData) return false;
|
||||
return !mData->isPlaying(ptr, "_say_sound");
|
||||
}
|
||||
|
||||
void SoundManager::streamMusic (const std::string& filename)
|
||||
{
|
||||
if(!mData) return;
|
||||
|
||||
// Play the sound and tell it to stream, if possible. TODO:
|
||||
// Store the reference, the jukebox will need to check status,
|
||||
// control volume etc.
|
||||
|
@ -184,6 +192,8 @@ namespace MWSound
|
|||
|
||||
void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
|
||||
{
|
||||
if(!mData) return;
|
||||
|
||||
// Play and forget
|
||||
float min, max;
|
||||
const std::string &file = mData->lookup(soundId, volume, min, max);
|
||||
|
@ -199,6 +209,8 @@ namespace MWSound
|
|||
void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
|
||||
float volume, float pitch, bool loop)
|
||||
{
|
||||
if(!mData) return;
|
||||
|
||||
// Look up the sound in the ESM data
|
||||
float min, max;
|
||||
const std::string &file = mData->lookup(soundId, volume, min, max);
|
||||
|
@ -208,21 +220,28 @@ namespace MWSound
|
|||
|
||||
void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId)
|
||||
{
|
||||
if(!mData) return;
|
||||
mData->remove(ptr, soundId);
|
||||
}
|
||||
|
||||
void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell)
|
||||
{
|
||||
if(!mData) return;
|
||||
mData->removeCell(cell);
|
||||
}
|
||||
|
||||
bool SoundManager::getSoundPlaying (MWWorld::Ptr ptr, const std::string& soundId) const
|
||||
{
|
||||
// Mark all sounds as playing, otherwise the scripts will just
|
||||
// keep trying to play them every frame.
|
||||
if(!mData) return true;
|
||||
|
||||
return mData->isPlaying(ptr, soundId);
|
||||
}
|
||||
|
||||
void SoundManager::updateObject(MWWorld::Ptr ptr)
|
||||
{
|
||||
if(!mData) return;
|
||||
mData->updatePositions(ptr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace MWSound
|
|||
|
||||
public:
|
||||
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
|
||||
const std::string &soundDir);
|
||||
const std::string &soundDir, bool useSound);
|
||||
~SoundManager();
|
||||
|
||||
void say (MWWorld::Ptr reference, const std::string& filename);
|
||||
|
|
Loading…
Reference in a new issue