#include "TileStamp.h"

TileStamp::TileStamp( int newTextureId, int newTotalWidth, int newTotalHeight, int newTileX, int newTileY )
{
	totalWidth = newTotalWidth;
	totalHeight = newTotalHeight;
	textureId = newTextureId;
	center = NULL;
	modulationColor = D3DCOLOR_RGBA(255,255,255,255);
	clippingRect = NULL;
	tileX = newTileX;
	tileY = newTileY;
}

TileStamp::~TileStamp(void)
{
	if ( center != NULL ) {
		delete center;
		center = NULL;
	}

	if ( clippingRect ) {
		delete clippingRect;
		clippingRect = NULL;
	}
}

Stamp::STAMP_TYPE TileStamp::getStampType() {
	return Stamp::TILE;
}

D3DXVECTOR3* TileStamp::getCenter() {
	return center;
}

void TileStamp::setCenter( D3DXVECTOR3* newCenter ) {
	center = newCenter;
}

D3DCOLOR TileStamp::getModulationColor() {
	return modulationColor;
}

void TileStamp::setModulationColor( D3DCOLOR newColor ) {
	modulationColor = newColor;
}

RECT* TileStamp::getClippingRect() {
	return clippingRect;
}

void TileStamp::setClippingRect( RECT* newClippingRect ) {
	clippingRect = newClippingRect;
}

int TileStamp::getTextureId() {
	return textureId;
}

void TileStamp::setTextureId( int newId ) {
	textureId = newId;
}

int TileStamp::getTotalWidth() {
	return totalWidth;
}

void TileStamp::setTotalWidth( int newTotalWidth ) {
	totalWidth = newTotalWidth;
}

int TileStamp::getTotalHeight() {
	return totalHeight;
}

void TileStamp::setTotalHeight( int newTotalHeight ) {
	totalHeight = newTotalHeight;
}

TileStamp* TileStamp::clone() {
	TileStamp* newTileStamp = new TileStamp( textureId, 
		totalWidth,
		totalHeight, tileX, tileY );
	if ( center != NULL ) {
		D3DXVECTOR3* newCenter = new D3DXVECTOR3( center->x, center->y, center->z );
		newTileStamp->setCenter( newCenter );
	}
	D3DCOLOR newModulationColor = modulationColor;
	newTileStamp->setModulationColor( newModulationColor );
	if ( clippingRect != NULL ) {
		RECT* newClip = new RECT();
		newClip->bottom = clippingRect->bottom;
		newClip->left = clippingRect->left;
		newClip->right = clippingRect->right;
		newClip->top = clippingRect->top;
		newTileStamp->setClippingRect( newClip );
	}

	return newTileStamp;
}

int TileStamp::getTileXOffset() {
	return tileX;
}

void TileStamp::setTileXOffset( int newOffset ) {
	tileX = newOffset;
}

int TileStamp::getTileYOffset() {
	return tileY;
}

void TileStamp::setTileYOffset( int newOffset ) {
	tileY = newOffset;
}
