class WardrobeOutfitSlotController extends inkLogicController
{
	private editable var m_slotNumberText : inkTextRef;
	private editable var m_newSetIndicator : inkWidgetRef;
	private var m_index : Int32;
	private var m_hovered : Bool;
	private var m_active : Bool;
	private var m_equipped : Bool;
	private var m_isNew : Bool;

	protected event OnInitialize()
	{
		RegisterToCallback( 'OnHoverOver', this, 'OnHoverOver' );
		RegisterToCallback( 'OnHoverOut', this, 'OnHoverOut' );
		RegisterToCallback( 'OnRelease', this, 'OnRelease' );
	}

	public function Setup( index : Int32, active : Bool, equipped : Bool, isNew : Bool )
	{
		m_index = index;
		m_active = active;
		m_equipped = equipped;
		m_isNew = isNew;
		inkTextRef.SetText( m_slotNumberText, IntToString( m_index + 1 ) );
		inkWidgetRef.SetVisible( m_newSetIndicator, isNew );
		UpdateState();
	}

	public function Update( active : Bool, equipped : Bool )
	{
		m_active = active;
		m_equipped = equipped;
		UpdateState();
	}

	public function SetIsNew( isNew : Bool )
	{
		m_isNew = isNew;
		inkWidgetRef.SetVisible( m_newSetIndicator, isNew );
	}

	public function GetIndex() : Int32
	{
		return m_index;
	}

	public function IsNew() : Bool
	{
		return m_isNew;
	}

	protected event OnHoverOver( e : inkPointerEvent )
	{
		var evt : WardrobeOutfitSlotHoverOverEvent;
		m_hovered = true;
		UpdateState();
		evt = new WardrobeOutfitSlotHoverOverEvent;
		evt.controller = this;
		evt.evt = e;
		QueueEvent( evt );
	}

	protected event OnHoverOut( e : inkPointerEvent )
	{
		m_hovered = false;
		UpdateState();
		QueueEvent( new WardrobeOutfitSlotHoverOutEvent );
	}

	protected event OnRelease( e : inkPointerEvent )
	{
		var evt : WardrobeOutfitSlotClickedEvent;
		if( e.IsAction( 'click' ) )
		{
			if( m_active )
			{
				PlaySound( 'Button', 'OnPress' );
				evt = new WardrobeOutfitSlotClickedEvent;
				evt.index = m_index;
				evt.equipped = m_equipped;
				QueueEvent( evt );
			}
			else
			{
				PlaySound( 'Item', 'OnCraftFailed' );
			}
		}
	}

	private function UpdateState()
	{
		if( m_active )
		{
			if( m_hovered && m_equipped )
			{
				GetRootWidget().SetState( 'EquippedHover' );
			}
			else if( m_hovered )
			{
				GetRootWidget().SetState( 'Hover' );
			}
			else if( m_equipped )
			{
				GetRootWidget().SetState( 'Equipped' );
			}
			else
			{
				GetRootWidget().SetState( 'Default' );
			}
		}
		else
		{
			GetRootWidget().SetState( 'Disabled' );
		}
	}

}

class WardrobeOutfitSlotClickedEvent extends Event
{
	var index : Int32;
	var equipped : Bool;
}

class WardrobeOutfitSlotHoverOverEvent extends Event
{
	var evt : inkPointerEvent;
	var controller : weak< WardrobeOutfitSlotController >;
}

class WardrobeOutfitSlotHoverOutEvent extends Event
{
}

class DummyTooltipData extends ATooltipData
{
}

class WardrobeOutfitInfoTooltipController extends AGenericTooltipController
{
	editable var m_videoWidget : inkVideoRef;

	public override function SetData( tooltipData : ATooltipData )
	{
		inkVideoRef.Stop( m_videoWidget );
		inkVideoRef.SetVideoPath( m_videoWidget, R"base\movies\misc\wardrobe\wardrobe_tooltip_footage_1.bk2" );
		inkVideoRef.SetLoop( m_videoWidget, true );
		inkVideoRef.Play( m_videoWidget );
	}

}

