ScummVM API documentation
riven.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 MOHAWK_RIVEN_H
23 #define MOHAWK_RIVEN_H
24 
25 #include "mohawk/installer_archive.h"
26 #include "mohawk/mohawk.h"
27 
28 #include "common/hashmap.h"
29 #include "common/hash-str.h"
30 #include "common/random.h"
31 #include "common/rect.h"
32 
33 #include "graphics/surface.h"
34 
35 namespace Common {
36 class Keymap;
37 }
38 
39 namespace GUI {
40 class GuiObject;
41 class OptionsContainerWidget;
42 }
43 
44 namespace Mohawk {
45 
46 struct MohawkGameDescription;
47 class MohawkArchive;
48 class RivenGraphics;
49 class RivenConsole;
50 struct RivenLanguage;
51 class RivenSaveLoad;
52 class RivenOptionsWidget;
53 class RivenStack;
54 class RivenCard;
55 class RivenHotspot;
56 class RivenScriptManager;
57 class RivenSoundManager;
58 class RivenInventory;
59 class RivenVideoManager;
60 
61 // Riven Stack Types
62 enum {
63  kStackUnknown = 0, // Default value for ReturnStackID
64  kStackOspit = 1, // 233rd Age (Gehn's Office)
65  kStackPspit = 2, // Prison Island
66  kStackRspit = 3, // Temple Island
67  kStackTspit = 4, // Rebel Age (Tay)
68  kStackBspit = 5, // Book-Making Island
69  kStackGspit = 6, // Garden Island
70  kStackJspit = 7, // Jungle Island
71  kStackAspit = 8, // Main Menu, Books, Setup
72 
73  kStackFirst = kStackOspit,
74  kStackLast = kStackAspit
75 };
76 
77 // Engine Debug Flags
78 enum {
79  kRivenDebugScript = (1 << 0),
80  kRivenDebugPatches = (1 << 1)
81 };
82 
83 struct ZipMode {
84  Common::String name;
85  uint16 id;
86  bool operator== (const ZipMode& z) const;
87 };
88 
90 
92 protected:
93  Common::Error run() override;
94 
95 public:
96  MohawkEngine_Riven(OSystem *syst, const MohawkGameDescription *gamedesc);
97  ~MohawkEngine_Riven() override;
98 
99  RivenVideoManager *_video;
100  RivenSoundManager *_sound;
101  RivenGraphics *_gfx;
102  Common::RandomSource *_rnd;
103  RivenScriptManager *_scriptMan;
104  RivenInventory *_inventory;
105 
106  // Display debug rectangles around the hotspots
107  bool _showHotspots;
108 
109  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
110  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
111  Common::Error loadGameState(int slot) override;
112  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
113  Common::String getSaveStateName(int slot) const override {
114  return Common::String::format("riven-%03d.rvn", slot);
115  }
116 
117  static const RivenLanguage *getLanguageDesc(Common::Language language);
118  Common::Language getLanguage() const override;
119 
120  bool hasFeature(EngineFeature f) const override;
121 
122  void applyGameSettings() override;
123  static Common::Array<Common::Keymap *> initKeymaps(const char *target);
124 
125  bool isInteractive() const;
126  void doFrame();
127  void processInput();
128 
129 private:
130  // Datafiles
131  MohawkArchive *_extrasFile; // We need a separate handle for the extra data
132  const char **listExpectedDatafiles() const;
133  void loadLanguageDatafile(char prefix, uint16 stackId);
134  bool checkDatafiles();
135 
136  RivenSaveLoad *_saveLoad;
137  InstallerArchive _installerArchive;
138 
139  // Stack/Card-related functions and variables
140  RivenCard *_card;
141  RivenStack *_stack;
142 
143  int _menuSavedCard;
144  int _menuSavedStack;
146 
147  bool _gameEnded;
148  uint32 _lastSaveTime;
149  Common::Language _currentLanguage;
150 
151  // Variables
152  void initVars();
153 
154  void pauseEngineIntern(bool) override;
155 
156 public:
157  // Stack/card/script funtions
158  RivenStack *constructStackById(uint16 id);
159  void changeToCard(uint16 dest);
160  void changeToStack(uint16 stackId);
161  void reloadCurrentCard();
162  RivenCard *getCard() const { return _card; }
163  RivenStack *getStack() const { return _stack; }
164 
165  // Hotspot functions/variables
166  Common::Array<ZipMode> _zipModeData;
167  void addZipVisitedCard(uint16 cardId, uint16 cardNameId);
168  bool isZipVisitedCard(const Common::String &hotspotName) const;
169 
170  // Variables
171  RivenVariableMap _vars;
172  uint32 &getStackVar(uint32 index);
173 
174  // Miscellaneous
175  Common::Array<uint16> getResourceIDList(uint32 type) const;
176  Common::SeekableReadStream *getExtrasResource(uint32 tag, uint16 id);
177  bool _activatedPLST;
178  bool _activatedSLST;
179  void delay(uint32 ms);
180  void runOptionsDialog();
181 
182  // Save / Load
183  bool canSaveAutosaveCurrently() override;
184 
188  bool hasGameEnded() const;
189 
193  void setGameEnded();
194 
195  // Main menu handling
196  void goToMainMenu();
197  void resumeFromMainMenu();
198  bool isInMainMenu() const;
199  bool isGameStarted() const;
200  void startNewGame();
201 };
202 
203 } // End of namespace Mohawk
204 
205 #endif
Definition: str.h:59
EngineFeature
Definition: engine.h:253
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: error.h:84
Definition: riven_saveload.h:59
Definition: array.h:52
Definition: random.h:44
Definition: stream.h:745
Definition: system.h:46
Definition: riven.h:91
Definition: riven_graphics.h:61
Definition: installer_archive.h:35
Definition: riven_metaengine.h:30
Definition: riven_stack.h:89
Definition: ustr.h:57
Definition: riven_scripts.h:164
Definition: riven_sound.h:65
Definition: algorithm.h:29
Common::String getSaveStateName(int slot) const override
Definition: riven.h:113
Definition: riven_video.h:130
Definition: mohawk.h:54
Definition: riven_inventory.h:36
Definition: riven.h:83
Definition: riven_card.h:44
Definition: system.h:161
Definition: resource.h:171
Definition: bitmap.h:32
Definition: detection.h:65
Language
Definition: language.h:45