ScummVM API documentation
backgroundresource.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 ILLUSIONS_BACKGROUNDRESOURCE_H
23 #define ILLUSIONS_BACKGROUNDRESOURCE_H
24 
25 #include "illusions/camera.h"
26 #include "illusions/graphics.h"
27 #include "illusions/pathfinder.h"
28 #include "illusions/resourcesystem.h"
29 #include "graphics/surface.h"
30 
31 #include "common/array.h"
32 #include "common/file.h"
33 #include "common/list.h"
34 #include "common/memstream.h"
35 #include "common/rect.h"
36 #include "common/substream.h"
37 #include "common/system.h"
38 
39 namespace Illusions {
40 
41 class IllusionsEngine;
42 struct Sequence;
43 
45 public:
47  ~BackgroundResourceLoader() override {}
48  void load(Resource *resource) override;
49  bool isFlag(int flag) override;
50 protected:
51  IllusionsEngine *_vm;
52 };
53 
54 struct TileMap {
55  int16 _width, _height;
56  //field_4 dd
57  byte *_map;
58  void load(byte *dataStart, Common::SeekableReadStream &stream);
59 };
60 
61 struct BgInfo {
62  uint32 _flags;
63  //field_4 dw
64  int16 _priorityBase;
65  SurfInfo _surfInfo;
66  Common::Point _panPoint;
67  TileMap _tileMap;
68  byte *_tilePixels;
69  void load(byte *dataStart, Common::SeekableReadStream &stream);
70 };
71 
73 public:
74  void load(byte *dataStart, Common::SeekableReadStream &stream);
75  int getPriority(Common::Point pos);
76 protected:
77  int16 _width, _height;
78  int16 _mapWidth, _mapHeight;
79  byte *_map, *_values;
80 };
81 
82 class ScaleLayer {
83 public:
84  void load(byte *dataStart, Common::SeekableReadStream &stream);
85  int getScale(Common::Point pos);
86 protected:
87  int16 _height;
88  byte *_values;
89 };
90 
91 class RegionLayer {
92 public:
93  void load(byte *dataStart, Common::SeekableReadStream &stream);
94  int getRegionIndex(Common::Point pos);
95  uint32 getRegionSequenceId(int regionIndex);
96 protected:
97  uint32 _unk;
98  byte *_regionSequenceIds;
99  int16 _width, _height;
100  int16 _mapWidth, _mapHeight;
101  byte *_map, *_values;
102 };
103 
104 struct Palette {
105  uint16 _count;
106  uint16 _unk;
107  byte *_palette;
108  void load(byte *dataStart, Common::SeekableReadStream &stream);
109 };
110 
112  uint32 _objectId;
113  uint16 _flags;
114  int16 _priority;
115  byte *_pointsConfig;
116  void load(byte *dataStart, Common::SeekableReadStream &stream);
117 };
118 
120  PointArray *_points;
121  PathWalkPoints() : _points(0) {}
122  ~PathWalkPoints() { delete _points; }
123  void load(byte *dataStart, Common::SeekableReadStream &stream);
124 };
125 
127  PathLines *_rects;
128  PathWalkRects() : _rects(0) {}
129  ~PathWalkRects() { delete _rects; }
130  void load(byte *dataStart, Common::SeekableReadStream &stream);
131 };
132 
134 public:
137  void load(byte *data, uint32 dataSize);
138  int findMasterBgIndex();
139  PriorityLayer *getPriorityLayer(uint index);
140  ScaleLayer *getScaleLayer(uint index);
141  RegionLayer *getRegionLayer(uint index);
142  PathWalkPoints *getPathWalkPoints(uint index);
143  PathWalkRects *getPathWalkRects(uint index);
144  Palette *getPalette(uint index);
145  bool findNamedPoint(uint32 namedPointId, Common::Point &pt);
146 public:
147 
148  uint _paletteIndex;
149 
150  uint _bgInfosCount;
151  BgInfo *_bgInfos;
152 
153  uint _priorityLayersCount;
154  PriorityLayer *_priorityLayers;
155 
156  uint _scaleLayersCount;
157  ScaleLayer *_scaleLayers;
158 
159  uint _regionLayersCount;
160  RegionLayer *_regionLayers;
161 
162  uint _regionSequencesCount;
163  Sequence *_regionSequences;
164 
165  uint _backgroundObjectsCount;
166  BackgroundObject *_backgroundObjects;
167 
168  uint _pathWalkPointsCount;
169  PathWalkPoints *_pathWalkPoints;
170 
171  uint _pathWalkRectsCount;
172  PathWalkRects *_pathWalkRects;
173 
174  NamedPoints _namedPoints;
175 
176  uint _palettesCount;
177  Palette *_palettes;
178 
179 };
180 
181 const uint kMaxBackgroundItemSurfaces = 3;
182 
184 public:
187  void load(Resource *resource) override;
188  void unload() override;
189  void pause() override;
190  void unpause() override;
191 public:
192  IllusionsEngine *_vm;
193  uint32 _sceneId;
194  int _pauseCtr;
195  BackgroundResource *_bgRes;
196  Common::Point _panPoints[kMaxBackgroundItemSurfaces];
197  Graphics::Surface *_surfaces[kMaxBackgroundItemSurfaces];
198  CameraState _savedCameraState;
199  byte *_savedPalette;
200  void registerResources();
201  void unregisterResources();
202  void initSurface();
203  void freeSurface();
204  void drawTiles(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
205  void drawTiles8(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
206  void drawTiles16(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
207 };
208 
210 public:
213  BackgroundInstance *createBackgroundInstance(Resource *resource);
214  void removeBackgroundInstance(BackgroundInstance *backgroundInstance);
215  void pauseBySceneId(uint32 sceneId);
216  void unpauseBySceneId(uint32 sceneId);
217  BackgroundInstance *findActiveBackgroundInstance();
218  BackgroundInstance *findBackgroundByResource(BackgroundResource *backgroundResource);
219  BackgroundResource *getActiveBgResource();
220  WidthHeight getMasterBgDimensions();
221  void refreshPan();
222  bool findActiveBackgroundNamedPoint(uint32 namedPointId, Common::Point &pt);
223 //protected:
224 public:
227  IllusionsEngine *_vm;
228  Items _items;
229 };
230 
231 } // End of namespace Illusions
232 
233 #endif // ILLUSIONS_BACKGROUNDRESOURCE_H
Definition: backgroundresource.h:209
Definition: backgroundresource.h:91
Definition: surface.h:67
Definition: backgroundresource.h:82
Definition: graphics.h:59
Definition: actor.h:34
Definition: stream.h:745
Definition: backgroundresource.h:104
Definition: resourcesystem.h:51
Definition: backgroundresource.h:119
Definition: graphics.h:38
Definition: graphics.h:31
Definition: backgroundresource.h:126
Definition: backgroundresource.h:72
Definition: camera.h:33
Definition: rect.h:45
Definition: backgroundresource.h:133
Definition: resourcesystem.h:42
Definition: resourcesystem.h:78
Definition: actorresource.h:51
Definition: list_intern.h:51
Definition: backgroundresource.h:183
Definition: backgroundresource.h:61
Definition: backgroundresource.h:44
Definition: backgroundresource.h:54
Definition: illusions.h:92
Definition: backgroundresource.h:111