1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
/********************************************************************
*
*	Created:	25/2/2014   13:46
*
*	File:		fsCSpriteComponent.h
*
*	Author:		Mick Waites
*
*	Purpose:	A component which renders a sprite to the display.
*
*********************************************************************/

#ifndef fsCSpriteComponenthdr
#define fsCSpriteComponenthdr

// Needed for COLLISION_DEBUG_MESSAGES definition
#include <fsAppCore/src/components/fsCDragDropComponent.h>

#include <fsCore/src/fsCUniqueId.h>
#include <fsCore/fsBaseTypes.h>

#include "../../fsIRenderData.h"
#include "fsISpriteComponent.h"

// #define OUTLINE_RENDERING

#ifdef COLLISION_DEBUG_MESSAGES
	#define COLLISION_OUTLINE_RENDERING
#endif

class fsCSprite;
class fsCLine;
struct fsPoint;
class fsSColour;
class fsCEntity;
class fsIComponent;
class fsCVariableTable;
class fsCBrush;
class fsRect;


class fsCSpriteComponent : public fsISpriteComponent
{
	friend class fsCComponentFactory;
	friend class fsCVertexStreamSpriteRenderData;
public:

	static const fsCUniqueId mTypeId;

	void polyInfoSet(fsIRenderData::fsSPolyInfo const& pPolyInfo);

protected:

	fsBool obscuredByBoundingBoxCheckDo(fsISpriteComponent* pOtherSprComp) override;

	void alphaBlendSetDo(fsS32 pBlend) override;

        fsBool hitTestDo(fsISpriteComponent* pOtherSprComp, fsBool pRequireHitMap) const override;
	fsBool hitTestDo(const fsPoint& pScreenPos, fsBool pRequireHitMap) const override;

	fsS32 widthGetDo() const override;
	fsS32 heightGetDo() const override;

	void colourSetDo(const fsSColour4B& pColour) override;

	void widthSetDo(fsS32 pWidth, fsBool pModifyRenderData = true) override;
	void heightSetDo(fsS32 pHeight, fsBool pModifyRenderData = true) override;

	std::shared_ptr<fsCBrush> brushGetDo() const override;
	void brushSetDo(std::shared_ptr<fsCBrush> pBrush) override;

	static fsIComponent* create(fsCEntity* pParent);

	void initialiseFromVariableTableDo(const fsCVariableTable& pVars) override;
	void renderDo() override;
	void matrixApplyDo() override;

	fsCSpriteComponent(fsCEntity* pParent);
	virtual ~fsCSpriteComponent();<--- Destructor in derived class

private:

#ifdef COLLISION_OUTLINE_RENDERING
	void renderDebugCollisionOutline(const fsRect& intersect, const fsSColour4B& pColour) const;
	void renderDebugMouseOverCollisionBox() const;
	void clearDebugCollisionOutline() const;
#endif
#ifdef OUTLINE_RENDERING
	void debugOutlineUpdate() const;
#endif

	fsCSprite* mSprite;
#ifdef OUTLINE_RENDERING
	fsCLine* mLine;
#endif

#ifdef COLLISION_OUTLINE_RENDERING
	fsCLine* mCollisionOutlineLine;
#endif
};

#endif