//
// Tools_GUIMenu_Element_Text.h
//
// Created by Richard Rice - 05/12/2006
// 
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//


#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif


#ifndef _TOOLS_GUIMENU_ELEMENT_TEXT_H_
#define _TOOLS_GUIMENU_ELEMENT_TEXT_H_
#ifdef ASURA_USE_GUI_MENU_SYSTEM

#include "GUIMenu/Tools_GUIMenu_Element_Base.h"


#define ASURA_GUIMENU_TEXT_ELEMENT_MAX_CUSTOM_STRING_SIZE	(1024)

class Asura_Font_Special_Effects;

// Tools effects class.
// Creates an overlay tab for Text and Status Text elements.
class Tools_GUIMenu_Font_Special_Effects
{
public:
	Tools_GUIMenu_Font_Special_Effects();

	void Initialise();
	void Copy(const Tools_GUIMenu_Font_Special_Effects* pxSource);
	void CopyFromAsura(Asura_Font_Special_Effects* pxEffects);
	void CopyToAsura(Asura_Font_Special_Effects* pxEffects);
	void AddEffectsOverlayControls(Asura_Overlay* pxOverlay, Asura_Tabs_Dialog* pxTabs, Asura_Vector_2& xOffset, bool* pbChanged);

	bool GetEnabledFlag() { return m_bSpecialEffects; }

	void DisableEditing(bool bDisable) { m_bDisableEditing = bDisable; }
private:

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

	OVERLAY_BOOL_CALLBACK(CanEditSpecialEffects)
	OVERLAY_BOOL_CALLBACK(CanEditTeletypeSettings)
	OVERLAY_BOOL_CALLBACK(CanEditDecryptSettings)
	OVERLAY_BOOL_CALLBACK(CanEditCursorSettings)
	OVERLAY_BOOL_CALLBACK(CanEnableSpecialEffects)
	OVERLAY_BOOL_CALLBACK(CanPlayEffect)

	OVERLAY_VOID_CALLBACK(PlayEffect)

#undef OVERLAY_VOID_CALLBACK
#undef OVERLAY_BOOL_CALLBACK

	bool m_bSpecialEffects;
	float m_fDelayTime;
	bool m_bTeleType;
	u_int m_uCharsPerSecond;
	float m_fAlphaFadeTime;

	int m_iTeletypeDirIndex;

	bool m_bDecrypt;
	float m_fDecryptTime;
	float m_fDecryptChangeCharTime;

	bool m_bCursor;
	float m_fCursorFlashTime;
	float m_fCursorStopTime;

	Asura_Font_Special_Effects* m_pxPlayEffects;

	bool m_bDisableEditing;
};


class Asura_GUIMenu_Element_Text;

class Tools_GUIMenu_Element_Text : public Tools_GUIMenu_Element_Base
{
	typedef Tools_GUIMenu_Element_Base PARENT;
public :
	Tools_GUIMenu_Element_Text(Asura_GUIMenu_Element_Text* pxAsuraText,Tools_GUIMenu_Root* pxToolsParent);

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

	virtual void Update();

	static void TextUpdated();

	//For changing the font on multiple elements at once
	static void SetFontOnSelection();

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

	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 bool GetTextToPreserve(Asura_Hash_ID& uTextID, Asura_Hash_ID& uTextPage) const;
	virtual void ApplyPreservedText(Asura_Hash_ID uTextID, Asura_Hash_ID uTextPage);
	virtual void SetFont(const char* szFont);

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


	OVERLAY_VOID_CALLBACK(ChooseFont)
	OVERLAY_VOID_CALLBACK(ChooseModifierFont)
	OVERLAY_VOID_CALLBACK(ChooseText)
	OVERLAY_VOID_CALLBACK(ChooseTextPage)
	OVERLAY_VOID_CALLBACK(ChooseModifierText)

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

	#undef OVERLAY_VOID_CALLBACK
	#undef OVERLAY_BOOL_CALLBACK

public:
	static int s_iMostRecentSelectedFont;

private:
	Asura_GUIMenu_Element_Text* m_pxAsuraText;
	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;

	float m_fOffsetX;
	float m_fOffsetY;
	float m_fScrollRate;
	// MRD 15/06/07: Varible for storing the required line spacing
	float m_fLineSpacing;

	int m_iCurrentHorzJustifyIndex;
	bool m_bHorzJustifyChanged;
	int m_iCurrentVertJustifyIndex;
	bool m_bVertJustifyChanged;
	int m_iCurrentShadowIndex;
	bool m_bShadowChanged;

	u_int m_uHorzRenderFlag;
	u_int m_uVertRenderFlag;
	u_int m_uShadowFlag;

	bool m_bWordWrap;
	bool m_bAutoScale;

	Tools_GUIMenu_Font_Special_Effects m_xToolsSpecialEffects;
};




#endif //ASURA_USE_GUI_MENU_SYSTEM
#endif //_TOOLS_GUIMENU_ELEMENT_TEXT_H_
