Пример #1
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();
		}
	}
}
Пример #2
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() );
	}

}
Пример #3
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 );
		}
	}
	
}
/*
========================
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();
			}
		}
	}
}