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
32namespace Supernova {
33
34const int32 kMaxTimerValue = 0x7FFFFFFF;
35
36enum EventFunction { kNoFn, kSupernovaFn, kGuardReturnedFn, kGuardWalkFn, kTaxiFn, kSearchStartFn, kSoberFn, kPyramidEndFn, kCaughtFn};
37
38
39class Inventory {
40public:
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
56private:
57 Object *_inventory[kMaxCarry];
58 Object *_nullObject;
59 int &_inventoryScroll;
60 int _numObjects;
61};
62
63class GuiElement : public Common::Rect {
64public:
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
89private:
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
102public:
103
104 GameManager(SupernovaEngine *vm, Sound *sound);
105 virtual ~GameManager();
106
107 virtual void updateEvents();
108 void processInput(Common::CustomEventType action);
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;
120 Common::EventType _mouseClickType;
121 bool _mouseClicked;
122 bool _keyPressed;
123 int _mouseX;
124 int _mouseY;
125 int _mouseField;
126 Room *_currentRoom;
127 Room *_lastRoom;
128 bool _newRoom;
129 Room **_rooms;
130 Inventory _inventory;
131 bool _processInput;
132 bool _guiEnabled;
133 bool _animationEnabled;
134 byte _roomBrightness;
135 Action _inputVerb;
136 Object _nullObject;
137 Object *_currentInputObject;
138 Object *_inputObject[2];
139 int32 _oldTime;
140 uint _timePaused;
141 bool _timerPaused;
142 int32 _messageDuration;
143 int32 _animationTimer;
144 int _inventoryScroll;
145 int _exitList[25];
146 GuiElement _guiCommandButton[10];
147 GuiElement _guiInventory[8];
148 GuiElement _guiInventoryArrow[2];
149 // Dialog
150 int _currentSentence;
151 int _sentenceNumber[6];
152 int _texts[6];
153 byte _rows[6];
154 byte _rowsStart[6];
155 int32 _time;
156 bool _dead;
157
158 void takeObject(Object &obj);
159 void setObjectNull(Object *&obj);
160 bool isNullObject(Object *obj);
161
162 virtual void initState();
163 virtual void initRooms();
164 virtual void destroyRooms();
165 void initGui();
166 virtual bool canSaveGameStateCurrently();
167 virtual bool genericInteract(Action verb, Object &obj1, Object &obj2);
168 void getInput(bool onlyKeys = false);
169 void wait(int ticks, bool checkInput = false, bool waitForSpeech = false);
170 bool waitOnInput(int ticks, Common::KeyCode &keycode, bool waitForSpeech = false);
171 void screenShake();
172 virtual void roomBrightness();
173 void showMenu();
174 void animationOff();
175 void animationOn();
176 void edit(Common::String &input, int x, int y, uint length);
177 int invertSection(int section);
178 virtual void drawMapExits();
179 void drawStatus();
180 void drawCommandBox();
181 void drawInventory();
182 void drawGUI();
183 void changeRoom(RoomId id);
184 void resetInputState();
185 virtual void handleInput();
186 virtual void handleTime();
187 void pauseTimer(bool pause);
188 virtual void loadTime();
189 virtual void saveTime();
190 void setAnimationTimer(int ticks);
191 void dead(int messageId);
192 int dialog(int num, byte rowLength[6], int text[6], int number);
193 void sentence(int number, bool brightness);
194 void say(int textId);
195 void say(const char *text);
196 void reply(int textId, int aus1, int aus2);
197 void reply(const char *text, int aus1, int aus2);
198 void mousePosDialog(int x, int y);
199 virtual void takeMoney(int amount);
200};
201
202}
203
204#endif // SUPERNOVA_GAME_MANAGER_H
Definition: stream.h:385
Definition: str.h:59
Definition: stream.h:77
Definition: game-manager.h:101
Definition: game-manager.h:63
Definition: game-manager.h:39
Definition: room.h:39
Definition: sound.h:85
Definition: supernova.h:61
EventType
Definition: events.h:49
uint32 CustomEventType
Definition: events.h:212
Definition: keyboard.h:294
Definition: rect.h:144
Definition: rect.h:536
Definition: msn_def.h:210