ScummVM API documentation
res.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_RES_H
23#define LURE_RES_H
24
25#include "lure/luredefs.h"
26#include "lure/memory.h"
27#include "lure/res_struct.h"
28#include "lure/hotspots.h"
29#include "lure/palette.h"
30
31#include "common/array.h"
32#include "common/file.h"
33#include "common/list.h"
34#include "common/random.h"
35
36namespace Lure {
37
38enum TalkState {TALK_NONE, TALK_START, TALK_SELECT, TALK_RESPOND, TALK_RESPONSE_WAIT,
39 TALK_RESPOND_2, TALK_RESPOND_3};
40
41#define MAX_TALK_SELECTIONS 4
42typedef TalkEntryData *TalkSelections[MAX_TALK_SELECTIONS];
43
45 Common::Rect bounds;
46 bool active;
47};
48
49#define NUM_GIVE_TALK_IDS 6
50
51class Resources {
52private:
54 Palette *_paletteSubset;
55 MemoryBlock *_cursors;
56 RoomDataList _roomData;
57 HotspotDataList _hotspotData;
58 HotspotOverrideList _hotspotOverrides;
59 HotspotAnimList _animData;
60 MemoryBlock *_scriptData;
61 MemoryBlock *_script2Data;
62 MemoryBlock *_messagesData;
63 uint16 *_hotspotScriptData;
64 RoomExitJoinList _exitJoins;
65 HotspotList _activeHotspots;
66 ValueTableData _fieldList;
67 HotspotActionSet _actionsList;
68 TalkHeaderList _talkHeaders;
69 TalkDataList _talkData;
70 Common::Array<uint16> _giveTalkIds;
71 SequenceDelayList _delayList;
72 Action _currentAction;
73 MemoryBlock *_talkDialogData;
74 RoomExitCoordinatesList _coordinateList;
75 CharacterScheduleList _charSchedules;
76 RandomActionList _randomActions;
77 RoomExitIndexedHotspotList _indexedRoomExitHospots;
78 PausedCharacterList _pausedList;
79 BarmanLists _barmanLists;
80 StringList _stringList;
81
82 int numCharOffsets;
83 uint16 *_charOffsets;
84
85 TalkData *_activeTalkData;
86 TalkState _talkState;
87 TalkSelections _talkSelections;
88 TalkDialogDetails _talkDetails;
89 int _talkSelection;
90 int _talkStartEntry;
91 uint16 _talkingCharacter;
92 byte _cursor[CURSOR_WIDTH * CURSOR_HEIGHT];
93
94 void reloadData();
95 void freeData();
96public:
97 Resources();
98 ~Resources();
99 static Resources &getReference();
100 void reset();
101
102 RoomDataList &roomData() { return _roomData; }
103 RoomData *getRoom(uint16 roomNumber);
104 bool checkHotspotExtent(HotspotData *hotspot);
105 void insertPaletteSubset(Palette &p);
106 byte *getCursor(uint8 cursorNum);
107 HotspotDataList &hotspotData() { return _hotspotData; }
108 HotspotOverrideList &hotspotOverrides() { return _hotspotOverrides; }
109 HotspotAnimList &animRecords() { return _animData; }
110 MemoryBlock *scriptData() { return _scriptData; }
111 MemoryBlock *hotspotScriptData() { return _script2Data; }
112 MemoryBlock *messagesData() { return _messagesData; }
113 uint16 getHotspotScript(uint16 index);
114 HotspotList &activeHotspots() { return _activeHotspots; }
115 uint16 getRandom() { return _rnd.getRandomNumber(0xffff); }
116 HotspotData *getHotspot(uint16 hotspotId);
117 Hotspot *getActiveHotspot(uint16 hotspotId);
118 HotspotOverrideData *getHotspotOverride(uint16 hotspotId);
119 HotspotAnimData *getAnimation(uint16 animRecordId);
120 int getAnimationIndex(HotspotAnimData *animData);
121 RoomExitJoinList &exitJoins() { return _exitJoins; }
122 RoomExitJoinData *getExitJoin(uint16 hotspotId);
123 uint16 getHotspotAction(uint16 actionsOffset, Action action);
124 HotspotActionList *getHotspotActions(uint16 actionsOffset);
125 TalkHeaderData *getTalkHeader(uint16 hotspotId);
126 ValueTableData &fieldList() { return _fieldList; }
127 SequenceDelayList &delayList() { return _delayList; }
128 MemoryBlock &getTalkDialogData() { return *_talkDialogData; }
129 RoomExitCoordinatesList &coordinateList() { return _coordinateList; }
130 CharacterScheduleList &charSchedules() { return _charSchedules; }
131 RandomActionList &randomActions() { return _randomActions; }
132 RoomExitIndexedHotspotList &exitHotspots() { return _indexedRoomExitHospots; }
133 PausedCharacterList &pausedList() { return _pausedList; }
134 BarmanLists &barmanLists() { return _barmanLists; }
135 StringList &stringList() { return _stringList; }
136 uint16 getCharOffset(int index) {
137 if (index >= numCharOffsets)
138 error("Invalid index %d passed to script engine support data offset list", index);
139 if (index == 1)
140 error("support data list index #1 was referenced - special handlng TODO");
141 return _charOffsets[index];
142 }
143 void copyCursorTo(Surface *s, uint8 cursorNum, int16 x, int16 y);
144
145 uint16 numInventoryItems();
146 void setTalkData(uint16 offset);
147 TalkData *getTalkData() { return _activeTalkData; }
148 void setTalkState(TalkState state) { _talkState = state; }
149 TalkState getTalkState() { return _talkState; }
150 TalkSelections &getTalkSelections() { return _talkSelections; }
151 TalkDialogDetails &getTalkDetails() { return _talkDetails; }
152 void setTalkSelection(int index) { _talkSelection = index; }
153 int getTalkSelection() { return _talkSelection; }
154 void setTalkStartEntry(int index) { _talkStartEntry = index; }
155 int getTalkStartEntry() { return _talkStartEntry; }
156 uint16 getTalkingCharacter() { return _talkingCharacter; }
157 void setTalkingCharacter(uint16 index);
158 uint16 getGiveTalkId(uint16 index) {
159 if (index >= _giveTalkIds.size())
160 error("Invalid give talk id specified");
161 return _giveTalkIds[index];
162 }
163 void setCurrentAction(Action action) { _currentAction = action; }
164 Action getCurrentAction() { return _currentAction; }
165 const char *getCurrentActionStr() {
166 if (_currentAction > EXAMINE)
167 error("Invalid current action %d", _currentAction);
168 return _stringList.getString(_currentAction);
169 }
170 Hotspot *activateHotspot(uint16 hotspotId);
171 Hotspot *addHotspot(uint16 hotspotId);
172 void addHotspot(Hotspot *hotspot);
173 void deactivateHotspot(uint16 hotspotId, bool isDestId = false);
174 void deactivateHotspot(Hotspot *hotspot);
175 void saveToStream(Common::WriteStream *stream);
176 void loadFromStream(Common::ReadStream *stream);
177};
178
179} // End of namespace Lure
180
181#endif
size_type size() const
Definition: array.h:316
Definition: random.h:44
uint getRandomNumber(uint max)
Definition: stream.h:385
Definition: stream.h:77
Definition: res_struct.h:824
Definition: res_struct.h:742
Definition: res_struct.h:372
Definition: res_struct.h:380
Definition: res_struct.h:607
Definition: res_struct.h:513
Definition: res_struct.h:576
Definition: hotspots.h:180
Definition: hotspots.h:486
Definition: res_struct.h:582
Definition: memory.h:31
Definition: palette.h:33
Definition: res_struct.h:798
Definition: res_struct.h:779
Definition: res.h:51
Definition: res_struct.h:313
Definition: res_struct.h:335
Definition: res_struct.h:686
Definition: res_struct.h:700
Definition: res_struct.h:349
Definition: res_struct.h:358
Definition: res_struct.h:719
Definition: res_struct.h:851
Definition: surface.h:35
Definition: res_struct.h:652
Definition: res_struct.h:664
Definition: res_struct.h:627
Definition: res_struct.h:898
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: animseq.h:27
Definition: rect.h:536
Definition: res.h:44