2010-07-02 16:08:00 +00:00
|
|
|
#ifndef GAME_SCRIPT_INTERPRETERCONTEXT_H
|
|
|
|
#define GAME_SCRIPT_INTERPRETERCONTEXT_H
|
|
|
|
|
2010-08-03 20:43:53 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2010-07-02 16:08:00 +00:00
|
|
|
#include <components/interpreter/context.hpp>
|
|
|
|
|
2012-07-03 10:30:50 +00:00
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2010-07-03 15:46:55 +00:00
|
|
|
#include "../mwworld/ptr.hpp"
|
2010-08-03 20:43:53 +00:00
|
|
|
#include "../mwworld/action.hpp"
|
2010-07-02 16:08:00 +00:00
|
|
|
|
2010-07-03 13:17:02 +00:00
|
|
|
namespace MWSound
|
|
|
|
{
|
|
|
|
class SoundManager;
|
|
|
|
}
|
|
|
|
|
2010-09-15 12:48:19 +00:00
|
|
|
namespace MWInput
|
|
|
|
{
|
|
|
|
struct MWInputManager;
|
|
|
|
}
|
|
|
|
|
2010-07-02 16:08:00 +00:00
|
|
|
namespace MWScript
|
|
|
|
{
|
|
|
|
struct Locals;
|
|
|
|
|
|
|
|
class InterpreterContext : public Interpreter::Context
|
2010-08-03 20:43:53 +00:00
|
|
|
{
|
2010-07-02 16:08:00 +00:00
|
|
|
Locals *mLocals;
|
2010-07-03 15:46:55 +00:00
|
|
|
MWWorld::Ptr mReference;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
|
|
|
MWWorld::Ptr mActivated;
|
|
|
|
bool mActivationHandled;
|
|
|
|
boost::shared_ptr<MWWorld::Action> mAction;
|
|
|
|
|
2014-01-09 01:14:08 +00:00
|
|
|
MWWorld::Ptr getReference (const std::string& id, bool activeOnly, bool doThrow=true);
|
2010-07-10 11:19:04 +00:00
|
|
|
|
2014-01-09 01:14:08 +00:00
|
|
|
const MWWorld::Ptr getReference (const std::string& id, bool activeOnly, bool doThrow=true) const;
|
2010-07-09 17:32:17 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
const Locals& getMemberLocals (std::string& id, bool global) const;
|
|
|
|
///< \a id is changed to the respective script ID, if \a id wasn't a script ID before
|
|
|
|
|
|
|
|
Locals& getMemberLocals (std::string& id, bool global);
|
|
|
|
///< \a id is changed to the respective script ID, if \a id wasn't a script ID before
|
|
|
|
|
2010-07-02 16:08:00 +00:00
|
|
|
public:
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference);
|
2010-07-02 16:08:00 +00:00
|
|
|
///< The ownership of \a locals is not transferred. 0-pointer allowed.
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-02 16:08:00 +00:00
|
|
|
virtual int getLocalShort (int index) const;
|
|
|
|
|
|
|
|
virtual int getLocalLong (int index) const;
|
|
|
|
|
|
|
|
virtual float getLocalFloat (int index) const;
|
|
|
|
|
2010-08-03 20:43:53 +00:00
|
|
|
virtual void setLocalShort (int index, int value);
|
2010-07-02 16:08:00 +00:00
|
|
|
|
|
|
|
virtual void setLocalLong (int index, int value);
|
|
|
|
|
|
|
|
virtual void setLocalFloat (int index, float value);
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-08-12 14:29:22 +00:00
|
|
|
using Interpreter::Context::messageBox;
|
2011-04-26 19:48:13 +00:00
|
|
|
|
2010-07-02 16:08:00 +00:00
|
|
|
virtual void messageBox (const std::string& message,
|
2010-08-03 20:43:53 +00:00
|
|
|
const std::vector<std::string>& buttons);
|
2010-07-03 13:04:00 +00:00
|
|
|
|
2011-04-26 19:48:13 +00:00
|
|
|
virtual void report (const std::string& message);
|
|
|
|
///< By default echo via messageBox.
|
|
|
|
|
2010-07-04 10:29:28 +00:00
|
|
|
virtual bool menuMode();
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-04 10:29:28 +00:00
|
|
|
virtual int getGlobalShort (const std::string& name) const;
|
|
|
|
|
|
|
|
virtual int getGlobalLong (const std::string& name) const;
|
|
|
|
|
|
|
|
virtual float getGlobalFloat (const std::string& name) const;
|
|
|
|
|
2010-08-03 20:43:53 +00:00
|
|
|
virtual void setGlobalShort (const std::string& name, int value);
|
2010-07-04 10:29:28 +00:00
|
|
|
|
2010-08-03 20:43:53 +00:00
|
|
|
virtual void setGlobalLong (const std::string& name, int value);
|
2010-07-04 10:29:28 +00:00
|
|
|
|
|
|
|
virtual void setGlobalFloat (const std::string& name, float value);
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-20 23:16:34 +00:00
|
|
|
virtual std::vector<std::string> getGlobals () const;
|
|
|
|
|
|
|
|
virtual char getGlobalType (const std::string& name) const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getActionBinding(const std::string& action) const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getNPCName() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getNPCRace() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getNPCClass() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getNPCFaction() const;
|
2013-03-17 03:20:30 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getNPCRank() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getPCName() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getPCRace() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getPCClass() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getPCRank() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getPCNextRank() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual int getPCBounty() const;
|
2014-02-10 13:45:55 +00:00
|
|
|
|
2012-12-21 18:09:31 +00:00
|
|
|
virtual std::string getCurrentCellName() const;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-07 18:14:50 +00:00
|
|
|
virtual bool isScriptRunning (const std::string& name) const;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-04 14:00:32 +00:00
|
|
|
virtual void startScript (const std::string& name);
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-04 14:00:32 +00:00
|
|
|
virtual void stopScript (const std::string& name);
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-09 18:55:39 +00:00
|
|
|
virtual float getDistance (const std::string& name, const std::string& id = "") const;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
|
|
|
bool hasBeenActivated (const MWWorld::Ptr& ptr);
|
|
|
|
///< \attention Calling this function for the right reference will mark the action as
|
|
|
|
/// been handled.
|
|
|
|
|
|
|
|
bool hasActivationBeenHandled() const;
|
|
|
|
|
|
|
|
void activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> action);
|
|
|
|
///< Store reference acted upon and action. The actual execution of the action does not
|
|
|
|
/// take place here.
|
|
|
|
|
|
|
|
void executeActivation();
|
|
|
|
///< Execute the action defined by the last activate call.
|
|
|
|
|
|
|
|
void clearActivation();
|
|
|
|
///< Discard the action defined by the last activate call.
|
|
|
|
|
2010-07-06 10:06:50 +00:00
|
|
|
virtual float getSecondsPassed() const;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-09 17:32:17 +00:00
|
|
|
virtual bool isDisabled (const std::string& id = "") const;
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-09 17:32:17 +00:00
|
|
|
virtual void enable (const std::string& id = "");
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2010-07-09 17:32:17 +00:00
|
|
|
virtual void disable (const std::string& id = "");
|
2010-08-03 20:43:53 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const;
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const;
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual float getMemberFloat (const std::string& id, const std::string& name, bool global) const;
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual void setMemberShort (const std::string& id, const std::string& name, int value, bool global);
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual void setMemberLong (const std::string& id, const std::string& name, int value, bool global);
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual void setMemberFloat (const std::string& id, const std::string& name, float value, bool global);
|
2012-06-07 09:59:45 +00:00
|
|
|
|
2014-01-09 01:14:08 +00:00
|
|
|
MWWorld::Ptr getReference(bool required=true);
|
2010-07-03 15:59:30 +00:00
|
|
|
///< Reference, that the script is running from (can be empty)
|
2010-07-02 16:08:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|