ScummVM API documentation
scene.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 ASYLUM_VIEWS_SCENE_H
23#define ASYLUM_VIEWS_SCENE_H
24
25#include "common/array.h"
26#include "common/events.h"
27#include "common/rational.h"
28
29#include "graphics/surface.h"
30
31#include "asylum/system/screen.h"
32
33#include "asylum/eventhandler.h"
34#include "asylum/shared.h"
35
36#define SCENE_FILE_MASK "scn.%03d"
37#define MUSIC_FILE_MASK "mus.%03d"
38
39// If defined, will show the scene update times on the debugger output
40//#define DEBUG_SCENE_TIMES
41
42namespace Asylum {
43
44class Actor;
45class AsylumEngine;
46class Puzzle;
47class Cursor;
48class GraphicResource;
49class Polygons;
50class Polygon;
51class ResourcePack;
52class SceneTitle;
53class Screen;
54class Special;
55class Speech;
56class Sound;
57class Text;
58class VideoPlayer;
59class WorldStats;
60
61struct ActionArea;
62struct AmbientSoundItem;
63struct GraphicFrame;
64struct ObjectItem;
65
66enum HitType {
67 kHitNone = -1,
68 kHitActionArea = 2,
69 kHitObject = 3,
70 kHitActor = 4
71};
72
73enum ActionAreaType {
74 kActionAreaType1 = 1,
75 kActionAreaType2 = 2
76};
77
78enum KeyDirection {
79 kWalkUp = 1,
80 kWalkDown = 2,
81 kWalkLeft = 4,
82 kWalkRight = 8
83};
84
85class Scene : public EventHandler {
86public:
87 Scene(AsylumEngine *engine);
88 virtual ~Scene();
89
95 void load(ResourcePackId packId);
96
102 void enter(ResourcePackId packId);
103
107 void enterLoad();
108
116 bool handleEvent(const AsylumEvent &ev);
117
123 ResourcePackId getPackId() { return _packId; }
124
130 Actor *getActor(ActorIndex index = kActorInvalid);
131
137 void changePlayer(ActorIndex index);
138
144 void changePlayerUpdate(ActorIndex index);
145
157 bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords = false, int32 *param = NULL);
158
165
170
174 void drawRain();
175
185 int32 findActionArea(ActionAreaType type, const Common::Point &pt, bool highlight = false);
186
201 bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) const;
202
203 Polygons *polygons() { return _polygons; }
204 WorldStats *worldstats() { return _ws; }
205 uint32 getFrameCounter() { return _frameCounter; }
206
207 const byte *getSavedPalette() { return _savedPalette; }
208 const Graphics::Surface &getSavedScreen() { return _savedScreen; }
209
210private:
211 AsylumEngine *_vm;
212
213 ResourcePackId _packId;
214
215 Polygons *_polygons;
216 WorldStats *_ws;
217
218 struct UpdateItem {
219 ActorIndex index;
220 int32 priority;
221 };
222
223 // Music volume
224 int32 _musicVolume;
225
226 Common::Array<UpdateItem> _updateList;
227 uint32 _frameCounter;
228
229 Graphics::Surface _savedScreen;
230 byte _savedPalette[PALETTE_SIZE];
231
232 bool _debugShowVersion;
233
234 byte _keyState;
235 bool _rightButtonDown;
236
238 // Message handling
239 void activate();
240 bool init();
241 bool update();
242 bool actionDown(AsylumAction a);
243 bool actionUp(AsylumAction a);
244 bool key(const AsylumEvent &evt);
245 bool clickDown(const AsylumEvent &evt);
246
248 // Scene update
250
256 bool updateScene();
257
261 void updateMouse();
262
266 void updateActors();
267
271 void updateObjects();
272
276 void updateMusic();
277
283 void updateAdjustScreen();
284
288 void updateCoordinates();
289
296 void updateCursor(ActorDirection direction, const Common::Rect &rect);
297
299 // Scene drawing
301
305 void preload();
306
312 bool drawScene();
313
317 void buildUpdateList();
318
322 void processUpdateList();
323
332 static bool updateListCompare(const UpdateItem &item1, const UpdateItem &item2);
333
337 void checkVisibleActorsPriority();
338
344 void adjustActorPriority(ActorIndex index);
345
346 int32 _chapter5RainFrameIndex;
347
349 // HitTest
351
359 int32 hitTest(HitType &type);
360
369 int32 hitTestScene(HitType &type);
370
376 int32 hitTestActionArea();
377
383 ActorIndex hitTestActor();
384
390 bool hitTestPlayer();
391
397 int32 hitTestObject();
398
410 bool hitTestPixel(ResourceId resourceId, uint32 frame, int16 x, int16 y, bool flipped);
411
413 // Hit actions
415
422 void handleHit(int32 index, HitType type);
423
424 void clickInventory();
425
426 void hitAreaChapter2(int32 id);
427 bool _isCTRLPressed;
428 int32 _hitAreaChapter7Counter;
429 void hitAreaChapter7(int32 id);
430 void hitAreaChapter11(int32 id);
431
432 void hitActorChapter2(ActorIndex index);
433 void hitActorChapter11(ActorIndex index);
434
436 // Helpers
438
442 void playIntroSpeech();
443
447 void stopSpeech();
448
456 bool speak(Common::KeyCode code);
457
466 bool pointBelowLine(const Common::Point &point, const Common::Rect &rect) const;
467
473 void adjustCoordinates(Common::Point *point);
474
476 // Scene debugging
478 void debugShowActors();
479 void debugShowObjects();
480 void debugShowPolygons();
481 void debugShowPolygon(uint32 index, uint32 color = 0xFF);
482 void debugHighlightPolygon(uint32 index);
483 void debugShowSceneRects();
484 void debugScreenScrolling();
485 void debugShowWalkRegion(Polygon *poly);
486
487 friend class SceneTitle;
488};
489
490} // end of namespace Asylum
491
492#endif // ASYLUM_VIEWS_SCENE_H
Definition: actor.h:86
Definition: asylum.h:73
Definition: eventhandler.h:61
Definition: polygons.h:50
Definition: scene.h:85
void enter(ResourcePackId packId)
int32 findActionArea(ActionAreaType type, const Common::Point &pt, bool highlight=false)
bool updateSceneCoordinates(int32 targetX, int32 targetY, int32 val, bool checkSceneCoords=false, int32 *param=NULL)
bool handleEvent(const AsylumEvent &ev)
void updateAmbientSounds()
ResourcePackId getPackId()
Definition: scene.h:123
void changePlayerUpdate(ActorIndex index)
Actor * getActor(ActorIndex index=kActorInvalid)
bool rectIntersect(int32 x, int32 y, int32 x1, int32 y1, int32 x2, int32 y2, int32 x3, int32 y3) const
bool updateScreen()
void load(ResourcePackId packId)
void enterLoad()
void changePlayer(ActorIndex index)
Definition: worldstats.h:64
Definition: eventhandler.h:43
Definition: rect.h:144
Definition: rect.h:536
Definition: atari-cursor.h:35
Definition: surface.h:67
Definition: atari-screen.h:58