// OpenLieroX


// Image
// Created 29/10/06
// Dark Charlie

// code under LGPL


#ifndef __CANIMATION_H__DEPRECATED_GUI__
#define __CANIMATION_H__DEPRECATED_GUI__

#include "InputEvents.h"
#include "GfxPrimitives.h"

namespace DeprecatedGUI {

// Events
enum {
	ANI_NONE = -1
};

class CAnimation : public CWidget {
public:
	CAnimation () {}

	// Constructor
	CAnimation(const std::string& Path, float frametime) {
		iType = wid_Animation;
		sPath = Path;
		tAnimation = NULL;
		if (Path != "")  {
			tAnimation = LoadGameImage(Path, true);

			if (tAnimation.get())  {
				iWidth = tAnimation.get()->w;
				iHeight = tAnimation.get()->h;
			} else {
				iWidth = iHeight = 0;
			}
		}
		fLastFrameChange = AbsTime();
		iCurFrame = 0;
		fFrameTime = frametime;

		Parse();
	}

private:
    // Attributes
	SmartPointer<SDL_Surface> tAnimation;
	std::string	sPath;
	std::vector<int> tFrameOffsets;
	std::vector<int> tFrameWidths;
	int			iNumFrames;
	int			iCurFrame;
	AbsTime		fLastFrameChange;
	float		fFrameTime;


public:
    // Methods

    void			Create();
	void			Destroy()		{  }
	void			Parse();

	std::string		getPath()		{ return sPath; }
	SmartPointer<SDL_Surface> getSurface()	{ return tAnimation; }
	float			getFrameTime()		{ return fFrameTime; }
	void			setFrameTime(float t) { fFrameTime = t; }
	void			Change(const std::string& Path, float frametime);

	//These events return an event id, otherwise they return -1
	int		MouseOver(mouse_t *tMouse)				{ return ANI_NONE; }
	int		MouseUp(mouse_t *tMouse, int nDown)		{ return ANI_NONE; }
	int		MouseDown(mouse_t *tMouse, int nDown)	{ return ANI_NONE; }
	int		MouseWheelDown(mouse_t *tMouse)			{ return ANI_NONE; }
	int		MouseWheelUp(mouse_t *tMouse)			{ return ANI_NONE; }
	int		KeyDown(UnicodeChar c, int keysym, const ModifiersState& modstate)		{ return ANI_NONE; }
	int		KeyUp(UnicodeChar c, int keysym, const ModifiersState& modstate)		{ return ANI_NONE; }

	DWORD SendMessage(int iMsg, DWORD Param1, DWORD Param2) { return 0; }
	DWORD SendMessage(int iMsg, const std::string& sStr, DWORD Param) { return 0; }
	DWORD SendMessage(int iMsg, std::string *sStr, DWORD Param)  { return 0; }

	void	Draw(SDL_Surface * bmpDest);

	void	LoadStyle() {}

	static CWidget * WidgetCreator( const std::vector< ScriptVar_t > & p, CGuiLayoutBase * layout, int id, int x, int y, int dx, int dy )
	{
		CWidget * w = new CAnimation( p[0].toString(), p[1].toFloat() );
		layout->Add( w, id, x, y, dx, dy );
		return w;
	};
	
	void	ProcessGuiSkinEvent(int iEvent) {};

};

}; // namespace DeprecatedGUI

#endif  //  __CANIMATION_H__DEPRECATED_GUI__


