00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KYRA_BOXRESOURCE_INCLUDED
00033 #define KYRA_BOXRESOURCE_INCLUDED
00034
00035 #include "kyraresource.h"
00036 #include "../engine/krmath.h"
00037 #include "../util/glcirclelist.h"
00038 #include "color.h"
00039
00040 class KrBox;
00041 struct KrPaintInfo;
00042
00043
00049 class KrBoxResource : public KrResource
00050 {
00051 public:
00069 KrBoxResource( const std::string& name,
00070 int width,
00071 int height,
00072 const KrRGBA* colorArray,
00073 int numColors,
00074 int boxtype );
00075
00076 virtual ~KrBoxResource() {}
00077
00078 enum
00079 {
00080 OUTLINE,
00081 FILL,
00082 CROSSHAIR
00083 };
00084
00085 enum {
00086 COLOR_ARRAY_SIZE = 4,
00087 MASK = 3,
00088 };
00089
00090 virtual U32 Type() { return KYRATAG_BOX; }
00091 virtual const std::string& TypeName() { return boxName; }
00092 virtual KrBoxResource* ToBoxResource() { return this; }
00093
00094 int Width() const { return width; }
00095 int Height() const { return height; }
00096 const KrRGBA* ColorArray() const { return colorArray; }
00097 int BoxType() const { return boxtype; }
00098
00099
00100
00101
00102
00103
00104
00105
00106 void Draw( KrPaintInfo* paintInfo,
00107 const KrMatrix2& matrix,
00108 const KrColorTransform& cForm,
00109 const grinliz::Rectangle2I& clipping );
00110
00111
00112
00113
00114
00115 bool HitTestTransformed( int x, int y, int hitFlags );
00116
00117
00118
00119
00120 void CalculateBounds( const KrMatrix2& matrix,
00121 grinliz::Rectangle2I* bounds ) const;
00122
00123 private:
00124 void DrawOpenGL(KrPaintInfo* paintInfo,
00125 const KrMatrix2& matrix,
00126 const KrColorTransform& cForm,
00127 const grinliz::Rectangle2I& clipping );
00128
00129 static const std::string boxName;
00130 static int boxId;
00131
00132 KrRGBA colorArray[COLOR_ARRAY_SIZE];
00133 int width;
00134 int height;
00135 int boxtype;
00136 bool sourceAlpha;
00137 };
00138
00139
00140 #endif