ScummVM API documentation
ngi.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 NGI_FULLPIPE_H
23 #define NGI_FULLPIPE_H
24 
25 #include "audio/mixer.h"
26 #include "common/scummsys.h"
27 #include "common/events.h"
28 #include "common/keyboard.h"
29 #include "common/ptr.h"
30 #include "common/random.h"
31 #include "common/savefile.h"
32 #include "common/system.h"
33 #include "graphics/surface.h"
34 
35 #include "engines/engine.h"
36 #include "ngi/console.h"
37 
38 namespace Audio {
39 class SoundHandle;
40 }
41 
42 namespace NGI {
43 
44 enum {
45  kDebugPathfinding = 1 << 0,
46  kDebugDrawing = 1 << 1,
47  kDebugLoading = 1 << 2,
48  kDebugAnimation = 1 << 3,
49  kDebugMemory = 1 << 4,
50  kDebugEvents = 1 << 5,
51  kDebugBehavior = 1 << 6,
52  kDebugInventory = 1 << 7,
53  kDebugSceneLogic = 1 << 8,
54  kDebugInteractions = 1 << 9,
55  kDebugXML = 1 << 10
56 };
57 
58 #define MAXGAMEOBJH 10000
59 
60 struct NGIGameDescription;
61 
62 
63 class BehaviorManager;
64 class BaseModalObject;
65 class GameLoader;
66 class GameVar;
67 class InputController;
68 class Inventory2;
69 struct CursorInfo;
70 struct EntranceInfo;
71 class ExCommand;
72 class Floaters;
73 class GameProject;
74 class GameObject;
75 class GlobalMessageQueueList;
76 struct MessageHandler;
77 class MessageQueue;
78 class AniHandler;
79 class NGIArchive;
80 class PictureObject;
81 struct PreloadItem;
82 class Scene;
83 class SoundList;
84 class StaticANIObject;
85 class Vars;
86 typedef Common::Array<int16> MovTable;
87 typedef Common::Array<Common::Point> PointList;
88 
89 struct Palette {
90  uint32 pal[256];
91  uint size;
92 
93  Palette() {
94  size = 0;
95  memset(pal, 0, 256 * 4);
96  }
97 
98  void copy(const Palette &src) {
99  size = src.size;
100  memcpy(pal, src.pal, 256 * 4);
101  }
102 };
103 
105 
106 int global_messageHandler1(ExCommand *cmd);
107 int global_messageHandler2(ExCommand *cmd);
108 int global_messageHandler3(ExCommand *cmd);
109 int global_messageHandler4(ExCommand *cmd);
110 void global_messageHandler_handleSound(ExCommand *cmd);
111 
112 
113 class NGIEngine : public ::Engine {
114 protected:
115 
116  Common::Error run() override;
117 
118 public:
119  NGIEngine(OSystem *syst, const NGIGameDescription *gameDesc);
120  ~NGIEngine() override;
121 
122  void initialize();
123  void restartGame();
124  bool shouldQuit();
125 
126  void setMusicAllowed(int val) { _musicAllowed = val; }
127 
128  // Detection related functions
129  const NGIGameDescription *_gameDescription;
130  uint32 getFeatures() const;
131  bool isDemo();
132  Common::Language getLanguage() const;
133  const char *getGameId() const;
134  int getGameGID() const;
135 
137 
138  Common::KeyCode _keyState;
139  uint16 _buttonState;
140 
141  void updateEvents();
142 
143  Graphics::Surface _backgroundSurface;
144  Graphics::PixelFormat _origFormat;
145 
146  Common::ScopedPtr<GameLoader> _gameLoader;
147  GameProject *_gameProject;
148  bool loadGam(const char *fname, int scene = 0);
149 
150  void loadGameObjH();
151  Common::String gameIdToStr(uint16 id);
152 
153  GameVar *getGameLoaderGameVar();
154  InputController *getGameLoaderInputController();
155 
156  int _gameProjectVersion;
157  int _pictureScale;
158  int _scrollSpeed;
159  bool _updateFlag;
160  bool _flgCanOpenMap;
161  bool _gamePaused;
162  bool _flgGameIsRunning;
163  bool _inputArFlag;
164  bool _recordEvents;
165  bool _mainMenu_debugEnabled;
166 
167  Common::Rect _sceneRect;
168  int _sceneWidth;
169  int _sceneHeight;
170  Scene *_currentScene;
171  Scene *_loaderScene;
172  Scene *_scene2;
173  Scene *_scene3;
174  StaticANIObject *_aniMan;
175  StaticANIObject *_aniMan2;
176  Palette _defaultPalette;
177  const Palette *_globalPalette;
178 
179  InputController *_inputController;
180  bool _inputDisabled;
181 
182  int _currentCheat;
183  int _currentCheatPos;
184 
185  void defHandleKeyDown(int key);
186 
187  SoundList *_currSoundList1[11];
188  int _currSoundListCount;
189  bool _soundEnabled;
190  bool _flgSoundList;
191  Common::Path _sceneTracks[10];
192  int _numSceneTracks;
193  bool _sceneTrackHasSequence;
194  int _musicMinDelay;
195  int _musicMaxDelay;
196  int _musicLocal;
197  Common::String _trackName;
198  int _trackStartDelay;
199  Common::Path _sceneTracksCurrentTrack;
200  bool _sceneTrackIsPlaying;
201 
202  void stopAllSounds();
203  void toggleMute();
204  void playSound(int id, int flag);
205  void playTrack(GameVar *sceneVar, const char *name, bool delayed);
206  int getSceneTrack();
207  void updateTrackDelay();
208  void startSceneTrack();
209  void startSoundStream1(const Common::Path &trackName);
210  void playOggSound(const Common::Path &trackName, Audio::SoundHandle &stream);
211  void stopSoundStream2();
212  void stopAllSoundStreams();
213  void stopAllSoundInstances(int id);
214  void updateSoundVolume();
215  void setMusicVolume(int vol);
216 
217  int _sfxVolume;
218  int _musicVolume;
219 
220  Common::ScopedPtr<GlobalMessageQueueList> _globalMessageQueueList;
221  MessageHandler *_messageHandlers;
222 
223  int _msgX;
224  int _msgY;
225  int _msgObjectId2;
226  int _msgId;
227 
228  Common::List<ExCommand *> _exCommandList;
229  bool _isProcessingMessages;
230 
231  int _mouseVirtX;
232  int _mouseVirtY;
233  Common::Point _mouseScreenPos;
234 
235  Common::ScopedPtr<BehaviorManager> _behaviorManager;
236 
237  Common::ScopedPtr<MovTable> _movTable;
238 
239  Common::ScopedPtr<Floaters> _floaters;
240  Common::ScopedPtr<AniHandler> _aniHandler;
241 
242  Common::Array<Common::Point> _arcadeKeys;
243 
244  void deleteModalObject();
245 
246  void initMap();
247  void updateMap(PreloadItem *pre);
248  void updateMapPiece(int mapId, int update);
249  void updateScreen();
250 
251  void freeGameLoader();
252  void cleanup();
253 
254  bool _gameContinue;
255  bool _needRestart;
256  bool _flgPlayIntro;
257  int _musicAllowed;
258  bool _normalSpeed;
259 
260  void enableSaves() { _isSaveAllowed = true; }
261  void disableSaves(ExCommand *ex);
262  bool isSaveAllowed();
263 
264  void initObjectStates();
265  void setLevelStates();
266  void setSwallowedEggsState();
267  void loadAllScenes();
268 
269  void initCursors();
270  void addCursor(CursorInfo *cursorInfo, Scene *inv, int pictureId, int hotspotX, int hotspotY, int itemPictureOffsX, int itemPictureOffsY);
271 
272  int32 _mapTable[200];
273 
274  Scene *_inventoryScene;
275  Inventory2 *_inventory;
276  int _currSelectedInventoryItemId;
277 
278  int32 _updateTicks;
279  int32 _lastInputTicks;
280  int32 _lastButtonUpTicks;
281 
282  BaseModalObject *_modalObject;
283 
284  int (*_updateScreenCallback)();
285  int (*_updateCursorCallback)();
286 
287  void drawAlphaRectangle(int x1, int y1, int x2, int y2, int alpha);
288  void sceneFade(Scene *sc, bool direction);
289 
290  int _cursorId;
291  int _minCursorId;
292  int _maxCursorId;
293  Common::Array<int> _objectIdCursors;
294  GameObject *_objectAtCursor;
295  int _objectIdAtCursor;
296 
297  void setCursor(int id);
298  void updateCursorCommon();
299 
300  int getObjectState(const Common::String &objname);
301  void setObjectState(const Common::String &name, int state);
302  int getObjectEnumState(const Common::String &name, const char *state);
303 
304  void sceneAutoScrolling();
305  bool sceneSwitcher(const EntranceInfo &entrance);
306  Scene *accessScene(int sceneId);
307  void setSceneMusicParameters(GameVar *var);
308  int convertScene(int scene);
309  int getSceneEntrance(int scene);
310  int getSceneFromTag(int tag);
311 
312  NGIArchive *_currArchive;
313 
314  void openMap();
315  void openHelp();
316  void openMainMenu();
317 
318  PictureObject *_arcadeOverlay;
319  PictureObject *_arcadeOverlayHelper;
320  int _arcadeOverlayX;
321  int _arcadeOverlayY;
322  int _arcadeOverlayMidX;
323  int _arcadeOverlayMidY;
324 
325  void initArcadeKeys(const char *varname);
326  void processArcade(ExCommand *ex);
327  void winArcade();
328  void setArcadeOverlay(int picId);
329  int drawArcadeOverlay(int adjust);
330 
331  void getAllInventory();
332 
333  StaticANIObject *_lastLiftButton;
334  MessageQueue *_liftEnterMQ;
335  MessageQueue *_liftExitMQ;
336  StaticANIObject *_lift;
337  int _liftX;
338  int _liftY;
339 
340  int lift_getButtonIdP(int objid);
341  int lift_getButtonIdH(int objid);
342  int lift_getButtonIdN(int objid);
343  void lift_setButton(const char *name, int state);
344  void lift_init(Scene *sc, int qu1, int qu2);
345  void lift_setButtonStatics(Scene *sc, int buttonId);
346  void lift_exitSeq(ExCommand *ex);
347  void lift_closedoorSeq();
348  void lift_clickButton();
349  void lift_walkAndGo();
350  void lift_goAnimation();
351  void lift_animateButton(StaticANIObject *button);
352  void lift_startExitQueue();
353  void lift_hoverButton(ExCommand *ex);
354  bool lift_checkButton(const char *varname);
355  void lift_openLift();
356 
357  GameVar *_musicGameVar;
358  Audio::SoundHandle _soundStream1;
359  Audio::SoundHandle _soundStream2;
360  Audio::SoundHandle _soundStream3;
361  Audio::SoundHandle _soundStream4;
362 
363  bool _stream2playing;
364 
365  GameObjHMap _gameObjH;
366 
367 public:
368 
369  bool _isSaveAllowed;
370 
371  Common::Error loadGameState(int slot) override;
372  Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
373  Common::String getSaveStateName(int slot) const override;
374 
375  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return true; }
376  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
377  bool hasFeature(EngineFeature f) const override;
378 
379 };
380 
381 extern NGIEngine *g_nmi;
382 extern Vars *g_vars;
383 
384 } // End of namespace NGI
385 
386 #endif /* NGI_FULLPIPE_H */
Definition: gfx.h:137
Definition: messages.h:177
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: ngi.h:376
Definition: str.h:59
Definition: surface.h:66
EngineFeature
Definition: engine.h:250
Definition: detection.h:34
Definition: interaction.h:90
Definition: gameloader.h:64
Definition: error.h:84
Definition: pixelformat.h:138
Definition: random.h:44
Definition: inventory.h:82
Definition: modal.h:43
Definition: list.h:44
Definition: rect.h:144
Definition: path.h:52
Definition: ngiarchive.h:44
Definition: gfx.h:166
Definition: sound.h:61
Definition: ptr.h:572
Definition: objects.h:33
Definition: input.h:46
Out copy(In first, In last, Out dst)
Definition: algorithm.h:52
Definition: ngi.h:113
Definition: mixer.h:49
Definition: messages.h:108
Definition: ustr.h:57
Definition: input.h:31
Definition: scenes.h:216
Definition: rect.h:45
Definition: objects.h:76
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: ngi.h:375
Definition: statics.h:172
Definition: messages.h:59
Definition: scene.h:32
Definition: ngi.h:89
Definition: anihandler.h:25
Definition: system.h:175
Definition: engine.h:143
Definition: system.h:37
Language
Definition: language.h:45