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

811 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 "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;
extern idCVar si_map;
extern idCVar si_mode;
enum partyLobbyCmds_t
{
2012-11-26 18:58:24 +00:00
PARTY_CMD_QUICK,
PARTY_CMD_FIND,
PARTY_CMD_CREATE,
PARTY_CMD_PWF,
PARTY_CMD_INVITE,
PARTY_CMD_LEADERBOARDS,
PARTY_CMD_TOGGLE_PRIVACY,
PARTY_CMD_SHOW_PARTY_GAMES,
};
/*
========================
idMenuScreen_Shell_PartyLobby::Initialize
========================
*/
void idMenuScreen_Shell_PartyLobby::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( "menuPartyLobby" );
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 );
btnBack = new( TAG_SWF ) idMenuWidget_Button();
2012-11-26 18:58:24 +00:00
btnBack->Initialize( data );
btnBack->SetLabel( "#str_02305" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
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 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 );
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_PartyLobby::Update
========================
*/
void idMenuScreen_Shell_PartyLobby::Update()
{
idLobbyBase& activeLobby = session->GetPartyLobbyBase();
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() );
}
}
2012-11-26 18:58:24 +00:00
UpdateOptions();
if( menuData != NULL && menuData->NextScreen() == SHELL_AREA_PARTY_LOBBY )
{
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_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 );
}
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
}
if( btnBack != NULL )
{
2012-11-26 18:58:24 +00:00
btnBack->BindSprite( root );
}
2012-11-26 18:58:24 +00:00
idMenuScreen::Update();
}
void idMenuScreen_Shell_PartyLobby::UpdateOptions()
{
2012-11-26 18:58:24 +00:00
bool forceUpdate = false;
if( ( session->GetPartyLobbyBase().IsHost() && ( !isHost || forceUpdate ) ) && options != NULL )
{
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_join_public" ); // Quick Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_find_match" ); // Find Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_create_private" ); // Create Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_pwf" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_leaderboards" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_only" ); // Toggle privacy
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
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, PARTY_CMD_QUICK, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_quick_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_FIND, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_find_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_CREATE, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_create_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_PWF, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_pwf_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_LEADERBOARDS, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_TOGGLE_PRIVACY, index );
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, PARTY_CMD_INVITE, index );
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 );
}
else if( session->GetPartyLobbyBase().IsPeer() && options != NULL )
{
if( !isPeer || forceUpdate )
{
2012-11-26 18:58:24 +00:00
menuOptions.Clear();
idList< idStr > option;
idMenuWidget_Button* buttonWidget = NULL;
2012-11-26 18:58:24 +00:00
option.Append( "#str_swf_leaderboards" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends" ); // Play With Friends
menuOptions.Append( option );
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, PARTY_CMD_LEADERBOARDS, index );
buttonWidget = dynamic_cast< idMenuWidget_Button* >( &options->GetChildByIndex( index ) );
if( buttonWidget != NULL )
{
2012-11-26 18:58:24 +00:00
buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_INVITE, index );
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
}
2012-11-26 18:58:24 +00:00
isPeer = true;
isHost = false;
}
if( forceUpdate )
{
2012-11-26 18:58:24 +00:00
options->Update();
}
2012-11-26 18:58:24 +00:00
}
/*
========================
idMenuScreen_Shell_PartyLobby::ShowScreen
========================
*/
void idMenuScreen_Shell_PartyLobby::ShowScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
isPeer = false;
isHost = false;
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( false );
}
}
if( session->GetPartyLobbyBase().IsHost() )
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
if( net_inviteOnly.GetBool() )
{
matchParameters.matchFlags |= MATCH_INVITE_ONLY;
2012-11-26 18:58:24 +00:00
}
else
{
matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
}
matchParameters.numSlots = session->GetTitleStorageInt( "MAX_PLAYERS_ALLOWED", 4 );
2012-11-26 18:58:24 +00:00
session->UpdatePartyParms( matchParameters );
}
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 );
}
}
/*
========================
idMenuScreen_Shell_PartyLobby::HideScreen
========================
*/
void idMenuScreen_Shell_PartyLobby::HideScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer
========================
*/
bool idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer( lobbyUserID_t& luid )
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
const int playerId = lobby->GetFocusIndex();
2012-11-26 18:58:24 +00:00
// can't kick yourself
idLobbyBase& activeLobby = session->GetPartyLobbyBase();
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_PartyLobby::ShowLeaderboards
========================
*/
void idMenuScreen_Shell_PartyLobby::ShowLeaderboards()
{
2012-11-26 18:58:24 +00:00
const bool canPlayOnline = session->GetSignInManager().GetMasterLocalUser() != NULL && session->GetSignInManager().GetMasterLocalUser()->CanPlayOnline();
if( !canPlayOnline )
{
2012-11-26 18:58:24 +00:00
common->Dialog().AddDialog( GDM_LEADERBOARD_ONLINE_NO_PROFILE, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
}
else if( menuData != NULL )
{
2012-11-26 18:58:24 +00:00
menuData->SetNextScreen( SHELL_AREA_LEADERBOARDS, MENU_TRANSITION_SIMPLE );
}
}
/*
========================
idMenuScreen_Shell_PartyLobby::HandleAction h
========================
*/
bool idMenuScreen_Shell_PartyLobby::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_PARTY_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->GetPartyLobbyBase();
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_MAIN );
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_MAIN );
return idSWFScriptVar();
}
};
idLobbyBase& activeLobby = session->GetActivePlatformLobbyBase();
if( activeLobby.GetNumActiveLobbyUsers() > 1 )
{
common->Dialog().AddDialog( GDM_LEAVE_LOBBY_RET_MAIN, 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->GetPartyLobbyBase();
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 PARTY_CMD_QUICK:
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
2012-11-26 18:58:24 +00:00
// Reset these to random for quick match.
matchParameters.gameMap = GAME_MAP_RANDOM;
matchParameters.gameMode = GAME_MODE_RANDOM;
2012-11-26 18:58:24 +00:00
// Always a public match.
matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
session->UpdatePartyParms( matchParameters );
2012-11-26 18:58:24 +00:00
// Update flags for game lobby.
matchParameters.matchFlags = DefaultPartyFlags | DefaultPublicGameFlags;
2012-11-26 18:58:24 +00:00
cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
2012-11-26 18:58:24 +00:00
// Force a default value for the si_timelimit and si_fraglimit for quickmatch
matchParameters.serverInfo.SetInt( "si_timelimit", 15 );
matchParameters.serverInfo.SetInt( "si_fraglimit", 10 );
2012-11-26 18:58:24 +00:00
session->FindOrCreateMatch( matchParameters );
break;
}
case PARTY_CMD_FIND:
{
2012-11-26 18:58:24 +00:00
menuData->SetNextScreen( SHELL_AREA_MODE_SELECT, MENU_TRANSITION_SIMPLE );
break;
}
case PARTY_CMD_CREATE:
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
2012-11-26 18:58:24 +00:00
const bool isInviteOnly = MatchTypeInviteOnly( matchParameters.matchFlags );
2012-11-26 18:58:24 +00:00
matchParameters.matchFlags = DefaultPartyFlags | DefaultPrivateGameFlags;
if( isInviteOnly )
{
2012-11-26 18:58:24 +00:00
matchParameters.matchFlags |= MATCH_INVITE_ONLY;
}
2012-11-26 18:58:24 +00:00
int mode = idMath::ClampInt( -1, GAME_COUNT - 1, si_mode.GetInteger() );
const idList< mpMap_t > maps = common->GetMapList();
int map = idMath::ClampInt( -1, maps.Num() - 1, si_map.GetInteger() );
2012-11-26 18:58:24 +00:00
matchParameters.gameMap = map;
matchParameters.gameMode = mode;
cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
session->CreateMatch( matchParameters );
break;
}
case PARTY_CMD_PWF:
{
2012-11-26 18:58:24 +00:00
menuData->SetNextScreen( SHELL_AREA_BROWSER, MENU_TRANSITION_SIMPLE );
break;
}
case PARTY_CMD_LEADERBOARDS:
{
2012-11-26 18:58:24 +00:00
ShowLeaderboards();
break;
}
case PARTY_CMD_TOGGLE_PRIVACY:
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
matchParameters.matchFlags ^= MATCH_INVITE_ONLY;
session->UpdatePartyParms( matchParameters );
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
net_inviteOnly.SetBool( bitSet != 0 ? true : false );
break;
}
case PARTY_CMD_SHOW_PARTY_GAMES:
{
2012-11-26 18:58:24 +00:00
session->ShowPartySessions();
break;
}
case PARTY_CMD_INVITE:
{
if( session->GetPartyLobbyBase().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;
}
}
2012-11-26 18:58:24 +00:00
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->GetPartyLobbyBase();
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 );
}
return true;
}
}
2012-11-26 18:58:24 +00:00
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_Shell_PartyLobby::UpdateLobby
========================
*/
void idMenuScreen_Shell_PartyLobby::UpdateLobby()
{
if( menuData != NULL && menuData->ActiveScreen() != SHELL_AREA_PARTY_LOBBY )
{
2012-11-26 18:58:24 +00:00
return;
}
// Keep this menu in sync with the session host/peer status.
if( session->GetPartyLobbyBase().IsHost() && !isHost )
{
2012-11-26 18:58:24 +00:00
Update();
}
if( session->GetPartyLobbyBase().IsPeer() && !isPeer )
{
2012-11-26 18:58:24 +00:00
Update();
}
if( isPeer )
{
2012-11-26 18:58:24 +00:00
Update();
}
2012-11-26 18:58:24 +00:00
UpdateOptions();
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 );
}
}
if( session->GetState() == idSession::PARTY_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 );
}
}
idSWFTextInstance* privacy = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtPrivacy" );
if( privacy != NULL )
{
if( isPeer )
{
2012-11-26 18:58:24 +00:00
privacy->SetText( "" );
}
else
{
2012-11-26 18:58:24 +00:00
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
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();
}
}
}
}
}