ScummVM API documentation
illusions.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 ILLUSIONS_ILLUSIONS_H
23 #define ILLUSIONS_ILLUSIONS_H
24 
25 #include "illusions/graphics.h"
26 #include "audio/mixer.h"
27 #include "audio/decoders/aiff.h"
28 
29 #include "common/array.h"
30 #include "common/events.h"
31 #include "common/file.h"
32 #include "common/memstream.h"
33 #include "common/random.h"
34 #include "common/str.h"
35 #include "common/substream.h"
36 #include "common/system.h"
37 
38 #include "engines/engine.h"
39 #include "graphics/surface.h"
40 #include "illusions/detection.h"
41 
42 namespace Illusions {
43 
44 char *debugW2I(uint16 *wstr);
45 void swapBytesInWideString(byte * wstr);
46 
47 #define ILLUSIONS_SAVEGAME_VERSION 0
48 
49 class ResourceSystem;
50 class BaseResourceReader;
51 
52 struct SurfInfo;
53 
54 class ActorInstanceList;
55 struct ActorType;
56 class BackgroundInstanceList;
57 class BackgroundResource;
58 class Camera;
59 class Control;
60 class Controls;
61 class Cursor;
62 class Dictionary;
63 struct Fader;
64 class FramesList;
65 class Input;
66 class Screen;
67 class ScreenText;
68 class ScriptOpcodes;
69 class ScriptResource;
70 class ScriptStack;
71 struct Sequence;
72 class SoundMan;
73 class SpecialCode;
74 class TalkInstanceList;
75 class ThreadList;
76 class UpdateFunctions;
77 class GameState;
78 class ScreenPaletteBase;
79 
80 class IllusionsEngine : public Engine {
81 public:
83  ~IllusionsEngine() override;
84  const Common::String getTargetName() { return _targetName; }
85 private:
86  const IllusionsGameDescription *_gameDescription;
87  Graphics::PixelFormat _pixelFormat;
88 public:
89 
90  Common::RandomSource *_random;
91  Dictionary *_dict;
92  ResourceSystem *_resSys;
93  BaseResourceReader *_resReader;
94  UpdateFunctions *_updateFunctions;
95  GameState *_gameState;
96 
97  void updateEvents();
98 
99  Screen *_screen;
100  ScreenPaletteBase *_screenPalette;
101  ScreenText *_screenText;
102  Input *_input;
103  ActorInstanceList *_actorInstances;
104  BackgroundInstanceList *_backgroundInstances;
105  Camera *_camera;
106  Controls *_controls;
107  TalkInstanceList *_talkItems;
108  ScriptOpcodes *_scriptOpcodes;
109  SpecialCode *_specialCode;
110  ThreadList *_threads;
111  SoundMan *_soundMan;
112 
113  uint32 _nextTempThreadId;
114  bool _doScriptThreadInit;
115  ScriptStack *_stack;
116  ScriptResource *_scriptResource;
117  bool _rerunThreads;
118 
119  Fader *_fader;
120 
121  int _pauseCtr;
122 
123  int _resGetCtr;
124  uint32 _resGetTime;
125  bool _unpauseControlActorFlag;
126  uint32 _lastUpdateTime;
127 
128  int _resumeFromSavegameRequested;
129  int _savegameSlotNum;
130  Common::String _savegameDescription;
131  uint32 _savegameSceneId;
132  uint32 _savegameThreadId;
133 
134  uint32 _fontId;
135  int _field8;
136  uint32 _fieldA;
137  uint32 _subtitleDuration;
138 
139  WidthHeight _defaultTextDimensions;
140  Common::Point _defaultTextPosition;
141 
142  int16 _menuChoiceOfs;
143 
144  int getGameId() const;
145  Common::Language getGameLanguage() const;
146 
147  void runUpdateFunctions();
148  int updateActors(uint flags);
149  int updateSequences(uint flags);
150  int updateGraphics(uint flags);
151  int updateSoundMan(uint flags);
152  int updateSprites(uint flags);
153 
154  uint32 getElapsedUpdateTime();
155  Common::Point *getObjectActorPositionPtr(uint32 objectId);
156  int getRandom(int max);
157  int convertPanXCoord(int16 x);
158  bool calcPointDirection(Common::Point &srcPt, Common::Point &dstPt, uint &facing);
159  bool isSoundActive();
160 
161  virtual void updateFader() {};
162  virtual void clearFader() {};
163  virtual void pauseFader() {};
164  virtual void unpauseFader() {};
165  virtual bool isVideoPlaying() { return false; }
166 
167  void setCurrFontId(uint32 fontId);
168  bool checkActiveTalkThreads();
169  void setTextDuration(int kind, uint32 duration);
170  uint32 clipTextDuration(uint32 duration);
171  void getDefaultTextDimensions(WidthHeight &dimensions);
172  void setDefaultTextDimensions(WidthHeight &dimensions);
173  void getDefaultTextPosition(Common::Point &position);
174  void setDefaultTextPosition(Common::Point &position);
175 
176  uint16 getSubtitleDuration();
177  void setSubtitleDuration(uint16 duration);
178 
179  FramesList *findActorSequenceFrames(Sequence *sequence);
180 
181  virtual void setDefaultTextCoords() = 0;
182  virtual void loadSpecialCode(uint32 resId) = 0;
183  virtual void unloadSpecialCode(uint32 resId) = 0;
184  virtual void notifyThreadId(uint32 &threadId) = 0;
185  virtual bool testMainActorFastWalk(Control *control) = 0;
186  virtual bool testMainActorCollision(Control *control) = 0;
187  virtual Control *getObjectControl(uint32 objectId) = 0;
188  virtual Common::Point getNamedPointPosition(uint32 namedPointId) = 0;
189  virtual uint32 getPriorityFromBase(int16 priority) = 0;
190  virtual uint32 getPrevScene() = 0;
191  virtual uint32 getCurrentScene() = 0;
192  virtual bool isCursorObject(uint32 actorTypeId, uint32 objectId) = 0;
193  virtual void setCursorControlRoutine(Control *control) = 0;
194  virtual void placeCursorControl(Control *control, uint32 sequenceId) = 0;
195  virtual void setCursorControl(Control *control) = 0;
196  virtual void showCursor() = 0;
197  virtual void hideCursor() = 0;
198  virtual void startScriptThreadSimple(uint32 threadId, uint32 callingThreadId) = 0;
199  virtual uint32 startTempScriptThread(byte *scriptCodeIp, uint32 callingThreadId,
200  uint32 value8, uint32 valueC, uint32 value10) = 0;
201 
202  // Savegame API
203 
204  enum kReadSaveHeaderError {
205  kRSHENoError = 0,
206  kRSHEInvalidType = 1,
207  kRSHEInvalidVersion = 2,
208  kRSHEIoError = 3
209  };
210 
211  struct SaveHeader {
212  Common::String description;
213  uint32 version;
214  byte gameID;
215  uint32 flags;
216  uint32 saveDate;
217  uint32 saveTime;
218  uint32 playTime;
219  Graphics::Surface *thumbnail;
220  };
221 
222  bool _isSaveAllowed;
223 
224  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
225  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
226  Common::Error loadGameState(int slot) override;
227  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
228  Common::Error removeGameState(int slot);
229  bool savegame(const char *filename, const char *description);
230  bool loadgame(const char *filename);
231  bool existsSavegame(int num);
232  static Common::String getSavegameFilename(const Common::String &target, int num);
233  static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
234 
235 };
236 
237 } // End of namespace Illusions
238 
239 #endif // ILLUSIONS_ILLUSIONS_H
Definition: input.h:77
Definition: backgroundresource.h:208
Definition: screen.h:99
Definition: str.h:59
Definition: screen.h:113
Definition: surface.h:66
Definition: talkresource.h:78
Definition: dictionary.h:85
Definition: error.h:84
Definition: pixelformat.h:138
Definition: resourcesystem.h:85
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: illusions.h:224
Definition: random.h:44
Definition: default_display_client.h:78
Definition: actor.h:34
Definition: actor.h:245
Definition: detection.h:34
Definition: stream.h:745
Definition: illusions.h:211
Definition: screen.h:154
Definition: graphics.h:31
Definition: sound.h:127
Definition: ustr.h:57
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: illusions.h:225
Definition: scriptopcodes.h:48
Definition: camera.h:65
Definition: rect.h:45
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: cursor.h:27
Definition: specialcode.h:44
Definition: resourcereader.h:29
Definition: screentext.h:56
const Common::String _targetName
Definition: engine.h:180
Common::Error loadGameState(int slot) override
Definition: scriptstack.h:27
Definition: actorresource.h:51
Definition: gamestate.h:30
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: system.h:167
Definition: actorresource.h:112
Definition: actor.h:180
Definition: scriptresource.h:114
Definition: thread.h:80
Definition: engine.h:143
Definition: updatefunctions.h:49
Definition: illusions.h:80
Definition: actorresource.h:76
Language
Definition: language.h:45