class NewGameMenuGameController extends PreGameSubMenuGameController
{
	private var m_categories : weak< SelectorController >;
	private var m_gameDefinitions : weak< SelectorController >;
	private var m_genders : weak< SelectorController >;

	protected event OnInitialize()
	{
		var bigButtonsList : weak< inkHorizontalPanel >;
		bigButtonsList = ( ( inkHorizontalPanel )( GetWidget( 'Data/StaticBigButtonsList' ) ) );
		AddBigButton( bigButtonsList, "RUN FUNC. TEST MAP", 'OnRunFunctionalTestMap' );
		SetCursorOverWidget( bigButtonsList.GetWidget( 0 ) );
		InitDynamicButtons();
		InitSelectors();
	}

	protected event OnRunFunctionalTestMap( e : inkPointerEvent )
	{
		if( e.IsAction( 'click' ) )
		{
			GetSystemRequestsHandler().RunUiFunctionalTestWorld();
		}
	}

	protected event OnStartDefinition( e : inkPointerEvent )
	{
		if( e.IsAction( 'click' ) )
		{
			GetSystemRequestsHandler().StartGameDefinition( m_categories.GetCurrIndex(), m_gameDefinitions.GetCurrIndex(), m_genders.GetCurrIndex() );
		}
	}

	protected event OnCategoryChanged( index : Int32, value : String )
	{
		var values : array< String >;
		values = GetSystemRequestsHandler().GetGameDefinitions( m_categories.GetCurrIndex() );
		m_gameDefinitions.Clear();
		m_gameDefinitions.AddValues( values );
		if( values.Size() > 0 )
		{
			m_gameDefinitions.SetCurrIndex( 0 );
		}
	}

	protected event OnBack( e : inkPointerEvent )
	{
		if( e.IsAction( 'click' ) )
		{
			m_menuEventDispatcher.SpawnEvent( 'OnBack' );
		}
	}

	public function InitDynamicButtons()
	{
		var bigButtonsList : weak< inkHorizontalPanel >;
		bigButtonsList = ( ( inkHorizontalPanel )( GetWidget( 'Data/DynamicBigButtonsList' ) ) );
		bigButtonsList.RemoveAllChildren();
		AddBigButton( bigButtonsList, "START GAMEDEF", 'OnStartDefinition' );
		AddBigButton( bigButtonsList, "BACK", 'OnBack' );
	}

	public function InitSelectors()
	{
		var handler : weak< inkISystemRequestsHandler >;
		var selectorsList : weak< inkVerticalPanel >;
		handler = GetSystemRequestsHandler();
		selectorsList = ( ( inkVerticalPanel )( GetWidget( 'Data/Selectors' ) ) );
		selectorsList.RemoveAllChildren();
		m_categories = AddSelector( selectorsList, "Category:", handler.GetGameDefCategories() );
		m_categories.RegisterToCallback( 'OnSelectionChanged', this, 'OnCategoryChanged' );
		m_gameDefinitions = AddSelector( selectorsList, "Definition:", handler.GetGameDefinitions( m_categories.GetCurrIndex() ) );
		m_genders = AddSelector( selectorsList, "Gender:", handler.GetGenders() );
	}

}

