class ClothingSetController extends BaseButtonView
{
	protected editable var m_setName : inkTextRef;
	private var m_clothingSet : ClothingSet;
	private var m_equipped : Bool;
	default m_equipped = false;
	private var m_selected : Bool;
	default m_selected = false;
	private var m_defined : Bool;
	default m_defined = false;
	private var m_isHovered : Bool;
	default m_isHovered = false;
	private var m_hasChanges : Bool;
	default m_hasChanges = false;
	private var m_disabled : Bool;
	default m_disabled = false;
	private var m_styleWidget : weak< inkWidget >;

	protected event OnInitialize()
	{
		m_clothingSet = new ClothingSet;
		m_styleWidget = this.GetRootWidget();
		super.OnInitialize();
	}

	protected override function ButtonStateChanged( oldState : inkEButtonState, newState : inkEButtonState )
	{
		if( newState == inkEButtonState.Hover )
		{
			m_isHovered = true;
		}
		else if( oldState == inkEButtonState.Hover )
		{
			m_isHovered = false;
		}
		UpdateVisualState();
	}

	private function UpdateVisualState()
	{
		if( m_disabled )
		{
			if( m_selected )
			{
				m_styleWidget.SetState( 'DisabledSelected' );
			}
			else
			{
				m_styleWidget.SetState( 'Disabled' );
			}
		}
		else
		{
			if( m_isHovered )
			{
				if( m_selected )
				{
					if( m_equipped )
					{
						m_styleWidget.SetState( 'EquippedSelectedHover' );
					}
					else if( m_defined || m_hasChanges )
					{
						m_styleWidget.SetState( 'DefaultSelectedHover' );
					}
					else
					{
						m_styleWidget.SetState( 'DisabledSelectedHover' );
					}
				}
				else
				{
					if( m_equipped )
					{
						m_styleWidget.SetState( 'EquippedHover' );
					}
					else if( m_defined || m_hasChanges )
					{
						m_styleWidget.SetState( 'DefaultHover' );
					}
					else
					{
						m_styleWidget.SetState( 'DisabledHover' );
					}
				}
			}
			else
			{
				if( m_selected )
				{
					if( m_equipped )
					{
						m_styleWidget.SetState( 'EquippedSelected' );
					}
					else if( m_defined || m_hasChanges )
					{
						m_styleWidget.SetState( 'DefaultSelected' );
					}
					else
					{
						m_styleWidget.SetState( 'DisabledSelected' );
					}
				}
				else
				{
					if( m_equipped )
					{
						m_styleWidget.SetState( 'Equipped' );
					}
					else if( m_defined || m_hasChanges )
					{
						m_styleWidget.SetState( 'Default' );
					}
					else
					{
						m_styleWidget.SetState( 'Disabled' );
					}
				}
			}
		}
	}

	public function SetClothingSet( clothingSet : ClothingSet, showName : Bool )
	{
		m_clothingSet = clothingSet;
		SetDefined( true );
		inkTextRef.SetVisible( m_setName, showName );
	}

	public function UpdateNumbering( slotNumber : Int32 )
	{
		var textParams : inkTextParams;
		textParams = new inkTextParams;
		textParams.AddNumber( "0", slotNumber + 1 );
		inkTextRef.SetText( m_setName, "{0}", textParams );
		m_clothingSet.setID = WardrobeSystem.NumberToWardrobeClothingSetIndex( slotNumber );
	}

	public function GetClothingSet() : ClothingSet
	{
		return m_clothingSet;
	}

	public function SetSelected( selected : Bool )
	{
		m_selected = selected;
		UpdateVisualState();
	}

	public function SetDefined( defined : Bool )
	{
		m_defined = defined;
		UpdateVisualState();
	}

	public function SetEquipped( equipped : Bool )
	{
		m_equipped = equipped;
		UpdateVisualState();
	}

	public function SetClothingSetChanged( changed : Bool )
	{
		m_hasChanges = changed;
		UpdateVisualState();
	}

	public function GetDefined() : Bool
	{
		return m_defined;
	}

	public function GetEquipped() : Bool
	{
		return m_equipped;
	}

	public function GetClothingSetChanged() : Bool
	{
		return m_hasChanges;
	}

	public function SetDisabled( disabled : Bool )
	{
		m_disabled = disabled;
		UpdateVisualState();
	}

	public function IsDisabled() : Bool
	{
		return m_disabled;
	}

	public function IsHovered() : Bool
	{
		return m_isHovered;
	}

}

