#include "C:\L\clientviews\PlayWin\PlayWindow.h"
PlayWindow::PlayWindow()
{
	//The VERY basics...
	Origin.x = 0; Origin.y = 0; Width = 467; Height = 467;

	ScrnType = SQR_Map;

	SqrTileW    = 32;	SqrTileH    = 32;	SqrScrnW    = _ViewSqrW;		SqrScrnH    = _ViewSqrH;
	SqrIsoTileW = 32;	SqrIsoTileH = 32;	SqrIsoScrnW = _ViewSqrIsoW;		SqrIsoScrnH = _ViewSqrIsoH;
	IsoTileW    = 32;	IsoTileH    = 16;	IsoScrnW    = _ViewIsoW;		IsoScrnH    = _ViewIsoH;

	//Need to change Hex's width to one of the authorized widths...and then
	//do the math in the calling function for Painting or Cursor testing - M. White 14 March, 2019
	HexTileW    = 48;	HexTileH    = 30;	HexScrnW    = _ViewHexW;		HexScrnH    = _ViewHexH;
	
	//Do this after everything is set...
	CalcModifications();
}
PlayWindow::~PlayWindow()
{
}
void PlayWindow::SetBasics(int x, int y, int w, int h, int type)
{
	Origin.x = x; Origin.y = y; Width = w; Height = h;

	//The default screen type is dependent upon the individual game...
	ScrnType = type;
	
	CalcModifications();
}
void PlayWindow::Move(int x, int y)
{
	Origin.x = x; Origin.y = y;

	//Do this after everything is set...
	CalcModifications();
}
void PlayWindow::CalcModifications()
{
	CenterX			= Origin.x + int(Width  / 2);
	CenterY			= Origin.y + int(Height / 2);

	SqrCentX		= int(SqrScrnW / 2); SqrCentY = int(SqrScrnH / 2);
	SqrOffX			= CenterX - int(SqrTileW * SqrCentX) - int(SqrTileW / 2) + 1;
	SqrOffY			= CenterY - int(SqrTileH * SqrCentY) - int(SqrTileH / 2);

	SqrIsoCentX		= int(SqrIsoScrnW / 2); SqrIsoCentY = int(SqrIsoScrnH / 2);
	SqrIsoOffX		= CenterX - int(SqrIsoTileW			* SqrIsoCentX) - int(SqrIsoTileW / 2);
	SqrIsoOffY		= CenterY - int((SqrIsoTileH / 2)	* SqrIsoCentY) - int(SqrIsoTileH / 2);
	
	IsoCentX		= int(IsoScrnW / 2); IsoCentY = int(IsoScrnH / 2);
	IsoOffX			= CenterX - int(IsoTileW			* IsoCentX) - (IsoTileW / 2) + 1;
    IsoOffY			= CenterY - int((IsoTileH / 2)		* IsoCentY) - (IsoTileH / 2) + 1;
	
	HexCentX		= int(HexScrnW / 2); HexCentY = int(HexScrnH / 2);
	HexOffX			= CenterX -  int(HexTileW * HexCentX) - 15;
	HexOffY			= CenterY - (int(HexTileH * HexCentY) / 2) - 15;

	scrnRect.left	= Origin.x;
	scrnRect.top	= Origin.y;
	scrnRect.right	= Origin.x + Width;
	scrnRect.bottom	= Origin.y + Height;
}
void PlayWindow::SetOriginX(int data)
{
	Origin.x = data;
}
int PlayWindow::GetOriginX() const
{
	return Origin.x;
}
void PlayWindow::SetOriginY(int data)
{
	Origin.y = data;
}
int PlayWindow::GetOriginY() const
{
	return Origin.y;
}
void PlayWindow::SetWidth(int data)
{
	Width = data;
}
int PlayWindow::GetWidth() const
{
	return Width;
}
void PlayWindow::SetHeight(int data)
{
	Height = data;
}
int PlayWindow::GetHeight() const
{
	return Height;
}
int PlayWindow::GetCenterX() const
{
	return CenterX;
}
int PlayWindow::GetCenterY() const
{
	return CenterY;
}
void PlayWindow::SetType(int data)
{
	ScrnType = data;
}
int PlayWindow::GetType() const
{
	return ScrnType;
}
int PlayWindow::GetTileW() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrTileW;	break;
	case DIA_Map:	return SqrIsoTileW;	break;
	case RHO_Map:	return IsoTileW;	break;
	case HEX_Map:	return HexTileW;	break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetTileH() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrTileH;	break;
	case DIA_Map:	return SqrIsoTileH;	break;
	case RHO_Map:	return IsoTileH;	break;
	case HEX_Map:	return HexTileH;	break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetTileOffX() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrOffX;		break;
	case DIA_Map:	return SqrIsoOffX;	break;
	case RHO_Map:	return IsoOffX;		break;
	case HEX_Map:	return HexOffX;		break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetTileOffY() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrOffY;		break;
	case DIA_Map:	return SqrIsoOffY;	break;
	case RHO_Map:	return IsoOffY;		break;
	case HEX_Map:	return HexOffY;		break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetScrnW() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrScrnW;	break;
	case DIA_Map:	return SqrIsoScrnW;	break;
	case RHO_Map:	return IsoScrnW;	break;
	case HEX_Map:	return HexScrnW;	break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetScrnH() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrScrnH;	break;
	case DIA_Map:	return SqrIsoScrnH;	break;
	case RHO_Map:	return IsoScrnH;	break;
	case HEX_Map:	return HexScrnH;	break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetCentTileX() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrCentX;	break;
	case DIA_Map:	return SqrIsoCentX;	break;
	case RHO_Map:	return IsoCentX;	break;
	case HEX_Map:	return HexCentX;	break;
	}
	return 0;//Default to appease the return type...
}
int PlayWindow::GetCentTileY() const
{
	switch(ScrnType)
	{
	case SQR_Map:	return SqrCentY;	break;
	case DIA_Map:	return SqrIsoCentY;	break;
	case RHO_Map:	return IsoCentY;	break;
	case HEX_Map:	return HexCentY;	break;
	}
	return 0;//Default to appease the return type...
}
void PlayWindow::SetSqrTileW(int data)
{
	SqrTileW = data;
}
void PlayWindow::SetSqrTileH(int data)
{
	SqrTileH = data;
}
void PlayWindow::SetSqrData(int TileW, int TileH, int ScrnW, int ScrnH)
{
	SqrTileW = TileW; SqrTileH = TileH;
	SqrScrnW = ScrnW; SqrScrnH = ScrnH;
}
void PlayWindow::SetSqrIsoTileW(int data)
{
	SqrIsoTileW = data;
}
int PlayWindow::GetSqrIsoTileW() const
{
	return SqrIsoTileW;
}
void PlayWindow::SetSqrIsoTileH(int data)
{
	SqrIsoTileH = data;
}
int PlayWindow::GetSqrIsoTileH() const
{
	return SqrIsoTileH;
}
void PlayWindow::SetSqrIsoData(int TileW, int TileH, int ScrnW, int ScrnH)
{
	SqrIsoTileW = TileW;
	SqrIsoTileH = TileH;
	SqrIsoScrnW	= ScrnW;
	SqrIsoScrnH	= ScrnH;
}