doom3-bfg/neo/d3xp/menus/MenuScreen_Shell_GameLobby.cpp

839 lines
25 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +00:00
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
2012-11-26 18:58:24 +00:00
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
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.
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.
===========================================================================
*/
#pragma hdrstop
#include "../../idlib/precompiled.h"
2012-11-26 18:58:24 +00:00
#include "../Game_local.h"
const static int NUM_LOBBY_OPTIONS = 8;
extern idCVar net_inviteOnly;
enum gameLobbyCmd_t
{
2012-11-26 18:58:24 +00:00
GAME_CMD_START,
GAME_CMD_INVITE,
GAME_CMD_SETTINGS,
GAME_CMD_TOGGLE_PRIVACY,
};
/*
========================
idMenuScreen_Shell_GameLobby::Initialize
========================
*/
void idMenuScreen_Shell_GameLobby::Initialize( idMenuHandler* data )
{
2012-11-26 18:58:24 +00:00
idMenuScreen::Initialize( data );
if( data != NULL )
{
2012-11-26 18:58:24 +00:00
menuGUI = data->GetGUI();
}
2012-11-26 18:58:24 +00:00
SetSpritePath( "menuGameLobby" );
options = new( TAG_SWF ) idMenuWidget_DynamicList();
2012-11-26 18:58:24 +00:00
options->SetNumVisibleOptions( NUM_LOBBY_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help* const helpWidget = new( TAG_SWF ) idMenuWidget_Help();
2012-11-26 18:58:24 +00:00
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while( options->GetChildren().Num() < NUM_LOBBY_OPTIONS )
{
idMenuWidget_Button* const buttonWidget = new( TAG_SWF ) idMenuWidget_Button();
2012-11-26 18:58:24 +00:00
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
lobby = new( TAG_SWF ) idMenuWidget_LobbyList();
2012-11-26 18:58:24 +00:00
lobby->SetNumVisibleOptions( 8 );
lobby->SetSpritePath( GetSpritePath(), "options" );
lobby->SetWrappingAllowed( true );
lobby->Initialize( data );
while( lobby->GetChildren().Num() < 8 )
{
idMenuWidget_LobbyButton* const buttonWidget = new( TAG_SWF ) idMenuWidget_LobbyButton();
2012-11-26 18:58:24 +00:00
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_GAMERTAG, lobby->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, lobby->GetChildren().Num() );
buttonWidget->Initialize( data );
lobby->AddChild( buttonWidget );
}
AddChild( lobby );
btnBack = new( TAG_SWF ) idMenuWidget_Button();
2012-11-26 18:58:24 +00:00
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_multiplayer" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
2012-11-26 18:58:24 +00:00
}
/*
========================
idMenuScreen_Shell_GameLobby::Update
========================
*/
void idMenuScreen_Shell_GameLobby::Update()
{
2012-11-26 18:58:24 +00:00
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
if( lobby != NULL )
{
if( activeLobby.GetNumActiveLobbyUsers() != 0 )
{
if( lobby->GetFocusIndex() >= activeLobby.GetNumActiveLobbyUsers() )
{
2012-11-26 18:58:24 +00:00
lobby->SetFocusIndex( activeLobby.GetNumActiveLobbyUsers() - 1 );
lobby->SetViewIndex( lobby->GetViewOffset() + lobby->GetFocusIndex() );
}
}
}
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
if( BindSprite( root ) )
{
idSWFTextInstance* heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if( heading != NULL )
{
2012-11-26 18:58:24 +00:00
heading->SetText( "#str_swf_multiplayer" ); // MULTIPLAYER
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance* gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if( gradient != NULL && heading != NULL )
{
2012-11-26 18:58:24 +00:00
gradient->SetXPos( heading->GetTextLength() );
}
}
if( privateGameLobby && options != NULL )
{
if( session->GetActivePlatformLobbyBase().IsHost() && !isHost )
{
2012-11-26 18:58:24 +00:00
menuOptions.Clear();
idList< idStr > option;
2012-11-26 18:58:24 +00:00
isHost = true;
isPeer = false;
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_start_match" ); // Start match
menuOptions.Append( option );
option.Clear();
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_match_settings" ); // Match Settings
menuOptions.Append( option );
option.Clear();
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_invite_only" ); // Toggle privacy
menuOptions.Append( option );
option.Clear();
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
idMenuWidget_Button* buttonWidget = NULL;
2012-11-26 18:58:24 +00:00
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_START, 0 );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_quick_start_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_SETTINGS, 1 );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_match_setting_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_TOGGLE_PRIVACY, 2 );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_toggle_privacy_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 3 );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
index++;
2012-11-26 18:58:24 +00:00
options->SetListData( menuOptions );
}
else if( session->GetActivePlatformLobbyBase().IsPeer() )
{
if( !isPeer )
{
2012-11-26 18:58:24 +00:00
menuOptions.Clear();
idList< idStr > option;
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
idMenuWidget_Button* buttonWidget = NULL;
2012-11-26 18:58:24 +00:00
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 0 );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
2012-11-26 18:58:24 +00:00
options->SetListData( menuOptions );
}
isPeer = true;
isHost = false;
}
}
if( menuData != NULL )
{
idMenuWidget_CommandBar* cmdBar = menuData->GetCmdBar();
if( cmdBar != NULL )
{
2012-11-26 18:58:24 +00:00
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t* buttonInfo;
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_swf_view_profile";
}
buttonInfo->action.Set( WIDGET_ACTION_SELECT_GAMERTAG );
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
2012-11-26 18:58:24 +00:00
lobbyUserID_t luid;
if( isHost && CanKickSelectedPlayer( luid ) )
{
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
buttonInfo->label = "#str_swf_kick";
buttonInfo->action.Set( WIDGET_ACTION_JOY4_ON_PRESS );
}
}
}
if( btnBack != NULL )
{
2012-11-26 18:58:24 +00:00
btnBack->BindSprite( root );
}
2012-11-26 18:58:24 +00:00
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_GameLobby::ShowScreen
========================
*/
void idMenuScreen_Shell_GameLobby::ShowScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
if( options != NULL )
{
2012-11-26 18:58:24 +00:00
options->SetFocusIndex( 0 );
options->SetViewIndex( 0 );
}
isHost = false;
isPeer = false;
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
2012-11-26 18:58:24 +00:00
// Make sure map name is up to date.
if( matchParameters.gameMap >= 0 )
{
2012-11-26 18:58:24 +00:00
matchParameters.mapName = common->GetMapList()[ matchParameters.gameMap ].mapFile;
}
2012-11-26 18:58:24 +00:00
privateGameLobby = MatchTypeIsPrivate( matchParameters.matchFlags );
if( !privateGameLobby ) // Public Game Lobby
{
2012-11-26 18:58:24 +00:00
menuOptions.Clear();
idList< idStr > option;
if( options != NULL )
{
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
2012-11-26 18:58:24 +00:00
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 0 );
idMenuWidget_Button* buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
2012-11-26 18:58:24 +00:00
options->SetListData( menuOptions );
}
2012-11-26 18:58:24 +00:00
longCountdown = Sys_Milliseconds() + WAIT_START_TIME_LONG;
longCountRemaining = longCountdown;
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
}
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
if( BindSprite( root ) )
{
idSWFSpriteInstance* waitTime = GetSprite()->GetScriptObject()->GetNestedSprite( "waitTime" );
if( waitTime != NULL )
{
2012-11-26 18:58:24 +00:00
waitTime->SetVisible( !privateGameLobby );
}
}
2012-11-26 18:58:24 +00:00
idMenuScreen::ShowScreen( transitionType );
if( lobby != NULL )
{
2012-11-26 18:58:24 +00:00
lobby->SetFocusIndex( 0 );
}
2012-11-26 18:58:24 +00:00
session->UpdateMatchParms( matchParameters );
}
/*
========================
idMenuScreen_Shell_GameLobby::HideScreen
========================
*/
void idMenuScreen_Shell_GameLobby::HideScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_GameLobby::CanKickSelectedPlayer
========================
*/
bool idMenuScreen_Shell_GameLobby::CanKickSelectedPlayer( lobbyUserID_t& luid )
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
const int playerId = lobby->GetFocusIndex();
2012-11-26 18:58:24 +00:00
// can't kick yourself
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
2012-11-26 18:58:24 +00:00
luid = activeLobby.GetLobbyUserIdByOrdinal( playerId );
if( session->GetSignInManager().GetMasterLocalUser() == activeLobby.GetLocalUserFromLobbyUser( luid ) )
{
2012-11-26 18:58:24 +00:00
return false;
}
2012-11-26 18:58:24 +00:00
return true;
}
/*
========================
idMenuScreen_Shell_GameLobby::HandleAction h
========================
*/
bool idMenuScreen_Shell_GameLobby::HandleAction( idWidgetAction& action, const idWidgetEvent& event, idMenuWidget* widget, bool forceHandled )
{
2012-11-26 18:58:24 +00:00
if( menuData == NULL )
{
2012-11-26 18:58:24 +00:00
return true;
}
if( menuData->ActiveScreen() != SHELL_AREA_GAME_LOBBY )
{
2012-11-26 18:58:24 +00:00
return false;
}
2012-11-26 18:58:24 +00:00
widgetAction_t actionType = action.GetType();
const idSWFParmList& parms = action.GetParms();
switch( actionType )
{
case WIDGET_ACTION_JOY4_ON_PRESS:
{
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
2012-11-26 18:58:24 +00:00
lobbyUserID_t luid;
if( CanKickSelectedPlayer( luid ) )
{
2012-11-26 18:58:24 +00:00
activeLobby.KickLobbyUser( luid );
}
return true;
}
case WIDGET_ACTION_GO_BACK:
{
class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted
{
2012-11-26 18:58:24 +00:00
public:
idSWFScriptFunction_Accept() { }
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY );
session->Cancel();
2012-11-26 18:58:24 +00:00
return idSWFScriptVar();
}
};
class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted
{
2012-11-26 18:58:24 +00:00
public:
idSWFScriptFunction_Cancel() { }
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
{
2012-11-26 18:58:24 +00:00
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY );
return idSWFScriptVar();
}
};
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
if( activeLobby.GetNumActiveLobbyUsers() > 1 )
{
common->Dialog().AddDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY, DIALOG_ACCEPT_CANCEL, new( TAG_SWF ) idSWFScriptFunction_Accept(), new( TAG_SWF ) idSWFScriptFunction_Cancel(), false );
}
else
{
2012-11-26 18:58:24 +00:00
session->Cancel();
}
2012-11-26 18:58:24 +00:00
return true;
}
case WIDGET_ACTION_MUTE_PLAYER:
{
if( parms.Num() != 1 )
{
2012-11-26 18:58:24 +00:00
return true;
}
2012-11-26 18:58:24 +00:00
int index = parms[0].ToInteger();
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
2012-11-26 18:58:24 +00:00
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( index );
if( luid.IsValid() )
{
2012-11-26 18:58:24 +00:00
session->ToggleLobbyUserVoiceMute( luid );
}
2012-11-26 18:58:24 +00:00
return true;
}
case WIDGET_ACTION_COMMAND:
{
if( options == NULL )
{
2012-11-26 18:58:24 +00:00
return true;
}
2012-11-26 18:58:24 +00:00
int selectionIndex = options->GetFocusIndex();
if( parms.Num() > 1 )
{
2012-11-26 18:58:24 +00:00
selectionIndex = parms[1].ToInteger();
}
if( selectionIndex != options->GetFocusIndex() )
{
2012-11-26 18:58:24 +00:00
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch( parms[0].ToInteger() )
{
case GAME_CMD_START:
{
idMenuHandler_Shell* handler = dynamic_cast< idMenuHandler_Shell* const >( menuData );
if( handler != NULL )
{
2012-11-26 18:58:24 +00:00
handler->SetTimeRemaining( 0 );
}
break;
}
case GAME_CMD_SETTINGS:
{
2012-11-26 18:58:24 +00:00
menuData->SetNextScreen( SHELL_AREA_MATCH_SETTINGS, MENU_TRANSITION_SIMPLE );
break;
}
case GAME_CMD_TOGGLE_PRIVACY:
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = idMatchParameters( session->GetActivePlatformLobbyBase().GetMatchParms() );
matchParameters.matchFlags ^= MATCH_INVITE_ONLY;
session->UpdateMatchParms( matchParameters );
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
net_inviteOnly.SetBool( bitSet != 0 ? true : false );
2012-11-26 18:58:24 +00:00
// Must update the party parameters too for Xbox JSIP to work in game lobbies.
idMatchParameters partyParms = session->GetPartyLobbyBase().GetMatchParms();
if( MatchTypeInviteOnly( matchParameters.matchFlags ) )
{
2012-11-26 18:58:24 +00:00
partyParms.matchFlags |= MATCH_INVITE_ONLY;
}
else
{
2012-11-26 18:58:24 +00:00
partyParms.matchFlags &= ~MATCH_INVITE_ONLY;
}
session->UpdatePartyParms( partyParms );
2012-11-26 18:58:24 +00:00
break;
}
case GAME_CMD_INVITE:
{
if( session->GetActivePlatformLobbyBase().IsLobbyFull() )
{
2012-11-26 18:58:24 +00:00
common->Dialog().AddDialog( GDM_CANNOT_INVITE_LOBBY_FULL, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
return true;
}
2012-11-26 18:58:24 +00:00
InvitePartyOrFriends();
break;
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER:
{
if( options == NULL )
{
2012-11-26 18:58:24 +00:00
return true;
}
if( parms.Num() == 4 )
{
2012-11-26 18:58:24 +00:00
int selectionIndex = parms[3].ToInteger();
if( selectionIndex != options->GetFocusIndex() )
{
2012-11-26 18:58:24 +00:00
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
case WIDGET_ACTION_SELECT_GAMERTAG:
{
2012-11-26 18:58:24 +00:00
int selectionIndex = lobby->GetFocusIndex();
if( parms.Num() > 0 )
{
2012-11-26 18:58:24 +00:00
selectionIndex = parms[0].ToInteger();
}
if( selectionIndex != lobby->GetFocusIndex() )
{
2012-11-26 18:58:24 +00:00
lobby->SetViewIndex( lobby->GetViewOffset() + selectionIndex );
lobby->SetFocusIndex( selectionIndex );
return true;
}
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
2012-11-26 18:58:24 +00:00
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( selectionIndex );
if( luid.IsValid() )
{
2012-11-26 18:58:24 +00:00
session->ShowLobbyUserGamerCardUI( luid );
}
2012-11-26 18:58:24 +00:00
return true;
}
}
2012-11-26 18:58:24 +00:00
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
2012-11-26 18:58:24 +00:00
idMenuScreen_Shell_GameLobby::UpdateLobby
========================
*/
void idMenuScreen_Shell_GameLobby::UpdateLobby()
{
2012-11-26 18:58:24 +00:00
if( menuData != NULL && menuData->ActiveScreen() != SHELL_AREA_GAME_LOBBY )
{
2012-11-26 18:58:24 +00:00
return;
}
2012-11-26 18:58:24 +00:00
// Keep this menu in sync with the session host/peer status.
if( session->GetActivePlatformLobbyBase().IsHost() && !isHost )
{
2012-11-26 18:58:24 +00:00
Update();
}
if( session->GetActivePlatformLobbyBase().IsPeer() && !isPeer )
{
2012-11-26 18:58:24 +00:00
Update();
}
if( !privateGameLobby )
{
2012-11-26 18:58:24 +00:00
int ms = 0;
if( session->GetActivePlatformLobbyBase().IsHost() )
{
idMenuHandler_Shell* handler = dynamic_cast< idMenuHandler_Shell* const >( menuData );
if( handler != NULL )
{
if( session->GetActivePlatformLobbyBase().IsLobbyFull() )
{
2012-11-26 18:58:24 +00:00
longCountdown = Sys_Milliseconds() + longCountRemaining;
int timeRemaining = shortCountdown - Sys_Milliseconds();
if( timeRemaining < 0 )
{
2012-11-26 18:58:24 +00:00
timeRemaining = 0;
}
ms = ( int ) ceilf( timeRemaining / 1000.0f );
2012-11-26 18:58:24 +00:00
handler->SetTimeRemaining( timeRemaining );
}
else if( session->GetActivePlatformLobbyBase().GetNumLobbyUsers() > 1 )
{
2012-11-26 18:58:24 +00:00
int timeRemaining = longCountdown - Sys_Milliseconds();
if( timeRemaining > WAIT_START_TIME_SHORT )
{
2012-11-26 18:58:24 +00:00
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
}
else
{
2012-11-26 18:58:24 +00:00
shortCountdown = timeRemaining;
}
2012-11-26 18:58:24 +00:00
longCountRemaining = timeRemaining;
if( timeRemaining < 0 )
{
2012-11-26 18:58:24 +00:00
timeRemaining = 0;
}
ms = ( int ) ceilf( timeRemaining / 1000.0f );
2012-11-26 18:58:24 +00:00
handler->SetTimeRemaining( timeRemaining );
}
else
{
2012-11-26 18:58:24 +00:00
ms = 0;
longCountdown = Sys_Milliseconds() + WAIT_START_TIME_LONG;
longCountRemaining = longCountdown;
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
handler->SetTimeRemaining( longCountRemaining );
}
}
}
else
{
if( menuData != NULL )
{
idMenuHandler_Shell* handler = dynamic_cast< idMenuHandler_Shell* const >( menuData );
if( handler != NULL )
{
ms = ( int ) ceilf( handler->GetTimeRemaining() / 1000.0f );
2012-11-26 18:58:24 +00:00
}
}
}
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
if( BindSprite( root ) )
{
idSWFTextInstance* waitTime = GetSprite()->GetScriptObject()->GetNestedText( "waitTime", "txtVal" );
if( waitTime != NULL )
{
2012-11-26 18:58:24 +00:00
idStr status;
if( ms == 1 )
{
2012-11-26 18:58:24 +00:00
status = idLocalization::GetString( "#str_online_game_starts_in_second" );
status.Replace( "<DNT_VAL>", idStr( ms ) );
waitTime->SetText( status );
}
else if( ms > 0 && ms < 30 )
{
2012-11-26 18:58:24 +00:00
status = idLocalization::GetString( "#str_online_game_starts_in_seconds" );
status.Replace( "<DNT_VAL>", idStr( ms ) );
2012-11-26 18:58:24 +00:00
waitTime->SetText( status );
}
else
{
2012-11-26 18:58:24 +00:00
waitTime->SetText( "" );
}
2012-11-26 18:58:24 +00:00
waitTime->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
Update();
}
else
{
if( isPeer )
{
2012-11-26 18:58:24 +00:00
Update();
}
2012-11-26 18:58:24 +00:00
}
if( session->GetState() == idSession::GAME_LOBBY )
{
if( options != NULL )
{
if( options->GetFocusIndex() >= options->GetTotalNumberOfOptions() && options->GetTotalNumberOfOptions() > 0 )
{
2012-11-26 18:58:24 +00:00
options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
options->SetFocusIndex( options->GetTotalNumberOfOptions() - 1 );
}
}
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
idSWFTextInstance* mapName = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtMapName" );
idSWFTextInstance* modeName = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtModeName" );
if( mapName != NULL )
{
2012-11-26 18:58:24 +00:00
const idList< mpMap_t > maps = common->GetMapList();
idStr name = idLocalization::GetString( maps[ idMath::ClampInt( 0, maps.Num() - 1, matchParameters.gameMap ) ].mapName );
mapName->SetText( name );
mapName->SetStrokeInfo( true );
}
if( modeName != NULL )
{
const idStrList& modes = common->GetModeDisplayList();
2012-11-26 18:58:24 +00:00
idStr mode = idLocalization::GetString( modes[ idMath::ClampInt( 0, modes.Num() - 1, matchParameters.gameMode ) ] );
modeName->SetText( mode );
modeName->SetStrokeInfo( true );
}
idSWFTextInstance* privacy = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtPrivacy" );
if( privacy != NULL )
{
if( isPeer || !privateGameLobby )
{
2012-11-26 18:58:24 +00:00
privacy->SetText( "" );
}
else
{
2012-11-26 18:58:24 +00:00
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
bool privacySet = ( bitSet != 0 ? true : false );
if( privacySet )
{
2012-11-26 18:58:24 +00:00
privacy->SetText( "#str_swf_privacy_closed" );
privacy->SetStrokeInfo( true );
}
else if( !privacySet )
{
2012-11-26 18:58:24 +00:00
privacy->SetText( "#str_swf_privacy_open" );
privacy->SetStrokeInfo( true );
}
}
}
idLocalUser* user = session->GetSignInManager().GetMasterLocalUser();
if( user != NULL && options != NULL )
{
if( user->IsInParty() && user->GetPartyCount() > 1 && !session->IsPlatformPartyInLobby() && menuOptions.Num() > 0 )
{
if( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_xbox_live_party" )
{
2012-11-26 18:58:24 +00:00
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_xbox_live_party"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
}
else if( menuOptions.Num() > 0 )
{
if( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_friends" )
{
2012-11-26 18:58:24 +00:00
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_friends"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
}
}
}
2012-11-26 18:58:24 +00:00
// setup names for lobby;
if( lobby != NULL )
{
idMenuHandler_Shell* mgr = dynamic_cast< idMenuHandler_Shell* >( menuData );
if( mgr != NULL )
{
2012-11-26 18:58:24 +00:00
mgr->UpdateLobby( lobby );
lobby->Update();
}
if( lobby->GetNumEntries() > 0 && lobby->GetFocusIndex() >= lobby->GetNumEntries() )
{
2012-11-26 18:58:24 +00:00
lobby->SetFocusIndex( lobby->GetNumEntries() - 1 );
lobby->SetViewIndex( lobby->GetNumEntries() - 1 );
}
}
}