DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

MenuWidget_Button.cpp (20514B)


      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_Button
     35 
     36 SWF object structure
     37 --------------------
     38 BUTTON (Frames: up, over, out, down, release, disabled, sel_up, sel_over, sel_out, sel_down, sel_release, selecting, unselecting)
     39 	txtOption
     40 		txtValue (Text)
     41 	optionType (Frames: One per mainMenuOption_t enum)
     42 		sliderBar
     43 			bar (Frames: 1-100 for percentage filled)
     44 			btnLess
     45 			btnMore
     46 		sliderText
     47 			txtVal (Text)
     48 			btnLess
     49 			btnMore
     50 
     51 Future work:
     52 - Perhaps this should be called "MultiButton", since it merges additional controls with a standard button?
     53 ================================================================================================
     54 */
     55 
     56 //---------------------------------
     57 // Animation State Transitions
     58 //
     59 // Maps animations that should be called when transitioning states:
     60 //
     61 //		X-axis = state transitioning FROM
     62 //		Y-axis = state transitioning TO
     63 //
     64 // An empty string indicates remain at current animation.
     65 //---------------------------------
     66 static const char * ANIM_STATE_TRANSITIONS[ idMenuWidget_Button::ANIM_STATE_MAX * idMenuWidget_Button::ANIM_STATE_MAX ] = {
     67 	// UP			DOWN			OVER
     68 	"",				"release",		"out",		// UP
     69 	"down",			"",				"down",		// DOWN
     70 	"over",			"over",			"",			// OVER
     71 };
     72 
     73 // script name for the control object for a given type of button
     74 static const char * const CONTROL_SPRITE_NAMES[ MAX_MENU_OPTION_TYPES ] = {
     75 	NULL,
     76 	"sliderBar",
     77 	"sliderText", 
     78 	"sliderText",
     79 	NULL,
     80 	"sliderText",
     81 };
     82 compile_time_assert( sizeof( CONTROL_SPRITE_NAMES ) / sizeof( CONTROL_SPRITE_NAMES[ 0 ] ) == MAX_MENU_OPTION_TYPES );
     83 
     84 /*
     85 ========================
     86 idMenuWidget_Button::Update
     87 ========================
     88 */
     89 void idMenuWidget_Button::Update() {
     90 
     91 	if ( menuData != NULL && menuData->GetGUI() != NULL ) {
     92 		BindSprite( menuData->GetGUI()->GetRootObject() );
     93 	}
     94 
     95 	if ( GetSprite() == NULL ) {
     96 		return;
     97 	}
     98 
     99 	idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
    100 
    101 	if ( btnLabel.IsEmpty() ) {
    102 		if ( values.Num() > 0 ) {
    103 			for ( int val = 0; val < values.Num(); ++val ) {
    104 				idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
    105 				if ( textObject != NULL ) {
    106 					idSWFTextInstance * const text = textObject->GetText();
    107 					text->SetIgnoreColor( ignoreColor );
    108 					text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
    109 					text->SetText( values[ val ].c_str() );
    110 					text->SetStrokeInfo( true, 0.75f, 2.0f );
    111 				}
    112 			}
    113 		} else if ( img != NULL ) {
    114 			idSWFSpriteInstance * btnImg = spriteObject->GetNestedSprite( "img" );
    115 			if ( btnImg != NULL ) {
    116 				btnImg->SetMaterial( img );
    117 			}
    118 
    119 			btnImg = spriteObject->GetNestedSprite( "imgTop" );
    120 			if ( btnImg != NULL ) {
    121 				btnImg->SetMaterial( img );
    122 			}
    123 		} else {
    124 			ClearSprite();
    125 		}
    126 	} else {
    127 		idSWFScriptObject * const textObject = spriteObject->GetNestedObj( "label0", "txtVal" );
    128 		if ( textObject != NULL ) {
    129 			idSWFTextInstance * const text = textObject->GetText();
    130 			text->SetIgnoreColor( ignoreColor );
    131 			text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
    132 			text->SetText( btnLabel.c_str() );
    133 			text->SetStrokeInfo( true, 0.75f, 2.0f );
    134 		}
    135 	}
    136 
    137 	// events
    138 	spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
    139 	spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
    140 
    141 	idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
    142 	if ( hitBox == NULL ) {
    143 		hitBox = spriteObject;
    144 	}
    145 
    146 	hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    147 	hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    148 }
    149 
    150 /*
    151 ========================
    152 idMenuWidget_Button::ExecuteEvent
    153 ========================
    154 */
    155 bool idMenuWidget_Button::ExecuteEvent( const idWidgetEvent & event ) {
    156 	bool handled = false;
    157 
    158 	// do nothing at all if it's disabled
    159 	if ( GetState() != WIDGET_STATE_DISABLED ) {
    160 		switch ( event.type ) {
    161 			case WIDGET_EVENT_PRESS: {
    162 				if ( GetMenuData() != NULL ) {
    163 					GetMenuData()->PlaySound( GUI_SOUND_ADVANCE );	
    164 				}
    165 				AnimateToState( ANIM_STATE_DOWN );
    166 				handled = true;
    167 				break;
    168 			}
    169 			case WIDGET_EVENT_RELEASE: {
    170 				AnimateToState( ANIM_STATE_UP );
    171 				GetMenuData()->ClearWidgetActionRepeater();
    172 				handled = true;
    173 				break;
    174 			}
    175 			case WIDGET_EVENT_ROLL_OVER: {
    176 				if ( GetMenuData() != NULL ) {
    177 					GetMenuData()->PlaySound( GUI_SOUND_ROLL_OVER );	
    178 				}
    179 				AnimateToState( ANIM_STATE_OVER );
    180 				handled = true;
    181 				break;
    182 			}
    183 			case WIDGET_EVENT_ROLL_OUT: {
    184 				AnimateToState( ANIM_STATE_UP );
    185 				GetMenuData()->ClearWidgetActionRepeater();
    186 				handled = true;
    187 				break;
    188 			}
    189 			case WIDGET_EVENT_FOCUS_OFF: {
    190 				SetState( WIDGET_STATE_NORMAL );
    191 				handled = true;
    192 				break;
    193 			}
    194 			case WIDGET_EVENT_FOCUS_ON: {
    195 				SetState( WIDGET_STATE_SELECTING );
    196 				handled = true;
    197 				break;
    198 			}
    199 			case WIDGET_EVENT_SCROLL_LEFT_RELEASE: {
    200 				GetMenuData()->ClearWidgetActionRepeater();
    201 				break;
    202 			}
    203 			case WIDGET_EVENT_SCROLL_RIGHT_RELEASE: {
    204 				GetMenuData()->ClearWidgetActionRepeater();
    205 				break;
    206 			}
    207 		}
    208 	}
    209 
    210 	idMenuWidget::ExecuteEvent( event );
    211 
    212 	return handled;
    213 }
    214 
    215 /*
    216 ========================
    217 idMenuWidget_Button::AddValue
    218 ========================
    219 */
    220 void idMenuWidget_Button::SetValues( idList< idStr > & list ) {
    221 	values.Clear();
    222 	for ( int i = 0; i < list.Num(); ++ i ) {
    223 		values.Append( list[ i ] );
    224 	}
    225 }
    226 
    227 /*
    228 ========================
    229 idMenuWidget_Button::GetValue
    230 ========================
    231 */
    232 const idStr & idMenuWidget_Button::GetValue( int index ) const {
    233 
    234 	return values[ index ];
    235 
    236 }
    237 
    238 /*
    239 ========================
    240 idMenuWidget_Button::SetupTransitionInfo
    241 ========================
    242 */
    243 void idMenuWidget_Button::SetupTransitionInfo( widgetTransition_t & trans, const widgetState_t buttonState, const animState_t sourceAnimState, const animState_t destAnimState ) const {
    244 	trans.prefixes.Clear();
    245 	if ( buttonState == WIDGET_STATE_DISABLED ) {
    246 		trans.animationName = "disabled";
    247 	} else {
    248 		const int animIndex = (int)destAnimState * ANIM_STATE_MAX + (int)sourceAnimState;
    249 		trans.animationName = ANIM_STATE_TRANSITIONS[ animIndex ];
    250 		if ( buttonState == WIDGET_STATE_SELECTING ) {
    251 			trans.prefixes.Append( "sel_" );
    252 		}
    253 	}
    254 	trans.prefixes.Append( "" );
    255 }
    256 
    257 /*
    258 ========================
    259 idMenuWidget_Button::AnimateToState
    260 
    261 Plays an animation from the current state to the target state.
    262 ========================
    263 */
    264 void idMenuWidget_Button::AnimateToState( const animState_t targetAnimState, const bool force ) {
    265 	if ( !force && targetAnimState == GetAnimState() ) {
    266 		return;
    267 	}
    268 
    269 	if ( GetSprite() != NULL ) {
    270 		widgetTransition_t trans;
    271 		SetupTransitionInfo( trans, GetState(), GetAnimState(), targetAnimState );
    272 		if ( trans.animationName[0] != '\0' ) {
    273 			for ( int i = 0; i < trans.prefixes.Num(); ++i ) {
    274 				const char * const frameLabel = va( "%s%s", trans.prefixes[ i ], trans.animationName );
    275 				if ( GetSprite()->FrameExists( frameLabel ) ) {
    276 					GetSprite()->PlayFrame( frameLabel );
    277 					Update();
    278 					break;
    279 				}
    280 			}
    281 		}
    282 
    283 		idSWFSpriteInstance * const focusSprite = GetSprite()->GetScriptObject()->GetSprite( "focusIndicator" );
    284 		if ( focusSprite != NULL ) {
    285 			if ( targetAnimState == ANIM_STATE_OVER ) {
    286 				focusSprite->PlayFrame( "show" );
    287 			} else {
    288 				focusSprite->PlayFrame( "hide" );
    289 			}
    290 		}
    291 	}
    292 
    293 	SetAnimState( targetAnimState );
    294 }
    295 
    296 //*****************************************************************************************************************
    297 // CONTROL BUTTON
    298 
    299 /*
    300 ========================
    301 idMenuWidget_ControlButton::Update
    302 ========================
    303 */
    304 void idMenuWidget_ControlButton::Update() {
    305 
    306 	if ( GetSprite() == NULL ) {
    307 		return;
    308 	}
    309 
    310 	idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject()->GetNestedObj( "type" );
    311 	if ( spriteObject == NULL ) {
    312 		return;
    313 	}
    314 	idSWFSpriteInstance * type = spriteObject->GetSprite();
    315 
    316 	if ( type == NULL ) {
    317 		return;
    318 	}
    319 
    320 	if ( GetOptionType() != OPTION_BUTTON_FULL_TEXT_SLIDER ) {
    321 		type->StopFrame( GetOptionType() + 1 );
    322 	}
    323 
    324 	idSWFTextInstance * text = spriteObject->GetNestedText( "label0", "txtVal" );
    325 	if ( text != NULL ) {
    326 		text->SetText( btnLabel );
    327 		text->SetStrokeInfo( true, 0.75f, 2.0f );
    328 	}
    329 
    330 	if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
    331 		idSWFSpriteInstance * controlSprite = NULL;
    332 		if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
    333 			controlSprite = type->GetScriptObject()->GetSprite( CONTROL_SPRITE_NAMES[ GetOptionType() ] );
    334 			if ( verify( controlSprite != NULL ) ) {
    335 				if ( verify( GetDataSource() != NULL ) ) {
    336 					idSWFScriptVar fieldValue = GetDataSource()->GetField( GetDataSourceFieldIndex() );
    337 					if ( GetOptionType() == OPTION_SLIDER_BAR ) {
    338 						controlSprite->StopFrame( 1 + fieldValue.ToInteger() );
    339 					} else if ( GetOptionType() == OPTION_SLIDER_TOGGLE ) {
    340 						idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
    341 						if ( verify( txtInfo != NULL ) ) {
    342 							txtInfo->SetText( fieldValue.ToBool() ? "#str_swf_enabled" : "#str_swf_disabled" );
    343 							txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
    344 						}
    345 					} else if ( GetOptionType() == OPTION_SLIDER_TEXT || GetOptionType() == OPTION_BUTTON_FULL_TEXT_SLIDER ) {
    346 						idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
    347 						if ( verify( txtInfo != NULL ) ) {
    348 							txtInfo->SetText( fieldValue.ToString() );
    349 							txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
    350 						}
    351 					}
    352 				}				
    353 
    354 				idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
    355 				idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
    356 
    357 				if ( btnLess != NULL && btnMore != NULL ) {
    358 					if ( disabled ) {
    359 						btnLess->GetSprite()->SetVisible( false );
    360 						btnMore->GetSprite()->SetVisible( false );
    361 					} else {
    362 						btnLess->GetSprite()->SetVisible( true );
    363 						btnMore->GetSprite()->SetVisible( true );
    364 
    365 						btnLess->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT, 0 ) );
    366 						btnLess->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RELEASE, 0 ) );
    367 
    368 						btnMore->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT, 0 ) );
    369 						btnMore->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RELEASE, 0 ) );
    370 
    371 						btnLess->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    372 						btnLess->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    373 
    374 						btnMore->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    375 						btnMore->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    376 					}
    377 				}
    378 			}
    379 		}
    380 	} else {
    381 		idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
    382 		idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
    383 
    384 		if ( btnLess != NULL && btnMore != NULL ) {
    385 			btnLess->GetSprite()->SetVisible( false );
    386 			btnMore->GetSprite()->SetVisible( false );
    387 		}
    388 	}
    389 
    390 	// events
    391 	GetSprite()->GetScriptObject()->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
    392 	GetSprite()->GetScriptObject()->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
    393 
    394 	idSWFScriptObject * hitBox = GetSprite()->GetScriptObject()->GetObject( "hitBox" );
    395 	if ( hitBox == NULL ) {
    396 		hitBox = GetSprite()->GetScriptObject();
    397 	}
    398 
    399 	hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    400 	hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    401 
    402 }
    403 
    404 /*
    405 ========================
    406 idMenuWidget_ControlButton::Update
    407 ========================
    408 */
    409 void idMenuWidget_ControlButton::SetupEvents( int delay, int index ) {
    410 	AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
    411 	AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
    412 	AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
    413 	AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
    414 	AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
    415 	AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
    416 	AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
    417 	AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
    418 }
    419 
    420 //****************************************************************
    421 // SERVER BUTTON
    422 //****************************************************************
    423 
    424 /*
    425 ========================
    426 idMenuWidget_ServerButton::Update
    427 ========================
    428 */
    429 void idMenuWidget_ServerButton::Update() {
    430 
    431 	if ( GetSprite() == NULL ) {
    432 		return;
    433 	}
    434 
    435 	idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
    436 	idSWFTextInstance * const txtName = spriteObject->GetNestedText( "label0", "txtVal" );
    437 	
    438 	if ( txtName != NULL ) {
    439 		txtName->SetText( serverName );
    440 		txtName->SetStrokeInfo( true, 0.75f, 1.75f );
    441 	}
    442 
    443 	// events
    444 	spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
    445 	spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
    446 
    447 	idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
    448 	if ( hitBox == NULL ) {
    449 		hitBox = spriteObject;
    450 	}
    451 
    452 	hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    453 	hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    454 
    455 }
    456 
    457 /*
    458 ========================
    459 idMenuWidget_ServerButton::SetButtonInfo
    460 ========================
    461 */
    462 void idMenuWidget_ServerButton::SetButtonInfo( idStr name_, idStrId mapName_, idStr modeName_, int index_, int players_, int maxPlayers_, bool joinable_, bool validMap_ ) {
    463 	serverName = name_;
    464 	index = index_;
    465 	players = players_;
    466 	maxPlayers = maxPlayers_;
    467 	joinable = joinable_;
    468 	validMap = validMap_;
    469 	mapName = mapName_;
    470 	modeName = modeName_;
    471 
    472 	idStr desc;
    473 	if ( index >= 0 ) {
    474 		idStr playerVal = va( "%s %d/%d", idLocalization::GetString( "#str_02396" ), players, maxPlayers );
    475 		idStr lobbyMapName = va( "%s %s", idLocalization::GetString( "#str_02045" ), mapName.GetLocalizedString() );
    476 		idStr lobbyMode;
    477 		if ( !modeName.IsEmpty() ) {
    478 			lobbyMode = va( "%s %s", idLocalization::GetString( "#str_02044" ), modeName.c_str() );
    479 		}
    480 
    481 		desc = va( "%s   %s   %s", playerVal.c_str(), lobbyMapName.c_str(), lobbyMode.c_str() );
    482 	}
    483 	SetDescription( desc );
    484 
    485 }
    486 
    487 //****************************************************************
    488 // LOBBY BUTTON
    489 //****************************************************************
    490 
    491 /*
    492 ========================
    493 idMenuWidget_LobbyButton::Update
    494 ========================
    495 */
    496 void idMenuWidget_LobbyButton::Update() {
    497 
    498 	if ( GetSprite() == NULL ) {
    499 		return;
    500 	}
    501 
    502 	idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
    503 	idSWFTextInstance * const txtName = spriteObject->GetNestedText( "itemName", "txtVal" );
    504 	idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
    505 
    506 	if ( txtName != NULL ) {
    507 		txtName->SetText( name );
    508 	} 
    509 
    510 	if ( talkIcon != NULL ) {
    511 		talkIcon->StopFrame( voiceState + 1 );
    512 		talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
    513 	}
    514 
    515 	// events
    516 	spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
    517 	spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
    518 
    519 	idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
    520 	if ( hitBox == NULL ) {
    521 		hitBox = spriteObject;
    522 	}
    523 
    524 	hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    525 	hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    526 }
    527 
    528 /*
    529 ========================
    530 idMenuWidget_LobbyButton::SetButtonInfo
    531 ========================
    532 */
    533 void idMenuWidget_LobbyButton::SetButtonInfo( idStr name_, voiceStateDisplay_t voiceState_ ) {
    534 	name = name_;
    535 	voiceState = voiceState_;
    536 }
    537 
    538 //****************************************************************
    539 // SCOREBOARD BUTTON
    540 //****************************************************************
    541 
    542 /*
    543 ========================
    544 idMenuWidget_ScoreboardButton::Update
    545 ========================
    546 */
    547 void idMenuWidget_ScoreboardButton::Update() {
    548 
    549 	if ( GetSprite() == NULL ) {
    550 		return;
    551 	}
    552 
    553 	if ( index == -1 ) {
    554 		GetSprite()->SetVisible( false );
    555 		return;
    556 	}
    557 
    558 	GetSprite()->SetVisible( true );
    559 
    560 	idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
    561 	for ( int val = 0; val < values.Num(); ++val ) {
    562 		idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
    563 		if ( textObject != NULL ) {
    564 			idSWFTextInstance * const text = textObject->GetText();
    565 			text->SetIgnoreColor( ignoreColor );
    566 			text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
    567 			text->SetText( values[ val ].c_str() );
    568 			text->SetStrokeInfo( true, 0.75f, 2.0f );
    569 		}
    570 	}
    571 
    572 	idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
    573 	if ( talkIcon != NULL ) {
    574 		talkIcon->StopFrame( voiceState + 1 );
    575 		talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
    576 	}
    577 
    578 	// events
    579 	spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
    580 	spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
    581 
    582 	idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
    583 	if ( hitBox == NULL ) {
    584 		hitBox = spriteObject;
    585 	}
    586 
    587 	hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
    588 	hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
    589 }
    590 
    591 /*
    592 ========================
    593 idMenuWidget_ScoreboardButton::SetButtonInfo
    594 ========================
    595 */
    596 void idMenuWidget_ScoreboardButton::SetButtonInfo( int index_, idList< idStr > & list, voiceStateDisplay_t voiceState_ ) {
    597 	index = index_;
    598 	voiceState = voiceState_;
    599 	SetValues( list );
    600 }