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