ScummVM API documentation
room.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 LURE_ROOM_H
23#define LURE_ROOM_H
24
25
26#include "common/scummsys.h"
27#include "lure/disk.h"
28#include "lure/res.h"
29#include "lure/memory.h"
30#include "lure/surface.h"
31#include "lure/screen.h"
32#include "lure/hotspots.h"
33
34namespace Lure {
35
36#define RECT_SIZE 32
37#define NUM_HORIZ_RECTS 10
38#define NUM_VERT_RECTS 6
39#define FULL_HORIZ_RECTS 18
40#define FULL_VERT_RECTS 14
41#define NUM_EDGE_RECTS 4
42#define GRID_SIZE (FULL_VERT_RECTS * FULL_HORIZ_RECTS)
43
44class RoomLayer: public Surface {
45private:
46 byte _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
47 uint16 _paletteId;
48public:
49 RoomLayer(uint16 screenId, bool backgroundLayer);
50 bool isOccupied(byte cellX, byte cellY) {
51 return _cells[cellY][cellX] < 0xfe;
52 }
53 uint8 getCell(byte cellX, byte cellY) {
54 return _cells[cellY][cellX];
55 }
56 void setCell(byte cellX, byte cellY, byte value) {
57 _cells[cellY][cellX] = value;
58 }
59 uint16 paletteId() { return _paletteId; }
60};
61
62enum CursorState {CS_NONE, CS_ACTION, CS_SEQUENCE, CS_TALKING, CS_BUMPED};
63
64class Room {
65private:
66 RoomData *_roomData;
67 Screen &_screen;
68 uint16 _roomNumber;
69 uint16 _descId;
70 uint16 _hotspotId;
71 uint16 _hotspotNameId;
72 uint16 _destRoomNumber;
73 bool _isExit;
74 char _hotspotName[MAX_HOTSPOT_NAME_SIZE + MAX_ACTION_NAME_SIZE];
75 char _statusLine[MAX_DESC_SIZE];
76 HotspotData *_hotspot;
77 bool _showInfo;
78 uint8 _numLayers;
79 RoomLayer *_layers[MAX_NUM_LAYERS];
80 TalkDialog *_talkDialog;
81 int16 _talkDialogX, _talkDialogY;
82 CursorState _cursorState;
83
84 void checkRoomHotspots();
85 CursorType checkRoomExits();
86 void loadRoomHotspots();
87 void addAnimation(Hotspot &h);
88 void addLayers(Hotspot &h);
89 void addCell(int16 xp, int16 yp, int layerNum);
90 void blockMerge();
91 void layersPostProcess();
92public:
93 RoomPathsDecompressedData tempLayer;
94 Room();
95 ~Room();
96 static Room &getReference();
97
98 void update();
99 void nextFrame();
100 void checkCursor();
101 uint16 roomNumber() { return _roomNumber; }
102 void setRoomNumber(uint16 newRoomNumber, bool showOverlay = false);
103 void leaveRoom();
104 uint8 numLayers() { return _numLayers; }
105 uint16 hotspotId() { return _hotspotId; }
106 uint16 destRoomNumber() { return _destRoomNumber; }
107 uint16 isExit() { return _isExit; }
108 uint32 hotspotActions() { return _hotspot->actions & 0x10ffffff; }
109 uint8 hotspotFlags() { return (_hotspot->actions >> 24) & 0xfe; }
110 HotspotData &hotspot() { return *_hotspot; }
111 uint16 descId() { return _descId; }
112 bool showInfo() { return _showInfo; }
113 CursorState cursorState() { return _cursorState; }
114 void setShowInfo(bool value) { _showInfo = value; }
115 void setTalkDialog(uint16 srcCharacterId, uint16 destCharacterId, uint16 usedId, uint16 stringId);
116 TalkDialog *talkDialog() { return _talkDialog; }
117 void setCursorState(CursorState state) { _cursorState = state; }
118 bool isDialogActive() { return _talkDialog != NULL; }
119 bool isDialogShowing() {
120 Resources &res = Resources::getReference();
121 Hotspot *talkCharacter = res.getActiveHotspot(res.getTalkingCharacter());
122 return isDialogActive() && (talkCharacter != NULL) && (talkCharacter->roomNumber() == _roomNumber);
123 }
124 bool checkInTalkDialog();
125 char *statusLine() { return _statusLine; }
126 void saveToStream(Common::WriteStream *stream);
127 void loadFromStream(Common::ReadStream *stream);
128 void reset();
129};
130
131} // End of namespace Lure
132
133#endif
Definition: stream.h:385
Definition: stream.h:77
Definition: res_struct.h:513
Definition: hotspots.h:180
Definition: res.h:51
Definition: res_struct.h:313
Definition: room.h:64
Definition: room.h:44
Definition: screen.h:35
Definition: surface.h:35
Definition: surface.h:97
Definition: animseq.h:27