Ejemplo n.º 1
0
//====================================================================
// [Evento] Indica el porcentaje de carga del mapa y un
// estado acerca de "que esta cargando"
//====================================================================
bool CGameUIPanelWeb::UpdateProgressBar( float progress, const char *statusText )
{
	// No estamos cargando ningún nivel
	if ( !GameUI().IsLoading() )
		return false;

	// Tratamos de traducir el mensaje
	LocalizeStringIndex_t pIndex = g_pVGuiLocalize->FindIndex( statusText );

	if ( pIndex != LOCALIZE_INVALID_STRING_INDEX )
		statusText = g_pVGuiLocalize->GetNameByIndex( pIndex );

	// progress es un valor de 0 a 1, aquí lo convertimos a un valor entre 0 a 100
	int iProgress = ( progress * 100 );

	// Mandamos el JavaScript
	ExecuteJavaScript( VarArgs("GameUI.updateProgressBar(%i, '%s')", iProgress, statusText), "");

	// TODO: Enviar "true" hara algo especial?
	return false;
}
//-----------------------------------------------------------------
// Purpose: Send key presses to the dialog's menu
//-----------------------------------------------------------------
void CSessionLobbyDialog::OnKeyCodePressed( vgui::KeyCode code )
{
	CDialogMenu *pMenu = &m_Menus[m_iActiveMenu];
	if ( !pMenu )
		return;

	int idx = pMenu->GetActiveItemIndex();
	int itemCt = pMenu->GetItemCount();

	CPlayerItem *pItem = dynamic_cast< CPlayerItem* >( pMenu->GetItem( idx ) );
	if ( !pItem )
		return;

	SetDeleteSelfOnClose( true );

	switch( code )
	{
	case KEY_XBUTTON_DOWN:
	case KEY_XSTICK1_DOWN:
		if ( idx >= itemCt - 1 )
		{
			ActivateNextMenu();
		}
		else
		{
			pMenu->HandleKeyCode( code );
		}
		break;

	case KEY_XBUTTON_UP:
	case KEY_XSTICK1_UP:
		if ( idx <= 0 )
		{
			ActivatePreviousMenu();
		}
		else
		{
			pMenu->HandleKeyCode( code );
		}
		break;

	case KEY_XBUTTON_A:
#ifdef _X360
		XShowGamerCardUI( XBX_GetPrimaryUserId(), pItem->m_nId );
#endif
		break;

	case KEY_XBUTTON_RIGHT_SHOULDER:
#ifdef _X360
		{
			// Don't allow player reviews in system link games
			CMatchmakingBasePanel *pBase = dynamic_cast< CMatchmakingBasePanel* >( m_pParent );
			if ( pBase && pBase->GetGameType() == GAMETYPE_SYSTEMLINK_MATCH )
				break;
		}

		XShowPlayerReviewUI( XBX_GetPrimaryUserId(), pItem->m_nId );
#endif
		break;

	case KEY_XBUTTON_LEFT_SHOULDER:
		{
			// Don't kick ourselves
			if ( m_bHostLobby )
			{
				if ( pItem && ((CPlayerItem*)pItem)->m_nId != m_nHostId )
				{
					GameUI().ShowMessageDialog( MD_KICK_CONFIRMATION, this );
				}
				else
				{
					vgui::surface()->PlaySound( "player/suit_denydevice.wav" );
				}
			}
		}
		break;

	case KEY_XBUTTON_B:
		GameUI().ShowMessageDialog( MD_EXIT_SESSION_CONFIRMATION, this );

		if ( m_bHostLobby )
		{
			SetStartGame( false );
		}
		break;

	case KEY_XBUTTON_X:
		if ( m_bStartingGame )
		{
			// We think we're loading the game, so play deny sound
			vgui::surface()->PlaySound( "player/suit_denydevice.wav" );
		}
		else
		{
			matchmaking->ChangeTeam( NULL );
		}
		break;

	case KEY_XBUTTON_Y:
		if ( m_bHostLobby )
		{
			// Don't allow settings changes in ranked games
			CMatchmakingBasePanel *pBase = dynamic_cast< CMatchmakingBasePanel* >( m_pParent );
			if ( pBase && pBase->GetGameType() == GAMETYPE_RANKED_MATCH )
				break;

			SetDeleteSelfOnClose( false );
			OnCommand( "SessionOptions_Modify" );
			SetStartGame( false );
		}
		break;

	case KEY_XBUTTON_START:
		SetStartGame( !m_bStartingGame );
		break;

	default:
		pMenu->HandleKeyCode( code );
		break;
	}
}