//@STATE=作成中
//@DESCRIPTION ---------------------------------------------------------------
// BGEditorImpl.h: BGEditorImpl クラスのインターフェイス
// マップエディタークラス
//	履歴：
// $Log: BGEditorImpl.h,v $
// Revision 1.1.1.1  2001/11/06 21:29:04  fujiwara
// no message
//
// Revision 1.1  2001/10/28 21:40:35  fujiwara
// DLLに分割
//
// Revision 1.4  2001/07/09 20:30:08  fujiwara
// 例外処理の組み込み
//
// Revision 1.3  2001/07/01 01:03:43  fujiwara
// const の見直し
// 配置エディタは途中経過
//
// Revision 1.2  2001/05/12 00:48:13  fujiwara
// ＣＶＳを導入し、ログ表示を追加
//
//@DESCRIPTION_END -----------------------------------------------------------
//@AUTHOR=S.F.
// Copyright (C) 2000 Satoshi Fujiwara. All Rights Reserved.
///////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_EDITOR_H__78B4933E_229E_4ACD_9183_C1E688557FE7__INCLUDED_)
#define AFX_EDITOR_H__78B4933E_229E_4ACD_9183_C1E688557FE7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "AbstractScene.h"
namespace sf {
	namespace application {
		namespace scene {

class BGEditorImpl : public sf::system::input::mouse::Listener ,
	public sf::system::input::keyboard::Listener ,public AbstractScene  
{
	
	// LIFE CYCLE //

public:
	BGEditorImpl(BGEditorParameter *pBGEditorParam);
	virtual ~BGEditorImpl();
	
	// OPERATIONS //

	void move(void);
	// 
	const TYPE type() const{return EDITOR;};
	// シーン終了時イベント
	void endOfScene(Scene * const pScene);
	// シーン中断(終了キーが押された)イベント
	void exitKeyPressed(Scene * const pScene);

	// マウスリスナー
	void leftButtonDown(const int screenX,const int screenY,const DWORD mkey)
	{
		mpGame->background()->setData((float)screenX,(float)screenY,mSelectedMapData);
	};
	void leftButtonUp(const int screenX,const int screenY,const DWORD mkey){;};
	void leftButtonDoubleClick(const int screenX,const int screenY,const DWORD mkey){;};
	void rightButtonDown(const int screenX,const int screenY,const DWORD mkey);
	void rightButtonUp(const int screenX,const int screenY,const DWORD mkey){;};
	void rightButtonDoubleClick(const int screenX,const int screenY,const DWORD mkey){;};
	void mouseMove(const int screenX,const int screenY,const DWORD mkey){;}
	void mouseWheel(const int screenX,const int screenY,const DWORD mkey);
	void mouseTalkerIsDeleted(void){mpInput = NULL;};
	// キーボードリスナー
	void keyDown(const DWORD keyCode,const DWORD extKeyCode);
	void keyUp(const DWORD keyCode,const DWORD extKeyCode){};
	void keyboardTalkerIsDeleted(void){mpInput = NULL;};

	// ACCESS //

	const float mouseX(void) { return mMouseX;};
	const float mouseY(void) { return mMouseY;};

	void selectedData(const DWORD value){mSelectedMapData = value;};
	const DWORD selectedData(void) const {return mSelectedMapData;};

	// INQUIRY //

	const bool isListeningMouse(void) const {return mbCallBack;};
	const bool isListeningKeyboard(void) const {return mbListening;};

private:

	// マップのテクスチャセレクタクラス //
	class CellSelector :
			public sf::system::input::mouse::Listener,
			public sf::system::console::ObjRectangle,
			public sf::application::scene::AbstractScene
			
	{

		// LIFE CYCLE //
	
	public:

		CellSelector(sf::system::console::Background::TextureList* pTextureList);
		~CellSelector();

		// OPERATIONS //

		// drawをオーバーライド
		void draw();
		// scene
		void move(void);
		const TYPE type() const{return CELLSELECTOR;};
		void endOfScene(Scene * const pScene){;};
		void exitKeyPressed(Scene * const pScene){;};
		// マウスリスナー
		void leftButtonDown(const int screenX,const int screenY,const DWORD mkey);
		void leftButtonUp(const int screenX,const int screenY,const DWORD mkey){};
		void leftButtonDoubleClick(const int screenX,const int screenY,const DWORD mkey){};
		void rightButtonDown(const int screenX,const int screenY,const DWORD mkey){};
		void rightButtonUp(const int screenX,const int screenY,const DWORD mkey){};
		void rightButtonDoubleClick(const int screenX,const int screenY,const DWORD mkey){};
		void mouseMove(const int screenX,const int screenY,const DWORD mkey)
			{mMouseX = (float)screenX;mMouseY = (float)screenY;};
		void mouseWheel(const int screenX,const int screenY,const DWORD mkey);
		const bool isListeningMouse(void) const {return mbMouseListening;};
		void mouseTalkerIsDeleted(void){mpInput = NULL;};

		// ACCESS //

		const DWORD selectedIndex(void) const {return mSelectedIndex;};
		void selectedIndex(DWORD value){mSelectedIndex = value;};

		const DWORD selectedTextureNo(void) const {return mSelectedTextureNo;};
		void selectedTextureNo(DWORD value){mSelectedTextureNo = value;};
		
		const float selectorX(void) const { return mSelectorX;};
		void selectorX(float value){ mSelectorX = value;};

		const float selectorY(void) const { return mSelectorY;};
		void selectorY(float value){ mSelectorY = value ;};

	private:
		bool initialize();
		bool mbMouseListening;
		
		DWORD mSelectedIndex;
		DWORD mSelectedTextureNo;
		
		// セルセレクタの中心座標
		float mSelectorX;
		float mSelectorY;

		// 現在のマウス座標 
		float mMouseX;
		float mMouseY;
		
		sf::system::console::Background::TextureList* mpTextureList;

		enum {
			INITIALIZE,
			MAIN
		} mState;

		// 定数 //

		static const float X_MIN;
		static const float X_MAX;
		static const float Y_MIN;
		static const float Y_MAX;			
		static const float WIDTH;
		static const float HEIGHT;

	};// CellSelector

	//

	CellSelector* mpCellSelector;	
	DWORD mSelectedMapData;
	bool initialize();

//	sf::system::console::Background mBackground;
	float mMouseX,mMouseY;
	bool mbCallBack;
	bool mbListening;
	
	enum STATE {
		INITIALIZE,
		MAIN,
		END
	} mState;

	Game *mpGame;

};// BGEditorImpl
		}
	}
}

#endif // !defined(AFX_EDITOR_H__78B4933E_229E_4ACD_9183_C1E688557FE7__INCLUDED_)
