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 
29 namespace Mohawk {
30 
39 class MystCard {
40 public:
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 
64  void updateActiveResource(const Common::Point &mouse);
65 
68 
74  void resetClickedResource();
75 
83 
90  void updateResourcesForInput(const Common::Point &mouse, bool mouseClicked, bool mouseMoved);
91 
93  bool isDraggingResource() const;
94 
96  uint16 getBackgroundImageId();
97 
99  void drawBackground();
100 
102  void drawResourceImages();
103 
105  void drawResourceRects();
106 
108  void redrawArea(uint16 var, bool updateScreen = true);
109 
110 private:
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 
159  Common::Array<MystCursorHint> _cursorHints;
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 
178 template<class T>
179 T *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
Common::Array< MystArea * > _resources
Definition: myst_card.h:58
Definition: myst_areas.h:253
Definition: array.h:52
void setResourceEnabled(uint16 resourceIndex, bool enable)
Definition: myst.h:100
uint16 getBackgroundImageId()
uint16 getId() const
void drawResourceRects()
int16 getActiveResourceCursor()
Definition: myst.h:129
void updateActiveResource(const Common::Point &mouse)
void redrawArea(uint16 var, bool updateScreen=true)
T * getResource(uint index)
Definition: myst_card.h:179
Definition: rect.h:45
Definition: myst.h:105
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: myst_areas.h:59
MystArea * forceUpdateClickedResource(const Common::Point &mouse)
bool isDraggingResource() const
Definition: myst_card.h:39
void updateResourcesForInput(const Common::Point &mouse, bool mouseClicked, bool mouseMoved)
void resetClickedResource()
void drawResourceImages()
Definition: bitmap.h:32