OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
interpretercontext.hpp
Go to the documentation of this file.
1 #ifndef GAME_SCRIPT_INTERPRETERCONTEXT_H
2 #define GAME_SCRIPT_INTERPRETERCONTEXT_H
3 
4 #include <boost/shared_ptr.hpp>
5 
7 
8 #include "../mwworld/ptr.hpp"
9 #include "../mwworld/action.hpp"
10 
11 namespace MWSound
12 {
13  class SoundManager;
14 }
15 
16 namespace MWInput
17 {
18  struct MWInputManager;
19 }
20 
21 namespace MWScript
22 {
23  class Locals;
24 
26  {
29 
30  std::string mTargetId;
31 
34  MWWorld::Ptr getReferenceImp (const std::string& id = "", bool activeOnly = false,
35  bool doThrow=true);
36 
39  const MWWorld::Ptr getReferenceImp (const std::string& id = "",
40  bool activeOnly = false, bool doThrow=true) const;
41 
42  const Locals& getMemberLocals (std::string& id, bool global) const;
44 
45  Locals& getMemberLocals (std::string& id, bool global);
47 
49  int findLocalVariableIndex (const std::string& scriptId, const std::string& name,
50  char type) const;
51 
52  public:
53 
55  const std::string& targetId = "");
57 
58  virtual int getLocalShort (int index) const;
59 
60  virtual int getLocalLong (int index) const;
61 
62  virtual float getLocalFloat (int index) const;
63 
64  virtual void setLocalShort (int index, int value);
65 
66  virtual void setLocalLong (int index, int value);
67 
68  virtual void setLocalFloat (int index, float value);
69 
71 
72  virtual void messageBox (const std::string& message,
73  const std::vector<std::string>& buttons);
74 
75  virtual void report (const std::string& message);
77 
78  virtual bool menuMode();
79 
80  virtual int getGlobalShort (const std::string& name) const;
81 
82  virtual int getGlobalLong (const std::string& name) const;
83 
84  virtual float getGlobalFloat (const std::string& name) const;
85 
86  virtual void setGlobalShort (const std::string& name, int value);
87 
88  virtual void setGlobalLong (const std::string& name, int value);
89 
90  virtual void setGlobalFloat (const std::string& name, float value);
91 
92  virtual std::vector<std::string> getGlobals () const;
93 
94  virtual char getGlobalType (const std::string& name) const;
95 
96  virtual std::string getActionBinding(const std::string& action) const;
97 
98  virtual std::string getNPCName() const;
99 
100  virtual std::string getNPCRace() const;
101 
102  virtual std::string getNPCClass() const;
103 
104  virtual std::string getNPCFaction() const;
105 
106  virtual std::string getNPCRank() const;
107 
108  virtual std::string getPCName() const;
109 
110  virtual std::string getPCRace() const;
111 
112  virtual std::string getPCClass() const;
113 
114  virtual std::string getPCRank() const;
115 
116  virtual std::string getPCNextRank() const;
117 
118  virtual int getPCBounty() const;
119 
120  virtual std::string getCurrentCellName() const;
121 
122  virtual bool isScriptRunning (const std::string& name) const;
123 
124  virtual void startScript (const std::string& name, const std::string& targetId = "");
125 
126  virtual void stopScript (const std::string& name);
127 
128  virtual float getDistance (const std::string& name, const std::string& id = "") const;
130 
133 
134  virtual float getSecondsPassed() const;
135 
136  virtual bool isDisabled (const std::string& id = "") const;
137 
138  virtual void enable (const std::string& id = "");
139 
140  virtual void disable (const std::string& id = "");
141 
142  virtual int getMemberShort (const std::string& id, const std::string& name, bool global) const;
143 
144  virtual int getMemberLong (const std::string& id, const std::string& name, bool global) const;
145 
146  virtual float getMemberFloat (const std::string& id, const std::string& name, bool global) const;
147 
148  virtual void setMemberShort (const std::string& id, const std::string& name, int value, bool global);
149 
150  virtual void setMemberLong (const std::string& id, const std::string& name, int value, bool global);
151 
152  virtual void setMemberFloat (const std::string& id, const std::string& name, float value, bool global);
153 
154  MWWorld::Ptr getReference(bool required=true);
156 
157  void updatePtr(const MWWorld::Ptr& base, const MWWorld::Ptr& updated);
159 
160  virtual std::string getTargetId() const;
161  };
162 }
163 
164 #endif
virtual float getLocalFloat(int index) const
Definition: interpretercontext.cpp:166
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
virtual int getMemberShort(const std::string &id, const std::string &name, bool global) const
Definition: interpretercontext.cpp:512
Definition: locals.hpp:16
MWWorld::Ptr getReference(bool required=true)
Reference, that the script is running from (can be empty)
Definition: interpretercontext.cpp:570
virtual std::string getPCName() const
Definition: interpretercontext.cpp:335
virtual std::string getPCRace() const
Definition: interpretercontext.cpp:342
virtual std::string getNPCRank() const
Definition: interpretercontext.cpp:318
virtual std::string getNPCName() const
Definition: interpretercontext.cpp:291
virtual std::vector< std::string > getGlobals() const
Definition: interpretercontext.cpp:247
virtual bool isDisabled(const std::string &id="") const
Definition: interpretercontext.cpp:494
virtual char getGlobalType(const std::string &name) const
Definition: interpretercontext.cpp:263
virtual float getGlobalFloat(const std::string &name) const
Definition: interpretercontext.cpp:227
virtual void enable(const std::string &id="")
Definition: interpretercontext.cpp:500
virtual bool isScriptRunning(const std::string &name) const
Definition: interpretercontext.cpp:427
MWWorld::Ptr mReference
Definition: interpretercontext.hpp:28
virtual void setGlobalFloat(const std::string &name, float value)
Definition: interpretercontext.cpp:242
virtual int getMemberLong(const std::string &id, const std::string &name, bool global) const
Definition: interpretercontext.cpp:522
virtual std::string getCurrentCellName() const
Definition: interpretercontext.cpp:422
virtual int getLocalLong(int index) const
Definition: interpretercontext.cpp:158
InterpreterContext(MWScript::Locals *locals, MWWorld::Ptr reference, const std::string &targetId="")
The ownership of locals is not transferred. 0-pointer allowed.
Definition: interpretercontext.cpp:139
virtual int getGlobalShort(const std::string &name) const
Definition: interpretercontext.cpp:216
virtual bool menuMode()
Definition: interpretercontext.cpp:211
virtual float getSecondsPassed() const
Definition: interpretercontext.cpp:489
virtual std::string getNPCClass() const
Definition: interpretercontext.cpp:304
int findLocalVariableIndex(const std::string &scriptId, const std::string &name, char type) const
Throws an exception if local variable can't be found.
Definition: interpretercontext.cpp:113
std::string mTargetId
Definition: interpretercontext.hpp:30
virtual float getMemberFloat(const std::string &id, const std::string &name, bool global) const
Definition: interpretercontext.cpp:532
virtual std::string getPCRank() const
Definition: interpretercontext.cpp:356
virtual std::string getPCNextRank() const
Definition: interpretercontext.cpp:385
Definition: context.hpp:9
virtual void setGlobalShort(const std::string &name, int value)
Definition: interpretercontext.cpp:232
virtual void messageBox(const std::string &message, const std::vector< std::string > &buttons)=0
virtual std::string getNPCFaction() const
Definition: interpretercontext.cpp:311
virtual float getDistance(const std::string &name, const std::string &id="") const
Definition: interpretercontext.cpp:442
virtual void startScript(const std::string &name, const std::string &targetId="")
Definition: interpretercontext.cpp:432
virtual void report(const std::string &message)
By default, do nothing.
Definition: interpretercontext.cpp:207
virtual std::string getActionBinding(const std::string &action) const
Definition: interpretercontext.cpp:269
Locals * mLocals
Definition: interpretercontext.hpp:27
virtual void messageBox(const std::string &message, const std::vector< std::string > &buttons)
Definition: interpretercontext.cpp:198
virtual int getPCBounty() const
Definition: interpretercontext.cpp:415
void updatePtr(const MWWorld::Ptr &base, const MWWorld::Ptr &updated)
Update the Ptr stored in mReference, if there is one stored there. Should be called after the referen...
Definition: interpretercontext.cpp:580
MWWorld::Ptr getReferenceImp(const std::string &id="", bool activeOnly=false, bool doThrow=true)
Definition: interpretercontext.cpp:32
virtual void setMemberFloat(const std::string &id, const std::string &name, float value, bool global)
Definition: interpretercontext.cpp:561
virtual void setLocalShort(int index, int value)
Definition: interpretercontext.cpp:174
virtual std::string getNPCRace() const
Definition: interpretercontext.cpp:297
virtual void setLocalFloat(int index, float value)
Definition: interpretercontext.cpp:190
virtual void setLocalLong(int index, int value)
Definition: interpretercontext.cpp:182
virtual void stopScript(const std::string &name)
Definition: interpretercontext.cpp:437
virtual int getLocalShort(int index) const
Definition: interpretercontext.cpp:150
virtual std::string getPCClass() const
Definition: interpretercontext.cpp:349
virtual std::string getTargetId() const
Definition: interpretercontext.cpp:575
virtual int getGlobalLong(const std::string &name) const
Definition: interpretercontext.cpp:221
virtual void setMemberShort(const std::string &id, const std::string &name, int value, bool global)
Definition: interpretercontext.cpp:542
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
Definition: interpretercontext.hpp:25
void executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor)
Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled...
Definition: interpretercontext.cpp:479
const Locals & getMemberLocals(std::string &id, bool global) const
id is changed to the respective script ID, if id wasn't a script ID before
Definition: interpretercontext.cpp:72
virtual void setGlobalLong(const std::string &name, int value)
Definition: interpretercontext.cpp:237
virtual void setMemberLong(const std::string &id, const std::string &name, int value, bool global)
Definition: interpretercontext.cpp:552
const char * name
Definition: crashcatcher.cpp:59
virtual void disable(const std::string &id="")
Definition: interpretercontext.cpp:506