ScummVM API documentation
resource.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 NEVERHOOD_RESOURCE_H
23#define NEVERHOOD_RESOURCE_H
24
25#include "common/str.h"
26#include "neverhood/neverhood.h"
27#include "neverhood/graphics.h"
28#include "neverhood/staticdata.h"
29#include "neverhood/resourceman.h"
30
31namespace Neverhood {
32
33enum {
34 kResTypeBitmap = 2,
35 kResTypePalette = 3,
36 kResTypeAnimation = 4,
37 kResTypeData = 5,
38 kResTypeText = 6,
39 kResTypeSound = 7,
40 kResTypeMusic = 8,
41 kResTypeVideo = 10
42};
43
44enum {
45 kResNhcTypeSubFont = 11,
46 kResNhcTypeMessages = 12,
47 kResNhcTypeSubtitles = 13
48};
49
50
52public:
55 void draw(Graphics::Surface *destSurface, bool flipX, bool flipY);
56 bool load(uint32 fileHash, bool doLoadPosition = false);
57 void unload();
58 const NDimensions& getDimensions() { return _dimensions; }
59 NPoint& getPosition() { return _position; }
60 bool isRle() const { return _rle; }
61 const byte *getPixels() const { return _pixels; }
62protected:
63 NeverhoodEngine *_vm;
64 ResourceHandle _resourceHandle;
65 NDimensions _dimensions;
66 NPoint _position;
67 const byte *_pixels;
68 bool _rle;
69};
70
72public:
75 bool load(uint32 fileHash);
76 void unload();
77 void copyPalette(byte *destPalette);
78 const byte *palette() { return _palette; }
79protected:
80 NeverhoodEngine *_vm;
81 ResourceHandle _resourceHandle;
82 const byte *_palette;
83};
84
86 uint32 frameHash;
87 int16 counter;
88 NDrawRect drawOffset;
89 int16 deltaX, deltaY;
90 NDrawRect collisionBoundsOffset;
91 uint32 spriteDataOffs;
92};
93
95public:
98 void draw(uint frameIndex, Graphics::Surface *destSurface, bool flipX, bool flipY);
99 bool load(uint32 fileHash);
100 void unload();
101 void clear();
102 uint getFrameCount() const { return _frames.size(); }
103 const AnimFrameInfo& getFrameInfo(int16 index) const { return _frames[index]; }
104 int16 getFrameIndex(uint32 frameHash);
105 void setReplEnabled(bool value) { _replEnabled = value; }
106 void setRepl(byte oldColor, byte newColor);
107 NDimensions loadSpriteDimensions(uint32 fileHash);
108protected:
109 NeverhoodEngine *_vm;
110 ResourceHandle _resourceHandle;
111 int16 _width, _height;
112 const byte *_currSpriteData;
113 uint32 _fileHash;
114 const byte *_paletteData;
115 const byte *_spriteData;
116 bool _replEnabled;
117 byte _replOldColor;
118 byte _replNewColor;
120};
121
123public:
125 void load(uint32 fileHash);
126 void unload();
127 NDrawRect& getRect();
128 void draw(int frameNum, Graphics::Surface *destSurface);
129 int getCursorNum() const { return _cursorNum; }
130 void setCursorNum(int cursorNum) { _cursorNum = cursorNum; }
131protected:
132 int _cursorNum;
133 SpriteResource _cursorSprite;
134 NDrawRect _rect;
135 uint32 _currFileHash;
136};
137
139public:
142 void load(uint32 fileHash);
143 void unload();
144 const char *getString(uint index, const char *&textEnd);
145 uint getCount() const { return _count;}
146protected:
147 NeverhoodEngine *_vm;
148 ResourceHandle _resourceHandle;
149 const byte *_textData;
150 uint _count;
151};
152
153/* DataResource
154 1 Single NPoint
155 2 Array of NPoints
156 3 Array of NRects
157 4 MessageList
158 5 SubRectList
159 6 RectList
160*/
161
163public:
166 void load(uint32 fileHash);
167 void unload();
168 NPoint getPoint(uint32 nameHash);
169 NPointArray *getPointArray(uint32 nameHash);
170 NRectArray *getRectArray(uint32 nameHash);
171 HitRectList *getHitRectList();
172 MessageList *getMessageListAtPos(int16 klaymenX, int16 klaymenY, int16 mouseX, int16 mouseY);
173protected:
174
176 uint32 nameHash;
177 uint16 offset;
178 uint16 type;
179 };
180
181 struct DRRect {
182 NRect rect;
183 uint16 subRectIndex;
184 };
185
186 struct DRSubRect {
187 NRect rect;
188 uint32 messageListHash;
189 uint16 messageListItemIndex;
190 };
191
193
194 NeverhoodEngine *_vm;
195 ResourceHandle _resourceHandle;
197 Common::Array<NPoint> _points;
198 Common::Array<NPointArray*> _pointArrays;
199 Common::Array<NRectArray*> _rectArrays;
200 Common::Array<HitRectList*> _hitRectLists;
201 Common::Array<MessageList*> _messageLists;
202 Common::Array<DRRect> _drRects;
203 Common::Array<DRSubRectList*> _drSubRectLists;
204 DataResource::DRDirectoryItem *findDRDirectoryItem(uint32 nameHash, uint16 type);
205};
206
207uint32 calcHash(const char *value);
208
209} // End of namespace Neverhood
210
211#endif /* NEVERHOOD_RESOURCE_H */
Definition: array.h:52
Definition: resource.h:94
Definition: resource.h:162
Definition: resource.h:122
Definition: neverhood.h:69
Definition: resource.h:71
Definition: resource.h:51
Definition: resource.h:138
Definition: surface.h:67
Definition: resource.h:85
Definition: resource.h:181
Definition: resource.h:186
Definition: graphics.h:38
Definition: graphics.h:67
Definition: graphics.h:32
Definition: graphics.h:42
Definition: resourceman.h:64