//Copyright (C) 2007 SiegeLord
//See ReadMe.txt and License.txt for copying information

#include "neonz.h"
#include "message.h"

const char* g_sMessageText = 0;
float g_fMessageTimer;
extern FONT* g_fntFont;

void SendMessage(const char* text)
{
	ClearMessage();
	g_sMessageText = strdup(text);
}

void ClearMessage()
{
	if(g_sMessageText)
		delete g_sMessageText;
	g_fMessageTimer = 15.0f;
	g_sMessageText = 0;
}

void HandleMessage()
{
	if(!g_sMessageText)
		return;
	g_fMessageTimer -= g_fDelta;
	if(g_fMessageTimer < 0)
		ClearMessage();
}

void DrawMessage()
{
	if(g_sMessageText)
	{
		zColor color = BlendColors(0x00000000, 0xffffffff, g_fMessageTimer / 15.0f);
		DrawTextAlign(g_sMessageText, SCREEN_W / 2, SCREEN_H - 20, -1, 0, color, g_fntFont);
	}
}
