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:
186  void load(Resource *resource) override;
187  void unload() override;
188  void pause() override;
189  void unpause() override;
190 public:
191  IllusionsEngine *_vm;
192  uint32 _sceneId;
193  int _pauseCtr;
194  BackgroundResource *_bgRes;
195  Common::Point _panPoints[kMaxBackgroundItemSurfaces];
196  Graphics::Surface *_surfaces[kMaxBackgroundItemSurfaces];
197  CameraState _savedCameraState;
198  byte *_savedPalette;
199  void registerResources();
200  void unregisterResources();
201  void initSurface();
202  void freeSurface();
203  void drawTiles(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
204  void drawTiles8(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
205  void drawTiles16(Graphics::Surface *surface, TileMap &tileMap, byte *tilePixels);
206 };
207 
209 public:
212  BackgroundInstance *createBackgroundInstance(Resource *resource);
213  void removeBackgroundInstance(BackgroundInstance *backgroundInstance);
214  void pauseBySceneId(uint32 sceneId);
215  void unpauseBySceneId(uint32 sceneId);
216  BackgroundInstance *findActiveBackgroundInstance();
217  BackgroundInstance *findBackgroundByResource(BackgroundResource *backgroundResource);
218  BackgroundResource *getActiveBgResource();
219  WidthHeight getMasterBgDimensions();
220  void refreshPan();
221  bool findActiveBackgroundNamedPoint(uint32 namedPointId, Common::Point &pt);
222 //protected:
223 public:
226  IllusionsEngine *_vm;
227  Items _items;
228 };
229 
230 } // End of namespace Illusions
231 
232 #endif // ILLUSIONS_BACKGROUNDRESOURCE_H
Definition: backgroundresource.h:208
Definition: backgroundresource.h:91
Definition: surface.h:66
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:80
Definition: backgroundresource.h:111