#include "InScreenMsg.h"
InScreenMsg::InScreenMsg()
{
	Reset();
}
InScreenMsg::~InScreenMsg()
{
	if(Messages.isEmpty() == false)
		while(Messages.isEmpty() == false) Messages.popFront();
}
void InScreenMsg::Reset()
{
	CopyRect(&CurrentRect, &StartRect);
	MsgTimer		= -1;
	ExpandAmount	= 1;
	ExpandMulti		= 0;
	MsgIndex		= 0;
}
void InScreenMsg::SetMsgRect(int L, int T, int R, int B)
{
	if(L >= 0 && T >= 0 && R > L && B > T)	SetRect(&CurrentRect, L, T, R, B);
	else									Reset();
}
void InScreenMsg::SetTimer(int timeInFPS)
{
	if(timeInFPS > 0)						MsgTimer = timeInFPS;
	else									Reset();
}
int InScreenMsg::GetTimer() const
{
	return MsgTimer;
}
void InScreenMsg::DecTimer()
{
	if(MsgTimer > 0)						MsgTimer--;
	else									Reset();
}
void InScreenMsg::SetStartRect(int L, int T, int R, int B)
{
	if(L >= 0 && T >= 0 && R > L && B > T)
	{
		SetRect(&StartRect, L, T, R, B);
		CopyRect(&CurrentRect, &StartRect);
	}
}
void InScreenMsg::IncMsgIndex()
{
	if(MsgIndex < NumMsg)					MsgIndex++;
}
void InScreenMsg::DecMsgIndex()
{
	if(MsgIndex > 0)						MsgIndex--;
}
void InScreenMsg::AddMessage(string msg)
{
	if(NumMsg < 20)
	{
		Messages.insertFront(msg);
		NumMsg++;
	}
	else
	{
		Messages.deleteNodeByRef(19);
		Messages.insertFront(msg);
	}
}
void InScreenMsg::IncExpand()
{
	if(ExpandAmount < MaxExpandedView)
	{
		ExpandAmount++;
		SetRect(&CurrentRect,
			StartRect.left,
			StartRect.bottom - (ExpandAmount * ExpandMulti),
			StartRect.right,
			StartRect.bottom);
	}
}
void InScreenMsg::DecExpand()
{
	if(ExpandAmount > 1)
	{
		ExpandAmount--;
		SetRect(&CurrentRect,
			StartRect.left,
			StartRect.bottom - (ExpandAmount * ExpandMulti),
			StartRect.right,
			StartRect.bottom);
	}
}
int InScreenMsg::GetExpand()
{
	return ExpandAmount;
}
void InScreenMsg::SetExpandBy(int amount)
{
	if(amount > 0)	ExpandMulti = amount;
	else			ExpandMulti = 0;
}
int InScreenMsg::GetExpandBy() const
{
	return ExpandMulti;
}
int InScreenMsg::GetNumMsg() const
{
	return NumMsg;
}
void InScreenMsg::SetExpandAmnt(int data)
{
	ExpandAmount = data;
		SetRect(&CurrentRect,
			StartRect.left,
			StartRect.bottom - (ExpandAmount * ExpandMulti),
			StartRect.right,
			StartRect.bottom);
}
int InScreenMsg::GetExpandAmnt() const
{
	return ExpandAmount;
}