ScummVM API documentation
cryomni3d.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 CRYOMNI3D_CRYOMNI3D_H
23 #define CRYOMNI3D_CRYOMNI3D_H
24 
25 #include "audio/mixer.h"
26 
27 #include "common/array.h"
28 #include "common/keyboard.h"
29 #include "common/queue.h"
30 #include "common/rect.h"
31 #include "common/scummsys.h"
32 
33 #include "engines/engine.h"
34 
35 #include "graphics/cursorman.h"
36 
37 #include "cryomni3d/font_manager.h"
38 #include "cryomni3d/objects.h"
39 #include "cryomni3d/sprites.h"
40 #include "cryomni3d/detection.h"
41 
42 class OSystem;
43 
44 namespace Common {
45 struct Point;
46 class SeekableReadStream;
47 }
48 
49 namespace Image {
50 class ImageDecoder;
51 }
52 
62 namespace CryOmni3D {
63 
64 class DATSeekableStream;
65 
66 // Engine Debug Flags
67 enum {
68  kDebugFile = (1 << 0),
69  kDebugVariable = (1 << 1),
70  kDebugSaveLoad = (1 << 2)
71 };
72 
73 enum DragStatus {
74  kDragStatus_NoDrag = 0,
75  kDragStatus_Pressed,
76  kDragStatus_Finished,
77  kDragStatus_Dragging
78 };
79 
80 class CryOmni3DEngine : public ::Engine {
81 protected:
82  Common::Error run() override;
83 
84 public:
85  CryOmni3DEngine(OSystem *syst, const CryOmni3DGameDescription *gamedesc);
86  ~CryOmni3DEngine() override;
87 
88  // Detection related functions
89  const CryOmni3DGameDescription *_gameDescription;
90  const char *getGameId() const;
91  uint32 getFeatures() const;
92  uint16 getVersion() const;
93  Common::Platform getPlatform() const;
94  uint8 getGameType() const;
95  Common::Language getLanguage() const;
96 
97  bool hasFeature(EngineFeature f) const override;
98  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return _canLoadSave; }
99  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _canLoadSave; }
100 
101  void setCanLoadSave(bool canLoadSave) { _canLoadSave = canLoadSave; }
102  static const uint kSaveDescriptionLen = 20;
103 private:
104  void pauseEngineIntern(bool) override;
105 
106 public:
107  Image::ImageDecoder *loadHLZ(const Common::Path &filepath);
108 
109  void fillSurface(byte color);
110  /* We use CursorMan because it avoids problems with cursors in GMM */
111  void setCursor(const Graphics::Cursor &cursor) const;
112  void setCursor(uint cursorId) const;
113  bool showMouse(bool visible) { return CursorMan.showMouse(visible); }
114  typedef void (CryOmni3DEngine::*HNMCallback)(uint frameNum);
115  void playHNM(const Common::Path &filepath,
117  HNMCallback beforeDraw = nullptr, HNMCallback afterDraw = nullptr);
118  bool displayHLZ(const Common::Path &filepath, uint32 timeout = uint(-1));
119 
120  bool pollEvents();
121  Common::Point getMousePos();
122  void setMousePos(const Common::Point &point);
123  uint getCurrentMouseButton() { return _lastMouseButton; }
124  Common::KeyState getNextKey();
125  bool checkKeysPressed();
126  bool checkKeysPressed(uint numKeys, ...);
127  void clearKeys() { _keysPressed.clear(); }
128  void waitMouseRelease();
129  void setAutoRepeatClick(uint millis);
130  DragStatus getDragStatus() { return _dragStatus; }
131 
132  virtual bool displayToolbar(const Graphics::Surface *original) = 0;
133  virtual bool hasPlaceDocumentation() = 0;
134  virtual bool displayPlaceDocumentation() = 0;
135  virtual uint displayOptions() = 0;
136  virtual bool shouldAbort() { return g_engine->shouldQuit(); }
137 
138  virtual void makeTranslucent(Graphics::Surface &dst, const Graphics::Surface &src) const = 0;
139  virtual void setupPalette(const byte *colors, uint start, uint num) = 0;
140 
141 protected:
142  DATSeekableStream *getStaticData(uint32 gameId, uint16 version) const;
143 
144  void copySubPalette(byte *dst, const byte *src, uint start, uint num);
145  void setPalette(const byte *colors, uint start, uint num);
146  void lockPalette(uint startRW, uint endRW) { _lockPaletteStartRW = startRW; _lockPaletteEndRW = endRW; }
147  void unlockPalette() { _lockPaletteStartRW = 0; _lockPaletteEndRW = 255; }
148  void fadeOutPalette();
149  void fadeInPalette(const byte *colors);
150  void setBlackPalette();
151 
152  void setHNMClipping(const Common::Rect &clip) { _hnmClipping = clip; _hnmHasClip = true; }
153  void unsetHNMClipping() { _hnmHasClip = false; }
154 
155 protected:
156  bool _canLoadSave;
157 
158  FontManager _fontManager;
159  Sprites _sprites;
160  Objects _objects;
161  Inventory _inventory;
162 
163  Common::Queue<Common::KeyState> _keysPressed;
164 
165  DragStatus _dragStatus;
166  Common::Point _dragStart;
167  uint _lastMouseButton;
168  uint _autoRepeatNextEvent;
169 
170 private:
171  uint _lockPaletteStartRW;
172  uint _lockPaletteEndRW;
173 
174  Common::Rect _hnmClipping;
175  bool _hnmHasClip;
176 };
177 
179 protected:
180  Common::Error run() override;
181 
182 public:
183  CryOmni3DEngine_HNMPlayer(OSystem *syst, const CryOmni3DGameDescription *gamedesc) : CryOmni3DEngine(syst, gamedesc) {}
184  ~CryOmni3DEngine_HNMPlayer() override {}
185 
186  bool displayToolbar(const Graphics::Surface *original) override { return false; }
187  bool hasPlaceDocumentation() override { return false; }
188  bool displayPlaceDocumentation() override { return false; }
189  uint displayOptions() override { return 0; }
190  void makeTranslucent(Graphics::Surface &dst, const Graphics::Surface &src) const override {}
191  void setupPalette(const byte *colors, uint start, uint num) override {}
192 };
193 
194 } // End of namespace CryOmni3D
195 
196 #endif
Definition: image_decoder.h:52
Definition: cryomni3d.h:62
Definition: surface.h:66
EngineFeature
Definition: engine.h:250
Definition: error.h:84
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: cryomni3d.h:98
Definition: objects.h:77
Definition: display_client.h:58
Definition: rect.h:144
Definition: font_manager.h:39
Definition: path.h:52
Engine * g_engine
SoundType
Definition: mixer.h:62
Definition: ustr.h:57
Definition: objects.h:70
Definition: detection.h:48
static bool shouldQuit()
Definition: datstream.h:33
Definition: cryomni3d.h:80
Definition: cursor.h:42
Definition: algorithm.h:29
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: cryomni3d.h:99
Definition: rect.h:45
Definition: sprites.h:40
Definition: keyboard.h:294
Definition: cryomni3d.h:178
Definition: system.h:167
Definition: movie_decoder.h:32
Definition: engine.h:143
Platform
Definition: platform.h:46
Definition: mixer.h:63
Language
Definition: language.h:45