MenuWidget_LobbyList.cpp (3966B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #pragma hdrstop 29 #include "../../idLib/precompiled.h" 30 #include "../Game_local.h" 31 32 /* 33 ======================== 34 idMenuWidget_LobbyList::Update 35 ======================== 36 */ 37 void idMenuWidget_LobbyList::Update() { 38 39 if ( GetSWFObject() == NULL ) { 40 return; 41 } 42 43 idSWFScriptObject & root = GetSWFObject()->GetRootObject(); 44 45 if ( !BindSprite( root ) ) { 46 return; 47 } 48 49 for ( int i = 0; i < headings.Num(); ++i ) { 50 idSWFTextInstance * txtHeading = GetSprite()->GetScriptObject()->GetNestedText( va( "heading%d", i ) ); 51 if ( txtHeading != NULL ) { 52 txtHeading->SetText( headings[i] ); 53 txtHeading->SetStrokeInfo( true, 0.75f, 1.75f ); 54 } 55 } 56 57 for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) { 58 bool shown = false; 59 if ( optionIndex < GetChildren().Num() ) { 60 idMenuWidget & child = GetChildByIndex( optionIndex ); 61 child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) ); 62 if ( child.BindSprite( root ) ) { 63 shown = PrepareListElement( child, optionIndex ); 64 if ( shown ) { 65 child.GetSprite()->SetVisible( true ); 66 child.Update(); 67 } else { 68 child.GetSprite()->SetVisible( false ); 69 } 70 } 71 } 72 } 73 } 74 75 /* 76 ======================== 77 idMenuWidget_LobbyList::PrepareListElement 78 ======================== 79 */ 80 bool idMenuWidget_LobbyList::PrepareListElement( idMenuWidget & widget, const int childIndex ) { 81 82 idMenuWidget_LobbyButton * const button = dynamic_cast< idMenuWidget_LobbyButton * >( &widget ); 83 if ( button == NULL ) { 84 return false; 85 } 86 87 if ( !button->IsValid() ) { 88 return false; 89 } 90 91 return true; 92 93 } 94 95 /* 96 ======================== 97 idMenuWidget_LobbyList::SetHeadingInfo 98 ======================== 99 */ 100 void idMenuWidget_LobbyList::SetHeadingInfo( idList< idStr > & list ) { 101 headings.Clear(); 102 for ( int index = 0; index < list.Num(); ++index ) { 103 headings.Append( list[ index ] ); 104 } 105 } 106 107 /* 108 ======================== 109 idMenuWidget_LobbyList::SetEntryData 110 ======================== 111 */ 112 void idMenuWidget_LobbyList::SetEntryData( int index, idStr name, voiceStateDisplay_t voiceState ) { 113 114 if ( GetChildren().Num() == 0 || index >= GetChildren().Num() ) { 115 return; 116 } 117 118 idMenuWidget & child = GetChildByIndex( index ); 119 idMenuWidget_LobbyButton * const button = dynamic_cast< idMenuWidget_LobbyButton * >( &child ); 120 121 if ( button == NULL ) { 122 return; 123 } 124 125 button->SetButtonInfo( name, voiceState ); 126 }