/*
 * GuiText.cpp
 *
 *  Created on: 2009-07-11
 *      Author: wasyl
 */


#include "GuiText.h"
#include "../prep/res/Resources.h"
GuiText::GuiText(Vec pos, std::string text, bool blink)
	: mText(text), mBlinking(blink)
{
	Resources::load(mFont, "media/font.ttf");
	mPos = pos;
	mTime = 0.0;
}

void GuiText::update(double dt)
{
	mTime += dt;
}

void GuiText::render()
{
	if (mBlinking)
	{
		int t = mTime * 10.0;
		if (t % 7 >= 5)
			return;
	}
	al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(0,0,0));
	al_draw_text(mFont, mPos.x + 1, mPos.y + 1, ALLEGRO_ALIGN_CENTRE, mText.c_str());
	al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgb(255,255,255));
	al_draw_text(mFont, mPos.x, mPos.y, ALLEGRO_ALIGN_CENTRE, mText.c_str());
}
