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