#ifndef __SPRITESW_H
#define __SPRITESW_H

#include <ui_fspritesw.h>
#include <QCloseEvent>
#include <QDialog>
#include <labelbtn.h>
#include <QList>

class QRadioButton;
class QSignalMapper;


class CSpritesSet
{
public:
	CSpritesSet();

	void SetColor( int sprite, int color );
	int GetColor( int sprite );
	
	int GetValue( int sprite, int index );
	void SetValue( int sprite, int index, int value );

private:
	int m_Set[4][256];
	int m_Colors[4];
};

class CSpritesW : public QDialog, public Ui_FSpritesW
{
	Q_OBJECT
public:

	CSpritesW();

	void Initialize();

	void NewSprites();
	bool LoadSprites( QString fileName );
	bool SaveSprites( QString fileName );
	bool ExportSprites( QString fileName );

	void Close();

public slots:
	void OnSpritesClickLeft( int, int );
	void OnSpritesClickRight( int, int );

	void OnCombos0Click( int );
	void OnCombos1Click( int );
	void OnCombos2Click( int );
	void OnCombos3Click( int );
	void OnCombosClick( int combo, int index );
	void OnFlipHClick();
	
	void OnSetsClick( int );
	
	void OnRadiosClick( int );
	
protected:
	void closeEvent( QCloseEvent *pEvent );

private:
	static const int BG_COLOR;

	bool m_Close;
	
	QComboBox *m_pSprites[4];
	QRadioButton *m_pSelSprite[4];
	CLabelBtn *m_pLblSprites;
	CLabelBtn *m_pLblViews[4];

	QSignalMapper *m_pSigRadios;

	QList<CSpritesSet*> m_Sprites;
	
	int m_SelSprite;
	int m_SelSet;


//	void UpdateDesigner();
	void UpdateDesigner( int set );
	void UpdateDesigner( int set, int sprite );
	void UpdateDesigner( int set, int sprite, int index, bool paintIsZ, QImage *pImage = NULL );
	
//	void UpdatePreview( int set );
//	void UpdatePreview( int set, int sprite );
	void UpdatePreview( int set, int sprite, int index, bool paintIsZ, QImage *pImage = NULL );
};

#endif
