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