1 #ifndef KYRA_ISOGEN_INCLUDED
2 #define KYRA_ISOGEN_INCLUDED
3 
4 #include "SDL.h"
5 #include <list>
6 #include <string>
7 #include <vector>
8 
9 #include "../../grinliz/gldebug.h"
10 #include "../../grinliz/gltypes.h"
11 #include "../../grinliz/glutil.h"
12 #include "../../grinliz/glvector.h"
13 #include "../../grinliz/glgeometry.h"
14 #include "../../grinliz/glcolor.h"
15 
16 #include "../../tinyxml/tinyxml.h"
17 
18 enum {
19 	USE_TEXTURE =	0x01,
20 	NORTH		=	0x02,
21 	SOUTH		=   0x04,
22 	EAST		=	0x08,
23 	WEST		=	0x10,
24 	CENTER		=   0x20,
25 	OFFSET		=   0x40,
26 	OVERLAYS    =	0x80
27 };
28 
29 // Data structure that contains all the information to render a texture
30 class Texture
31 {
32   private:
33 	SDL_Surface* surface;			// a pointer to the surface that contains the texture
34 									// data. Not owned by this class.
35 	grinliz::Vector2I origin;		// origin of the texture, in screen coordinates.
36 
37 	// Mapping constants.
38 	// u = x*a + y*b
39 	// v = x*c + y*d
40 	float a;
41 	float b;
42 	float c;
43 	float d;
44 
45 	grinliz::Color4U8 GetPixel( int u, int v );
46 	inline int WrapX( SDL_Surface* surface, int x );
47 	inline int WrapY( SDL_Surface* surface, int y );
48 
49 	U8 alpha;
50 	bool emit;
51 	bool colorKey;
52 
53   public:
Texture()54 	Texture()	{	surface = 0;
55 					origin.Set( 0, 0 );
56 					alpha = 255;
57 					emit = false;
58 					colorKey = false;
59 				}
60 
61 	void InitTexture(	SDL_Surface* surface,
62 						bool overlay,
63 						const grinliz::Vector2I& p,
64 						const grinliz::Vector2I& _q,
65 						const grinliz::Vector2I& _r,
66 						U8 alpha = 255,
67 						bool emit = false );
68 
69 	grinliz::Color4U8 Lookup( int x, int y );
70 
Valid()71 	bool Valid()	{ return surface != 0; }
Emit()72 	bool Emit()		{ return emit; }
73 
Alpha()74 	U8 Alpha()		{ return alpha; }
75 };
76 
77 // Information to initialize a texture (read from the XML file)
78 struct TexData
79 {
ClearTexData80 	void Clear() { surface = 0; alpha = 255; emit=false; }
81 
82 	SDL_Surface* surface;
83 	U8 alpha;
84 	bool emit;
85 };
86 
87 // Information to draw a set of icons
88 struct SetData
89 {
90 	bool useAA;
91 
92 	bool drawAll;
93 	bool drawDouble;
94 
95 	bool drawBasic;
96 	bool drawWall;
97 	bool drawJoin;
98 	bool drawWallJoin;	// the 2 joins that have a wall to overlay to
99 	bool drawRamp;
100 
101 	std::vector< TexData > wallTexture;
102 	std::vector< TexData > floorTexture;
103 	std::string action;
104 
InitSetData105 	void Init() {
106 		useAA = true;
107 		drawAll = true;
108 		drawBasic = false;
109 		drawWall = false;
110 		drawJoin = false;
111 		drawWallJoin = false;
112 		drawRamp = false;
113 		drawDouble = false;
114 	}
115 	void Clear();
116 };
117 
118 
119 
120 #endif
121