/*
 * PressPad.h
 *
 *  Created on: 2009-07-12
 *      Author: wasyl
 */

#ifndef PRESSPAD_H_
#define PRESSPAD_H_

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

class PressPad : public Entity
{
protected:
	Sheet *mSprite;
	ALLEGRO_SAMPLE *mSndSwitch;

	int mControls;
	bool mDefault, mOn, mLast;

public:
	PressPad(int controls, bool def);
	~PressPad();

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

	int order(int index)
	{
		if (index == ID("rndr"))
			return 55;
		else
			return (int)this;
	}

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

	Entity *clone() { return new PressPad(mControls, mDefault); };
	const char *code() { return "pr"; };
	std::string edString() { return SPrintF::format("presspad(%d,%s)", mControls, mDefault?"on":"off"); }

	void load(FILE *f);
	void save(FILE *f);
};

#endif /* PRESSPAD_H_ */
