/* ======================== 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() ); } }
/* ======================== 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(); } } } }