forked from teamnwah/openmw-tes3coop
moved sound manager from world to engine (first step of another round of refactoring)
This commit is contained in:
parent
c12752df4d
commit
f8cb4c2502
7 changed files with 35 additions and 18 deletions
|
@ -13,6 +13,8 @@
|
|||
#include "mwscript/interpretercontext.hpp"
|
||||
#include "mwscript/extensions.hpp"
|
||||
|
||||
#include "mwsound/soundmanager.hpp"
|
||||
|
||||
#include "world.hpp"
|
||||
|
||||
void OMW::Engine::executeLocalScripts()
|
||||
|
@ -20,7 +22,7 @@ void OMW::Engine::executeLocalScripts()
|
|||
for (World::ScriptList::const_iterator iter (mWorld->getLocalScripts().begin());
|
||||
iter!=mWorld->getLocalScripts().end(); ++iter)
|
||||
{
|
||||
MWScript::InterpreterContext interpreterContext (*mWorld, iter->second);
|
||||
MWScript::InterpreterContext interpreterContext (*mWorld, *mSoundManager, iter->second);
|
||||
mScriptManager->run (iter->first, interpreterContext);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +54,7 @@ void OMW::Engine::processCommands()
|
|||
}
|
||||
|
||||
OMW::Engine::Engine()
|
||||
: mWorld(NULL), mDebug (false), mScriptManager (0), mScriptContext (0)
|
||||
: mWorld(NULL), mDebug (false), mSoundManager (0), mScriptManager (0), mScriptContext (0)
|
||||
{
|
||||
mspCommandServer.reset(
|
||||
new OMW::CommandServer::Server(&mCommandQueue, kCommandServerPort));
|
||||
|
@ -62,6 +64,7 @@ OMW::Engine::~Engine()
|
|||
{
|
||||
// mspCommandServer->stop();
|
||||
delete mWorld;
|
||||
delete mSoundManager;
|
||||
delete mScriptManager;
|
||||
delete mScriptContext;
|
||||
}
|
||||
|
@ -162,6 +165,8 @@ void OMW::Engine::go()
|
|||
// Create the world
|
||||
mWorld = new World (mOgre, mDataDir, mMaster, mCellName);
|
||||
|
||||
mSoundManager = new MWSound::SoundManager;
|
||||
|
||||
MWScript::registerExtensions (mExtensions);
|
||||
|
||||
mScriptContext = new MWScript::CompilerContextScript;
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "components/commandserver/command.hpp"
|
||||
#include <components/compiler/extensions.hpp>
|
||||
|
||||
#include "mwrender/mwscene.hpp"
|
||||
|
||||
namespace Compiler
|
||||
{
|
||||
class Context;
|
||||
|
@ -25,6 +23,11 @@ namespace MWScript
|
|||
class ScriptManager;
|
||||
}
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class SoundManager;
|
||||
}
|
||||
|
||||
namespace OMW
|
||||
{
|
||||
class World;
|
||||
|
@ -46,6 +49,7 @@ namespace OMW
|
|||
TsDeque<OMW::Command> mCommandQueue;
|
||||
std::auto_ptr<OMW::CommandServer::Server> mspCommandServer;
|
||||
|
||||
MWSound::SoundManager *mSoundManager;
|
||||
MWScript::ScriptManager *mScriptManager;
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
|
||||
namespace MWScript
|
||||
{
|
||||
InterpreterContext::InterpreterContext (OMW::World& world, MWScript::Locals *locals)
|
||||
: mWorld (world), mLocals (locals)
|
||||
InterpreterContext::InterpreterContext (OMW::World& world,
|
||||
MWSound::SoundManager& soundManager, MWScript::Locals *locals)
|
||||
: mWorld (world), mSoundManager (soundManager), mLocals (locals)
|
||||
{}
|
||||
|
||||
int InterpreterContext::getLocalShort (int index) const
|
||||
|
@ -74,5 +75,10 @@ namespace MWScript
|
|||
{
|
||||
return mWorld;
|
||||
}
|
||||
|
||||
MWSound::SoundManager& InterpreterContext::getSoundManager()
|
||||
{
|
||||
return mSoundManager;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@ namespace OMW
|
|||
class World;
|
||||
}
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
class SoundManager;
|
||||
}
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
struct Locals;
|
||||
|
@ -15,11 +20,13 @@ namespace MWScript
|
|||
class InterpreterContext : public Interpreter::Context
|
||||
{
|
||||
OMW::World& mWorld;
|
||||
MWSound::SoundManager& mSoundManager;
|
||||
Locals *mLocals;
|
||||
|
||||
public:
|
||||
|
||||
InterpreterContext (OMW::World& world, MWScript::Locals *locals);
|
||||
InterpreterContext (OMW::World& world, MWSound::SoundManager& soundManager,
|
||||
MWScript::Locals *locals);
|
||||
///< The ownership of \a locals is not transferred. 0-pointer allowed.
|
||||
|
||||
virtual int getLocalShort (int index) const;
|
||||
|
@ -38,6 +45,8 @@ namespace MWScript
|
|||
const std::vector<std::string>& buttons);
|
||||
|
||||
OMW::World& getWorld();
|
||||
|
||||
MWSound::SoundManager& getSoundManager();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
#include "../world.hpp"
|
||||
|
||||
#include "soundmanager.hpp"
|
||||
|
||||
namespace MWSound
|
||||
{
|
||||
namespace Script
|
||||
|
@ -24,7 +26,7 @@ namespace MWSound
|
|||
MWScript::InterpreterContext& context
|
||||
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
|
||||
|
||||
runtime.push (context.getWorld().getSoundManager().sayDone ("", context));
|
||||
runtime.push (context.getSoundManager().sayDone ("", context));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,7 +42,7 @@ namespace MWSound
|
|||
int index = runtime[0];
|
||||
runtime.pop();
|
||||
|
||||
runtime.push (context.getWorld().getSoundManager().getSoundPlaying (
|
||||
runtime.push (context.getSoundManager().getSoundPlaying (
|
||||
"", runtime.getStringLiteral (index), context));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -123,9 +123,4 @@ namespace OMW
|
|||
// Cell change not implemented yet.
|
||||
return false;
|
||||
}
|
||||
|
||||
MWSound::SoundManager& World::getSoundManager()
|
||||
{
|
||||
return mSoundManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "apps/openmw/mwrender/playerpos.hpp"
|
||||
#include "apps/openmw/mwrender/mwscene.hpp"
|
||||
|
||||
#include "mwsound/soundmanager.hpp"
|
||||
|
||||
#include "refdata.hpp"
|
||||
|
||||
|
@ -49,7 +48,6 @@ namespace OMW
|
|||
ESM::ESMReader mEsm;
|
||||
ESMS::ESMStore mStore;
|
||||
std::map<std::string, CellStore> mInteriors;
|
||||
MWSound::SoundManager mSoundManager;
|
||||
ScriptList mLocalScripts;
|
||||
|
||||
// not implemented
|
||||
|
@ -74,8 +72,6 @@ namespace OMW
|
|||
|
||||
bool hasCellChanged() const;
|
||||
///< Has the player moved to a different cell, since the last frame?
|
||||
|
||||
MWSound::SoundManager& getSoundManager();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue