ScummVM API documentation
sprites.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 ULTIMA_SPRITES_H
23 #define ULTIMA_SPRITES_H
24 
25 #include "common/array.h"
26 #include "common/path.h"
27 #include "graphics/managed_surface.h"
28 #include "ultima/shared/core/rect.h"
29 
30 namespace Ultima {
31 namespace Shared {
32 namespace Gfx {
33 
34 class Sprite {
35 private:
36  Graphics::ManagedSurface _surface;
37  Graphics::ManagedSurface _transSurface;
38 public:
42  Sprite();
43 
47  Sprite(const Sprite &src);
48 
56  Sprite(const byte *src, uint bpp, uint16 w = 16, uint16 h = 16);
57 
61  Sprite &operator=(const Sprite &src);
62 
66  void draw(Graphics::ManagedSurface &dest, const Common::Point &pt);
67 
71  uint16 w() const { return _surface.w; }
72 
76  uint16 h() const { return _surface.h; }
77 
81  byte *getPixels() { return (byte *)_surface.getPixels(); }
82 
86  byte *getBasePtr(int16 x, int16 y) { return (byte *)_surface.getBasePtr(x, y); }
87 
91  const byte *getBasePtr(int16 x, int16 y) const { return (const byte *)_surface.getBasePtr(x, y); }
92 };
93 
94 class Sprites {
95 protected:
97  Point _spriteSize; // Size of individual sprites
98 protected:
106  void load(const Common::Path &name, uint bpp, uint16 w = 16, uint16 h = 16);
107 public:
111  virtual ~Sprites() {}
112 
116  Point getSpriteSize() const { return _spriteSize; }
117 
121  size_t size() const { return _data.size(); }
122 
126  bool empty() const { return size() == 0; }
127 
131  virtual Sprite &operator[](uint idx) { return _data[idx]; }
132 };
133 
134 } // End of namespace Gfx
135 } // End of namespace Shared
136 } // End of namespace Ultima
137 
138 #endif
Definition: managed_surface.h:51
size_t size() const
Definition: sprites.h:121
byte * getPixels()
Definition: sprites.h:81
int16 & w
Definition: managed_surface.h:117
const byte * getBasePtr(int16 x, int16 y) const
Definition: sprites.h:91
Definition: array.h:52
Definition: sprites.h:34
const void * getBasePtr(int x, int y) const
Definition: managed_surface.h:250
virtual ~Sprites()
Definition: sprites.h:111
Sprite & operator=(const Sprite &src)
Definition: path.h:52
Definition: detection.h:27
int16 & h
Definition: managed_surface.h:118
Definition: sprites.h:94
void * getPixels()
Definition: managed_surface.h:269
Definition: rect.h:45
Point getSpriteSize() const
Definition: sprites.h:116
size_type size() const
Definition: array.h:315
byte * getBasePtr(int16 x, int16 y)
Definition: sprites.h:86
uint16 h() const
Definition: sprites.h:76
bool empty() const
Definition: sprites.h:126
virtual Sprite & operator[](uint idx)
Definition: sprites.h:131
void draw(Graphics::ManagedSurface &dest, const Common::Point &pt)
uint16 w() const
Definition: sprites.h:71