ScummVM API documentation
myst_card.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 MYST_CARD_H
23#define MYST_CARD_H
24
25#include "common/rect.h"
26
27#include "mohawk/myst.h"
28
29namespace Mohawk {
30
39class MystCard {
40public:
41 MystCard(MohawkEngine_Myst *vm, uint16 id);
42 ~MystCard();
43
45 uint16 getId() const;
46
48 void enter();
49
51 void leave();
52
54 template<class T>
55 T *getResource(uint index);
56
59
61 void setResourceEnabled(uint16 resourceIndex, bool enable);
62
65
68
75
83
90 void updateResourcesForInput(const Common::Point &mouse, bool mouseClicked, bool mouseMoved);
91
93 bool isDraggingResource() const;
94
97
100
103
106
108 void redrawArea(uint16 var, bool updateScreen = true);
109
110private:
111 // View flags
112 enum {
113 kMystZipDestination = (1 << 0)
114 };
115
116 struct MystCursorHint {
117 uint16 id;
118 int16 cursor;
119
120 MystCondition variableHint;
121 };
122
123 MohawkEngine_Myst *_vm;
124
125 // General card data
126 uint16 _id;
127 uint16 _flags;
128
129 // Image Data
130 Common::Array<MystCondition> _conditionalImages;
131 uint16 _mainImage;
132
133 // Sound Data
134 MystSoundBlock _soundBlock;
135
136 // Script Resources
137 enum ScriptResourceType {
138 kResourceImage = 1,
139 kResourceSound = 2,
140 kResourceSwitch = 3,
141 kResourceImageNoCache = 4,
142 kResourceSoundNoCache = 5
143 };
144
145 struct ScriptResource {
146 ScriptResourceType type;
147 uint16 id;
148 uint16 switchVar;
149 ScriptResourceType switchResourceType;
150 Common::Array<int16> switchResourceIds;
151 };
152 Common::Array<ScriptResource> _scriptResources;
153
154 uint16 _resourceListId;
155 uint16 _hintResourceId;
156 uint16 _initScriptId;
157 uint16 _exitScriptId;
158
160
162 MystAreaHover *_hoverResource;
163
165 MystArea *_activeResource;
166
168 MystArea *_clickedResource;
169
170 void loadView();
171 void loadResources();
172 void loadCursorHints();
173
174 void runInitScript();
175 void runExitScript();
176};
177
178template<class T>
179T *MystCard::getResource(uint index) {
180 T *resource = dynamic_cast<T *>(_resources[index]);
181
182 if (!resource) {
183 error("View resource '%d' has unexpected type", index);
184 }
185
186 return resource;
187}
188
189} // End of namespace Mohawk
190
191#endif
Definition: array.h:52
Definition: myst.h:129
Definition: myst_areas.h:59
Definition: myst_card.h:39
uint16 getBackgroundImageId()
bool isDraggingResource() const
void updateResourcesForInput(const Common::Point &mouse, bool mouseClicked, bool mouseMoved)
void resetClickedResource()
void setResourceEnabled(uint16 resourceIndex, bool enable)
int16 getActiveResourceCursor()
MystArea * forceUpdateClickedResource(const Common::Point &mouse)
T * getResource(uint index)
Definition: myst_card.h:179
void updateActiveResource(const Common::Point &mouse)
void drawResourceRects()
Common::Array< MystArea * > _resources
Definition: myst_card.h:58
void drawResourceImages()
void redrawArea(uint16 var, bool updateScreen=true)
uint16 getId() const
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: bitmap.h:32
Definition: rect.h:144
Definition: myst.h:100