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/audio.h"
30 #include "mads/scene.h"
31 #include "mads/game_data.h"
32 #include "mads/globals.h"
33 #include "mads/inventory.h"
34 #include "mads/player.h"
35 #include "mads/screen.h"
36 #include "mads/camera.h"
37 
38 namespace MADS {
39 
40 class MADSEngine;
41 
42 enum KernelMode {
43  KERNEL_GAME_LOAD = 0, KERNEL_SECTION_PRELOAD = 1, KERNEL_SECTION_INIT = 2,
44  KERNEL_ROOM_PRELOAD = 3, KERNEL_ROOM_INIT = 4, KERNEL_ACTIVE_CODE = 5
45 };
46 
47 enum SyncType {
48  SYNC_SEQ = 1, SYNC_PLAYER = 2, SYNC_ANIM = 3, SYNC_CLOCK = 4
49 };
50 
51 
52 #define MADS_SAVEGAME_VERSION 1
53 
55  uint8 _version;
56  Common::String _saveName;
57  Graphics::Surface *_thumbnail;
58  int _year, _month, _day;
59  int _hour, _minute;
60  int _totalFrames;
61 };
62 
63 class Game {
64 private:
68  void gameLoop();
69 
73  void sectionLoop();
74 
78  void loadQuotes();
79 protected:
80  MADSEngine *_vm;
81  MSurface *_surface;
82  int _statusFlag;
83  Common::StringArray _quotes;
84  bool _quoteEmergency;
85  bool _vocabEmergency;
86  bool _anyEmergency;
87  int _lastSave;
88  Common::String _saveName;
89  Common::InSaveFile *_saveFile;
90  Graphics::Surface *_saveThumb;
91 
95  Game(MADSEngine *vm);
96 
100  void initSection(int sectionNumber);
101 
103 
108  virtual void startGame() = 0;
109 
113  virtual void initializeGlobals() = 0;
114 
118  virtual void setSectionHandler() = 0;
119 
123  virtual void checkShowDialog() = 0;
124 
126 
127 public:
128  static Game *init(MADSEngine *vm);
129 
130 public:
131  Player _player;
132  ScreenObjects _screenObjects;
133  int _sectionNumber;
134  int _priorSectionNumber;
135  int _currentSectionNumber;
136  InventoryObjects _objects;
137  SectionHandler *_sectionHandler;
138  VisitedScenes _visitedScenes;
139  Scene _scene;
140  KernelMode _kernelMode;
141  int _trigger;
142  ScreenTransition _fx;
143  TriggerMode _triggerMode;
144  TriggerMode _triggerSetupMode;
145  uint32 _priorFrameTimer;
146  Common::Path _aaName;
147  int _winStatus;
148  int _widepipeCtr;
149  int _loadGameSlot;
150  int _panningSpeed;
151  Camera _camX, _camY;
152 
153 public:
154  virtual ~Game();
155 
159  void run();
160 
164  uint32 getQuotesSize() { return _quotes.size(); }
165 
169  const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
170 
174  void splitQuote(const Common::String &source, Common::String &line1, Common::String &line2);
175 
176  Common::StringArray getMessage(uint32 id);
177 
181  virtual Globals &globals() = 0;
182 
186  virtual void doObjectAction() = 0;
187 
191  virtual void unhandledAction() = 0;
192 
196  virtual void step() = 0;
197 
203  virtual void synchronize(Common::Serializer &s, bool phase1);
204 
205  virtual void setNaughtyMode(bool naughtyMode) {}
206  virtual bool getNaughtyMode() const { return true; }
207 
208  // DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
209  void clearQuotes() {}
210  void loadQuoteRange(int startNum, int endNum) {}
211  void loadQuoteSet(...) {}
212  void loadQuote(int quoteNum) {}
213 
217  void handleKeypress(const Common::KeyState &kbd);
218 
222  void handleAction(const Common::CustomEventType &action);
223 
229  void loadGame(int slotNumber);
230 
234  void saveGame(int slotNumber, const Common::String &saveName);
235 
239  void writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &header);
240 
244  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header, bool skipThumbnail = true);
245 
249  void createThumbnail();
250 
251  void syncTimers(SyncType slaveType, int slaveId, SyncType masterType, int masterId);
252 
253  void camInitDefault();
254  void camSetSpeed();
255  void camUpdate();
256 };
257 
258 } // End of namespace MADS
259 
260 #endif /* MADS_GAME_H */
Definition: screen.h:141
Definition: str.h:59
Definition: surface.h:67
Definition: savefile.h:54
uint32 getQuotesSize()
Definition: game.h:164
Definition: game_data.h:57
Definition: camera.h:33
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:193
Definition: stream.h:745
const Common::String & getQuote(uint32 index)
Definition: game.h:169
Definition: inventory.h:79
Definition: serializer.h:79
Definition: game_data.h:34
Definition: game.h:54
Definition: globals.h:32
bool createThumbnail(Graphics::Surface &thumb)
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: scene.h:44
size_type size() const
Definition: array.h:315
Definition: mads.h:87
Definition: keyboard.h:294
Definition: game.h:63
Definition: action.h:28
Definition: msurface.h:172
Definition: player.h:64