struct MetaQuestStatus
{
	var MetaQuest1Hidden : Bool;
	var MetaQuest1Value : Int32;
	var MetaQuest1Description : String;
	var MetaQuest2Hidden : Bool;
	var MetaQuest2Description : String;
	var MetaQuest2Value : Int32;
	var MetaQuest3Hidden : Bool;
	var MetaQuest3Description : String;
	var MetaQuest3Value : Int32;
}

class MetaQuestLogicController extends inkLogicController
{
	private editable var m_MetaQuestHint : inkWidgetRef;
	private editable var m_MetaQuestHintText : inkTextRef;
	private editable var m_MetaQuest1 : inkWidgetRef;
	private editable var m_MetaQuest2 : inkWidgetRef;
	private editable var m_MetaQuest3 : inkWidgetRef;
	private editable var m_MetaQuest1Value : inkTextRef;
	private editable var m_MetaQuest2Value : inkTextRef;
	private editable var m_MetaQuest3Value : inkTextRef;
	private var m_metaQuest1Description : String;
	private var m_metaQuest2Description : String;
	private var m_metaQuest3Description : String;
	private var animMeta1 : inkAnimProxy;
	private var animMeta2 : inkAnimProxy;
	private var animMeta3 : inkAnimProxy;
	private var animTooltip : inkAnimProxy;

	protected event OnInitialize()
	{
		InitMetaQuestControlls();
	}

	private function InitMetaQuestControlls()
	{
		inkWidgetRef.RegisterToCallback( m_MetaQuest1, 'OnHoverOver', this, 'OnItem1HoverOver' );
		inkWidgetRef.RegisterToCallback( m_MetaQuest2, 'OnHoverOver', this, 'OnItem2HoverOver' );
		inkWidgetRef.RegisterToCallback( m_MetaQuest3, 'OnHoverOver', this, 'OnItem3HoverOver' );
		inkWidgetRef.RegisterToCallback( m_MetaQuest1, 'OnHoverOut', this, 'OnHoverOut' );
		inkWidgetRef.RegisterToCallback( m_MetaQuest2, 'OnHoverOut', this, 'OnHoverOut' );
		inkWidgetRef.RegisterToCallback( m_MetaQuest3, 'OnHoverOut', this, 'OnHoverOut' );
	}

	public function SetMetaQuests( const status : ref< MetaQuestStatus > )
	{
		if( status.MetaQuest1Description != "" )
		{
			m_metaQuest1Description = status.MetaQuest1Description;
		}
		else
		{
			m_metaQuest1Description = "[Error: No description defined by the quest block. Contact quest team.]";
		}
		if( status.MetaQuest2Description != "" )
		{
			m_metaQuest2Description = status.MetaQuest2Description;
		}
		else
		{
			m_metaQuest2Description = "[Error: No description defined by the quest block. Contact quest team.]";
		}
		if( status.MetaQuest3Description != "" )
		{
			m_metaQuest3Description = status.MetaQuest3Description;
		}
		else
		{
			m_metaQuest3Description = "[Error: No description defined by the quest block. Contact quest team.]";
		}
		inkTextRef.SetText( m_MetaQuest1Value, status.MetaQuest1Value + "%" );
		inkTextRef.SetText( m_MetaQuest2Value, status.MetaQuest2Value + "%" );
		inkTextRef.SetText( m_MetaQuest3Value, status.MetaQuest3Value + "%" );
		inkWidgetRef.SetVisible( m_MetaQuest1, !( status.MetaQuest1Hidden ) );
		inkWidgetRef.SetVisible( m_MetaQuest2, !( status.MetaQuest2Hidden ) );
		inkWidgetRef.SetVisible( m_MetaQuest3, !( status.MetaQuest3Hidden ) );
	}

	protected event OnItem1HoverOver( evt : inkPointerEvent )
	{
		inkWidgetRef.SetVisible( m_MetaQuestHint, true );
		inkTextRef.SetText( m_MetaQuestHintText, GetLocalizedText( m_metaQuest1Description ) );
		inkWidgetRef.SetMargin( m_MetaQuestHint, inkMargin( -1070.0, -60.0, 0.0, 0.0 ) );
		animTooltip.Stop();
		if( !( animMeta1.IsPlaying() ) )
		{
			animMeta1 = PlayLibraryAnimation( 'metaquest1_hoverin' );
		}
		animTooltip = PlayLibraryAnimation( 'tooltip_in' );
	}

	protected event OnItem2HoverOver( evt : inkPointerEvent )
	{
		inkWidgetRef.SetVisible( m_MetaQuestHint, true );
		inkTextRef.SetText( m_MetaQuestHintText, GetLocalizedText( m_metaQuest2Description ) );
		inkWidgetRef.SetMargin( m_MetaQuestHint, inkMargin( 50.0, 570.0, 0.0, 0.0 ) );
		animTooltip.Stop();
		if( !( animMeta2.IsPlaying() ) )
		{
			animMeta2 = PlayLibraryAnimation( 'metaquest2_hoverin' );
		}
		animTooltip = PlayLibraryAnimation( 'tooltip_in' );
	}

	protected event OnItem3HoverOver( evt : inkPointerEvent )
	{
		inkWidgetRef.SetVisible( m_MetaQuestHint, true );
		inkTextRef.SetText( m_MetaQuestHintText, GetLocalizedText( m_metaQuest3Description ) );
		inkWidgetRef.SetMargin( m_MetaQuestHint, inkMargin( 1070.0, -60.0, 0.0, 0.0 ) );
		animTooltip.Stop();
		if( !( animMeta3.IsPlaying() ) )
		{
			animMeta3 = PlayLibraryAnimation( 'metaquest3_hoverin' );
		}
		animTooltip = PlayLibraryAnimation( 'tooltip_in' );
	}

	protected event OnHoverOut( evt : inkPointerEvent )
	{
		inkWidgetRef.SetVisible( m_MetaQuestHint, false );
	}

}

