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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef CRYOMNI3D_SPRITES_H
24 #define CRYOMNI3D_SPRITES_H
25 
26 #include "common/array.h"
27 #include "common/str.h"
28 
29 #include "graphics/cursor.h"
30 
31 namespace Common {
32 class ReadStream;
33 }
34 
35 namespace Graphics {
36 struct Surface;
37 }
38 
39 namespace CryOmni3D {
40 
41 class Sprites {
42 public:
43 	Sprites();
44 	virtual ~Sprites();
45 
46 	void loadSprites(Common::ReadStream &spr_fl);
47 	void setupMapTable(const uint *table, uint size);
48 
49 	void setSpriteHotspot(uint spriteId, uint x, uint y);
50 
51 	void replaceSprite(uint oldSpriteId, uint newSpriteId);
52 
53 	uint getSpritesCount() const;
54 
55 	void replaceSpriteColor(uint spriteId, byte currentColor, byte newColor);
56 
57 	const Graphics::Surface &getSurface(uint spriteId) const;
58 	const Graphics::Cursor &getCursor(uint spriteId) const;
59 
60 	uint revMapSpriteId(uint id) const;
61 	uint calculateSpriteId(uint baseId, uint offset) const;
62 
getKeyColor(uint spriteId)63 	byte getKeyColor(uint spriteId) const { return 0; }
64 
65 private:
66 	class CryoCursor : public Graphics::Cursor {
67 	public:
getWidth()68 		uint16 getWidth() const override { return _width; }
getHeight()69 		uint16 getHeight() const override { return _height; }
getHotspotX()70 		uint16 getHotspotX() const override { return _offX; }
getHotspotY()71 		uint16 getHotspotY() const override { return _offY; }
getKeyColor()72 		byte getKeyColor() const override { return 0; }
73 
getSurface()74 		const byte *getSurface() const override { return _data; }
75 
getPalette()76 		const byte *getPalette() const override { return nullptr; }
getPaletteStartIndex()77 		byte getPaletteStartIndex() const override { return 0; }
getPaletteCount()78 		uint16 getPaletteCount() const override { return 0; }
79 
80 		uint setup(uint16 width, uint16 height);
81 
82 		uint16 _width;
83 		uint16 _height;
84 		int16 _offX;
85 		int16 _offY;
86 		uint _constantId;
87 
88 		byte *_data;
89 
90 		uint refCnt;
91 
92 		CryoCursor();
93 		~CryoCursor() override;
94 	};
95 
96 	// Pointer to avoid to mutate Sprites when asking for a cursor
97 	Graphics::Surface *_surface;
98 	Common::Array<CryoCursor *> _cursors;
99 	Common::Array<uint> *_map;
100 };
101 
102 } // End of namespace CryOmni3D
103 
104 #endif
105