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(); 100 // void shutdown(); 101 102 public: 103 ToltecsEngine(OSystem *syst, const ToltecsGameDescription *gameDesc); 104 virtual ~ToltecsEngine(); 105 106 virtual bool hasFeature(EngineFeature f) const; 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(); 114 getDebugger()115 GUI::Debugger *getDebugger() { return _console; } 116 117 void setupSysStrings(); 118 void requestSavegame(int slotNum, Common::String &description); 119 void requestLoadgame(int slotNum); 120 121 void loadScene(uint resIndex); 122 123 void updateScreen(); 124 void drawScreen(); 125 void updateInput(); 126 127 void setGuiHeight(int16 guiHeight); 128 129 void setCamera(int16 x, int16 y); 130 bool getCameraChanged(); 131 void scrollCameraUp(int16 delta); 132 void scrollCameraDown(int16 delta); 133 void scrollCameraLeft(int16 delta); 134 void scrollCameraRight(int16 delta); 135 void updateCamera(); 136 137 void showMenu(MenuID menuId); 138 139 void talk(int16 slotIndex, int16 slotOffset); 140 141 void walk(byte *walkData); 142 143 int16 findRectAtPoint(byte *rectData, int16 x, int16 y, int16 index, int16 itemSize, 144 byte *rectDataEnd); 145 146 int _cfgVoicesVolume, _cfgMusicVolume, _cfgSoundFXVolume; 147 bool _cfgText, _cfgVoices; 148 public: 149 150 AnimationPlayer *_anim; 151 ArchiveReader *_arc; 152 Console *_console; 153 Input *_input; 154 MenuSystem *_menuSystem; 155 MoviePlayer *_moviePlayer; 156 Music *_music; 157 Palette *_palette; 158 ResourceCache *_res; 159 ScriptInterpreter *_script; 160 Screen *_screen; 161 SegmentMap *_segmap; 162 Sound *_sound; 163 164 Common::String _sysStrings[kSysStrCount]; 165 166 int _saveLoadRequested; 167 int _saveLoadSlot; 168 Common::String _saveLoadDescription; 169 170 uint _sceneResIndex; 171 int16 _sceneWidth, _sceneHeight; 172 173 int _counter01, _counter02; 174 bool _movieSceneFlag; 175 byte _flag01; 176 177 int16 _cameraX, _cameraY; 178 int16 _newCameraX, _newCameraY; 179 int16 _cameraHeight; 180 int16 _guiHeight; 181 182 bool _doSpeech, _doText; 183 184 int16 _walkSpeedY, _walkSpeedX; 185 186 Common::KeyState _keyState; 187 int16 _mouseX, _mouseY; 188 int16 _mouseDblClickTicks; 189 bool _mouseWaitForRelease; 190 byte _mouseButton; 191 int16 _mouseDisabled; 192 bool _leftButtonDown, _rightButtonDown; 193 getSysString(int index)194 const char *getSysString(int index) const { return _sysStrings[index].c_str(); } 195 196 /* Save/load */ 197 198 enum kReadSaveHeaderError { 199 kRSHENoError = 0, 200 kRSHEInvalidType = 1, 201 kRSHEInvalidVersion = 2, 202 kRSHEIoError = 3 203 }; 204 205 struct SaveHeader { 206 Common::String description; 207 uint32 version; 208 byte gameID; 209 uint32 flags; 210 uint32 saveDate; 211 uint32 saveTime; 212 uint32 playTime; 213 Graphics::Surface *thumbnail; 214 }; 215 216 bool _isSaveAllowed; 217 canLoadGameStateCurrently()218 bool canLoadGameStateCurrently() { return _isSaveAllowed; } canSaveGameStateCurrently()219 bool canSaveGameStateCurrently() { return _isSaveAllowed; } 220 Common::Error loadGameState(int slot); 221 Common::Error saveGameState(int slot, const Common::String &description); 222 void savegame(const char *filename, const char *description); 223 void loadgame(const char *filename); 224 225 const char *getSavegameFilename(int num); 226 static Common::String getSavegameFilename(const Common::String &target, int num); 227 228 WARN_UNUSED_RESULT static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true); 229 230 }; 231 232 } // End of namespace Toltecs 233 234 #endif /* TOLTECS_TOLTECS_H */ 235