import class InteractionsHubGameController extends inkHUDGameController
{
	private const editable var m_TopInteractionWidgetsLibraries : array< inkWidgetLibraryReference >;
	private editable var m_TopInteractionsRoot : inkWidgetRef;
	private const editable var m_BotInteractionWidgetsLibraries : array< inkWidgetLibraryReference >;
	private editable var m_BotInteractionsRoot : inkWidgetRef;
	private editable var m_TooltipsManagerRef : inkWidgetRef;
	private editable var m_TooltipsAnchorPoint : inkWidgetRef;
	private var m_TooltipsManager : weak< gameuiTooltipsManager >;
	var m_tooltipProvider : weak< TooltipProvider >;

	public import function SetShowTooltipsTimer( optional time : Float );
	public import function ResetShowTooltipsTimer();

	protected event OnInitialize()
	{
		var i, limit : Int32;
		var libraryRef : inkWidgetLibraryReference;
		var createdWidget : weak< inkWidget >;
		for( i = 0, limit = m_TopInteractionWidgetsLibraries.Size(); i < limit; i += 1 )
		{
			libraryRef = m_TopInteractionWidgetsLibraries[ i ];
			createdWidget = SpawnFromExternal( inkWidgetRef.Get( m_TopInteractionsRoot ), inkWidgetLibraryResource.GetPath( libraryRef.widgetLibrary ), libraryRef.widgetItem );
			createdWidget.RegisterToCallback( 'OnTooltipRequest', this, 'OnTooltipRequest' );
		}
		for( i = 0, limit = m_BotInteractionWidgetsLibraries.Size(); i < limit; i += 1 )
		{
			libraryRef = m_BotInteractionWidgetsLibraries[ i ];
			createdWidget = SpawnFromExternal( inkWidgetRef.Get( m_BotInteractionsRoot ), inkWidgetLibraryResource.GetPath( libraryRef.widgetLibrary ), libraryRef.widgetItem );
			createdWidget.RegisterToCallback( 'OnTooltipRequest', this, 'OnTooltipRequest' );
		}
		m_TooltipsManager = ( ( gameuiTooltipsManager )( inkWidgetRef.GetControllerByType( m_TooltipsManagerRef, 'gameuiTooltipsManager' ) ) );
		if( m_TooltipsManager )
		{
			m_TooltipsManager.Setup( ETooltipsStyle.HUD, false );
		}
	}

	protected event OnRefreshTooltipEvent( e : RefreshTooltipEvent )
	{
		m_tooltipProvider = ( ( TooltipProvider )( e.widget.GetControllerByType( 'TooltipProvider' ) ) );
		if( m_tooltipProvider && m_TooltipsManager )
		{
			m_TooltipsManager.HideTooltips();
			m_TooltipsManager.PlayHidingAnimation();
			if( m_tooltipProvider.IsVisible() )
			{
				SetShowTooltipsTimer();
			}
			else
			{
				ResetShowTooltipsTimer();
			}
		}
	}

	protected event OnInvalidateHidden( e : InvalidateTooltipHiddenStateEvent )
	{
		m_tooltipProvider = ( ( TooltipProvider )( e.widget.GetControllerByType( 'TooltipProvider' ) ) );
		if( ( m_TooltipsManager && m_tooltipProvider ) && !( m_tooltipProvider.IsVisible() ) )
		{
			ResetShowTooltipsTimer();
			m_TooltipsManager.HideTooltips();
			m_TooltipsManager.PlayHidingAnimation();
		}
	}

	protected event OnTooltipRequest( e : weak< inkWidget > )
	{
		m_tooltipProvider = ( ( TooltipProvider )( e.GetControllerByType( 'TooltipProvider' ) ) );
		if( m_tooltipProvider && m_TooltipsManager )
		{
			m_TooltipsManager.HideTooltips();
			m_TooltipsManager.PlayHidingAnimation();
			SetShowTooltipsTimer();
		}
	}

	protected event OnShowTooltips()
	{
		if( m_tooltipProvider && m_TooltipsManager )
		{
			m_TooltipsManager.ShowTooltips( m_tooltipProvider.GetTooltipsData() );
			m_TooltipsManager.PlayShowingAnimation();
		}
	}

}

