added support for a ton of stuff, fixed lots
[riven-wahrk.git] / src / Script.h
blob05eda31cdf783857d36f519c0922b6714942a334
2 #ifndef _SCRIPT_H_
3 #define _SCRIPT_H_
5 #include <map>
6 #include <vector>
8 #include "Common.h"
9 #include "File.h"
11 using namespace std;
13 class Game;
15 class Handler {
17 public:
19 enum Event {
20 MouseDown = 0,
21 MouseUp = 2,
22 MouseWithin = 4,
23 MouseLeave = 5,
24 CardLoad = 6,
25 CardClose = 7,
26 CardOpen = 9,
27 DisplayUpdate = 10 };
29 private:
31 Event eventType;
32 uint16_t *cmdList;
33 // we don't know how many bytes long a handler is, so
34 // we find it for each segment, and save it in a cache.
35 map<int, uint16_t> *cmdLength;
37 Game *game; // pointer to Game
39 int findSegmentSize (int offset);
41 void runSegment (int addr);
42 void runCmd (uint16_t *cmd);
44 public:
46 Handler (uint16_t *cmdListIn, Game *gameIn);
47 void run () {
48 runSegment (1);
51 uint16_t getLength () { // number of shorts
52 return cmdLength->find(1)->second + 1;
55 Event getEventType () {
56 return eventType;
62 class Script {
64 uint16_t *cmdList;
65 vector<Handler*> *handler;
67 public:
69 Script (File *fileIn, int start, Game *game);
71 void runHandler (Handler::Event event);
72 int getSize ();
76 #endif