/*
 * Message.h
 *
 *  Created on: 2009-07-11
 *      Author: wasyl
 */

#ifndef MESSAGE_H_
#define MESSAGE_H_

#include <allegro5/allegro.h>
#include <allegro5/a5_font.h>
#include "../prep/misc/Vector2D.h"
#include "../prep/ent/Entity.h"
#include "../prep/res/Sheet.h"
#include "PopUp.h"

/**
 * A message embedded in a level.
 */
class Message : public Entity
{
private:
	std::string mMessage;
	Sheet *mSprite;
	ALLEGRO_FONT *mFont;
	PopUp *mPop;

public:
	Message(std::string message = "");

	int *indices()
	{
		static int ind[] = {ID("entt"), ID("rndr"), ID("dyna"), ID("posi"), ID("mesg"), 0};
		return ind;
	}

	int order(int index)
	{
		if (index == ID("rndr"))
			return 30;
		else
			return (int)(mPos.x * 600 + mPos.y);
	}

	void update(double dt);
	void render();
	Rect bbox();

	void setMessage(std::string message);

	Entity *clone() { return new Message(mMessage); }
	const char *code() { return "ms"; }
	void load(FILE *f);
	void save(FILE *f);
	std::string edString() { return "message"; }
};

#endif /* MESSAGE_H_ */
