ScummVM API documentation
xeen.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 XEEN_XEEN_H
23 #define XEEN_XEEN_H
24 
25 #include "common/scummsys.h"
26 #include "common/system.h"
27 #include "common/error.h"
28 #include "common/random.h"
29 #include "common/serializer.h"
30 #include "common/util.h"
31 #include "engines/engine.h"
32 #include "mm/xeen/combat.h"
33 #include "mm/xeen/debugger.h"
34 #include "mm/xeen/dialogs/dialogs.h"
35 #include "mm/xeen/events.h"
36 #include "mm/xeen/files.h"
37 #include "mm/xeen/interface.h"
38 #include "mm/xeen/locations.h"
39 #include "mm/xeen/map.h"
40 #include "mm/xeen/party.h"
41 #include "mm/xeen/patcher.h"
42 #include "mm/xeen/resources.h"
43 #include "mm/xeen/saves.h"
44 #include "mm/xeen/screen.h"
45 #include "mm/xeen/scripts.h"
46 #include "mm/xeen/sound.h"
47 #include "mm/xeen/spells.h"
48 #include "mm/xeen/window.h"
49 #include "mm/detection.h"
50 #include "mm/mm.h"
51 
61 namespace MM {
62 namespace Xeen {
63 
64 enum Mode {
65  MODE_FF = -1,
66  MODE_STARTUP = 0,
67  MODE_INTERACTIVE = 1,
68  MODE_COMBAT = 2,
69  MODE_3 = 3,
70  MODE_4 = 4,
71  MODE_SLEEPING = 5,
72  MODE_6 = 6,
73  MODE_7 = 7,
74  MODE_8 = 8,
75  MODE_SCRIPT_IN_PROGRESS = 9,
76  MODE_CHARACTER_INFO = 10,
77  MODE_INTERACTIVE2 = 12,
78  MODE_DIALOG_123 = 13,
79  MODE_INTERACTIVE7 = 17,
80  MODE_86 = 86
81 };
82 
83 enum GameMode {
84  GMODE_NONE = 0,
85  GMODE_STARTUP = 1,
86  GMODE_MENU = 2,
87  GMODE_PLAY_GAME = 3,
88  GMODE_QUIT = 4
89 };
90 
91 #define XEEN_SAVEGAME_VERSION 2
92 
93 class XeenEngine : public MMEngine {
97  struct ExtendedOptions {
98  bool _showItemCosts;
99  bool _durableArmor;
100  bool _showHpSpBars;
101 
102  ExtendedOptions() :
103  _showItemCosts(false),
104  _durableArmor(false),
105  _showHpSpBars(false)
106  {}
107  };
108 private:
112  bool initialize();
113 
117  void loadSettings();
118 
119  // Engine APIs
120  Common::Error run() override;
121 
126  void outerGameLoop();
127 
131  void gameLoop();
132 
136  void play();
137 protected:
138  int _loadSaveSlot;
139 protected:
143  virtual void showStartup() = 0;
144 
148  virtual void showMainMenu() = 0;
149 
153  virtual void playGame();
154 
158  virtual void death() = 0;
159 public:
160  Combat *_combat;
161  Debugger *_debugger;
162  EventsManager *_events;
163  FileManager *_files;
164  Interface *_interface;
165  LocationManager *_locations;
166  Map *_map;
167  Party *_party;
168  Patcher *_patcher;
169  Resources *_resources;
170  SavesManager *_saves;
171  Screen *_screen;
172  Scripts *_scripts;
173  Sound *_sound;
174  Spells *_spells;
175  Windows *_windows;
176  Mode _mode;
177  GameMode _gameMode;
178  bool _noDirectionSense;
179  bool _startupWindowActive;
180  uint _endingScore;
181  bool _gameWon[3];
182  uint _finalScore;
183  ExtendedOptions _extOptions;
184 
185  CCArchive *_xeenCc = nullptr, *_darkCc = nullptr,
186  *_introCc = nullptr;
187  SaveArchive *_xeenSave = nullptr, *_darkSave = nullptr;
188  BaseCCArchive *_currentArchive = nullptr;
189  SaveArchive *_currentSave = nullptr;
190 public:
191  XeenEngine(OSystem *syst, const MM::MightAndMagicGameDescription *gameDesc);
192  ~XeenEngine() override;
193 
198  uint32 getSpecificGameId() const;
199 
203  uint32 getGameFeatures() const;
204 
208  int getRandomNumber(int maxNumber);
209 
213  int getRandomNumber(int minNumber, int maxNumber);
214 
218  bool shouldExit() const {
219  return _gameMode != GMODE_NONE || isLoadPending() || shouldQuit();
220  }
221 
225  bool isLoadPending() const {
226  return _loadSaveSlot != -1;
227  }
228 
232  Common::Error loadGameState(int slot) override;
233 
237  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
238 
242  void syncSoundSettings() override;
243 
247  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
248 
252  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
253 
257  bool canSaveAutosaveCurrently() override;
258 
265  virtual void showCutscene(const Common::String &name, int status, uint score) {
266  }
267 
271  virtual void dream() = 0;
272 
273  static Common::String printMil(uint value);
274 
275  static Common::String printK(uint value);
276 
277  static Common::String printK2(uint value);
278 
282  void saveSettings();
283 
287  void GUIError(const Common::U32String &msg);
288 };
289 
290 extern XeenEngine *g_vm;
291 
292 } // End of namespace Xeen
293 } // End of namespace MM
294 
295 #endif
bool shouldExit() const
Definition: xeen.h:218
Definition: str.h:59
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
bool isLoadPending() const
Definition: xeen.h:225
Definition: error.h:84
uint32 getGameFeatures() const
Definition: party.h:159
Definition: screen.h:40
Definition: combat.h:114
Definition: mm.h:37
Definition: scripts.h:213
virtual void playGame()
Definition: files.h:150
Definition: xeen.h:93
Definition: interface.h:97
Definition: debugger.h:33
Definition: patcher.h:28
virtual void showStartup()=0
Definition: ustr.h:57
static bool shouldQuit()
int getRandomNumber(int maxNumber)
void GUIError(const Common::U32String &msg)
Definition: saves.h:48
Definition: detection.h:27
Definition: cc_archive.h:51
virtual void showMainMenu()=0
virtual void death()=0
Definition: detection.h:43
virtual void dream()=0
virtual void showCutscene(const Common::String &name, int status, uint score)
Definition: xeen.h:265
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
void syncSoundSettings() override
Common::Error loadGameState(int slot) override
Definition: files.h:67
Definition: resources.h:40
Definition: system.h:161
Definition: cc_archive.h:94
Definition: sound.h:35
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: spells.h:62
Definition: map.h:422
bool canSaveAutosaveCurrently() override
Definition: locations.h:381
uint32 getSpecificGameId() const
Definition: window.h:53
Definition: events.h:60