mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 12:53:52 +00:00
Issue 255: moved global scripts into script manager (simplifying the environment class)
This commit is contained in:
parent
2bfd90f3f9
commit
7102a825c2
7 changed files with 19 additions and 32 deletions
|
@ -142,7 +142,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
||||||
|
|
||||||
// global scripts
|
// global scripts
|
||||||
mEnvironment.mGlobalScripts->run (mEnvironment);
|
mEnvironment.mScriptManager->getGlobalScripts().run (mEnvironment);
|
||||||
|
|
||||||
bool changed = mEnvironment.mWorld->hasCellChanged();
|
bool changed = mEnvironment.mWorld->hasCellChanged();
|
||||||
|
|
||||||
|
@ -205,7 +205,6 @@ OMW::Engine::~Engine()
|
||||||
{
|
{
|
||||||
delete mEnvironment.mWorld;
|
delete mEnvironment.mWorld;
|
||||||
delete mEnvironment.mSoundManager;
|
delete mEnvironment.mSoundManager;
|
||||||
delete mEnvironment.mGlobalScripts;
|
|
||||||
delete mEnvironment.mMechanicsManager;
|
delete mEnvironment.mMechanicsManager;
|
||||||
delete mEnvironment.mDialogueManager;
|
delete mEnvironment.mDialogueManager;
|
||||||
delete mEnvironment.mJournal;
|
delete mEnvironment.mJournal;
|
||||||
|
@ -402,9 +401,6 @@ void OMW::Engine::go()
|
||||||
mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(),
|
mEnvironment.mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(),
|
||||||
mVerboseScripts, *mScriptContext);
|
mVerboseScripts, *mScriptContext);
|
||||||
|
|
||||||
mEnvironment.mGlobalScripts = new MWScript::GlobalScripts (mEnvironment.mWorld->getStore(),
|
|
||||||
*mEnvironment.mScriptManager);
|
|
||||||
|
|
||||||
// Create game mechanics system
|
// Create game mechanics system
|
||||||
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
|
mEnvironment.mMechanicsManager = new MWMechanics::MechanicsManager (mEnvironment);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
MWBase::Environment *MWBase::Environment::sThis = 0;
|
MWBase::Environment *MWBase::Environment::sThis = 0;
|
||||||
|
|
||||||
MWBase::Environment::Environment()
|
MWBase::Environment::Environment()
|
||||||
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0),
|
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
|
||||||
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0)
|
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0)
|
||||||
{
|
{
|
||||||
assert (!sThis);
|
assert (!sThis);
|
||||||
|
@ -28,11 +28,6 @@ void MWBase::Environment::setSoundManager (MWSound::SoundManager *soundManager)
|
||||||
mSoundManager = soundManager;
|
mSoundManager = soundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWBase::Environment::setGlobalScripts (MWScript::GlobalScripts *globalScripts)
|
|
||||||
{
|
|
||||||
mGlobalScripts = globalScripts;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager)
|
void MWBase::Environment::setScriptManager (MWScript::ScriptManager *scriptManager)
|
||||||
{
|
{
|
||||||
mScriptManager = scriptManager;
|
mScriptManager = scriptManager;
|
||||||
|
@ -75,12 +70,6 @@ MWSound::SoundManager *MWBase::Environment::getSoundManager() const
|
||||||
return mSoundManager;
|
return mSoundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWScript::GlobalScripts *MWBase::Environment::getGlobalScripts() const
|
|
||||||
{
|
|
||||||
assert (mGlobalScripts);
|
|
||||||
return mGlobalScripts;
|
|
||||||
}
|
|
||||||
|
|
||||||
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const
|
MWScript::ScriptManager *MWBase::Environment::getScriptManager() const
|
||||||
{
|
{
|
||||||
assert (mScriptManager);
|
assert (mScriptManager);
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace MWSound
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
class GlobalScripts;
|
|
||||||
class ScriptManager;
|
class ScriptManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +51,6 @@ namespace MWBase
|
||||||
|
|
||||||
MWWorld::World *mWorld;
|
MWWorld::World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
MWSound::SoundManager *mSoundManager;
|
||||||
MWScript::GlobalScripts *mGlobalScripts;
|
|
||||||
MWScript::ScriptManager *mScriptManager;
|
MWScript::ScriptManager *mScriptManager;
|
||||||
MWGui::WindowManager *mWindowManager;
|
MWGui::WindowManager *mWindowManager;
|
||||||
MWMechanics::MechanicsManager *mMechanicsManager;
|
MWMechanics::MechanicsManager *mMechanicsManager;
|
||||||
|
@ -76,8 +74,6 @@ namespace MWBase
|
||||||
|
|
||||||
void setSoundManager (MWSound::SoundManager *soundManager);
|
void setSoundManager (MWSound::SoundManager *soundManager);
|
||||||
|
|
||||||
void setGlobalScripts (MWScript::GlobalScripts *globalScripts);
|
|
||||||
|
|
||||||
void setScriptManager (MWScript::ScriptManager *scriptManager);
|
void setScriptManager (MWScript::ScriptManager *scriptManager);
|
||||||
|
|
||||||
void setWindowManager (MWGui::WindowManager *windowManager);
|
void setWindowManager (MWGui::WindowManager *windowManager);
|
||||||
|
@ -95,8 +91,6 @@ namespace MWBase
|
||||||
|
|
||||||
MWSound::SoundManager *getSoundManager() const;
|
MWSound::SoundManager *getSoundManager() const;
|
||||||
|
|
||||||
MWScript::GlobalScripts *getGlobalScripts() const;
|
|
||||||
|
|
||||||
MWScript::ScriptManager *getScriptManager() const;
|
MWScript::ScriptManager *getScriptManager() const;
|
||||||
|
|
||||||
MWGui::WindowManager *getWindowManager() const;
|
MWGui::WindowManager *getWindowManager() const;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "locals.hpp"
|
#include "locals.hpp"
|
||||||
#include "globalscripts.hpp"
|
#include "globalscripts.hpp"
|
||||||
|
#include "scriptmanager.hpp"
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
|
@ -174,17 +175,17 @@ namespace MWScript
|
||||||
|
|
||||||
bool InterpreterContext::isScriptRunning (const std::string& name) const
|
bool InterpreterContext::isScriptRunning (const std::string& name) const
|
||||||
{
|
{
|
||||||
return mEnvironment.mGlobalScripts->isRunning (name);
|
return mEnvironment.mScriptManager->getGlobalScripts().isRunning (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::startScript (const std::string& name)
|
void InterpreterContext::startScript (const std::string& name)
|
||||||
{
|
{
|
||||||
mEnvironment.mGlobalScripts->addScript (name);
|
mEnvironment.mScriptManager->getGlobalScripts().addScript (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterContext::stopScript (const std::string& name)
|
void InterpreterContext::stopScript (const std::string& name)
|
||||||
{
|
{
|
||||||
mEnvironment.mGlobalScripts->removeScript (name);
|
mEnvironment.mScriptManager->getGlobalScripts().removeScript (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
|
float InterpreterContext::getDistance (const std::string& name, const std::string& id) const
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace MWScript
|
||||||
Compiler::Context& compilerContext)
|
Compiler::Context& compilerContext)
|
||||||
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose),
|
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose),
|
||||||
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
|
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext),
|
||||||
mOpcodesInstalled (false)
|
mOpcodesInstalled (false), mGlobalScripts (store, *this)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool ScriptManager::compile (const std::string& name)
|
bool ScriptManager::compile (const std::string& name)
|
||||||
|
@ -151,4 +151,9 @@ namespace MWScript
|
||||||
|
|
||||||
return iter->second.second;
|
return iter->second.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalScripts& ScriptManager::getGlobalScripts()
|
||||||
|
{
|
||||||
|
return mGlobalScripts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
#include <components/interpreter/interpreter.hpp>
|
#include <components/interpreter/interpreter.hpp>
|
||||||
#include <components/interpreter/types.hpp>
|
#include <components/interpreter/types.hpp>
|
||||||
|
|
||||||
|
#include "globalscripts.hpp"
|
||||||
|
|
||||||
namespace ESMS
|
namespace ESMS
|
||||||
{
|
{
|
||||||
struct ESMStore;
|
struct ESMStore;
|
||||||
|
@ -42,8 +44,8 @@ namespace MWScript
|
||||||
typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
|
typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
|
||||||
typedef std::map<std::string, CompiledScript> ScriptCollection;
|
typedef std::map<std::string, CompiledScript> ScriptCollection;
|
||||||
|
|
||||||
|
|
||||||
ScriptCollection mScripts;
|
ScriptCollection mScripts;
|
||||||
|
GlobalScripts mGlobalScripts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -63,6 +65,8 @@ namespace MWScript
|
||||||
|
|
||||||
Compiler::Locals& getLocals (const std::string& name);
|
Compiler::Locals& getLocals (const std::string& name);
|
||||||
///< Return locals for script \a name.
|
///< Return locals for script \a name.
|
||||||
|
|
||||||
|
GlobalScripts& getGlobalScripts();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ namespace MWSound
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
class GlobalScripts;
|
|
||||||
class ScriptManager;
|
class ScriptManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,14 +41,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Environment()
|
Environment()
|
||||||
: mWorld (0), mSoundManager (0), mGlobalScripts (0), mScriptManager (0), mWindowManager (0),
|
: mWorld (0), mSoundManager (0), mScriptManager (0), mWindowManager (0),
|
||||||
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0),
|
mMechanicsManager (0), mDialogueManager (0), mJournal (0), mFrameDuration (0),
|
||||||
mInputManager (0)
|
mInputManager (0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
World *mWorld;
|
World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
MWSound::SoundManager *mSoundManager;
|
||||||
MWScript::GlobalScripts *mGlobalScripts;
|
|
||||||
MWScript::ScriptManager *mScriptManager;
|
MWScript::ScriptManager *mScriptManager;
|
||||||
MWGui::WindowManager *mWindowManager;
|
MWGui::WindowManager *mWindowManager;
|
||||||
MWMechanics::MechanicsManager *mMechanicsManager;
|
MWMechanics::MechanicsManager *mMechanicsManager;
|
||||||
|
|
Loading…
Reference in a new issue