00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __IMAGECOMPONENT_H__
00017 #define __IMAGECOMPONENT_H__
00018
00019
00020 #include "../../dependencies.h"
00021 #include "../../core/EntityComponent.h"
00022
00023
00024
00033 class ImageComponent : public EntityComponent
00034 {
00035 public:
00036
00037
00040 ImageComponent(Entity *parent);
00051 ImageComponent(Entity *parent, const std::string &fileName, const vector2di &position,
00052 const rect<s32> &sourceRect, const rect<s32> &clipRect,
00053 const SColor &color = SColor(255, 255, 255, 255),
00054 const SColor &alphaColor = SColor(255, 255, 255, 255),
00055 bool useAlphaColor = false);
00066 ImageComponent(Entity *parent, ITexture *texture, const vector2di &position,
00067 const rect<s32> &sourceRect, const rect<s32> &clipRect,
00068 const SColor &color = SColor(255, 255, 255, 255),
00069 const SColor &alphaColor = SColor(255, 255, 255, 255),
00070 bool useAlphaColor = false);
00072 ~ImageComponent();
00073
00074
00076 const SColor& getAlphaColor() const;
00078 const rect<s32>& getClipRect() const;
00080 const SColor& getColor() const;
00082 const vector2di& getPosition() const;
00084 const rect<s32>& getSourceRect() const;
00086 const ITexture* getTexture() const;
00088 bool getUseAlphaColor() const;
00089
00098 void setAlphaColor(const SColor &color);
00108 void setClipRect(const rect<s32> &rectangle);
00117 void setColor(const SColor &color);
00126 void setPosition(const vector2di &position);
00135 void setSourceRect(const rect<s32> &rectangle);
00144 void setTexture(const std::string &fileName);
00148 void setTexture(ITexture *texture);
00157 void setUseAlphaColor(bool value);
00158
00159
00162 void onRender(void *p);
00165 void onPause(void *p);
00168 void onUnPause(void *p);
00171 void onTexture(void *p);
00172
00173
00176 static bool parseXML(IXMLReader *file, Entity *entity);
00177
00178 private:
00179
00180
00182 void init();
00183
00184
00185 ITexture *mTexture;
00186
00187 vector2di mPosition;
00188 rect<s32> mSourceRect;
00189 rect<s32> mClipRect;
00190 SColor mColor;
00191 SColor mAlphaColor;
00192
00193 bool mVisible;
00194 bool mUseAlphaColor;
00195 bool mWasVisible;
00196
00197 std::string mTextureFileName;
00198 };
00199
00200 #endif