2010-07-02 16:08:00 +00:00
|
|
|
|
|
|
|
#include "interpretercontext.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "locals.hpp"
|
2010-07-03 13:41:20 +00:00
|
|
|
#include "../mwworld/world.hpp"
|
2010-07-02 16:08:00 +00:00
|
|
|
|
|
|
|
namespace MWScript
|
|
|
|
{
|
2010-07-03 13:41:20 +00:00
|
|
|
InterpreterContext::InterpreterContext (MWWorld::World& world,
|
2010-07-03 15:46:55 +00:00
|
|
|
MWSound::SoundManager& soundManager, MWScript::Locals *locals, MWWorld::Ptr reference)
|
|
|
|
: mWorld (world), mSoundManager (soundManager), mLocals (locals), mReference (reference)
|
2010-07-02 16:08:00 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
int InterpreterContext::getLocalShort (int index) const
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
return mLocals->mShorts.at (index);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InterpreterContext::getLocalLong (int index) const
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
return mLocals->mLongs.at (index);
|
|
|
|
}
|
|
|
|
|
|
|
|
float InterpreterContext::getLocalFloat (int index) const
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
return mLocals->mFloats.at (index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpreterContext::setLocalShort (int index, int value)
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
mLocals->mShorts.at (index) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpreterContext::setLocalLong (int index, int value)
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
mLocals->mLongs.at (index) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpreterContext::setLocalFloat (int index, float value)
|
|
|
|
{
|
|
|
|
if (!mLocals)
|
|
|
|
throw std::runtime_error ("local variables not available in this context");
|
|
|
|
|
|
|
|
mLocals->mFloats.at (index) = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpreterContext::messageBox (const std::string& message,
|
|
|
|
const std::vector<std::string>& buttons)
|
|
|
|
{
|
|
|
|
std::cout << "message box: " << message << std::endl;
|
|
|
|
|
|
|
|
if (!buttons.empty())
|
|
|
|
std::cerr << "error: message box buttons not supported" << std::endl;
|
|
|
|
}
|
2010-07-03 10:12:13 +00:00
|
|
|
|
2010-07-03 13:41:20 +00:00
|
|
|
MWWorld::World& InterpreterContext::getWorld()
|
2010-07-03 10:12:13 +00:00
|
|
|
{
|
2010-07-03 13:04:00 +00:00
|
|
|
return mWorld;
|
2010-07-03 10:12:13 +00:00
|
|
|
}
|
2010-07-03 13:17:02 +00:00
|
|
|
|
|
|
|
MWSound::SoundManager& InterpreterContext::getSoundManager()
|
|
|
|
{
|
|
|
|
return mSoundManager;
|
|
|
|
}
|
2010-07-03 15:59:30 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr InterpreterContext::getReference()
|
|
|
|
{
|
|
|
|
return mReference;
|
|
|
|
}
|
2010-07-02 16:08:00 +00:00
|
|
|
}
|
|
|
|
|