ScummVM API documentation
toltecs.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 TOLTECS_TOLTECS_H
23 #define TOLTECS_TOLTECS_H
24 
25 #include "common/scummsys.h"
26 #include "common/endian.h"
27 #include "common/events.h"
28 #include "common/file.h"
29 #include "common/keyboard.h"
30 #include "common/random.h"
31 #include "common/textconsole.h"
32 
33 #include "engines/engine.h"
34 
35 #include "graphics/surface.h"
36 
37 #include "gui/debugger.h"
38 
39 #include "toltecs/console.h"
40 
41 namespace Toltecs {
42 
43 struct ToltecsGameDescription;
44 
45 class AnimationPlayer;
46 class ArchiveReader;
47 class Input;
48 class MenuSystem;
49 class MoviePlayer;
50 class Music;
51 class Palette;
52 class ResourceCache;
53 class ScriptInterpreter;
54 class Screen;
55 class SegmentMap;
56 class Sound;
57 
58 enum SysString {
59  kStrLoadingPleaseWait,
60  kStrWhatCanIDoForYou,
61  kStrLoad,
62  kStrSave,
63  kStrTextOn,
64  kStrTextOff,
65  kStrVoicesOn,
66  kStrVoicesOff,
67  kStrVolume,
68  kStrPlay,
69  kStrQuit,
70  kStrLoadGame,
71  kStrSaveGame,
72  kStrAdjustVolume,
73  kStrMaster,
74  kStrVoices,
75  kStrMusic,
76  kStrSoundFx,
77  kStrBackground,
78  kStrCancel,
79  kStrDone,
80  kStrAreYouSure,
81  kStrYes,
82  kStrNo,
83  kSysStrCount
84 };
85 
86 enum MenuID {
87  kMenuIdNone,
88  kMenuIdMain,
89  kMenuIdSave,
90  kMenuIdLoad,
91  kMenuIdVolumes
92 };
93 
94 class ToltecsEngine : public ::Engine {
95  Common::KeyState _keyPressed;
96 
97 protected:
98  Common::Error run() override;
99 // void shutdown();
100 
101 public:
102  ToltecsEngine(OSystem *syst, const ToltecsGameDescription *gameDesc);
103  ~ToltecsEngine() override;
104 
105  bool hasFeature(EngineFeature f) const override;
106 
107  Common::RandomSource *_rnd;
108  const ToltecsGameDescription *_gameDescription;
109  uint32 getFeatures() const;
110  Common::Language getLanguage() const;
111  const Common::String& getTargetName() const { return _targetName; }
112  void syncSoundSettings() override;
113 
114  void setupSysStrings();
115  void requestSavegame(int slotNum, Common::String &description);
116  void requestLoadgame(int slotNum);
117 
118  void loadScene(uint resIndex);
119 
120  void updateScreen();
121  void drawScreen();
122  void updateInput();
123 
124  void setGuiHeight(int16 guiHeight);
125 
126  void setCamera(int16 x, int16 y);
127  bool getCameraChanged();
128  void scrollCameraUp(int16 delta);
129  void scrollCameraDown(int16 delta);
130  void scrollCameraLeft(int16 delta);
131  void scrollCameraRight(int16 delta);
132  void updateCamera();
133 
134  void showMenu(MenuID menuId);
135 
136  void talk(int16 slotIndex, int16 slotOffset);
137 
138  void walk(byte *walkData);
139 
140  int16 findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize,
141  byte *rectDataEnd);
142 
143  int _cfgVoicesVolume, _cfgMusicVolume, _cfgSoundFXVolume;
144  bool _cfgText, _cfgVoices;
145 public:
146 
147  AnimationPlayer *_anim;
148  ArchiveReader *_arc;
149  Input *_input;
150  MenuSystem *_menuSystem;
151  MoviePlayer *_moviePlayer;
152  Music *_music;
153  Palette *_palette;
154  ResourceCache *_res;
155  ScriptInterpreter *_script;
156  Screen *_screen;
157  SegmentMap *_segmap;
158  Sound *_sound;
159 
160  Common::String _sysStrings[kSysStrCount];
161 
162  int _saveLoadRequested;
163  int _saveLoadSlot;
164  Common::String _saveLoadDescription;
165 
166  uint _sceneResIndex;
167  int16 _sceneWidth, _sceneHeight;
168 
169  int _counter01, _counter02;
170  bool _movieSceneFlag;
171  byte _flag01;
172 
173  int16 _cameraX, _cameraY;
174  int16 _newCameraX, _newCameraY;
175  int16 _cameraHeight;
176  int16 _guiHeight;
177 
178  bool _doSpeech, _doText;
179 
180  int16 _walkSpeedY, _walkSpeedX;
181 
182  Common::KeyState _keyState;
183  int16 _mouseX, _mouseY;
184  int16 _mouseDblClickTicks;
185  bool _mouseWaitForRelease;
186  byte _mouseButton;
187  int16 _mouseDisabled;
188  bool _leftButtonDown, _rightButtonDown;
189 
190  const char *getSysString(int index) const { return _sysStrings[index].c_str(); }
191 
192  /* Save/load */
193 
194  enum kReadSaveHeaderError {
195  kRSHENoError = 0,
196  kRSHEInvalidType = 1,
197  kRSHEInvalidVersion = 2,
198  kRSHEIoError = 3
199  };
200 
201  struct SaveHeader {
202  Common::String description;
203  uint32 version;
204  byte gameID;
205  uint32 flags;
206  uint32 saveDate;
207  uint32 saveTime;
208  uint32 playTime;
209  Graphics::Surface *thumbnail;
210  };
211 
212  bool _isSaveAllowed;
213 
214  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
215  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
216  Common::Error loadGameState(int slot) override;
217  Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
218  void savegame(const char *filename, const char *description);
219  void loadgame(const char *filename);
220 
221  const char *getSavegameFilename(int num);
222  static Common::String getSavegameFilename(const Common::String &target, int num);
223 
224  WARN_UNUSED_RESULT static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
225 
226 };
227 
228 } // End of namespace Toltecs
229 
230 #endif /* TOLTECS_TOLTECS_H */
Definition: animation.h:28
Definition: toltecs.h:201
Definition: str.h:59
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
Definition: sound.h:50
Definition: error.h:84
Definition: palette.h:35
Definition: segmap.h:46
Definition: random.h:44
Definition: menu.h:72
void syncSoundSettings() override
Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave=false) override
Definition: resource.h:37
Definition: atari-screen.h:60
Definition: stream.h:745
Definition: resource.h:63
Definition: music.h:52
Definition: ustr.h:57
Common::Error loadGameState(int slot) override
bool hasFeature(EngineFeature f) const override
Definition: toltecs.h:94
bool skipThumbnail(Common::SeekableReadStream &in)
const Common::String _targetName
Definition: engine.h:181
Common::Error run() override
Definition: animation.h:30
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: toltecs.h:215
Definition: keyboard.h:294
Definition: screen.h:150
Definition: system.h:161
Definition: script.h:39
Definition: engine.h:144
Definition: detection.h:27
Definition: movie.h:33
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: toltecs.h:214
Language
Definition: language.h:45
Definition: atari-screen.h:44