Added --nosound switch

actorid
Nicolay Korslund 15 years ago
parent 304692dc8e
commit 31017447eb

@ -106,6 +106,7 @@ OMW::Engine::Engine()
: mDebug (false) : mDebug (false)
, mVerboseScripts (false) , mVerboseScripts (false)
, mNewGame (false) , mNewGame (false)
, mUseSound (true)
, mScriptManager (0) , mScriptManager (0)
, mScriptContext (0) , mScriptContext (0)
{ {
@ -239,7 +240,8 @@ void OMW::Engine::go()
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(), mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
mOgre.getCamera(), mOgre.getCamera(),
mEnvironment.mWorld->getStore(), mEnvironment.mWorld->getStore(),
(mDataDir / "Sound").file_string()); (mDataDir / "Sound").file_string(),
mUseSound);
// Create script system // Create script system
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full, mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,

@ -59,6 +59,7 @@ namespace OMW
bool mDebug; bool mDebug;
bool mVerboseScripts; bool mVerboseScripts;
bool mNewGame; bool mNewGame;
bool mUseSound;
MWWorld::Environment mEnvironment; MWWorld::Environment mEnvironment;
MWScript::ScriptManager *mScriptManager; MWScript::ScriptManager *mScriptManager;
@ -115,6 +116,9 @@ namespace OMW
/// Enable verbose script output /// Enable verbose script output
void enableVerboseScripts(); void enableVerboseScripts();
/// Disable all sound
void disableSound() { mUseSound = false; }
/// Start as a new game. /// Start as a new game.
void setNewGame(); void setNewGame();

@ -31,6 +31,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
("master", bpo::value<std::string>()->default_value ("Morrowind"), ("master", bpo::value<std::string>()->default_value ("Morrowind"),
"master file") "master file")
( "debug", "debug mode" ) ( "debug", "debug mode" )
( "nosound", "disable all sound" )
( "script-verbose", "verbose script output" ) ( "script-verbose", "verbose script output" )
( "new-game", "activate char gen/new game mechanics" ) ( "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")) if (variables.count ("debug"))
engine.enableDebugMode(); engine.enableDebugMode();
if (variables.count ("nosound"))
engine.disableSound();
if (variables.count ("script-verbose")) if (variables.count ("script-verbose"))
engine.enableVerboseScripts(); engine.enableVerboseScripts();

@ -150,29 +150,37 @@ namespace MWSound
SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera, SoundManager::SoundManager(Ogre::Root *root, Ogre::Camera *camera,
const ESMS::ESMStore &store, 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() SoundManager::~SoundManager()
{ {
delete mData; if(mData)
delete mData;
} }
void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename) void SoundManager::say (MWWorld::Ptr ptr, const std::string& filename)
{ {
// The range values are not tested // The range values are not tested
if(!mData) return;
mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false); mData->add(filename, ptr, "_say_sound", 1, 1, 100, 10000, false);
} }
bool SoundManager::sayDone (MWWorld::Ptr ptr) const bool SoundManager::sayDone (MWWorld::Ptr ptr) const
{ {
if(!mData) return false;
return !mData->isPlaying(ptr, "_say_sound"); return !mData->isPlaying(ptr, "_say_sound");
} }
void SoundManager::streamMusic (const std::string& filename) void SoundManager::streamMusic (const std::string& filename)
{ {
if(!mData) return;
// Play the sound and tell it to stream, if possible. TODO: // Play the sound and tell it to stream, if possible. TODO:
// Store the reference, the jukebox will need to check status, // Store the reference, the jukebox will need to check status,
// control volume etc. // control volume etc.
@ -184,6 +192,8 @@ namespace MWSound
void SoundManager::playSound (const std::string& soundId, float volume, float pitch) void SoundManager::playSound (const std::string& soundId, float volume, float pitch)
{ {
if(!mData) return;
// Play and forget // Play and forget
float min, max; float min, max;
const std::string &file = mData->lookup(soundId, volume, 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, void SoundManager::playSound3D (MWWorld::Ptr ptr, const std::string& soundId,
float volume, float pitch, bool loop) float volume, float pitch, bool loop)
{ {
if(!mData) return;
// Look up the sound in the ESM data // Look up the sound in the ESM data
float min, max; float min, max;
const std::string &file = mData->lookup(soundId, volume, 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) void SoundManager::stopSound3D (MWWorld::Ptr ptr, const std::string& soundId)
{ {
if(!mData) return;
mData->remove(ptr, soundId); mData->remove(ptr, soundId);
} }
void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell) void SoundManager::stopSound (MWWorld::Ptr::CellStore *cell)
{ {
if(!mData) return;
mData->removeCell(cell); mData->removeCell(cell);
} }
bool SoundManager::getSoundPlaying (MWWorld::Ptr ptr, const std::string& soundId) const 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); return mData->isPlaying(ptr, soundId);
} }
void SoundManager::updateObject(MWWorld::Ptr ptr) void SoundManager::updateObject(MWWorld::Ptr ptr)
{ {
if(!mData) return;
mData->updatePositions(ptr); mData->updatePositions(ptr);
} }
} }

@ -28,7 +28,7 @@ namespace MWSound
public: public:
SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store, SoundManager(Ogre::Root*, Ogre::Camera*, const ESMS::ESMStore &store,
const std::string &soundDir); const std::string &soundDir, bool useSound);
~SoundManager(); ~SoundManager();
void say (MWWorld::Ptr reference, const std::string& filename); void say (MWWorld::Ptr reference, const std::string& filename);

Loading…
Cancel
Save