DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

MenuScreen_Shell_PartyLobby.cpp (25355B)


      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 const static int NUM_LOBBY_OPTIONS = 8;
     33 
     34 extern idCVar net_inviteOnly;
     35 extern idCVar si_map;
     36 extern idCVar si_mode;
     37 
     38 enum partyLobbyCmds_t {
     39 	PARTY_CMD_QUICK,
     40 	PARTY_CMD_FIND,
     41 	PARTY_CMD_CREATE,
     42 	PARTY_CMD_PWF,
     43 	PARTY_CMD_INVITE,
     44 	PARTY_CMD_LEADERBOARDS,
     45 	PARTY_CMD_TOGGLE_PRIVACY,
     46 	PARTY_CMD_SHOW_PARTY_GAMES,
     47 };
     48 
     49 /*
     50 ========================
     51 idMenuScreen_Shell_PartyLobby::Initialize
     52 ========================
     53 */
     54 void idMenuScreen_Shell_PartyLobby::Initialize( idMenuHandler * data ) {
     55 	idMenuScreen::Initialize( data );
     56 
     57 	if ( data != NULL ) {
     58 		menuGUI = data->GetGUI();
     59 	}
     60 
     61 	SetSpritePath( "menuPartyLobby" );
     62 
     63 	options = new  (TAG_SWF) idMenuWidget_DynamicList();
     64 	options->SetNumVisibleOptions( NUM_LOBBY_OPTIONS );
     65 	options->SetSpritePath( GetSpritePath(), "info", "options" );
     66 	options->SetWrappingAllowed( true );
     67 	AddChild( options );
     68 
     69 	idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
     70 	helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
     71 	AddChild( helpWidget );	
     72 
     73 	while ( options->GetChildren().Num() < NUM_LOBBY_OPTIONS ) {
     74 		idMenuWidget_Button * const buttonWidget = new  (TAG_SWF) idMenuWidget_Button();
     75 		buttonWidget->Initialize( data );
     76 		buttonWidget->RegisterEventObserver( helpWidget );
     77 		options->AddChild( buttonWidget );
     78 	}
     79 	options->Initialize( data );
     80 	
     81 
     82 	btnBack = new (TAG_SWF) idMenuWidget_Button();
     83 	btnBack->Initialize( data );
     84 	btnBack->SetLabel( "#str_02305" );
     85 	btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
     86 	btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
     87 	AddChild( btnBack );
     88 
     89 	lobby = new (TAG_SWF) idMenuWidget_LobbyList();
     90 	lobby->SetNumVisibleOptions( 8 );
     91 	lobby->SetSpritePath( GetSpritePath(), "options" );
     92 	lobby->SetWrappingAllowed( true );
     93 	lobby->Initialize( data );
     94 	while ( lobby->GetChildren().Num() < 8 ) {
     95 		idMenuWidget_LobbyButton * const buttonWidget = new idMenuWidget_LobbyButton();
     96 		buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_GAMERTAG, lobby->GetChildren().Num() );
     97 		buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, lobby->GetChildren().Num() );
     98 		buttonWidget->Initialize( data );
     99 		lobby->AddChild( buttonWidget );
    100 	}
    101 	AddChild( lobby );
    102 
    103 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
    104 	AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
    105 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
    106 	AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
    107 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
    108 	AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
    109 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
    110 	AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
    111 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
    112 	AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
    113 	AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
    114 	AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
    115 }
    116 
    117 /*
    118 ========================
    119 idMenuScreen_Shell_PartyLobby::Update
    120 ========================
    121 */
    122 void idMenuScreen_Shell_PartyLobby::Update() {
    123 
    124 	idLobbyBase & activeLobby = session->GetPartyLobbyBase();
    125 	if ( lobby != NULL ) {
    126 		if ( activeLobby.GetNumActiveLobbyUsers() != 0 ) {
    127 			if ( lobby->GetFocusIndex() >= activeLobby.GetNumActiveLobbyUsers()  ) {
    128 				lobby->SetFocusIndex( activeLobby.GetNumActiveLobbyUsers() - 1 );
    129 				lobby->SetViewIndex( lobby->GetViewOffset() + lobby->GetFocusIndex() );
    130 			}
    131 		}
    132 	}
    133 
    134 	idSWFScriptObject & root = GetSWFObject()->GetRootObject();
    135 	if ( BindSprite( root ) ) {
    136 		idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
    137 		if ( heading != NULL ) {
    138 			heading->SetText( "#str_swf_multiplayer" );	// MULTIPLAYER
    139 			heading->SetStrokeInfo( true, 0.75f, 1.75f );
    140 		}
    141 
    142 		idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
    143 		if ( gradient != NULL && heading != NULL ) {
    144 			gradient->SetXPos( heading->GetTextLength() );
    145 		}
    146 	}
    147 
    148 	UpdateOptions();
    149 	
    150 	if ( menuData != NULL && menuData->NextScreen() == SHELL_AREA_PARTY_LOBBY ) {
    151 		idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
    152 		if ( cmdBar != NULL ) {
    153 			cmdBar->ClearAllButtons();
    154 			idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;			
    155 			buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
    156 			if ( menuData->GetPlatform() != 2 ) {
    157 				buttonInfo->label = "#str_00395";
    158 			}
    159 			buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
    160 
    161 			buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
    162 			if ( menuData->GetPlatform() != 2 ) {
    163 				buttonInfo->label = "#str_SWF_SELECT";
    164 			}
    165 			buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
    166 
    167 			lobbyUserID_t luid;
    168 			if ( isHost && CanKickSelectedPlayer( luid ) ) {
    169 				buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
    170 				buttonInfo->label = "#str_swf_kick";
    171 				buttonInfo->action.Set( WIDGET_ACTION_JOY4_ON_PRESS );
    172 			}
    173 
    174 			buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
    175 			if ( menuData->GetPlatform() != 2 ) {
    176 				buttonInfo->label = "#str_swf_view_profile";
    177 			}
    178 			buttonInfo->action.Set( WIDGET_ACTION_SELECT_GAMERTAG );
    179 		}		
    180 	}
    181 
    182 	if ( btnBack != NULL ) {
    183 		btnBack->BindSprite( root );
    184 	}
    185 
    186 	idMenuScreen::Update();
    187 }
    188 
    189 void idMenuScreen_Shell_PartyLobby::UpdateOptions() {
    190 
    191 	bool forceUpdate = false;
    192 
    193 
    194 	if ( ( session->GetPartyLobbyBase().IsHost() && ( !isHost || forceUpdate ) ) && options != NULL ) {
    195 
    196 		menuOptions.Clear();
    197 		idList< idStr > option;
    198 
    199 		isHost = true;
    200 		isPeer = false;
    201 
    202 		option.Append( "#str_swf_join_public" );	// Quick Match
    203 		menuOptions.Append( option );
    204 		option.Clear();
    205 		option.Append( "#str_swf_find_match" );	// Find Match
    206 		menuOptions.Append( option );
    207 		option.Clear();
    208 		option.Append( "#str_swf_create_private" );	// Create Match
    209 		menuOptions.Append( option );
    210 		option.Clear();
    211 		option.Append( "#str_swf_pwf" );	// Play With Friends
    212 		menuOptions.Append( option );
    213 		option.Clear();
    214 		option.Append( "#str_swf_leaderboards" );	// Play With Friends
    215 		menuOptions.Append( option );
    216 		option.Clear();
    217 		option.Append( "#str_swf_invite_only" );	// Toggle privacy
    218 		menuOptions.Append( option );
    219 		option.Clear();
    220 		option.Append( "#str_swf_invite_friends" );	// Invite Friends
    221 		menuOptions.Append( option );
    222 
    223 		idMenuWidget_Button * buttonWidget = NULL;
    224 		int index = 0;
    225 		options->GetChildByIndex( index ).ClearEventActions();
    226 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_QUICK, index );
    227 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    228 		if ( buttonWidget != NULL ) {
    229 			buttonWidget->SetDescription( "#str_swf_quick_desc" );
    230 		}
    231 		index++;
    232 		options->GetChildByIndex( index ).ClearEventActions();
    233 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_FIND, index );
    234 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    235 		if ( buttonWidget != NULL ) {
    236 			buttonWidget->SetDescription( "#str_swf_find_desc" );
    237 		}
    238 		index++;
    239 		options->GetChildByIndex( index ).ClearEventActions();
    240 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_CREATE, index );
    241 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    242 		if ( buttonWidget != NULL ) {
    243 			buttonWidget->SetDescription( "#str_swf_create_desc" );
    244 		}
    245 		index++;
    246 		options->GetChildByIndex( index ).ClearEventActions();
    247 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_PWF, index );
    248 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    249 		if ( buttonWidget != NULL ) {
    250 			buttonWidget->SetDescription( "#str_swf_pwf_desc" );
    251 		}
    252 		index++;
    253 		options->GetChildByIndex( index ).ClearEventActions();
    254 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_LEADERBOARDS, index );
    255 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    256 		if ( buttonWidget != NULL ) {
    257 			buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
    258 		}
    259 		index++;
    260 		options->GetChildByIndex( index ).ClearEventActions();
    261 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_TOGGLE_PRIVACY, index );
    262 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    263 		if ( buttonWidget != NULL ) {
    264 			buttonWidget->SetDescription( "#str_swf_toggle_privacy_desc" );
    265 		}
    266 		index++;
    267 		options->GetChildByIndex( index ).ClearEventActions();
    268 		options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_INVITE, index );
    269 		buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    270 		if ( buttonWidget != NULL ) {
    271 			buttonWidget->SetDescription( "#str_swf_invite_desc" );
    272 		}
    273 
    274 		options->SetListData( menuOptions );
    275 
    276 	} else if ( session->GetPartyLobbyBase().IsPeer() && options != NULL ) {
    277 		if ( !isPeer || forceUpdate ) {		
    278 
    279 			menuOptions.Clear();
    280 			idList< idStr > option;
    281 
    282 			idMenuWidget_Button * buttonWidget = NULL;
    283 			option.Append( "#str_swf_leaderboards" );	// Play With Friends
    284 			menuOptions.Append( option );
    285 			option.Clear();
    286 			option.Append( "#str_swf_invite_friends" );	// Play With Friends
    287 			menuOptions.Append( option );
    288 
    289 			int index = 0;
    290 			options->GetChildByIndex( index ).ClearEventActions();
    291 			options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_LEADERBOARDS, index );
    292 			buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    293 			if ( buttonWidget != NULL ) {
    294 				buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
    295 			}
    296 			index++;
    297 			options->GetChildByIndex( index ).ClearEventActions();
    298 			options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_INVITE, index );
    299 			buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
    300 			if ( buttonWidget != NULL ) {
    301 				buttonWidget->SetDescription( "#str_swf_invite_desc" );
    302 			}
    303 
    304 			options->SetListData( menuOptions );
    305 
    306 		}
    307 
    308 		isPeer = true;
    309 		isHost = false;
    310 	}
    311 
    312 	if ( forceUpdate ) {
    313 		options->Update();
    314 	}
    315 
    316 }
    317 
    318 /*
    319 ========================
    320 idMenuScreen_Shell_PartyLobby::ShowScreen
    321 ========================
    322 */
    323 void idMenuScreen_Shell_PartyLobby::ShowScreen( const mainMenuTransition_t transitionType ) {
    324 
    325 	isPeer = false;
    326 	isHost = false;
    327 
    328 	idSWFScriptObject & root = GetSWFObject()->GetRootObject();
    329 	if ( BindSprite( root ) ) {
    330 		idSWFSpriteInstance * waitTime = GetSprite()->GetScriptObject()->GetNestedSprite( "waitTime" );
    331 		if ( waitTime != NULL ) {
    332 			waitTime->SetVisible( false );
    333 		}
    334 	}
    335 
    336 	if ( session->GetPartyLobbyBase().IsHost() ) {
    337 		idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
    338 		if ( net_inviteOnly.GetBool() ) {
    339 			matchParameters.matchFlags |= MATCH_INVITE_ONLY; 
    340 		} else {
    341 			matchParameters.matchFlags &= ~MATCH_INVITE_ONLY; 
    342 		}
    343 
    344 		matchParameters.numSlots = session->GetTitleStorageInt("MAX_PLAYERS_ALLOWED", 4 );
    345 
    346 		session->UpdatePartyParms( matchParameters );
    347 	}
    348 
    349 	idMenuScreen::ShowScreen( transitionType );
    350 	if ( lobby != NULL ) {
    351 		lobby->SetFocusIndex( 0 );
    352 	}
    353 }
    354 
    355 /*
    356 ========================
    357 idMenuScreen_Shell_PartyLobby::HideScreen
    358 ========================
    359 */
    360 void idMenuScreen_Shell_PartyLobby::HideScreen( const mainMenuTransition_t transitionType ) {
    361 	idMenuScreen::HideScreen( transitionType );
    362 }
    363 
    364 /*
    365 ========================
    366 idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer
    367 ========================
    368 */
    369 bool idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer( lobbyUserID_t & luid ) {
    370 
    371 	idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
    372 	const int playerId = lobby->GetFocusIndex();
    373 
    374 	// can't kick yourself
    375 	idLobbyBase & activeLobby = session->GetPartyLobbyBase();
    376 	luid = activeLobby.GetLobbyUserIdByOrdinal( playerId );
    377 	if ( session->GetSignInManager().GetMasterLocalUser() == activeLobby.GetLocalUserFromLobbyUser( luid ) ) {
    378 		return false;
    379 	}
    380 
    381 	return true;
    382 }
    383 
    384 /*
    385 ========================
    386 idMenuScreen_Shell_PartyLobby::ShowLeaderboards
    387 ========================
    388 */
    389 void idMenuScreen_Shell_PartyLobby::ShowLeaderboards() {
    390 
    391 	const bool canPlayOnline = session->GetSignInManager().GetMasterLocalUser() != NULL && session->GetSignInManager().GetMasterLocalUser()->CanPlayOnline();
    392 
    393 	if ( !canPlayOnline ) {
    394 		common->Dialog().AddDialog( GDM_LEADERBOARD_ONLINE_NO_PROFILE, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
    395 	} else if ( menuData != NULL ) {
    396 		menuData->SetNextScreen( SHELL_AREA_LEADERBOARDS, MENU_TRANSITION_SIMPLE );
    397 	}
    398 }
    399 
    400 /*
    401 ========================
    402 idMenuScreen_Shell_PartyLobby::HandleAction h
    403 ========================
    404 */
    405 bool idMenuScreen_Shell_PartyLobby::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
    406 
    407 	if ( menuData == NULL ) {
    408 		return true;
    409 	}
    410 
    411 	if ( menuData->ActiveScreen() != SHELL_AREA_PARTY_LOBBY ) {
    412 		return false;
    413 	}
    414 
    415 	widgetAction_t actionType = action.GetType();
    416 	const idSWFParmList & parms = action.GetParms();
    417 
    418 	switch ( actionType ) {
    419 		case WIDGET_ACTION_JOY4_ON_PRESS: {
    420 
    421 			idLobbyBase & activeLobby = session->GetPartyLobbyBase();
    422 			lobbyUserID_t luid;
    423 			if ( CanKickSelectedPlayer( luid ) ) {
    424 				activeLobby.KickLobbyUser( luid );
    425 			}
    426 			return true;
    427 		}
    428 		case WIDGET_ACTION_GO_BACK: {
    429 			class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
    430 			public:
    431 				idSWFScriptFunction_Accept() { }
    432 				idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
    433 					common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_MAIN );
    434 					session->Cancel();
    435 
    436 					return idSWFScriptVar();
    437 				}
    438 			};
    439 			class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted {
    440 			public:
    441 				idSWFScriptFunction_Cancel() { }
    442 				idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
    443 					common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_MAIN );
    444 					return idSWFScriptVar();
    445 				}
    446 			};
    447 
    448 			idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
    449 
    450 			if( activeLobby.GetNumActiveLobbyUsers() > 1 ) {
    451 				common->Dialog().AddDialog( GDM_LEAVE_LOBBY_RET_MAIN, DIALOG_ACCEPT_CANCEL, new (TAG_SWF) idSWFScriptFunction_Accept(), new (TAG_SWF) idSWFScriptFunction_Cancel(), false );
    452 			} else {
    453 				session->Cancel();
    454 			}
    455 
    456 			return true;
    457 		}
    458 		case WIDGET_ACTION_MUTE_PLAYER: {
    459 
    460 			if ( parms.Num() != 1 ) {
    461 				return true;
    462 			}
    463 
    464 			int index = parms[0].ToInteger();
    465 
    466 			idLobbyBase & activeLobby = session->GetPartyLobbyBase();
    467 			lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( index );
    468 			if ( luid.IsValid() ) {
    469 				session->ToggleLobbyUserVoiceMute( luid );
    470 			}
    471 
    472 			return true;
    473 		}
    474 		case WIDGET_ACTION_COMMAND: {
    475 			
    476 			if ( options == NULL ) {
    477 				return true;
    478 			}
    479 
    480 			int selectionIndex = options->GetFocusIndex();
    481 			if ( parms.Num() > 1 ) {
    482 				selectionIndex = parms[1].ToInteger();
    483 			}
    484 
    485 			if ( selectionIndex != options->GetFocusIndex() ) {
    486 				options->SetViewIndex( options->GetViewOffset() + selectionIndex );
    487 				options->SetFocusIndex( selectionIndex );
    488 			}
    489 
    490 			switch ( parms[0].ToInteger() ) {
    491 				case PARTY_CMD_QUICK: {
    492 					idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
    493 
    494 					// Reset these to random for quick match.
    495 					matchParameters.gameMap =  GAME_MAP_RANDOM;
    496 					matchParameters.gameMode = GAME_MODE_RANDOM;
    497 
    498 					// Always a public match.
    499 					matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
    500 					
    501 					session->UpdatePartyParms( matchParameters );
    502 
    503 					// Update flags for game lobby.
    504 					matchParameters.matchFlags = DefaultPartyFlags | DefaultPublicGameFlags;					
    505 					cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
    506 
    507 					// Force a default value for the si_timelimit and si_fraglimit for quickmatch
    508 					matchParameters.serverInfo.SetInt( "si_timelimit", 15 );
    509 					matchParameters.serverInfo.SetInt( "si_fraglimit", 10 );
    510 
    511 					session->FindOrCreateMatch( matchParameters );
    512 					break;
    513 				}
    514 				case PARTY_CMD_FIND: {
    515 					menuData->SetNextScreen( SHELL_AREA_MODE_SELECT, MENU_TRANSITION_SIMPLE );
    516 					break;
    517 				}
    518 				case PARTY_CMD_CREATE: {
    519 					idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
    520 
    521 					const bool isInviteOnly = MatchTypeInviteOnly( matchParameters.matchFlags );
    522 
    523 					matchParameters.matchFlags = DefaultPartyFlags | DefaultPrivateGameFlags;
    524 
    525 					if ( isInviteOnly ) {
    526 						matchParameters.matchFlags |= MATCH_INVITE_ONLY;
    527 					}
    528 
    529 					int mode = idMath::ClampInt( -1, GAME_COUNT - 1, si_mode.GetInteger() );
    530 					const idList< mpMap_t > maps = common->GetMapList();
    531 					int map = idMath::ClampInt( -1, maps.Num() - 1, si_map.GetInteger() );
    532 
    533 					matchParameters.gameMap = map;
    534 					matchParameters.gameMode = mode;
    535 					cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
    536 					session->CreateMatch( matchParameters );
    537 					break;
    538 				}
    539 				case PARTY_CMD_PWF: {
    540 					menuData->SetNextScreen( SHELL_AREA_BROWSER, MENU_TRANSITION_SIMPLE );
    541 					break;
    542 				}
    543 				case PARTY_CMD_LEADERBOARDS: {
    544 					ShowLeaderboards();
    545 					break;
    546 				}
    547 				case PARTY_CMD_TOGGLE_PRIVACY: {
    548 					idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
    549 					matchParameters.matchFlags ^= MATCH_INVITE_ONLY;
    550 					session->UpdatePartyParms( matchParameters );
    551 					int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
    552 					net_inviteOnly.SetBool( bitSet != 0 ? true : false );
    553 					break;
    554 				}
    555 				case PARTY_CMD_SHOW_PARTY_GAMES: {
    556 					session->ShowPartySessions();
    557 					break;
    558 				}
    559 				case PARTY_CMD_INVITE: {
    560 					if ( session->GetPartyLobbyBase().IsLobbyFull() ) {
    561 						common->Dialog().AddDialog( GDM_CANNOT_INVITE_LOBBY_FULL, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
    562 						return true;
    563 					}
    564 
    565 					InvitePartyOrFriends();
    566 					break;
    567 				}
    568 			}
    569 
    570 			return true;
    571 		}
    572 		case WIDGET_ACTION_START_REPEATER: {
    573 
    574 			if ( options == NULL ) {
    575 				return true;
    576 			}
    577 
    578 			if ( parms.Num() == 4 ) {
    579 				int selectionIndex = parms[3].ToInteger();
    580 				if ( selectionIndex != options->GetFocusIndex() ) {
    581 					options->SetViewIndex( options->GetViewOffset() + selectionIndex );
    582 					options->SetFocusIndex( selectionIndex );
    583 				}
    584 			}
    585 			break;
    586 		}
    587 		case WIDGET_ACTION_SELECT_GAMERTAG: {
    588 			int selectionIndex = lobby->GetFocusIndex();
    589 			if ( parms.Num() > 0 ) {
    590 				selectionIndex = parms[0].ToInteger();
    591 			}
    592 
    593 			if ( selectionIndex != lobby->GetFocusIndex() ) {
    594 				lobby->SetViewIndex( lobby->GetViewOffset() + selectionIndex );
    595 				lobby->SetFocusIndex( selectionIndex );
    596 				return true;
    597 			}
    598 
    599 			idLobbyBase & activeLobby = session->GetPartyLobbyBase();
    600 			lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( selectionIndex );
    601 			if ( luid.IsValid() ) {
    602 				session->ShowLobbyUserGamerCardUI( luid );
    603 			}
    604 			
    605 			return true;
    606 		}
    607 	}
    608 
    609 	return idMenuWidget::HandleAction( action, event, widget, forceHandled );
    610 }
    611 
    612 /*
    613 ========================
    614 idMenuScreen_Shell_PartyLobby::UpdateLobby
    615 ========================
    616 */
    617 void idMenuScreen_Shell_PartyLobby::UpdateLobby() {
    618 	
    619 	if ( menuData != NULL && menuData->ActiveScreen() != SHELL_AREA_PARTY_LOBBY ) {
    620 		return;
    621 	}
    622 	
    623 	// Keep this menu in sync with the session host/peer status.
    624 	if ( session->GetPartyLobbyBase().IsHost() && !isHost ) {
    625 		Update();
    626 	}
    627 
    628 	if ( session->GetPartyLobbyBase().IsPeer() && !isPeer ) {
    629 		Update();
    630 	}
    631 
    632 	if ( isPeer ) {
    633 		Update();
    634 	}
    635 
    636 	UpdateOptions();
    637 
    638 	// setup names for lobby;
    639 	if ( lobby != NULL ) {
    640 		idMenuHandler_Shell * mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
    641 		if ( mgr != NULL ) {
    642 			mgr->UpdateLobby( lobby );
    643 			lobby->Update();
    644 		}
    645 
    646 		if ( lobby->GetNumEntries() > 0 && lobby->GetFocusIndex() >= lobby->GetNumEntries() ) {
    647 			lobby->SetFocusIndex( lobby->GetNumEntries() - 1 );
    648 			lobby->SetViewIndex( lobby->GetNumEntries() - 1 );
    649 		}
    650 	}
    651 	
    652 	if ( session->GetState() == idSession::PARTY_LOBBY ) {
    653 
    654 		if ( options != NULL ) {
    655 			if ( options->GetFocusIndex() >= options->GetTotalNumberOfOptions() && options->GetTotalNumberOfOptions() > 0 ) {
    656 				options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
    657 				options->SetFocusIndex( options->GetTotalNumberOfOptions() - 1 );
    658 			}
    659 		}
    660 
    661 		idSWFTextInstance * privacy = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtPrivacy" );
    662 		if ( privacy != NULL ) {
    663 			if ( isPeer ) {
    664 				privacy->SetText( "" );
    665 			} else {				
    666 
    667 				idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
    668 				int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
    669 				bool privacySet = ( bitSet != 0 ? true : false );
    670 				if ( privacySet ) {
    671 					privacy->SetText( "#str_swf_privacy_closed" );
    672 					privacy->SetStrokeInfo( true );
    673 				} else if ( !privacySet  ) {
    674 					privacy->SetText( "#str_swf_privacy_open" );
    675 					privacy->SetStrokeInfo( true );
    676 				}
    677 			}
    678 		}
    679 
    680 		idLocalUser * user = session->GetSignInManager().GetMasterLocalUser();
    681 		if ( user != NULL && options != NULL ) {
    682 			if ( user->IsInParty() && user->GetPartyCount() > 1 && !session->IsPlatformPartyInLobby() && menuOptions.Num() > 0 ) {
    683 				if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_xbox_live_party" ) {
    684 					menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_xbox_live_party";	// invite Xbox LIVE party
    685 					options->SetListData( menuOptions );
    686 					options->Update();
    687 				}
    688 			} else if ( menuOptions.Num() > 0 ) {
    689 				if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_friends" ) {
    690 					menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_friends";	// invite Xbox LIVE party
    691 					options->SetListData( menuOptions );
    692 					options->Update();
    693 				}
    694 			}
    695 		}
    696 	}
    697 }