ScummVM API documentation
ringworld2_logic.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 TSAGE_RINGWORLD2_LOGIC_H
23#define TSAGE_RINGWORLD2_LOGIC_H
24
25#include "common/scummsys.h"
26#include "tsage/events.h"
27#include "tsage/core.h"
28#include "tsage/scenes.h"
29#include "tsage/globals.h"
30
31namespace TsAGE {
32
33namespace Ringworld2 {
34
35using namespace TsAGE;
36
37#define R2_INVENTORY (*((::TsAGE::Ringworld2::Ringworld2InvObjectList *)g_globals->_inventory))
38
40public:
41 static Scene *createScene(int sceneNumber);
42};
43
44class SceneArea: public SceneItem {
45public:
46 bool _enabled;
47 bool _insideArea;
48 CursorType _cursorNum;
49 CursorType _savedCursorNum;
50 int _cursorState;
51public:
52 SceneArea();
53 void setDetails(const Rect &bounds, CursorType cursor);
54
55 Common::String getClassName() override { return "SceneArea"; }
56 void synchronize(Serializer &s) override;
57 void remove() override;
58 void process(Event &event) override;
59 bool startAction(CursorType action, Event &event) override { return false; }
60 void doAction(int action) override {}
61};
62
63class SceneExit: public SceneArea {
64public:
65 bool _moving;
66 int _sceneNumber;
67 Common::Point _destPos;
68public:
69 SceneExit();
70 virtual void setDetails(const Rect &bounds, CursorType cursor, int sceneNumber);
71 virtual void setDest(const Common::Point &p) { _destPos = p; }
72 virtual void changeScene();
73
74 void synchronize(Serializer &s) override;
75 void process(Event &event) override;
76};
77
78class SceneExt: public Scene {
79private:
80 static void startStrip();
81 static void endStrip();
82public:
83 byte _shadowPaletteMap[256];
84 bool _savedPlayerEnabled;
85 bool _savedUiEnabled;
86 bool _savedCanWalk;
87 bool _preventSaving;
88
89 Visage _cursorVisage;
91public:
92 SceneExt();
93
94 Common::String getClassName() override { return "SceneExt"; }
95 void synchronize(Serializer &s) override;
96 void postInit(SceneObjectList *OwnerList = NULL) override;
97 void remove() override;
98 void process(Event &event) override;
99 void dispatch() override;
100 void refreshBackground(int xAmount, int yAmount) override;
101 virtual void saveCharacter(int characterIndex);
102 virtual void restore() {}
103
104 bool display(CursorType action, Event &event);
105 void fadeOut();
106 void clearScreen();
107 void scalePalette(int RFactor, int GFactor, int BFactor);
108 void loadBlankScene();
109};
110
112public:
113 void postInit(SceneObjectList *OwnerList = NULL) override;
114 void process(Event &event) override;
115 void postLoad(int priorSceneBeforeLoad, int currentSceneBeforeLoad) override;
116 void dispatch() override;
117
118 void setupPaletteMaps();
119};
120
121
123private:
124 Common::Array<int> _actions;
125 bool performAction(int action);
126public:
127 DisplayHotspot(int regionId, ...);
128
129 void doAction(int action) override {
130 if (!performAction(action))
131 SceneHotspot::doAction(action);
132 }
133};
134
136private:
137 Common::Array<int> _actions;
138 bool performAction(int action);
139public:
140 DisplayObject(int firstAction, ...);
141
142 void doAction(int action) override {
143 if (!performAction(action))
144 SceneHotspot::doAction(action);
145 }
146};
147
149public:
150 int _state;
151
152 void synchronize(Serializer &s) override {
153 SceneObject::synchronize(s);
154 s.syncAsSint16LE(_state);
155 }
156 Common::String getClassName() override { return "SceneObjectExt"; }
157};
158
159/*--------------------------------------------------------------------------*/
160
162private:
163 static bool SelectItem(int objectNumber);
164 static void selectDefault(int obectNumber);
165public:
166 InvObject _none;
167 InvObject _optoDisk;
168 InvObject _reader;
169 InvObject _negatorGun;
170 InvObject _steppingDisks;
171 InvObject _attractorUnit;
172 InvObject _sensorProbe;
173 InvObject _sonicStunner;
174 InvObject _cableHarness;
175 InvObject _comScanner;
176 InvObject _spentPowerCapsule; // 10
177 InvObject _chargedPowerCapsule;
178 InvObject _aerosol;
179 InvObject _remoteControl;
180 InvObject _opticalFiber;
181 InvObject _clamp;
182 InvObject _attractorHarness;
183 InvObject _fuelCell;
184 InvObject _gyroscope;
185 InvObject _airbag;
186 InvObject _rebreatherTank; // 20
187 InvObject _reserveTank;
188 InvObject _guidanceModule;
189 InvObject _thrusterValve;
190 InvObject _balloonBackpack;
191 InvObject _radarMechanism;
192 InvObject _joystick;
193 InvObject _ignitor;
194 InvObject _diagnosticsDisplay;
195 InvObject _glassDome;
196 InvObject _wickLamp; // 30
197 InvObject _scrithKey;
198 InvObject _tannerMask;
199 InvObject _pureGrainAlcohol;
200 InvObject _blueSapphire;
201 InvObject _ancientScrolls;
202 InvObject _flute;
203 InvObject _gunpowder;
204 InvObject _unused;
205 InvObject _comScanner2;
206 InvObject _superconductorWire; // 40
207 InvObject _pillow;
208 InvObject _foodTray;
209 InvObject _laserHacksaw;
210 InvObject _photonStunner;
211 InvObject _battery;
212 InvObject _soakedFaceMask;
213 InvObject _lightBulb;
214 InvObject _alcoholLamp1;
215 InvObject _alcoholLamp2;
216 InvObject _alocholLamp3; // 50
217 InvObject _brokenDisplay;
218 InvObject _toolbox;
219
221 void reset();
222 void setObjectScene(int objectNum, int sceneNumber);
223
224 Common::String getClassName() override { return "Ringworld2InvObjectList"; }
225};
226
227#define RING2_INVENTORY (*((::TsAGE::Ringworld2::Ringworld2InvObjectList *)g_globals->_inventory))
228
229class Ringworld2Game: public Game {
230public:
231 void start() override;
232 void restartGame() override;
233 void restart() override;
234 void endGame(int resNum, int lineNum) override;
235
236 Scene *createScene(int sceneNumber) override;
237 void processEvent(Event &event) override;
238 void rightClick() override;
239 bool canSaveGameStateCurrently() override;
240 bool canLoadGameStateCurrently() override;
241};
242
244public:
245 NamedHotspot();
246
247 bool startAction(CursorType action, Event &event) override;
248 Common::String getClassName() override { return "NamedHotspot"; }
249};
250
252public:
253 int _flag;
254 NamedHotspotExt() { _flag = 0; }
255
256 Common::String getClassName() override { return "NamedHotspot"; }
257 void synchronize(Serializer &s) override {
258 NamedHotspot::synchronize(s);
259 s.syncAsSint16LE(_flag);
260 }
261};
262
263class SceneActor: public SceneObject {
264public:
265 Common::String getClassName() override { return "SceneActor"; }
266 void postInit(SceneObjectList *OwnerList = NULL) override;
267 void remove() override;
268 bool startAction(CursorType action, Event &event) override;
269 GfxSurface getFrame() override;
270};
271
273public:
274 int _state;
275
276 SceneActorExt() { _state = 0; }
277
278 Common::String getClassName() override { return "SceneActorExt"; }
279 void synchronize(Serializer &s) override {
280 SceneActor::synchronize(s);
281 s.syncAsSint16LE(_state);
282 }
283};
284
285enum MazeDirection { MAZEDIR_NONE = 0, MAZEDIR_NORTH = 1, MAZEDIR_NORTHEAST = 2, MAZEDIR_EAST = 3,
286 MAZEDIR_SOUTHEAST = 4, MAZEDIR_SOUTH = 5, MAZEDIR_SOUTHWEST = 6, MAZEDIR_WEST = 7,
287 MAZEDIR_NORTHWEST = 8 };
288
289class MazeUI: public SceneObject {
290private:
291 void clear();
292public:
293 // The dimensions (in cells) of the entire maze map
294 Rect _mapBounds;
295
296 // Encoded cell map specifying the features of the maze
297 byte *_mapData;
298 // Image surface used to store a line of the map for rendering
299 GfxSurface _mapImage;
300
301 Common::Point _cellsVisible;
302 Common::Point _mapCells;
303 Common::Point _cellSize;
304 Common::Point _mapOffset;
305 int _resNum;
306 int _cellsResNum;
307 int _frameCount;
308 int _resCount;
309 int _mapImagePitch;
310public:
311 MazeUI();
312 ~MazeUI() override;
313
314 void setDisplayBounds(const Rect &r);
315 bool setMazePosition(const Common::Point &pt);
316 void load(int resNum);
317 int getCellFromPixelXY(const Common::Point &pt);
318 int getCellFromCellXY(const Common::Point &p);
319 int pixelToCellXY(Common::Point &pt);
320
321 Common::String getClassName() override { return "MazeUI"; }
322 void synchronize(Serializer &s) override;
323 void reposition() override;
324 void draw() override;
325};
326
328 class Object1: public SceneActor {
329 public:
330 };
331public:
332 Object1 _object1;
333 int _insetCount;
334
335 void remove() override;
336 void process(Event &event) override;
337 void setDetails(int visage, int strip, int frameNumber, const Common::Point &pt);
338 void setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum);
339};
340
341/*--------------------------------------------------------------------------*/
342
344public:
345 int _sliceOffset;
346 int _drawMode;
347 int _secondaryIndex;
348public:
349 void load(Common::File &f);
350};
351
353public:
354 int _dataSize;
355 int _dataSize2;
356 AnimationSlice _slices[4];
357 byte *_pixelData;
358public:
361
362 void load(Common::File &f);
363 int loadPixels(Common::File &f, int slicesSize);
364};
365
367public:
368 int _duration;
369 int _frameRate;
370 int _framesPerSlices;
371 int _drawType;
372 int _sliceSize;
373 int _ySlices;
374 int _field16;
375 int _palStart;
376 int _palSize;
377 byte _palData[256 * 3];
378 int32 _totalSize;
379 AnimationSlices _slices;
380public:
381 void load(Common::File &f);
382};
383
385public:
386 AnimationSlices _slices;
387 int _dataSize;
388 int _animSlicesSize;
389};
390
391enum AnimationPaletteMode { ANIMPALMODE_REPLACE_PALETTE = 0, ANIMPALMODE_CURR_PALETTE = 1,
392 ANIMPALMODE_NONE = 2 };
393
394enum AnimationObjectMode { ANIMOBJMODE_1 = 1, ANIMOBJMODE_2 = 2, ANIMOBJMODE_42 = 42 };
395
397private:
398 void rleDecode(const byte *pSrc, byte *pDest, int size);
399
400 void drawFrame(int sliceIndex);
401 void nextSlices();
402 void getSlices();
403public:
404 AnimationData *_animData1, *_animData2;
405 AnimationData *_sliceCurrent;
406 AnimationData *_sliceNext;
407 Common::File _resourceFile;
408 Rect _rect1, _screenBounds;
409 bool _animLoaded;
410 bool _canSkip;
411 AnimationPaletteMode _paletteMode;
412 AnimationObjectMode _objectMode;
413 int _sliceHeight;
414 byte _palIndexes[256];
415 ScenePalette _palette;
416 AnimationPlayerSubData _subData;
417 Action *_endAction;
418 int _dataNeeded;
419 int _playbackTick;
420 int _playbackTickPrior;
421 int _position;
422 int _nextSlicesPosition;
423 uint _frameDelay;
424 uint32 _gameFrame;
425public:
427 ~AnimationPlayer() override;
428
429 void synchronize(Serializer &s) override;
430 void remove() override;
431 void process(Event &event) override;
432 void dispatch() override;
433 virtual void flipPane() {}
434 virtual void changePane() {}
435 virtual void closing() {}
436
437
438 bool load(int animId, Action *endAction = NULL);
439 bool isCompleted();
440 void close();
441};
442
444public:
445 bool _isActive;
446public:
448
449 void synchronize(Serializer &s) override;
450};
451
452class ModalWindow: public SceneArea {
453public:
454 SceneActor _object1;
455 int _insetCount;
456public:
457 ModalWindow();
458
459 void remove() override;
460 void synchronize(Serializer &s) override;
461 Common::String getClassName() override { return "ModalWindow"; }
462 void process(Event &event) override;
463 virtual void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY);
464 virtual void setup3(int resNum, int lookLineNum, int talkLineNum, int useLineNum);
465};
466
468
469 class Button: public SceneActor {
470 private:
471 void reset();
472 public:
473 int _buttonId;
474 bool _buttonDown;
475 public:
476 Button();
477 void setup(int buttonId);
478
479 void synchronize(Serializer &s) override;
480 Common::String getClassName() override { return "ScannerButton"; }
481 void process(Event &event) override;
482 bool startAction(CursorType action, Event &event) override;
483 };
484 class Slider: public SceneActor {
485 private:
486 void update();
487 public:
488 int _initial;
489 int _xStart;
490 int _yp;
491 int _width;
492 int _xInc;
493 bool _sliderDown;
494 public:
495 Slider();
496 void setup(int initial, int xStart, int yp, int width, int xInc);
497
498 void synchronize(Serializer &s) override;
499 Common::String getClassName() override { return "ScannerSlider"; }
500 void remove() override;
501 void process(Event &event) override;
502 bool startAction(CursorType action, Event &event) override;
503 };
504public:
505 Button _talkButton;
506 Button _scanButton;
507 Slider _slider;
508 SceneActor _obj4;
509 SceneActor _obj5;
510 SceneActor _obj6;
511 SceneActor _obj7;
512public:
514
515 Common::String getClassName() override { return "ScannerDialog"; }
516 void remove() override;
517 void setup2(int visage, int stripFrameNum, int frameNum, int posX, int posY) override;
518};
519
520} // End of namespace Ringworld2
521
522} // End of namespace TsAGE
523
524#endif
Definition: input.h:69
Definition: file.h:47
Definition: str.h:59
Definition: core.h:134
Definition: core.h:115
Definition: events.h:47
Definition: scenes.h:109
Definition: graphics.h:79
Definition: core.h:47
Definition: core.h:75
Definition: graphics.h:40
Definition: ringworld2_logic.h:384
Definition: ringworld2_logic.h:443
Definition: ringworld2_logic.h:396
Definition: ringworld2_logic.h:366
Definition: ringworld2_logic.h:343
Definition: ringworld2_logic.h:352
Definition: ringworld2_logic.h:122
Definition: ringworld2_logic.h:135
Definition: ringworld2_logic.h:289
Definition: ringworld2_logic.h:452
Definition: ringworld2_logic.h:251
Definition: ringworld2_logic.h:243
Definition: ringworld2_logic.h:229
Definition: ringworld2_logic.h:161
Definition: ringworld2_logic.h:467
Definition: ringworld2_logic.h:272
Definition: ringworld2_logic.h:263
Definition: ringworld2_logic.h:44
Definition: ringworld2_logic.h:327
Definition: ringworld2_logic.h:63
Definition: ringworld2_logic.h:78
Definition: ringworld2_logic.h:39
Definition: ringworld2_logic.h:111
Definition: ringworld2_logic.h:148
Definition: core.h:895
Definition: core.h:443
Definition: scenes.h:33
Definition: core.h:407
Definition: core.h:519
Definition: core.h:736
Definition: core.h:355
Definition: saveload.h:63
Definition: saveload.h:115
Definition: core.h:472
Definition: rect.h:144