ScummVM API documentation
buried.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 BURIED_BURIED_H
23#define BURIED_BURIED_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "common/list.h"
28#include "common/hashmap.h"
29#include "common/path.h"
30#include "common/str-array.h"
31
32#include "engines/engine.h"
33
34#include "backends/keymapper/keymapper.h"
35
36class OSystem;
37
39
40namespace Common {
41class SeekableReadStream;
42class Serializer;
43class WinResources;
44class WriteStream;
45}
46
47namespace Graphics {
48struct WinCursorGroup;
49}
50
51namespace Buried {
52
53enum {
54 GF_TRUECOLOR = (1 << 1),
55 GF_WIN95 = (1 << 2),
56 GF_COMPRESSED = (1 << 3),
57 GF_TRIAL = (1 << 4)
58};
59
60enum BURIEDActions {
61 kActionNone,
62 kActionQuit,
63 kActionQuitToMainMenu,
64 kActionQuitToMainMenuInv,
65 kActionSkip,
66 kActionMoveUp,
67 kActionMoveLeft,
68 kActionMoveRight,
69 kActionMoveDown,
70 kActionMoveForward,
71 kActionSave,
72 kActionLoad,
73 kActionPause,
74 kActionAIComment,
75 kActionBiochipAI,
76 kActionBiochipBlank,
77 kActionBiochipCloak,
78 kActionBiochipEvidence,
79 kActionBiochipFiles,
80 kActionBiochipInterface,
81 kActionBiochipJump,
82 kActionBiochipTranslate,
83 kActionPoints,
84 kActionControl,
85};
86
87class BuriedConsole;
88struct GlobalFlags;
89class GraphicsManager;
90struct Location;
91class Message;
92class SoundManager;
93class Window;
94class VideoWindow;
95
96class BuriedEngine : public ::Engine {
97protected:
98 Common::Error run() override;
99
100public:
101 BuriedEngine(OSystem *syst, const ADGameDescription *gamedesc);
102 virtual ~BuriedEngine();
103
104 // Detection related functions
105 const ADGameDescription *_gameDescription;
106 bool isDemo() const;
107 bool isTrial() const;
108 bool isTrueColor() const;
109 bool isWin95() const;
110 bool isCompressed() const;
111 Common::Path getEXEName() const;
112 Common::Path getLibraryName() const;
113 Common::Language getLanguage() const;
114
115 bool hasFeature(EngineFeature f) const override;
116 void pauseEngineIntern(bool pause) override;
117
118 // Resources
119 Common::String getString(uint32 stringID);
120 Common::Path getFilePath(uint32 stringID);
121 Common::Path getFilePath(int timeZone, int environment, int fileOffset);
122 Graphics::WinCursorGroup *getCursorGroup(uint32 cursorGroupID);
123 Common::SeekableReadStream *getBitmapStream(uint32 bitmapID);
124 Common::SeekableReadStream *getNavData(uint32 resourceID);
125 Common::SeekableReadStream *getSndData(uint32 resourceID);
126 Common::SeekableReadStream *getAnimData(uint32 resourceID);
127 Common::SeekableReadStream *getAIData(uint32 resourceID);
128 Common::SeekableReadStream *getItemData(uint32 resourceID);
129 Common::SeekableReadStream *getBookData(uint32 resourceID);
130 Common::SeekableReadStream *getFileBCData(uint32 resourceID);
131 Common::SeekableReadStream *getINNData(uint32 resourceID);
132 uint32 getVersion();
133 uint32 computeNavDBResourceID(int timeZone, int environment);
134 uint32 computeAnimDBResourceID(int timeZone, int environment);
135 uint32 computeAIDBResourceID(int timeZone, int environment);
136 uint32 computeFileNameResourceID(int timeZone, int environment, int fileOffset);
137
138 GraphicsManager *_gfx;
139 SoundManager *_sound;
140 Window *_mainWindow; // Only one main window is supported.
141 Window *_focusedWindow;
142 Window *_captureWindow;
143
144 // Timers
145 uint createTimer(Window *window, uint period);
146 bool killTimer(uint timer);
147 void removeAllTimers(Window *window);
148
149 // Video
150 void addVideo(VideoWindow *window);
151 void removeVideo(VideoWindow *window);
152 void updateVideos();
153
154 // Messaging
155 void postMessageToWindow(Window *dest, Message *message);
156 void sendAllMessages();
157 void processAudioVideoSkipMessages(VideoWindow *video, int soundId);
158 void removeKeyboardMessages(Window *window);
159 void removeMouseMessages(Window *window);
160 void removeActionMessages(Window *window);
161 void removeAllMessages(Window *window);
162 void removeMessages(Window *window, int messageBegin, int messageEnd);
163 bool hasMessage(Window *window, int messageBegin, int messageEnd) const;
164
165 // Miscellaneous
166 void yield(VideoWindow *video, int soundId);
167 int getTransitionSpeed();
168 void setTransitionSpeed(int newSpeed);
169 void releaseCapture() { _captureWindow = 0; }
170 bool runQuitDialog();
171 bool isControlDown() const;
172 void pauseGame();
173 void showPoints();
174 void enableCutsceneKeymap(bool enable);
175
176 // Save/Load
177 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
178 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
179 Common::String getSaveStateName(int slot) const override {
180 return Common::String::format("buried.%03d", slot);
181 }
183 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
184 void handleSaveDialog();
185 void handleRestoreDialog();
186
187private:
188 Common::WinResources *_mainEXE, *_library;
189
190 struct Timer {
191 Window *owner;
192 uint32 period;
193 uint32 nextTrigger;
194 };
195
196 typedef Common::HashMap<uint, Timer> TimerMap;
197 TimerMap _timers;
198 uint _timerSeed;
199 uint32 _pauseStartTime;
200
201 typedef Common::List<VideoWindow *> VideoList;
202 VideoList _videos;
203
204 bool _yielding;
205 bool _allowVideoSkip;
206
207 struct MessageInfo { // I did think about calling this "Envelope"
208 Window *dest;
209 Message *message;
210 };
211
212 // LordHoto didn't want me to add an iterator to Common::Queue.
213 typedef Common::List<MessageInfo> MessageQueue;
214 MessageQueue _messageQueue;
215 void pollForEvents();
216
217 // Saves
218 bool syncLocation(Common::Serializer &s, Location &location);
219 bool syncGlobalFlags(Common::Serializer &s, GlobalFlags &flags);
220 Common::Error syncSaveData(Common::Serializer &ser);
221 Common::Error syncSaveData(Common::Serializer &ser, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems);
222 void checkForOriginalSavedGames();
223 void convertSavedGame(Common::String oldFile, Common::String newFile);
224};
225
226// Macro for creating a version field
227#define MAKEVERSION(a, b, c, d) \
228 (((uint32)((a) & 0xFF) << 24) | ((uint32)((b) & 0xFF) << 16) | ((uint32)((c) & 0xFF) << 8) | ((uint32)((d) & 0xFF)))
229
230} // End of namespace Buried
231
232#endif
Definition: buried.h:96
Common::String getSaveStateName(int slot) const override
Definition: buried.h:179
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
void pauseEngineIntern(bool pause) override
Common::Error run() override
bool hasFeature(EngineFeature f) const override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: graphics.h:76
Definition: message.h:62
Definition: sound.h:40
Definition: video_window.h:37
Definition: window.h:38
Definition: error.h:81
Definition: path.h:52
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
static String format(MSVC_PRINTF const char *fmt,...) GCC_PRINTF(1
Definition: ustr.h:57
Definition: winexe.h:110
Definition: stream.h:77
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: graphics.h:38
Definition: system.h:166
Language
Definition: language.h:45
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: advancedDetector.h:164
Definition: wincursor.h:54