//
// Tools_GUIMenu_Element_StatusText.h
//
// Created by Steven Keen - 26/04/2007
// 
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//


#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif


#ifndef _TOOLS_GUIMENU_ELEMENT_STATUSTEXT_H_
#define _TOOLS_GUIMENU_ELEMENT_STATUSTEXT_H_
#ifdef ASURA_USE_GUI_MENU_SYSTEM

#include "GUIMenu/Tools_GUIMenu_Element_Base.h"
#include "GUIMenu/Tools_GUIMenu_Element_Text.h"
#include "GUIMenu/Asura_GUIMenu_Element_StatusText.h"
#include "Misc/Tools_Dialog.h"
#include "Misc/Tools_Modal_Overlay.h"

#define ASURA_GUIMENU_TEXT_ELEMENT_MAX_CUSTOM_STRING_SIZE	(1024)

class Asura_GUIMenu_Element_StatusText;


class Tools_GUIMenu_Element_StatusText : public Tools_GUIMenu_Element_Base
{
	typedef Tools_GUIMenu_Element_Base PARENT;
public :
	Tools_GUIMenu_Element_StatusText(Asura_GUIMenu_Element_StatusText* pxAsuraText,Tools_GUIMenu_Root* pxToolsParent);

	virtual void InitialiseNewItem();
	virtual void Copy(const Tools_GUIMenu_Root* pxSource);

	virtual void Update();

	static void TextUpdated();

	Asura_GUIMenu_Element_StatusText* GetAsuraData( void)	{	return m_pxAsuraStatusText;	}

protected :
	virtual void AddOverlayControls(Asura_Overlay* pxOverlay,Asura_Vector_2& xOffset);
	virtual void AddExtraOverlayControls(Asura_Overlay* pxOverlay, Asura_Tabs_Dialog* pxTabs, Asura_Vector_2& xOffset);

	virtual void UpdateOverlayControls(Asura_Overlay* pxOverlay);
	virtual const char* GetLocalDataFlagName(u_int uFlagValue) const;
	virtual bool IsModifierTypeSupported( ASURA_GUIMENU_MODIFY_TYPE eType ) const;
	virtual void CopyToAsura();
	virtual void CopyFromAsura();
	virtual void AddModifierOverlayControls(Asura_GUIMenu_Modifier* pxModifier, Asura_Vector_2& xOffset);
	virtual void InitialiseModifier(Asura_GUIMenu_Modifier* pxModifier);
	virtual void AddToPreviewOverlay() const;
	virtual void SetFont(const char* szFont);

	void AddTextInfoToDialog( u_int uIndex, Asura_Subwindow_Dialog* pxSubWindow, Asura_Vector_2& xOffset);

private :
	#define OVERLAY_VOID_CALLBACK(__FnName)\
	static void __FnName(int iThis){((Tools_GUIMenu_Element_StatusText*)iThis)->__FnName();}\
	void __FnName();
	#define OVERLAY_BOOL_CALLBACK(__FnName)\
	static bool __FnName(int iThis){return ((Tools_GUIMenu_Element_StatusText*)iThis)->__FnName();}\
	bool __FnName();

	static void _EditTextInfoDetails( int iValue);

	static void _MoveUp(int iIndex);
	static void _MoveDown(int iIndex);
	static void _Delete(int iIndex);

	OVERLAY_VOID_CALLBACK(ChooseFont)
	OVERLAY_VOID_CALLBACK(ChooseModifierFont)
//	OVERLAY_VOID_CALLBACK(ChooseText)
	OVERLAY_VOID_CALLBACK(ChooseModifierText)
	OVERLAY_VOID_CALLBACK(AddNewTextInfo)

	OVERLAY_BOOL_CALLBACK(CanEditFontScale)
	OVERLAY_BOOL_CALLBACK(CanEditFontName)
//	OVERLAY_BOOL_CALLBACK(CanEditTextID)
	OVERLAY_BOOL_CALLBACK(CanEditXOffset)
	OVERLAY_BOOL_CALLBACK(CanEditYOffset)
	OVERLAY_BOOL_CALLBACK(CanEditRenderFlags)

	#undef OVERLAY_VOID_CALLBACK
	#undef OVERLAY_BOOL_CALLBACK

//	bool ChooseText(Asura_Hash_ID& uTextID) const;

public:
	static int s_iMostRecentSelectedFont;
	static Tools_GUIMenu_Element_StatusText* s_pxThis;


private:
	Asura_GUIMenu_Element_StatusText* m_pxAsuraStatusText;
//	Asura_UnicodeChar m_wszString[ASURA_GUIMENU_TEXT_ELEMENT_MAX_CUSTOM_STRING_SIZE];

// SK - 23.02.07 - moved to public scope because i need to access it from the numeric tool widget
//	static int s_iMostRecentSelectedFont;

	int m_iCurrentHorzJustifyIndex;
	bool m_bHorzJustifyChanged;
	int m_iCurrentVertJustifyIndex;
	bool m_bVertJustifyChanged;

	u_int m_uHorzRenderFlag;
	u_int m_uVertRenderFlag;

	bool m_bListChanged;

	bool m_bAutoScale;

	bool m_bShadowChanged;
	u_int m_uShadowFlag;
	int m_iCurrentShadowIndex;

	Tools_GUIMenu_Font_Special_Effects m_xToolsSpecialEffects;
};

// --------------------------------------------------------------------
// -- EditStatusTextInfo modal overlay --

class StatusTextInfoOverlay : public Tools_Modal_Overlay
{
public :
	StatusTextInfoOverlay();
	bool DoModal();

	void SetData( Asura_GUIMenu_StatusText_Info xInfo)	{	m_xInfo = xInfo;	}
	Asura_GUIMenu_StatusText_Info GetData( void)	{	return m_xInfo;	}

private :
	void InitialiseOverlay(class Asura_Overlay* pxOverlay);
	void Update();

	static void OkaySelected(int iData);
	static void CancelSelected(int iData);

#define OVERLAY_VOID_CALLBACK(__FnName)\
	static void __FnName(int iThis){((StatusTextInfoOverlay*)iThis)->__FnName();}\
	void __FnName();

		OVERLAY_VOID_CALLBACK(ChooseTextPage)
		OVERLAY_VOID_CALLBACK(ChooseText)
		//OVERLAY_VOID_CALLBACK(ChooseColour)

#undef OVERLAY_VOID_CALLBACK

	bool m_bReturnValue;

	Asura_GUIMenu_StatusText_Info m_xInfo;

	bool m_bTextChanged;
	bool m_bCondTypeChanged;
	bool m_bChanged;

	int m_iCurrentConditionIndex;
};


#endif //ASURA_USE_GUI_MENU_SYSTEM
#endif //_TOOLS_GUIMENU_ELEMENT_STATUSTEXT_H_
