/* ======================== idMenuWidget::SetFocusIndex ======================== */ void idMenuWidget::SetFocusIndex( const int index, bool skipSound ) { if( GetChildren().Num() == 0 ) { return; } const int oldIndex = focusIndex; assert( index >= 0 && index < GetChildren().Num() ); //&& oldIndex >= 0 && oldIndex < GetChildren().Num() ); focusIndex = index; if( oldIndex != focusIndex && !skipSound ) { if( menuData != NULL ) { menuData->PlaySound( GUI_SOUND_FOCUS ); } } idSWFParmList parms; parms.Append( oldIndex ); parms.Append( index ); // need to mark the widget as having lost focus if( oldIndex != index && oldIndex >= 0 && oldIndex < GetChildren().Num() && GetChildByIndex( oldIndex ).GetState() != WIDGET_STATE_HIDDEN ) { GetChildByIndex( oldIndex ).ReceiveEvent( idWidgetEvent( WIDGET_EVENT_FOCUS_OFF, 0, NULL, parms ) ); } //assert( GetChildByIndex( index ).GetState() != WIDGET_STATE_HIDDEN ); GetChildByIndex( index ).ReceiveEvent( idWidgetEvent( WIDGET_EVENT_FOCUS_ON, 0, NULL, parms ) ); }
void HighScoreListItem::Update(void) { c3_Static *subItem; MBCHAR strbuf[256]; subItem = (c3_Static *)GetChildByIndex(0); subItem->SetText(m_name); subItem = (c3_Static *)GetChildByIndex(1); sprintf(strbuf,"%d",m_score); subItem->SetText(strbuf); }
/* ======================== 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(); } } }
/* ======================== 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() ); } }
void MessageEyePointListItem::Update(void) { c3_Static *subItem; subItem = (c3_Static *)GetChildByIndex(0); subItem->SetText(m_name); }
/* ======================== 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(); }
/* ======================== 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 ); } } } } }
HRESULT DXDiagNVUtil::GetDisplayDeviceNode( DWORD dwDeviceIndex, IDxDiagContainer ** ppNode ) { // fill *ppNode with pointer to the display device at index nDevice of the DXDiag_DisplayDevices container // you must SAFE_RELEASE( *ppNode ) outside of this function. HRESULT hr = S_OK; FAIL_IF_NULL( ppNode ); IDxDiagContainer * pDevicesNode; hr = GetChildContainer( L"DxDiag_DisplayDevices", & pDevicesNode ); MSG_AND_RET_VAL_IF( FAILED(hr), "GetDisplayDeviceNode() couldn't get devices node!\n", hr ); // Get the device at the appropriate index hr = GetChildByIndex( pDevicesNode, dwDeviceIndex, ppNode ); SAFE_RELEASE( pDevicesNode ); return( hr ); }
/* ======================== idMenuWidget_LobbyList::SetEntryData ======================== */ void idMenuWidget_LobbyList::SetEntryData( int index, idStr name, voiceStateDisplay_t voiceState ) { if( GetChildren().Num() == 0 || index >= GetChildren().Num() ) { return; } idMenuWidget& child = GetChildByIndex( index ); idMenuWidget_LobbyButton* const button = dynamic_cast< idMenuWidget_LobbyButton* >( &child ); if( button == NULL ) { return; } button->SetButtonInfo( name, voiceState ); }
/* ======================== idMenuWidget_DynamicList::Recalculate ======================== */ void idMenuWidget_DynamicList::Recalculate() { idSWF * swf = GetSWFObject(); if ( swf == NULL ) { return; } idSWFScriptObject & root = swf->GetRootObject(); for ( int i = 0; i < GetChildren().Num(); ++i ) { idMenuWidget & child = GetChildByIndex( i ); child.SetSpritePath( GetSpritePath(), "info", "list", va( "item%d", i ) ); if ( child.BindSprite( root ) ) { child.SetState( WIDGET_STATE_NORMAL ); child.GetSprite()->StopFrame( 1 ); } } }
/* ======================== idMenuWidget_DevList::RecalculateDevMenu ======================== */ void idMenuWidget_DevList::RecalculateDevMenu() { if ( devMapListInfos.Num() > 0 ) { const idDeclDevMenuList * const devMenuListDecl = idDeclDevMenuList::resourceList.Load( devMapListInfos[ devMapListInfos.Num() - 1 ].name, false ); if ( devMenuListDecl != NULL ) { devMenuList = devMenuListDecl; } } idSWFScriptObject & root = gameLocal->GetMainMenu()->GetSWF()->GetRootObject(); for ( int i = 0; i < GetChildren().Num(); ++i ) { idMenuWidget & child = GetChildByIndex( i ); child.SetSpritePath( GetSpritePath(), va( "option%d", i ) ); if ( child.BindSprite( root ) ) { child.SetState( WIDGET_STATE_NORMAL ); child.GetSprite()->StopFrame( 1 ); } } }
/* ======================== idMenuScreen::Update ======================== */ void idMenuScreen::Update() { if( menuGUI == NULL ) { return; } // // Display // for( int childIndex = 0; childIndex < GetChildren().Num(); ++childIndex ) { GetChildByIndex( childIndex ).Update(); } if( menuData != NULL ) { menuData->UpdateChildren(); } }
/* ======================== idMenuWidget_DevList::NavigateForward ======================== */ void idMenuWidget_DevList::NavigateForward( const int optionIndex ) { if ( devMenuList == NULL ) { return; } const int focusedIndex = GetViewOffset() + optionIndex; const idDeclDevMenuList::idDevMenuOption & devOption = devMenuList->devMenuList[ focusedIndex ]; if ( ( devOption.devMenuDisplayName.Length() == 0 ) || ( devOption.devMenuDisplayName.Cmp( "..." ) == 0 ) ) { return; } if ( devOption.devMenuSubList != NULL ) { indexInfo_t & indexes = devMapListInfos.Alloc(); indexes.name = devOption.devMenuSubList->GetName(); indexes.focusIndex = GetFocusIndex(); indexes.viewIndex = GetViewIndex(); indexes.viewOffset = GetViewOffset(); RecalculateDevMenu(); SetViewIndex( 0 ); SetViewOffset( 0 ); Update(); // NOTE: This must be done after the Update() because it MAY change the sprites that // children refer to GetChildByIndex( 0 ).SetState( WIDGET_STATE_SELECTED ); ForceFocusIndex( 0 ); SetFocusIndex( 0 ); gameLocal->GetMainMenu()->ClearWidgetActionRepeater(); } else { cmdSystem->AppendCommandText( va( "loadDevMenuOption %s %d\n", devMapListInfos[ devMapListInfos.Num() - 1 ].name, focusedIndex ) ); } }
/* ======================== 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(); } } } }
/* ======================== idMenuWidget_PDA_AudioFiles::Update ======================== */ void idMenuWidget_PDA_AudioFiles::Update() { if( GetSWFObject() == NULL ) { return; } idSWFScriptObject& root = GetSWFObject()->GetRootObject(); if( !BindSprite( root ) || GetSprite() == NULL ) { return; } idPlayer* player = gameLocal.GetLocalPlayer(); if( player == NULL ) { return; } if( pdaIndex > player->GetInventory()->pdas.Num() ) { return; } const idDeclPDA* pda = player->GetInventory()->pdas[ pdaIndex ]; idSWFScriptObject* dataObj = GetSprite()->GetScriptObject()->GetNestedObj( "info" ); if( dataObj != NULL && pda != NULL ) { idSWFTextInstance* txtOwner = dataObj->GetNestedText( "txtOwner" ); if( txtOwner != NULL ) { idStr ownerText = idLocalization::GetString( "#str_04203" ); ownerText.Append( ": " ); ownerText.Append( pda->GetFullName() ); txtOwner->SetText( ownerText.c_str() ); } idMenuWidget_DynamicList* const audioList = dynamic_cast< idMenuWidget_DynamicList* >( &GetChildByIndex( 0 ) ); if( audioList != NULL ) { audioFileNames.Clear(); if( pda->GetNumAudios() == 0 ) { idList< idStr > audioName; audioName.Append( idLocalization::GetString( "#str_04168" ) ); audioList->GetChildByIndex( 0 ).SetState( WIDGET_STATE_DISABLED ); audioFileNames.Append( audioName ); } else { audioList->GetChildByIndex( 0 ).SetState( WIDGET_STATE_NORMAL ); const idDeclAudio* aud = NULL; for( int index = 0; index < pda->GetNumAudios(); ++index ) { idList< idStr > audioName; aud = pda->GetAudioByIndex( index ); if( aud != NULL ) { audioName.Append( aud->GetAudioName() ); } else { audioName.Append( "" ); } audioFileNames.Append( audioName ); } } audioList->SetListData( audioFileNames ); if( audioList->BindSprite( root ) ) { audioList->Update(); } } } //idSWFSpriteInstance * dataSprite = dataObj->GetSprite(); }
/* ======================== idMenuWidget_PDA_AudioFiles::ObserveEvent ======================== */ void idMenuWidget_PDA_AudioFiles::ObserveEvent( const idMenuWidget& widget, const idWidgetEvent& event ) { const idMenuWidget_Button* const button = dynamic_cast< const idMenuWidget_Button* >( &widget ); if( button == NULL ) { return; } const idMenuWidget* const listWidget = button->GetParent(); if( listWidget == NULL ) { return; } switch( event.type ) { case WIDGET_EVENT_FOCUS_ON: { const idMenuWidget_DynamicList* const list = dynamic_cast< const idMenuWidget_DynamicList* const >( listWidget ); if( GetSprite() != NULL ) { if( list->GetViewIndex() == 0 ) { GetSprite()->PlayFrame( "rollOff" ); } else if( ( pdaIndex == 0 || GetSprite()->GetCurrentFrame() <= 2 || GetSprite()->GetCurrentFrame() > GetSprite()->FindFrame( "idle" ) ) && list->GetViewIndex() != 0 ) { GetSprite()->PlayFrame( "rollOn" ); } } pdaIndex = list->GetViewIndex(); if( GetParent() != NULL && menuData != NULL && menuData->ActiveScreen() == PDA_AREA_USER_DATA ) { GetParent()->Update(); } else { Update(); } idMenuWidget_DynamicList* const audioList = dynamic_cast< idMenuWidget_DynamicList* >( &GetChildByIndex( 0 ) ); if( audioList != NULL ) { audioList->SetFocusIndex( 0 ); audioList->SetViewIndex( 0 ); } break; } case WIDGET_EVENT_FOCUS_OFF: { idMenuWidget_DynamicList* const audioList = dynamic_cast< idMenuWidget_DynamicList* >( &GetChildByIndex( 0 ) ); if( audioList != NULL ) { audioList->SetFocusIndex( 0 ); audioList->SetViewIndex( 0 ); } Update(); break; } } }