/*  $Id: sprite_generic.h,v 1.21 2004/04/20 13:36:27 sphair Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#ifndef header_sprite_generic
#define header_sprite_generic

#if _MSC_VER > 1000
#pragma once
#endif

#include "API/Display/surface.h"
#include "API/Display/blend_func.h"
#include "API/Core/Math/origin.h"
#include "API/Display/sprite.h"
#include "API/Core/Math/point.h"
#include "API/Core/Math/rect.h"

#include <vector>

class CL_Sprite_Generic
{
//! Construction:
public:
	CL_Sprite_Generic();

	virtual ~CL_Sprite_Generic();

public:
	class SpriteFrame
	{
	public:
		//: Image data
		CL_Surface surface;

		//: Position in surface that frame is located at.
		CL_Rect position;

		//: Draw offset 
		CL_Point offset;

		//: Animation delay
		float delay;
	};

//! Attributes:
public:
	SpriteFrame *get_frame(unsigned int index);
	
	float angle, angle_pitch, angle_yaw;
	float base_angle;
	float scale_x, scale_y;

	float red,green,blue,alpha;

	CL_BlendFunc blend_src;
	CL_BlendFunc blend_dest;

	CL_Point translation_hotspot;
	CL_Point rotation_hotspot;
	CL_Origin translation_origin;
	CL_Origin rotation_origin;

	short current_frame;
	short delta_frame;

	float update_time;
	float last_time;

	int id;
	
	bool finished;
	bool play_loop;
	bool play_backward;
	bool play_pingpong;
	CL_Sprite::ShowOnFinish show_on_finish;

	std::vector<SpriteFrame> frames;

//! Operations:
public:
	//: Copy assignment operator.
	CL_Sprite_Generic &operator =(const CL_Sprite_Generic &copy);

	float calc_time_elapsed();

//! Signals:
public:
	CL_Signal_v0 sig_animation_finished;
};

#endif
