ScummVM API documentation
game-manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef SUPERNOVA_GAME_MANAGER_H
23 #define SUPERNOVA_GAME_MANAGER_H
24 
25 #include "common/events.h"
26 #include "common/rect.h"
27 #include "common/keyboard.h"
28 #include "common/error.h"
29 #include "supernova/room.h"
30 #include "supernova/sound.h"
31 
32 namespace Supernova {
33 
34 const int32 kMaxTimerValue = 0x7FFFFFFF;
35 
36 enum EventFunction { kNoFn, kSupernovaFn, kGuardReturnedFn, kGuardWalkFn, kTaxiFn, kSearchStartFn, kSoberFn, kPyramidEndFn, kCaughtFn};
37 
38 
39 class Inventory {
40 public:
41  Inventory(Object *nullObject, int &inventoryScroll)
42  : _numObjects(0)
43  , _nullObject(nullObject)
44  , _inventoryScroll(inventoryScroll) {
45  for (int i = 0; i < kMaxCarry; ++i)
46  _inventory[i] = nullptr;
47  }
48 
49  void add(Object &obj);
50  void remove(Object &obj);
51  void clear();
52  Object *get(int index) const;
53  Object *get(ObjectId id) const;
54  int getSize() const { return _numObjects; }
55 
56 private:
57  Object *_inventory[kMaxCarry];
58  Object *_nullObject;
59  int &_inventoryScroll;
60  int _numObjects;
61 };
62 
63 class GuiElement : public Common::Rect {
64 public:
65  GuiElement();
66 
67  void setSize(int x1, int y1, int x2, int y2);
68  void setText(const char *text);
69  void setTextPosition(int x, int y);
70  void setColor(int bgColor, int textColor, int bgColorHighlighted, int textColorHightlighted);
71  void setHighlight(bool isHighlighted);
72 
73  const char *getText() const {
74  return _text;
75  }
76  int getBackgroundColor() const {
77  return _bgColor;
78  }
79  int getTextColor() const {
80  return _textColor;
81  }
82  const Common::Point &getTextPos() const {
83  return _textPosition;
84  }
85  bool isHighlighted() const {
86  return _isHighlighted;
87  }
88 
89 private:
90  Common::Point _textPosition;
91  char _text[128];
92  int _bgColor;
93  int _textColor;
94  int _bgColorNormal;
95  int _bgColorHighlighted;
96  int _textColorNormal;
97  int _textColorHighlighted;
98  bool _isHighlighted;
99 };
100 
101 class GameManager {
102 public:
103 
104  GameManager(SupernovaEngine *vm, Sound *sound);
105  virtual ~GameManager();
106 
107  virtual void updateEvents();
108  void processInput(Common::KeyState &state);
109  void processInput();
110  virtual void executeRoom();
111  virtual bool serialize(Common::WriteStream *out);
112  virtual bool deserialize(Common::ReadStream *in, int version);
113 
114  static int guiCommands[];
115  static int guiStatusCommands[];
116  SupernovaEngine *_vm;
117  Sound *_sound;
118  Common::KeyState _key;
119  Common::EventType _mouseClickType;
120  bool _mouseClicked;
121  bool _keyPressed;
122  int _mouseX;
123  int _mouseY;
124  int _mouseField;
125  Room *_currentRoom;
126  Room *_lastRoom;
127  bool _newRoom;
128  Room **_rooms;
129  Inventory _inventory;
130  bool _processInput;
131  bool _guiEnabled;
132  bool _animationEnabled;
133  byte _roomBrightness;
134  Action _inputVerb;
135  Object _nullObject;
136  Object *_currentInputObject;
137  Object *_inputObject[2];
138  int32 _oldTime;
139  uint _timePaused;
140  bool _timerPaused;
141  int32 _messageDuration;
142  int32 _animationTimer;
143  int _inventoryScroll;
144  int _exitList[25];
145  GuiElement _guiCommandButton[10];
146  GuiElement _guiInventory[8];
147  GuiElement _guiInventoryArrow[2];
148  // Dialog
149  int _currentSentence;
150  int _sentenceNumber[6];
151  int _texts[6];
152  byte _rows[6];
153  byte _rowsStart[6];
154  int32 _time;
155  bool _dead;
156 
157  void takeObject(Object &obj);
158  void setObjectNull(Object *&obj);
159  bool isNullObject(Object *obj);
160 
161  virtual void initState();
162  virtual void initRooms();
163  virtual void destroyRooms();
164  void initGui();
165  virtual bool canSaveGameStateCurrently();
166  virtual bool genericInteract(Action verb, Object &obj1, Object &obj2);
167  void getInput(bool onlyKeys = false);
168  void wait(int ticks, bool checkInput = false, bool waitForSpeech = false);
169  bool waitOnInput(int ticks, Common::KeyCode &keycode, bool waitForSpeech = false);
170  void screenShake();
171  virtual void roomBrightness();
172  void showMenu();
173  void animationOff();
174  void animationOn();
175  void edit(Common::String &input, int x, int y, uint length);
176  int invertSection(int section);
177  virtual void drawMapExits();
178  void drawStatus();
179  void drawCommandBox();
180  void drawInventory();
181  void drawGUI();
182  void changeRoom(RoomId id);
183  void resetInputState();
184  virtual void handleInput();
185  virtual void handleTime();
186  void pauseTimer(bool pause);
187  virtual void loadTime();
188  virtual void saveTime();
189  void setAnimationTimer(int ticks);
190  void dead(int messageId);
191  int dialog(int num, byte rowLength[6], int text[6], int number);
192  void sentence(int number, bool brightness);
193  void say(int textId);
194  void say(const char *text);
195  void reply(int textId, int aus1, int aus2);
196  void reply(const char *text, int aus1, int aus2);
197  void mousePosDialog(int x, int y);
198  virtual void takeMoney(int amount);
199 };
200 
201 }
202 
203 #endif // SUPERNOVA_GAME_MANAGER_H
Definition: supernova.h:61
Definition: game-manager.h:101
Definition: str.h:59
Definition: stream.h:77
Definition: console.h:27
Definition: room.h:39
EventType
Definition: events.h:49
Definition: game-manager.h:63
Definition: sound.h:85
Definition: rect.h:144
Definition: rect.h:45
Definition: game-manager.h:39
Definition: keyboard.h:294
Definition: stream.h:385
Definition: msn_def.h:210