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

	ScrnType = SQR_Map;
}
NewPlayWindow::~NewPlayWindow()
{
}
void NewPlayWindow::SetBasics(int x, int y, int w, int h, int type)
{
	Origin.x = x; Origin.y = y; Width = w; Height = h;

	//These must me odd integers - M. White 22 March, 2019
	if(Width  % 2 == 0) Width++;
	if(Height % 2 == 0)	Height++;

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

	//Do this after everything is set...
	CalcMods();
}
void NewPlayWindow::CalcMods()
{
	//Common to all MapTypes after calling function has 
	//did the calculations - M. White 23 March, 2019
	scrnRect.left	= Origin.x;
	scrnRect.top	= Origin.y;
	scrnRect.right	= Origin.x + Width;
	scrnRect.bottom	= Origin.y + Height;

	CenterX			= Origin.x + int(Width  / 2);
	CenterY			= Origin.y + int(Height / 2);

	//Do work specific to Screen Type - M. White 23 March, 2019
	switch(ScrnType)
	{
	case SQR_Map:
		{
			NumCols = NumRows = 1;
			while((NumCols * TileW) <= Width)			NumCols++; NumCols += 2; if(NumCols % 2 == 0) NumCols++;
			while((NumRows * TileH) <= Height)			NumRows++; NumRows += 2; if(NumRows % 2 == 0) NumRows++;
			CentCol			= int(NumCols / 2);
			CentRow			= int(NumRows / 2);
			OffSetX			= CenterX - int(TileW * CentCol) - int(TileW / 2);
			OffSetY			= CenterY - int(TileH * CentRow) - int(TileH / 2);
		}
		break;
	case DIA_Map:
		{
			NumCols = NumRows = 1;
			while((NumCols * TileW) <= Width)			NumCols++; NumCols += 2; if(NumCols % 2 == 0) NumCols++;
			while((NumRows * int(TileH / 2)) <= Height)	NumRows++; NumRows += 4; if(NumRows % 2 == 0) NumRows++;
			CentCol = int(NumCols / 2);
			CentRow = int(NumRows / 2);
			//CentCol must be an odd integer, and CentRow must be an even integer - M. White 3 April, 2019
			if(CentCol % 2 == 0)	{ NumCols += 2; CentCol = int(NumCols / 2); }
			if(CentRow % 2 != 0)	{ NumRows += 2; CentRow = int(NumRows / 2); }
			OffSetX = CenterX - (CentCol * TileW)			- int(TileW / 2);
			OffSetY = CenterY - (CentRow * int(TileH / 2))	- int(TileH / 2);
		}
		break;
	case RHO_Map:
		{
			NumCols = NumRows = 1;
			while((NumCols * TileW) <= Width)			NumCols++; NumCols += 2; if(NumCols % 2 == 0) NumCols++;
			while((NumRows * int(TileH / 2)) <= Height)	NumRows++; NumRows += 4; if(NumRows % 2 == 0) NumRows++;
			CentCol = int(NumCols / 2);
			CentRow = int(NumRows / 2);
			//CentCol must be an odd integer, and CentRow must be an even integer - M. White 3 April, 2019
			if(CentCol % 2 == 0)	{ NumCols += 2; CentCol = int(NumCols / 2); }
			if(CentRow % 2 != 0)	{ NumRows += 2; CentRow = int(NumRows / 2); }
			OffSetX = CenterX - (CentCol * TileW)			- int(TileW / 2);
			OffSetY = CenterY - (CentRow * int(TileH / 2))	- int(TileH / 2);
		}
		break;
	case HEX_Map01:
		{
			NumCols = NumRows = 1;
			while((NumCols * TileW) <= Width)			NumCols++; NumCols += 2; if(NumCols % 2 == 0) NumCols++;
			while((NumRows * int(TileH / 2)) <= Height)	NumRows++; NumRows += 5; if(NumRows % 2 == 0) NumRows++;
			CentCol = int(NumCols / 2);
			CentRow = int(NumRows / 2);
			//CentCol must be an odd integer, and CentRow must be an even integer - M. White 3 April, 2019
			if(CentCol % 2 == 0)	{ NumCols += 2; CentCol = int(NumCols / 2); }
			if(CentRow % 2 != 0)	{ NumRows += 2; CentRow = int(NumRows / 2); }
			OffSetX = CenterX - (CentCol * TileW)			- int(TileW / 2) - 1; //-1 to account for BMP's +1 width - M. White 4 April, 2019
			OffSetY = CenterY - (CentRow * int(TileH / 2))	- int(TileH / 2) - 1;
		}
		break;
	case HEX_Map02:
		{
		}
		break;
	};
}
void NewPlayWindow::SetOriginX(int data)
{
	Origin.x = data;
}
int NewPlayWindow::GetOriginX() const
{
	return Origin.x;
}
void NewPlayWindow::SetOriginY(int data)
{
	Origin.y = data;
}
int NewPlayWindow::GetOriginY() const
{
	return Origin.y;
}
void NewPlayWindow::SetWidth(int data)
{
	Width = data;
}
int NewPlayWindow::GetWidth() const
{
	return Width;
}
void NewPlayWindow::SetHeight(int data)
{
	Height = data;
}
int NewPlayWindow::GetHeight() const
{
	return Height;
}
int NewPlayWindow::GetCenterX() const
{
	return CenterX;
}
int NewPlayWindow::GetCenterY() const
{
	return CenterY;
}
void NewPlayWindow::SetType(int data)
{
	ScrnType = data;
}
int NewPlayWindow::GetType() const
{
	return ScrnType;
}
void NewPlayWindow::SetTileW(int W)
{
	TileW = W;
}
int NewPlayWindow::GetTileW() const
{
	return TileW;
}
void NewPlayWindow::SetTileH(int H)
{
	TileH = H;
}
int NewPlayWindow::GetTileH() const
{
	return TileH;
}
int NewPlayWindow::GetTileOffX() const
{
	return OffSetX;
}
int NewPlayWindow::GetTileOffY() const
{
	return OffSetY;
}
void NewPlayWindow::SetNumCol(int Number)
{
	NumCols = Number;
}
int NewPlayWindow::GetNumCol() const
{
	return NumCols;
}
void NewPlayWindow::SetNumRow(int Number)
{
	NumRows = Number;
}
int NewPlayWindow::GetNumRow() const
{
	return NumRows;
}
int NewPlayWindow::GetCentCol() const
{
	return CentCol;
}
int NewPlayWindow::GetCentRow() const
{
	return CentRow;
}