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