ScummVM API documentation
game.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 MADS_GAME_H
23 #define MADS_GAME_H
24 
25 #include "common/scummsys.h"
26 #include "common/savefile.h"
27 #include "common/str-array.h"
28 #include "common/serializer.h"
29 #include "mads/nebular/core/audio.h"
30 #include "mads/nebular/core/scene.h"
31 #include "mads/nebular/core/game_data.h"
32 #include "mads/nebular/core/globals.h"
33 #include "mads/nebular/core/inventory.h"
34 #include "mads/nebular/core/player.h"
35 #include "mads/nebular/core/screen.h"
36 #include "mads/nebular/core/camera.h"
37 
38 namespace MADS {
39 namespace Nebular {
40 
41 class RexNebularEngine;
42 
43 enum KernelMode {
44  KERNEL_GAME_LOAD = 0, KERNEL_SECTION_PRELOAD = 1, KERNEL_SECTION_INIT = 2,
45  KERNEL_ROOM_PRELOAD = 3, KERNEL_ROOM_INIT = 4, KERNEL_ACTIVE_CODE = 5
46 };
47 
48 enum SyncType {
49  SYNC_SEQ = 1, SYNC_PLAYER = 2, SYNC_ANIM = 3, SYNC_CLOCK = 4
50 };
51 
52 
53 #define MADS_SAVEGAME_VERSION 1
54 
56  uint8 _version;
57  Common::String _saveName;
58  Graphics::Surface *_thumbnail;
59  int _year, _month, _day;
60  int _hour, _minute;
61  int _totalFrames;
62 };
63 
64 class Game {
65 private:
69  void gameLoop();
70 
74  void sectionLoop();
75 
79  void loadQuotes();
80 protected:
81  RexNebularEngine *_vm;
82  MSurface *_surface;
83  int _statusFlag;
84  Common::StringArray _quotes;
85  bool _quoteEmergency;
86  bool _vocabEmergency;
87  bool _anyEmergency;
88  int _lastSave;
89  Common::String _saveName;
90  Common::InSaveFile *_saveFile;
91  Graphics::Surface *_saveThumb;
92 
97 
101  void initSection(int sectionNumber);
102 
104 
109  virtual void startGame() = 0;
110 
114  virtual void initializeGlobals() = 0;
115 
119  virtual void setSectionHandler() = 0;
120 
124  virtual void checkShowDialog() = 0;
125 
127 
128 public:
129  static Game *init(RexNebularEngine *vm);
130 
131 public:
132  Player _player;
133  ScreenObjects _screenObjects;
134  int _sectionNumber;
135  int _priorSectionNumber;
136  int _currentSectionNumber;
137  InventoryObjects _objects;
138  SectionHandler *_sectionHandler;
139  VisitedScenes _visitedScenes;
140  Scene _scene;
141  KernelMode _kernelMode;
142  int _trigger;
143  ScreenTransition _fx;
144  TriggerMode _triggerMode;
145  TriggerMode _triggerSetupMode;
146  uint32 _priorFrameTimer;
147  Common::Path _aaName;
148  int _winStatus;
149  int _widepipeCtr;
150  int _loadGameSlot;
151  int _panningSpeed;
152  Camera _camX, _camY;
153 
154 public:
155  virtual ~Game();
156 
160  void run();
161 
165  uint32 getQuotesSize() {
166  return _quotes.size();
167  }
168 
172  const Common::String &getQuote(uint32 index) {
173  return _quotes[index - 1];
174  }
175 
179  void splitQuote(const Common::String &source, Common::String &line1, Common::String &line2);
180 
181  Common::StringArray getMessage(uint32 id);
182 
186  virtual Globals &globals() = 0;
187 
191  virtual void doObjectAction() = 0;
192 
196  virtual void unhandledAction() = 0;
197 
201  virtual void step() = 0;
202 
208  virtual void synchronize(Common::Serializer &s, bool phase1);
209 
210  virtual void setNaughtyMode(bool naughtyMode) {
211  }
212  virtual bool getNaughtyMode() const {
213  return true;
214  }
215 
216  // DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
217  void clearQuotes() {
218  }
219  void loadQuoteRange(int startNum, int endNum) {
220  }
221  void loadQuoteSet(...) {
222  }
223  void loadQuote(int quoteNum) {
224  }
225 
229  void handleKeypress(const Common::KeyState &kbd);
230 
234  void handleAction(const Common::CustomEventType &action);
235 
241  void loadGame(int slotNumber);
242 
246  void saveGame(int slotNumber, const Common::String &saveName);
247 
251  void writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &header);
252 
256  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header, bool skipThumbnail = true);
257 
261  void createThumbnail();
262 
263  void syncTimers(SyncType slaveType, int slaveId, SyncType masterType, int masterId);
264 
265  void camInitDefault();
266  void camSetSpeed();
267  void camUpdate();
268 };
269 
270 } // namespace Nebular
271 } // namespace MADS
272 
273 #endif
Definition: str.h:59
Definition: surface.h:67
Definition: nebular.h:51
Definition: savefile.h:54
const Common::String & getQuote(uint32 index)
Definition: game.h:172
uint32 getQuotesSize()
Definition: game.h:165
Definition: game_data.h:35
Definition: camera.h:34
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:204
Definition: screen.h:143
Definition: stream.h:745
Definition: serializer.h:80
Definition: game_data.h:58
Definition: globals.h:33
Definition: inventory.h:81
Definition: scene.h:47
bool createThumbnail(Graphics::Surface &thumb)
bool skipThumbnail(Common::SeekableReadStream &in)
size_type size() const
Definition: array.h:316
Definition: player.h:68
Definition: keyboard.h:294
Definition: mps_installer.h:31
Definition: msurface.h:188
Definition: game.h:64