OpenMW
apps/openmw/mwscript/interpretercontext.hpp
Go to the documentation of this file.
00001 #ifndef GAME_SCRIPT_INTERPRETERCONTEXT_H
00002 #define GAME_SCRIPT_INTERPRETERCONTEXT_H
00003 
00004 #include <boost/shared_ptr.hpp>
00005 
00006 #include <components/interpreter/context.hpp>
00007 
00008 #include "../mwbase/world.hpp"
00009 
00010 #include "../mwworld/ptr.hpp"
00011 #include "../mwworld/action.hpp"
00012 
00013 namespace MWSound
00014 {
00015     class SoundManager;
00016 }
00017 
00018 namespace MWInput
00019 {
00020     struct MWInputManager;
00021 }
00022 
00023 namespace MWScript
00024 {
00025     struct Locals;
00026 
00027     class InterpreterContext : public Interpreter::Context
00028     {
00029             Locals *mLocals;
00030             MWWorld::Ptr mReference;
00031 
00032             MWWorld::Ptr mActivated;
00033             bool mActivationHandled;
00034             boost::shared_ptr<MWWorld::Action> mAction;
00035 
00036             MWWorld::Ptr getReference (const std::string& id, bool activeOnly);
00037 
00038             const MWWorld::Ptr getReference (const std::string& id, bool activeOnly) const;
00039 
00040         public:
00041 
00042             InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference);
00044 
00045             virtual int getLocalShort (int index) const;
00046 
00047             virtual int getLocalLong (int index) const;
00048 
00049             virtual float getLocalFloat (int index) const;
00050 
00051             virtual void setLocalShort (int index, int value);
00052 
00053             virtual void setLocalLong (int index, int value);
00054 
00055             virtual void setLocalFloat (int index, float value);
00056 
00057             using Interpreter::Context::messageBox;
00058 
00059             virtual void messageBox (const std::string& message,
00060                 const std::vector<std::string>& buttons);
00061 
00062             virtual void report (const std::string& message);
00064 
00065             virtual bool menuMode();
00066 
00067             virtual int getGlobalShort (const std::string& name) const;
00068 
00069             virtual int getGlobalLong (const std::string& name) const;
00070 
00071             virtual float getGlobalFloat (const std::string& name) const;
00072 
00073             virtual void setGlobalShort (const std::string& name, int value);
00074 
00075             virtual void setGlobalLong (const std::string& name, int value);
00076 
00077             virtual void setGlobalFloat (const std::string& name, float value);
00078             
00079             virtual std::vector<std::string> getGlobals () const;
00080 
00081             virtual char getGlobalType (const std::string& name) const;
00082             
00083             virtual std::string getActionBinding(const std::string& action) const;
00084             
00085             virtual std::string getNPCName() const;
00086             
00087             virtual std::string getNPCRace() const;
00088             
00089             virtual std::string getNPCClass() const;
00090             
00091             virtual std::string getNPCFaction() const;
00092 
00093             virtual std::string getNPCRank() const;
00094             
00095             virtual std::string getPCName() const;
00096             
00097             virtual std::string getPCRace() const;
00098             
00099             virtual std::string getPCClass() const;
00100             
00101             virtual std::string getPCRank() const;
00102             
00103             virtual std::string getPCNextRank() const;
00104             
00105             virtual int getPCBounty() const;
00106             
00107             virtual std::string getCurrentCellName() const;
00108 
00109             virtual bool isScriptRunning (const std::string& name) const;
00110 
00111             virtual void startScript (const std::string& name);
00112 
00113             virtual void stopScript (const std::string& name);
00114 
00115             virtual float getDistance (const std::string& name, const std::string& id = "") const;
00116 
00117             bool hasBeenActivated (const MWWorld::Ptr& ptr);
00120 
00121             bool hasActivationBeenHandled() const;
00122 
00123             void activate (const MWWorld::Ptr& ptr, boost::shared_ptr<MWWorld::Action> action);
00126 
00127             void executeActivation();
00129 
00130             void clearActivation();
00132 
00133             virtual float getSecondsPassed() const;
00134 
00135             virtual bool isDisabled (const std::string& id = "") const;
00136 
00137             virtual void enable (const std::string& id = "");
00138 
00139             virtual void disable (const std::string& id = "");
00140 
00141             virtual int getMemberShort (const std::string& id, const std::string& name) const;
00142 
00143             virtual int getMemberLong (const std::string& id, const std::string& name) const;
00144 
00145             virtual float getMemberFloat (const std::string& id, const std::string& name) const;
00146 
00147             virtual void setMemberShort (const std::string& id, const std::string& name, int value);
00148 
00149             virtual void setMemberLong (const std::string& id, const std::string& name, int value);
00150 
00151             virtual void setMemberFloat (const std::string& id, const std::string& name, float value);
00152 
00153             MWWorld::Ptr getReference();
00155     };
00156 }
00157 
00158 #endif