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 XEEN_XEEN_H 24 #define XEEN_XEEN_H 25 26 #include "common/scummsys.h" 27 #include "common/system.h" 28 #include "common/error.h" 29 #include "common/random.h" 30 #include "common/serializer.h" 31 #include "common/util.h" 32 #include "engines/engine.h" 33 #include "xeen/combat.h" 34 #include "xeen/debugger.h" 35 #include "xeen/dialogs/dialogs.h" 36 #include "xeen/events.h" 37 #include "xeen/files.h" 38 #include "xeen/interface.h" 39 #include "xeen/locations.h" 40 #include "xeen/map.h" 41 #include "xeen/party.h" 42 #include "xeen/patcher.h" 43 #include "xeen/resources.h" 44 #include "xeen/saves.h" 45 #include "xeen/screen.h" 46 #include "xeen/scripts.h" 47 #include "xeen/sound.h" 48 #include "xeen/spells.h" 49 #include "xeen/window.h" 50 51 /** 52 * This is the namespace of the Xeen engine. 53 * 54 * Status of this engine: In Development 55 * 56 * Games using this engine: 57 * - Might & Magic 4: Clouds of Xeen 58 * - Might & Magic 5: Dark Side of Xeen 59 * - Might & Magic: World of Xeen 60 * - Might & Magic: Swords of Xeen 61 */ 62 namespace Xeen { 63 64 enum { 65 GType_Clouds = 1, 66 GType_DarkSide = 2, 67 GType_WorldOfXeen = 3, 68 GType_Swords = 4 69 }; 70 71 enum XeenDebugChannels { 72 kDebugPath = 1 << 0, 73 kDebugScripts = 1 << 1, 74 kDebugGraphics = 1 << 2, 75 kDebugSound = 1 << 3 76 }; 77 78 enum Mode { 79 MODE_FF = -1, 80 MODE_STARTUP = 0, 81 MODE_INTERACTIVE = 1, 82 MODE_COMBAT = 2, 83 MODE_3 = 3, 84 MODE_4 = 4, 85 MODE_SLEEPING = 5, 86 MODE_6 = 6, 87 MODE_7 = 7, 88 MODE_8 = 8, 89 MODE_SCRIPT_IN_PROGRESS = 9, 90 MODE_CHARACTER_INFO = 10, 91 MODE_INTERACTIVE2 = 12, 92 MODE_DIALOG_123 = 13, 93 MODE_INTERACTIVE7 = 17, 94 MODE_86 = 86 95 }; 96 97 enum GameMode { 98 GMODE_NONE = 0, 99 GMODE_STARTUP = 1, 100 GMODE_MENU = 2, 101 GMODE_PLAY_GAME = 3, 102 GMODE_QUIT = 4 103 }; 104 105 struct XeenGameDescription; 106 107 #define XEEN_SAVEGAME_VERSION 1 108 109 class XeenEngine : public Engine { 110 /** 111 * Container to a set of options newly introduced under ScummVM 112 */ 113 struct ExtendedOptions { 114 bool _showItemCosts; 115 bool _durableArmor; 116 ExtendedOptionsExtendedOptions117 ExtendedOptions() : _showItemCosts(false), _durableArmor(false) {} 118 }; 119 private: 120 const XeenGameDescription *_gameDescription; 121 Common::RandomSource _randomSource; 122 private: 123 /** 124 * Initializes all the engine sub-objects 125 */ 126 bool initialize(); 127 128 /** 129 * Load settings 130 */ 131 void loadSettings(); 132 133 // Engine APIs 134 virtual Common::Error run(); 135 virtual bool hasFeature(EngineFeature f) const; 136 137 /** 138 * Outer gameplay loop responsible for dispatching control to game-specific 139 * intros, main menus, or to play the actual game 140 */ 141 void outerGameLoop(); 142 143 /** 144 * Inner game loop 145 */ 146 void gameLoop(); 147 148 /** 149 * Plays the actual game 150 */ 151 void play(); 152 protected: 153 int _loadSaveSlot; 154 protected: 155 /** 156 * Show the starting sequence/intro 157 */ 158 virtual void showStartup() = 0; 159 160 /** 161 * Show the startup menu 162 */ 163 virtual void showMainMenu() = 0; 164 165 /** 166 * Play the game 167 */ 168 virtual void playGame(); 169 170 /** 171 * Death cutscene 172 */ 173 virtual void death() = 0; 174 public: 175 Combat *_combat; 176 Debugger *_debugger; 177 EventsManager *_events; 178 FileManager *_files; 179 Interface *_interface; 180 LocationManager *_locations; 181 Map *_map; 182 Party *_party; 183 Patcher *_patcher; 184 Resources *_resources; 185 SavesManager *_saves; 186 Screen *_screen; 187 Scripts *_scripts; 188 Sound *_sound; 189 Spells *_spells; 190 Windows *_windows; 191 Mode _mode; 192 GameMode _gameMode; 193 bool _noDirectionSense; 194 bool _startupWindowActive; 195 uint _endingScore; 196 bool _gameWon[3]; 197 uint _finalScore; 198 ExtendedOptions _extOptions; 199 public: 200 XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc); 201 virtual ~XeenEngine(); 202 203 /** 204 * Returns the features 205 */ 206 uint32 getFeatures() const; 207 208 /** 209 * Returns the game language 210 */ 211 Common::Language getLanguage() const; 212 213 /** 214 * Returns the game's platform 215 */ 216 Common::Platform getPlatform() const; 217 218 /** 219 * Gets the game Id 220 */ 221 uint32 getGameID() const; 222 223 /** 224 * Returns the game Id, but with a reuslt of Clouds or Dark Side for World of Xeen, 225 * depending on which side the player is currently on 226 */ 227 uint32 getSpecificGameId() const; 228 229 /** 230 * Returns the game features 231 */ 232 uint32 getGameFeatures() const; 233 234 /** 235 * Returns true if the game is the CD version 236 */ 237 bool getIsCD() const; 238 239 /** 240 * Returns a random number 241 */ 242 int getRandomNumber(int maxNumber); 243 244 /** 245 * Returns a random number 246 */ 247 int getRandomNumber(int minNumber, int maxNumber); 248 249 /** 250 * Returns true if the game should be exited (either quitting, exiting to the main menu, or loading a savegame) 251 */ shouldExit()252 bool shouldExit() const { return _gameMode != GMODE_NONE || isLoadPending() || shouldQuit(); } 253 254 /** 255 * Returns true if a savegame load is pending 256 */ isLoadPending()257 bool isLoadPending() const { return _loadSaveSlot != -1; } 258 259 /** 260 * Load a savegame 261 */ 262 virtual Common::Error loadGameState(int slot); 263 264 /** 265 * Save the game 266 */ 267 virtual Common::Error saveGameState(int slot, const Common::String &desc); 268 269 /** 270 * Updates sound settings 271 */ 272 virtual void syncSoundSettings(); 273 274 /** 275 * Returns true if a savegame can currently be loaded 276 */ 277 virtual bool canLoadGameStateCurrently(); 278 279 /** 280 * Returns true if the game can currently be saved 281 */ 282 virtual bool canSaveGameStateCurrently(); 283 284 /** 285 * Show a cutscene 286 * @param name Name of cutscene 287 * @param status For World of Xeen, Goober status 288 * @param score Final score 289 */ showCutscene(const Common::String & name,int status,uint score)290 virtual void showCutscene(const Common::String &name, int status, uint score) {} 291 292 /** 293 * Dream sequence 294 */ 295 virtual void dream() = 0; 296 297 static Common::String printMil(uint value); 298 299 static Common::String printK(uint value); 300 301 static Common::String printK2(uint value); 302 303 /** 304 * Saves engine settings 305 */ 306 void saveSettings(); 307 308 /** 309 * Show an error message in a GUI dialog 310 */ 311 void GUIError(const Common::String &msg); 312 313 /** 314 * Checks if an auto save should be done, and if so, takes care of it 315 */ 316 void autoSaveCheck(int &lastSaveTime); 317 }; 318 319 extern XeenEngine *g_vm; 320 321 } // End of namespace Xeen 322 323 #endif /* XEEN_XEEN_H */ 324