ScummVM API documentation
gfx.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 NGI_GFX_H
23 #define NGI_GFX_H
24 
25 #include "common/ptr.h"
26 
27 namespace Graphics {
28  struct Surface;
29  class ManagedSurface;
30 }
31 
32 namespace NGI {
33 
34 class DynamicPhase;
35 class Movement;
36 struct PicAniInfo;
37 
38 typedef Common::Point Dims;
39 
40 struct Bitmap {
41  int _x;
42  int _y;
43  int _width;
44  int _height;
45  int _type;
46  int _dataSize;
47  int _flags;
48  int _flipping;
49  Graphics::ManagedSurface *_surface;
51 
52  Bitmap();
53  Bitmap(const Bitmap &src);
54  ~Bitmap();
55 
56  void load(Common::ReadStream *s);
57  void decode(byte *pixels, const Palette &palette);
58  void putDib(int x, int y, const Palette &palette, byte alpha);
59  void putDibRB(byte *pixels, const Palette &palette);
60  void putDibCB(byte *pixels, const Palette &palette);
61 
62  void convertPalette(const Palette &palette);
63 
64  void colorFill(uint8 *dest, uint8 *mask, byte color, int len);
65  void paletteFill(uint8 *dest, uint8 *mask, byte *src, int len);
66  void copier8(uint8 *dest, byte *src, int len);
67  void copier16(uint16 *dest, byte *src, int len);
68 
70  Bitmap *reverseImage(bool flip = true) const;
72  Bitmap *flipVertical() const;
73 
74  void drawShaded(int type, int x, int y, const Palette &palette, int alpha);
75  void drawRotated(int x, int y, int angle, const Palette &palette, int alpha);
76 
77  bool isPixelHitAtPos(int x, int y);
78 
79 private:
80  Bitmap operator=(const Bitmap &);
81 };
82 
83 class Picture : public MemoryObject {
84 public:
85  Picture();
86  ~Picture() override;
87 
88  void freePicture();
89  void freePixelData();
90 
91  bool load(MfcArchive &file) override;
92  void setAOIDs();
93  virtual void init();
94  void getDibInfo();
95  const Bitmap *getPixelData();
96  virtual void draw(int x, int y, int style, int angle);
97  void drawRotated(int x, int y, int angle);
98 
99  byte getAlpha() { return (byte)_alpha; }
100  void setAlpha(byte alpha) { _alpha = alpha; }
101 
102  Dims getDimensions() const { return Dims(_width, _height); }
103  bool isPointInside(int x, int y);
104  bool isPixelHitAtPos(int x, int y);
105  int getPixelAtPos(int x, int y);
106  int getPixelAtPosEx(int x, int y);
107 
108  const Bitmap *getConvertedBitmap() const { return _convertedBitmap.get(); }
109  const Palette &getPaletteData() const { return _paletteData; }
110  void setPaletteData(const Palette &pal);
111 
112  void copyMemoryObject2(Picture &src);
113 
114  int _x, _y;
115 
116 protected:
117  Common::Rect _rect;
118  Common::ScopedPtr<Bitmap> _convertedBitmap;
119  int _field_44;
120  int _width;
121  int _height;
123  int _field_54;
124  Common::ScopedPtr<MemoryObject2> _memoryObject2;
125  int _alpha;
126  Palette _paletteData;
127 
128  void displayPicture();
129 };
130 
131 class BigPicture : public Picture {
132  public:
133  BigPicture() {}
134  ~BigPicture() override {}
135 
136  bool load(MfcArchive &file) override;
137  void draw(int x, int y, int style, int angle) override;
138 };
139 
140 class GameObject : public CObject {
141  public:
142  int16 _odelay;
143  int _field_8;
144  int16 _flags;
145  int16 _id;
146  Common::String _objectName;
147  int _ox;
148  int _oy;
149  int _priority;
150  int _field_20;
151 
152  public:
153  GameObject();
154  GameObject(GameObject *src);
155 
156  virtual Common::String toXML();
157  bool load(MfcArchive &file) override;
158  void setOXY(int x, int y);
159  void renumPictures(Common::Array<StaticANIObject *> *lst);
160  void renumPictures(Common::Array<PictureObject *> *lst);
161  void setFlags(int16 flags) { _flags = flags; }
162  void clearFlags() { _flags = 0; }
163  Common::String getName() { return _objectName; }
164 
165  bool getPicAniInfo(PicAniInfo &info);
166  bool setPicAniInfo(const PicAniInfo &info);
167 };
168 
169 class PictureObject : public GameObject {
170 public:
171  PictureObject();
172  ~PictureObject();
173 
175 
176  virtual bool load(MfcArchive &file, bool bigPicture);
177  bool load(MfcArchive &file) override { assert(0); return false; } // Disable base class
178 
179  Dims getDimensions() const { return _picture->getDimensions(); }
180  void draw();
181  void drawAt(int x, int y);
182 
183  bool setPicAniInfo(const PicAniInfo &picAniInfo);
184  bool isPointInside(int x, int y);
185  bool isPixelHitAtPos(int x, int y);
186  void setOXY2();
187 
188  Picture *_picture;
189 
190 private:
191  Common::Array<GameObject> _pictureObject2List;
192  int _ox2;
193  int _oy2;
194 };
195 
196 class Background : public CObject {
197 public:
200 
201  Common::String _bgname;
202  int _x;
203  int _y;
204  int16 _messageQueueId;
205  Palette _palette;
208  uint _bigPictureXDim;
209  uint _bigPictureYDim;
210 
211 public:
212  Background();
213  ~Background() override;
214 
215  bool load(MfcArchive &file) override;
216  void addPictureObject(PictureObject *pct);
217 
218  BigPicture *getBigPicture(int x, int y) { return _bigPictureArray[y * _bigPictureXDim + x]; }
219 };
220 
221 struct ShadowsItem {
222  int width;
223  int height;
224  DynamicPhase *dynPhase;
225 };
226 
228 
229 class Shadows : public CObject {
230  int _sceneId;
231  int _staticAniObjectId;
232  int _movementId;
233  ShadowsItemArray _items;
234 
235  public:
236  Shadows();
237  bool load(MfcArchive &file) override;
238  void init();
239 
240  void initMovement(Movement *mov);
241  DynamicPhase *findSize(int width, int height);
242 };
243 
244 } // End of namespace NGI
245 
246 #endif /* NGI_GFX_H */
Definition: managed_surface.h:51
Definition: gfx.h:196
Definition: gfx.h:140
Definition: str.h:59
Definition: utils.h:39
Common::Array< BigPicture * > _bigPictureArray
Definition: gfx.h:207
Definition: array.h:52
Definition: statics.h:67
Definition: rect.h:524
Definition: objects.h:45
Definition: statics.h:107
Definition: gfx.h:169
Definition: ptr.h:572
Definition: gfx.h:131
Definition: gfx.h:83
Definition: formatinfo.h:28
Definition: rect.h:144
Movement
Definition: walking.h:85
Definition: gfx.h:40
Definition: gfx.h:229
Definition: stream.h:385
Definition: ngi.h:103
Definition: anihandler.h:25
Definition: utils.h:139
Definition: gfx.h:221
Definition: utils.h:106
Common::Array< PictureObject * > _picObjList
Definition: gfx.h:199