Exemplo n.º 1
0
/*
========================
idMenuWidget_DynamicList::Update
========================
*/
void idMenuWidget_DynamicList::Update() {

	if ( GetSWFObject() == NULL ) {
		return;
	}

	idSWFScriptObject & root = GetSWFObject()->GetRootObject();

	if ( !BindSprite( root ) ) {
		return;
	}

	for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
		
		if ( optionIndex >= children.Num() ) {
			idSWFSpriteInstance * item = GetSprite()->GetScriptObject()->GetNestedSprite( va( "item%d", optionIndex ) );
			if ( item != NULL ) {
				item->SetVisible( false );
				continue;
			}
		}

		idMenuWidget & child = GetChildByIndex( optionIndex );
		const int childIndex = GetViewOffset() + optionIndex;
		bool shown = false;
		child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
		if ( child.BindSprite( root ) ) {
			
			if ( optionIndex >= GetTotalNumberOfOptions() ) {
				child.ClearSprite();
				continue;
			} else {
				//const int controlIndex = GetNumVisibleOptions() - Min( GetNumVisibleOptions(), GetTotalNumberOfOptions() ) + optionIndex;
				shown = PrepareListElement( child, childIndex );
				child.Update();
			}

			if ( !shown ) {
				child.SetState( WIDGET_STATE_HIDDEN );
			} else {
				if ( optionIndex == focusIndex ) {
					child.SetState( WIDGET_STATE_SELECTING );
				} else {
					child.SetState( WIDGET_STATE_NORMAL );
				}
			}
		}
	}

	idSWFSpriteInstance * const upSprite = GetSprite()->GetScriptObject()->GetSprite( "upIndicator" );
	if ( upSprite != NULL ) {
		upSprite->SetVisible( GetViewOffset() > 0 );
	}

	idSWFSpriteInstance * const downSprite = GetSprite()->GetScriptObject()->GetSprite( "downIndicator" );
	if ( downSprite != NULL ) {
		downSprite->SetVisible( GetViewOffset() + GetNumVisibleOptions() < GetTotalNumberOfOptions() );
	}

}
Exemplo n.º 2
0
/*
========================
idMenuWidget_MenuBar::PrepareListElement
========================
*/
bool idMenuWidget_MenuBar::PrepareListElement( idMenuWidget & widget, const int navIndex ) {

	if ( navIndex >= GetNumVisibleOptions() ) {
		return false;
	}

	idMenuWidget_MenuButton * const button = dynamic_cast< idMenuWidget_MenuButton * >( &widget );
	if ( button == NULL || button->GetSprite() == NULL ) {
		return false;
	}

	if ( navIndex >= headings.Num() ) {
		button->SetLabel( "" );
	} else {
		button->SetLabel( headings[navIndex] );
		idSWFTextInstance * ti = button->GetSprite()->GetScriptObject()->GetNestedText( "txtVal" );
		if ( ti != NULL ) {
			ti->SetStrokeInfo( true, 0.7f, 1.25f );
			ti->SetText( headings[ navIndex ] );			
			button->SetPosition( buttonPos );
			totalWidth += ti->GetTextLength();
			buttonPos += rightSpacer + ti->GetTextLength();
		}
	}

	return true;
}
Exemplo n.º 3
0
/*
========================
idMenuWidget_ScoreboardList::Update
========================
*/
void idMenuWidget_ScoreboardList::Update() {

	if ( GetSWFObject() == NULL ) {
		return;
	}

	idSWFScriptObject & root = GetSWFObject()->GetRootObject();

	if ( !BindSprite( root ) ) {
		return;
	}

	for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
		idMenuWidget & child = GetChildByIndex( optionIndex );
		const int childIndex = GetViewOffset() + optionIndex;
		bool shown = false;
		child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
		if ( child.BindSprite( root ) ) {
			shown = PrepareListElement( child, childIndex );

			if ( optionIndex == focusIndex && child.GetState() != WIDGET_STATE_SELECTED && child.GetState() != WIDGET_STATE_SELECTING ) {
				child.SetState( WIDGET_STATE_SELECTING );
			} else if ( optionIndex != focusIndex && child.GetState() != WIDGET_STATE_NORMAL ) {
				child.SetState( WIDGET_STATE_NORMAL );
			}

			child.Update();
		}
	}
}
Exemplo n.º 4
0
/*
========================
idMenuWidget_DevList::NavigateBack
========================
*/
void idMenuWidget_DevList::NavigateBack() {
	assert( devMapListInfos.Num() != 0 );
	if ( devMapListInfos.Num() == 1 ) {
		// Important that this goes through as a DIRECT event, since more than likely the list
		// widget will have the parent's focus, so a standard ReceiveEvent() here would turn
		// into an infinite recursion.
		idWidgetEvent event( WIDGET_EVENT_BACK, 0, NULL, idSWFParmList() );
		
		idWidgetAction action;
		action.Set( WIDGET_ACTION_GO_BACK, MENU_ROOT );
		HandleAction( action, event );
		
		return;
	}

	// NOTE: we need a copy here, since it's about to be removed from the list
	const indexInfo_t indexes = devMapListInfos[ devMapListInfos.Num() - 1 ];
	assert( indexes.focusIndex < GetChildren().Num() );
	assert( ( indexes.viewIndex - indexes.viewOffset ) < GetNumVisibleOptions() );
	devMapListInfos.RemoveIndex( devMapListInfos.Num() - 1 );

	RecalculateDevMenu();

	SetViewIndex( indexes.viewIndex );
	SetViewOffset( indexes.viewOffset );

	Update();

	// NOTE: This must be done AFTER Update() because so that it is sure to refer to the proper sprite
	GetChildByIndex( indexes.focusIndex ).SetState( WIDGET_STATE_SELECTED );
	ForceFocusIndex( indexes.focusIndex );
	SetFocusIndex( indexes.focusIndex );

	gameLocal->GetMainMenu()->ClearWidgetActionRepeater();
}
Exemplo n.º 5
0
/*
========================
idMenuWidget_MenuBar::Update
========================
*/
void idMenuWidget_MenuBar::Update()
{

	if( GetSWFObject() == NULL )
	{
		return;
	}
	
	idSWFScriptObject& root = GetSWFObject()->GetRootObject();
	
	if( !BindSprite( root ) )
	{
		return;
	}
	
	totalWidth = 0.0f;
	buttonPos = 0.0f;
	
	for( int index = 0; index < GetNumVisibleOptions(); ++index )
	{
	
		if( index >= children.Num() )
		{
			break;
		}
		
		if( index != 0 )
		{
			totalWidth += rightSpacer;
		}
		
		idMenuWidget& child = GetChildByIndex( index );
		child.SetSpritePath( GetSpritePath(), va( "btn%d", index ) );
		if( child.BindSprite( root ) )
		{
			PrepareListElement( child, index );
			child.Update();
		}
	}
	
	// 640 is half the size of our flash files width
	float xPos = 640.0f - ( totalWidth / 2.0f );
	GetSprite()->SetXPos( xPos );
	
	idSWFSpriteInstance* backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" );
	if( backing != NULL )
	{
		if( menuData != NULL && menuData->GetPlatform() != 2 )
		{
			backing->SetVisible( false );
		}
		else
		{
			backing->SetVisible( true );
			backing->SetXPos( totalWidth / 2.0f );
		}
	}
	
}
Exemplo n.º 6
0
/*
========================
idMenuWidget_DevList::Initialize
========================
*/
void idMenuWidget_DevList::Initialize() {
	AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, 1 );
	AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, -1 );
	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
	AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );

	int optionIndex = 0;
	while ( GetChildren().Num() < GetNumVisibleOptions() ) {
		idMenuWidget_Button * const buttonWidget = new ( TAG_MENU ) idMenuWidget_Button();
		buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( new ( TAG_SWF ) DevList_NavigateForward( this, optionIndex++ ) );
		AddChild( buttonWidget );
	}
}
/*
========================
idMenuWidget_NavBar::PrepareListElement
========================
*/
bool idMenuWidget_NavBar::PrepareListElement( idMenuWidget& widget, const int navIndex )
{

	if( navIndex >= GetNumVisibleOptions() || navIndex >= headings.Num() )
	{
		return false;
	}
	
	idMenuWidget_NavButton* const button = dynamic_cast< idMenuWidget_NavButton* >( &widget );
	if( button == NULL || button->GetSprite() == NULL )
	{
		return false;
	}
	
	button->SetLabel( headings[navIndex] );
	idSWFTextInstance* ti = button->GetSprite()->GetScriptObject()->GetNestedText( "txtVal" );
	if( ti != NULL )
	{
		ti->SetStrokeInfo( true, 0.7f, 1.25f );
		if( navIndex < GetFocusIndex() )
		{
			ti->SetText( headings[ navIndex ] );
			buttonPos = buttonPos + ti->GetTextLength();
			button->SetPosition( buttonPos );
			button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_LEFT );
			buttonPos += leftSpacer;
		}
		else if( navIndex > GetFocusIndex() )
		{
			ti->SetText( headings[ navIndex ] );
			ti->SetStrokeInfo( true, 0.7f, 1.25f );
			button->GetSprite()->SetXPos( buttonPos );
			button->SetPosition( buttonPos );
			button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_RIGHT );
			buttonPos = buttonPos + ti->GetTextLength() + rightSpacer;
		}
		else
		{
			ti->SetText( headings[ navIndex ] );
			ti->SetStrokeInfo( true, 0.7f, 1.25f );
			button->GetSprite()->SetXPos( buttonPos );
			button->SetPosition( buttonPos );
			button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_SELECTED );
			buttonPos = buttonPos + ti->GetTextLength() + selectedSpacer;
		}
	}
	
	return true;
	
}
/*
========================
idMenuWidget_LobbyList::Update
========================
*/
void idMenuWidget_LobbyList::Update()
{

	if( GetSWFObject() == NULL )
	{
		return;
	}
	
	idSWFScriptObject& root = GetSWFObject()->GetRootObject();
	
	if( !BindSprite( root ) )
	{
		return;
	}
	
	for( int i = 0; i < headings.Num(); ++i )
	{
		idSWFTextInstance* txtHeading = GetSprite()->GetScriptObject()->GetNestedText( va( "heading%d", i ) );
		if( txtHeading != NULL )
		{
			txtHeading->SetText( headings[i] );
			txtHeading->SetStrokeInfo( true, 0.75f, 1.75f );
		}
	}
	
	for( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex )
	{
		bool shown = false;
		if( optionIndex < GetChildren().Num() )
		{
			idMenuWidget& child = GetChildByIndex( optionIndex );
			child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
			if( child.BindSprite( root ) )
			{
				shown = PrepareListElement( child, optionIndex );
				if( shown )
				{
					child.GetSprite()->SetVisible( true );
					child.Update();
				}
				else
				{
					child.GetSprite()->SetVisible( false );
				}
			}
		}
	}
}
/*
========================
idMenuWidget_NavBar::PrepareListElement
========================
*/
void idMenuWidget_NavBar::Update()
{

	if( GetSWFObject() == NULL )
	{
		return;
	}
	
	idSWFScriptObject& root = GetSWFObject()->GetRootObject();
	
	if( !BindSprite( root ) )
	{
		return;
	}
	
	int rightIndex = 0;
	
	buttonPos = initialPos;
	
	for( int index = 0; index < GetNumVisibleOptions() - 1; ++index )
	{
		idSWFSpriteInstance* const rightOption = GetSprite()->GetScriptObject()->GetSprite( va( "optionRight%d", index ) );
		rightOption->SetVisible( false );
		idSWFSpriteInstance* const leftOption = GetSprite()->GetScriptObject()->GetSprite( va( "optionLeft%d", index ) );
		leftOption->SetVisible( false );
	}
	
	for( int index = 0; index < GetTotalNumberOfOptions(); ++index )
	{
		idMenuWidget& child = GetChildByIndex( index );
		idMenuWidget_NavButton* const button = dynamic_cast< idMenuWidget_NavButton* >( &child );
		button->SetLabel( "" );
	}
	
	for( int index = 0; index < GetNumVisibleOptions(); ++index )
	{
		if( index < GetFocusIndex() )
		{
			idMenuWidget& child = GetChildByIndex( index );
			child.SetSpritePath( GetSpritePath(), va( "optionLeft%d", index ) );
			
			if( child.BindSprite( root ) )
			{
				PrepareListElement( child, index );
				child.Update();
			}
			
		}
		else if( index > GetFocusIndex() )
		{
			int rightChildIndex = ( GetNumVisibleOptions() - 1 ) + ( index - 1 );
			idMenuWidget& child = GetChildByIndex( rightChildIndex );
			child.SetSpritePath( GetSpritePath(), va( "optionRight%d", rightIndex ) );
			rightIndex++;
			
			if( child.BindSprite( root ) )
			{
				PrepareListElement( child, index );
				child.Update();
			}
			
		}
		else
		{
			int mainIndex = GetTotalNumberOfOptions() - 1;
			idMenuWidget& child = GetChildByIndex( mainIndex );
			child.SetSpritePath( GetSpritePath(), va( "option" ) );
			
			if( child.BindSprite( root ) )
			{
				PrepareListElement( child, index );
				child.Update();
			}
		}
	}
}