MenuWidget_LobbyList.cpp 3.9 KB

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