void BaseModHybridButton::NavigateTo( )
{
	BaseClass::NavigateTo( );

	UpdateFooterHelpText();

	FlyoutMenu* parentMenu = dynamic_cast< FlyoutMenu* >( GetParent() );
	if( parentMenu )
	{
		parentMenu->NotifyChildFocus( this );
	}

	if (GetVParent())
	{
		KeyValues *msg = new KeyValues("OnHybridButtonNavigatedTo");
		msg->SetInt("button", ToHandle() );

		ivgui()->PostMessage(GetVParent(), msg, GetVPanel());
	}

	m_isNavigateTo = true;
	if ( IsPC() )
	{
		RequestFocus( 0 );
	}
}
void BaseModHybridButton::OnSiblingHybridButtonOpened()
{
	if ( !IsPC() )
		return;

	bool bClosed = false;

	FlyoutMenu *pActiveFlyout = FlyoutMenu::GetActiveMenu();

	if ( pActiveFlyout )
	{
		BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( pActiveFlyout->GetNavFrom() );
		if ( button && button == this )
		{
			// We need to close the flyout attached to this button
			FlyoutMenu::CloseActiveMenu();
			bClosed = true;
		}
	}

	if ( !bClosed )
	{
		SetClosed();
	}

	m_isNavigateTo = false;
}
void DropDownMenu::CloseDropDown()
{
	FlyoutMenu* flyout = GetCurrentFlyout();
	if ( flyout && flyout->IsVisible() )
	{
		flyout->CloseMenu( m_pButton );
	}
}
//=============================================================================
void MainMenu::OnThink()
{
	// need to change state of flyout if user suddenly disconnects
	// while flyout is open
	BaseModUI::FlyoutMenu *flyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmCampaignFlyout" ) );
	if ( flyout )
	{
		BaseModHybridButton *pButton = dynamic_cast< BaseModHybridButton* >( flyout->FindChildButtonByCommand( "QuickMatchCoOp" ) );
		if ( pButton )
		{
			if ( !CUIGameData::Get()->SignedInToLive() )
			{
				pButton->SetText( "#L4D360UI_QuickStart" );
				if ( m_iQuickJoinHelpText != MMQJHT_QUICKSTART )
				{
					pButton->SetHelpText( "#L4D360UI_QuickMatch_Offline_Tip" );
					m_iQuickJoinHelpText = MMQJHT_QUICKSTART;
				}
			}
			else
			{
				pButton->SetText( "#L4D360UI_QuickMatch" );
				if ( m_iQuickJoinHelpText != MMQJHT_QUICKMATCH )
				{
					pButton->SetHelpText( "#L4D360UI_QuickMatch_Tip" );
					m_iQuickJoinHelpText = MMQJHT_QUICKMATCH;
				}
			}
		}
	}

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			const MaterialSystem_Config_t &config = materials->GetCurrentConfigForVideoCard();
			pFlyout->SetControlEnabled( "BtnBrightness", !config.Windowed() );
		}
	}

	BaseClass::OnThink();
}
Example #5
0
//=============================================================================
void Cloud::Activate()
{
	BaseClass::Activate();

	if ( m_drpCloud )
	{
		CGameUIConVarRef cl_cloud_settings( "cl_cloud_settings" );

		int iCloudSettings = cl_cloud_settings.GetInt();

		if ( iCloudSettings == -1 || iCloudSettings != 0 )
		{
			m_bCloudEnabled = true;
			m_drpCloud->SetCurrentSelection( "SteamCloudEnabled" );
		}
		else
		{
			m_bCloudEnabled = false;
			m_drpCloud->SetCurrentSelection( "SteamCloudDisabled" );
		}

		FlyoutMenu *pFlyout = m_drpCloud->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	UpdateFooter();

	if ( m_drpCloud )
	{
		if ( m_ActiveControl )
		{
			m_ActiveControl->NavigateFrom( );
		}

		m_drpCloud->NavigateTo();
		m_ActiveControl = m_drpCloud;
	}
}
Example #6
0
//=============================================================================
void MainMenu::ApplySchemeSettings( IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	const char *pSettings = "Resource/UI/BaseModUI/MainMenu.res";

#if !defined( _X360 )
	if ( !g_pMatchFramework->GetMatchSystem() )
	{
		Msg( "BAD!\n" );
	}
	if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager() )
	{
		Msg( "BAD PLAYER MANAGER!\n" );
	}
	if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( 0 ) )
	{
		pSettings = "Resource/UI/BaseModUI/MainMenuStub.res";
	}
#endif

	LoadControlSettings( pSettings );

	BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnPlaySolo" ) );
	if ( button )
	{
#ifdef _X360
		button->SetText( ( XBX_GetNumGameUsers() > 1 ) ? ( "#L4D360UI_MainMenu_PlaySplitscreen" ) : ( "#L4D360UI_MainMenu_PlaySolo" ) );
		button->SetHelpText( ( XBX_GetNumGameUsers() > 1 ) ? ( "#L4D360UI_MainMenu_OfflineCoOp_Tip" ) : ( "#L4D360UI_MainMenu_PlaySolo_Tip" ) );
#endif
	}

#ifdef _X360
	if ( !XBX_GetPrimaryUserIsGuest() )
	{
		wchar_t wszListText[ 128 ];
		wchar_t wszPlayerName[ 128 ];

		IPlayer *player1 = NULL;
		if ( XBX_GetNumGameUsers() > 0 )
		{
			player1 = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( 0 ) );
		}

		IPlayer *player2 = NULL;
		if ( XBX_GetNumGameUsers() > 1 )
		{
			player2 = g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( 1 ) );
		}

		if ( player1 )
		{
			Label *pLblPlayer1GamerTag = dynamic_cast< Label* >( FindChildByName( "LblPlayer1GamerTag" ) );
			if ( pLblPlayer1GamerTag )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( player1->GetName(), wszPlayerName, sizeof( wszPlayerName ) );
				g_pVGuiLocalize->ConstructString( wszListText, sizeof( wszListText ), g_pVGuiLocalize->Find( "#L4D360UI_MainMenu_LocalProfilePlayer1" ), 1, wszPlayerName );

				pLblPlayer1GamerTag->SetVisible( true );
				pLblPlayer1GamerTag->SetText( wszListText );
			}
		}

		if ( player2 )
		{
			Label *pLblPlayer2GamerTag = dynamic_cast< Label* >( FindChildByName( "LblPlayer2GamerTag" ) );
			if ( pLblPlayer2GamerTag )
			{
				g_pVGuiLocalize->ConvertANSIToUnicode( player2->GetName(), wszPlayerName, sizeof( wszPlayerName ) );
				g_pVGuiLocalize->ConstructString( wszListText, sizeof( wszListText ), g_pVGuiLocalize->Find( "#L4D360UI_MainMenu_LocalProfilePlayer2" ), 1, wszPlayerName );

				pLblPlayer2GamerTag->SetVisible( true );
				pLblPlayer2GamerTag->SetText( wszListText );

				// in split screen, have player2 gamer tag instead of enable, and disable
				SetControlVisible( "LblPlayer2DisableIcon", true );
				SetControlVisible( "LblPlayer2Disable", true );
				SetControlVisible( "LblPlayer2Enable", false );
			}
		}
		else
		{
			SetControlVisible( "LblPlayer2DisableIcon", false );
			SetControlVisible( "LblPlayer2Disable", false );

			// not in split screen, no player2 gamertag, instead have enable
			SetControlVisible( "LblPlayer2GamerTag", false );
			SetControlVisible( "LblPlayer2Enable", true );
		}
	}
#endif

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			bool bUsesCloud = false;

#ifdef IS_WINDOWS_PC
			ISteamRemoteStorage *pRemoteStorage = SteamClient()?(ISteamRemoteStorage *)SteamClient()->GetISteamGenericInterface(
				SteamAPI_GetHSteamUser(), SteamAPI_GetHSteamPipe(), STEAMREMOTESTORAGE_INTERFACE_VERSION ):NULL;
#else
			ISteamRemoteStorage *pRemoteStorage =  NULL; 
			AssertMsg( false, "This branch run on a PC build without IS_WINDOWS_PC defined." );
#endif

			int32 availableBytes, totalBytes = 0;
			if ( pRemoteStorage && pRemoteStorage->GetQuota( &totalBytes, &availableBytes ) )
			{
				DevMsg("Accessing remote storage.  totalBytes = %i\n", totalBytes);
				if ( totalBytes > 0 )
				{
					DevMsg("Enabling cloud.\n");
					bUsesCloud = true;
				}
			}

			pFlyout->SetControlEnabled( "BtnCloud", bUsesCloud );
		}
	}

	SetFooterState();

	if ( IsX360() )
	{		
		GameModes *pGameModes =  dynamic_cast< GameModes* >( FindChildByName( "BtnGameModes" ) );	
		if ( pGameModes )
		{
			char lastActive[MAX_PATH];
			if ( pGameModes->GetLastActiveNameId( lastActive, sizeof( lastActive ) ) )
			{
				pGameModes->SetActive( lastActive, true );
			}
			else
			{
				pGameModes->SetActive( "BtnPlaySolo", true );
			}
			m_ActiveControl = pGameModes;
		}
	}

	if ( IsPC() )
	{
		vgui::Panel *firstPanel = FindChildByName( "BtnCoOp" );
		if ( firstPanel )
		{
			if ( m_ActiveControl )
			{
				m_ActiveControl->NavigateFrom( );
			}
			firstPanel->NavigateTo();
		}
	}

#if defined( _X360 ) && defined( _DEMO )
	SetControlVisible( "BtnExtras", !engine->IsDemoHostedFromShell() );
	SetControlVisible( "BtnQuit", engine->IsDemoHostedFromShell() );
#endif

	// CERT CATCH ALL JUST IN CASE!
#ifdef _X360
	bool bAllUsersCorrectlySignedIn = ( XBX_GetNumGameUsers() > 0 );
	for ( int k = 0; k < ( int ) XBX_GetNumGameUsers(); ++ k )
	{
		if ( !g_pMatchFramework->GetMatchSystem()->GetPlayerManager()->GetLocalPlayer( XBX_GetUserId( k ) ) )
			bAllUsersCorrectlySignedIn = false;
	}
	if ( !bAllUsersCorrectlySignedIn )
	{
		Warning( "======= SIGNIN FAIL SIGNIN FAIL SIGNIN FAIL SIGNIN FAIL ==========\n" );
		Assert( 0 );
		CBaseModPanel::GetSingleton().CloseAllWindows( CBaseModPanel::CLOSE_POLICY_EVEN_MSGS );
		CAttractScreen::SetAttractMode( CAttractScreen::ATTRACT_GAMESTART );
		CBaseModPanel::GetSingleton().OpenWindow( WT_ATTRACTSCREEN, NULL, true );
		Warning( "======= SIGNIN RESET SIGNIN RESET SIGNIN RESET SIGNIN RESET ==========\n" );
	}
#endif
}
Example #7
0
//=============================================================================
void Video::Activate( bool bRecommendedSettings )
{
	BaseClass::Activate();

	if ( !bRecommendedSettings )
	{
		SetupActivateData();
	}
	else
	{
		if ( !SetupRecommendedActivateData() )
			return;
	}

	if ( m_drpAspectRatio )
	{
		switch ( m_iAspectRatio )
		{
		default:
		case 0:
			m_drpAspectRatio->SetCurrentSelection( "#GameUI_AspectNormal" );
			break;
		case 1:
			m_drpAspectRatio->SetCurrentSelection( "#GameUI_AspectWide16x9" );
			break;
		case 2:
			m_drpAspectRatio->SetCurrentSelection( "#GameUI_AspectWide16x10" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpAspectRatio->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpDisplayMode )
	{
		if ( m_bWindowed )
		{
			if ( m_bNoBorder )
			{
				m_drpDisplayMode->SetCurrentSelection( "#L4D360UI_VideoOptions_Windowed_NoBorder" );
			}
			else
			{
				m_drpDisplayMode->SetCurrentSelection( "#GameUI_Windowed" );
			}
		}
		else
		{
			m_drpDisplayMode->SetCurrentSelection( "#GameUI_Fullscreen" );
		}

		FlyoutMenu *pFlyout = m_drpDisplayMode->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpResolution )
	{
		FlyoutMenu *pFlyout = m_drpResolution->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpLockMouse )
	{
		if ( m_bLockMouse )
		{
			m_drpLockMouse->SetCurrentSelection( "#L4D360UI_Enabled" );
		}
		else
		{
			m_drpLockMouse->SetCurrentSelection( "#L4D360UI_Disabled" );
		}

		FlyoutMenu *pFlyout = m_drpLockMouse->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_sldFilmGrain )
	{
		if ( !bRecommendedSettings )
		{
			m_sldFilmGrain->Reset();
		}
		else
		{
			m_sldFilmGrain->SetCurrentValue( m_flFilmGrain );
			m_sldFilmGrain->ResetSliderPosAndDefaultMarkers();
		}
	}

	if ( m_drpModelDetail )
	{
		switch ( m_iModelTextureDetail )
		{
		case 0:
			m_drpModelDetail->SetCurrentSelection( "ModelDetailLow" );
			break;
		case 1:
			m_drpModelDetail->SetCurrentSelection( "ModelDetailMedium" );
			break;
		case 2:
			m_drpModelDetail->SetCurrentSelection( "ModelDetailHigh" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpModelDetail->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpPagedPoolMem )
	{
		switch ( m_iPagedPoolMem )
		{
		case 0:
			m_drpPagedPoolMem->SetCurrentSelection( "PagedPoolMemLow" );
			break;
		case 1:
			m_drpPagedPoolMem->SetCurrentSelection( "PagedPoolMemMedium" );
			break;
		case 2:
			m_drpPagedPoolMem->SetCurrentSelection( "PagedPoolMemHigh" );
			break;
		}
		
		m_drpPagedPoolMem->SetOpenCallback( PagedPoolMemOpenned );

		FlyoutMenu *pFlyout = m_drpPagedPoolMem->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpAntialias )
	{
		FlyoutMenu *pFlyout = m_drpAntialias->GetCurrentFlyout();
		if ( pFlyout )
		{
			char szCurrentButton[ 32 ];
			Q_strncpy( szCurrentButton, VIDEO_ANTIALIAS_COMMAND_PREFIX, sizeof( szCurrentButton ) );

			int iCommandNumberPosition = Q_strlen( szCurrentButton );
			szCurrentButton[ iCommandNumberPosition + 1 ] = '\0';

			// We start with no entries
			m_nNumAAModes = 0;

			// Always have the possibility of no AA
			Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
			szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
			SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_None" );

			m_nAAModes[m_nNumAAModes].m_nNumSamples = 1;
			m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
			m_nNumAAModes++;

			// Add other supported AA settings
			if ( materials->SupportsMSAAMode(2) )
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_2X" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 2;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
				m_nNumAAModes++;
			}

			if ( materials->SupportsMSAAMode(4) )
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_4X" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
				m_nNumAAModes++;
			}

			if ( materials->SupportsMSAAMode(6) )
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_6X" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 6;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
				m_nNumAAModes++;
			}

			if ( materials->SupportsCSAAMode(4, 2) )							// nVidia CSAA			"8x"
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_8X_CSAA" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 2;
				m_nNumAAModes++;
			}

			if ( materials->SupportsCSAAMode(4, 4) )							// nVidia CSAA			"16x"
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_16X_CSAA" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 4;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 4;
				m_nNumAAModes++;
			}

			if ( materials->SupportsMSAAMode(8) )
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_8X" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 8;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 0;
				m_nNumAAModes++;
			}

			if ( materials->SupportsCSAAMode(8, 2) )							// nVidia CSAA			"16xQ"
			{
				Assert( m_nNumAAModes < MAX_DYNAMIC_AA_MODES );
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAAModes + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, "#GameUI_16XQ_CSAA" );

				m_nAAModes[m_nNumAAModes].m_nNumSamples = 8;
				m_nAAModes[m_nNumAAModes].m_nQualityLevel = 2;
				m_nNumAAModes++;
			}

			// Change the height to fit the active items
			pFlyout->SetBGTall( m_nNumAAModes * 20 + 5 );

			// Disable the remaining possible choices
			for ( int i = m_nNumAAModes; i <= 9; ++i )
			{
				szCurrentButton[ iCommandNumberPosition ] = i + '0';

				Button *pButton = pFlyout->FindChildButtonByCommand( szCurrentButton );
				if ( pButton )
				{
					pButton->SetVisible( false );
				}
			}

			// Select the currently set type
			m_iAntiAlias = FindMSAAMode( m_nAASamples, m_nAAQuality );
			szCurrentButton[ iCommandNumberPosition ] = m_iAntiAlias + '0';
			m_drpAntialias->SetCurrentSelection( szCurrentButton );

			pFlyout->SetListener( this );
		}
	}

	if ( m_drpFiltering )
	{
		switch ( m_iFiltering )
		{
		case 0:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Bilinear" );
			break;
		case 1:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Trilinear" );
			break;
		case 2:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Anisotropic2X" );
			break;
		case 4:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Anisotropic4X" );
			break;
		case 8:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Anisotropic8X" );
			break;
		case 16:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Anisotropic16X" );
			break;
		default:
			m_drpFiltering->SetCurrentSelection( "#GameUI_Trilinear" );
			m_iFiltering = 1;
			break;
		}

		FlyoutMenu *pFlyout = m_drpFiltering->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpVSync )
	{
		if ( m_bVSync )
		{
			if ( m_bTripleBuffered )
			{
				m_drpVSync->SetCurrentSelection( "VSyncTripleBuffered" );
			}
			else
			{
				m_drpVSync->SetCurrentSelection( "VSyncEnabled" );
			}
		}
		else
		{
			m_drpVSync->SetCurrentSelection( "VSyncDisabled" );
		}

		FlyoutMenu *pFlyout = m_drpVSync->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpQueuedMode )
	{
		// Only allow the options on multi-processor machines.
		if ( GetCPUInformation().m_nPhysicalProcessors >= 2 )
		{
			if ( m_iQueuedMode != 0 )
			{
				m_drpQueuedMode->SetCurrentSelection( "QueuedModeEnabled" );
			}
			else
			{
				m_drpQueuedMode->SetCurrentSelection( "QueuedModeDisabled" );
			}

			FlyoutMenu *pFlyout = m_drpQueuedMode->GetCurrentFlyout();
			if ( pFlyout )
			{
				pFlyout->SetListener( this );
			}
		}
		else
		{
			m_drpQueuedMode->SetEnabled( false );
		}
	}

	if ( m_drpShaderDetail )
	{
		switch ( m_iGPUDetail )
		{
		case 0:
			m_drpShaderDetail->SetCurrentSelection( "ShaderDetailLow" );
			break;
		case 1:
			m_drpShaderDetail->SetCurrentSelection( "ShaderDetailMedium" );
			break;
		case 2:
			m_drpShaderDetail->SetCurrentSelection( "ShaderDetailHigh" );
			break;
		case 3:
			m_drpShaderDetail->SetCurrentSelection( "ShaderDetailVeryHigh" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpShaderDetail->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpCPUDetail )
	{
		switch ( m_iCPUDetail )
		{
		case 0:
			m_drpCPUDetail->SetCurrentSelection( "CPUDetailLow" );
			break;
		case 1:
			m_drpCPUDetail->SetCurrentSelection( "CPUDetailMedium" );
			break;
		case 2:
			m_drpCPUDetail->SetCurrentSelection( "CPUDetailHigh" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpCPUDetail->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if( m_drpLighting )
	{
		if( deferred_lighting_enabled.GetBool() )
			m_drpLighting->SetCurrentSelection( "DeferredLighting" );
		else
			m_drpLighting->SetCurrentSelection( "StandardLighting" );
		
		FlyoutMenu *pFlyout = m_drpLighting->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	UpdateFooter();
	
	if ( !bRecommendedSettings )
	{
		if ( m_drpAspectRatio )
		{
			if ( m_ActiveControl )
				m_ActiveControl->NavigateFrom( );
			m_drpAspectRatio->NavigateTo();
			m_ActiveControl = m_drpAspectRatio;
		}
	}
}
Example #8
0
//=============================================================================
void AudioVideo::Activate()
{
	BaseClass::Activate();

#ifdef _X360
	CGameUIConVarRef mat_xbox_ishidef( "mat_xbox_ishidef" );
	CGameUIConVarRef mat_xbox_iswidescreen( "mat_xbox_iswidescreen" );
#endif

	if ( m_sldBrightness )
	{
		m_sldBrightness->Reset();
		m_sldBrightness->NavigateTo();
	}

	if ( m_drpColorMode )
	{
		CGameUIConVarRef mat_monitorgamma_tv_enabled( "mat_monitorgamma_tv_enabled" );

		if ( mat_monitorgamma_tv_enabled.GetBool() )
		{
			m_drpColorMode->SetCurrentSelection( "#L4D360UI_ColorMode_Television" );
		}
		else
		{
			m_drpColorMode->SetCurrentSelection( "#L4D360UI_ColorMode_LCD" );
		}

		FlyoutMenu *pFlyout = m_drpColorMode->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_sldFilmGrain )
	{
		m_sldFilmGrain->Reset();

#ifdef _X360
		if ( !mat_xbox_ishidef.GetBool() )
		{
			m_sldFilmGrain->SetEnabled( false );
		}
#endif
	}

	if ( m_drpSplitScreenDirection )
	{
		bool bWidescreen = false;
#ifdef _X360
		bWidescreen = mat_xbox_iswidescreen.GetBool();
#endif

		if ( !bWidescreen )
		{
			m_drpSplitScreenDirection->SetEnabled( false );
			m_drpSplitScreenDirection->SetCurrentSelection( "#L4D360UI_SplitScreenDirection_Horizontal" );
		}
		else
		{
			CGameUIConVarRef ss_splitmode( "ss_splitmode" );
			int iSplitMode = ss_splitmode.GetInt();

			switch ( iSplitMode )
			{
			case 1:
				m_drpSplitScreenDirection->SetCurrentSelection( "#L4D360UI_SplitScreenDirection_Horizontal" );
				break;
			case 2:
				m_drpSplitScreenDirection->SetCurrentSelection( "#L4D360UI_SplitScreenDirection_Vertical" );
				break;
			default:
				m_drpSplitScreenDirection->SetCurrentSelection( "#L4D360UI_SplitScreenDirection_Default" );
			}
		}

		FlyoutMenu *pFlyout = m_drpSplitScreenDirection->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_sldGameVolume )
	{
		m_sldGameVolume->Reset();
	}

	if ( m_sldMusicVolume )
	{
		m_sldMusicVolume->Reset();
	}

	if ( m_drpCaptioning )
	{
		CGameUIConVarRef closecaption("closecaption");
		CGameUIConVarRef cc_subtitles("cc_subtitles");

		if ( !closecaption.GetBool() )
		{
			m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOff" );
		}
		else
		{
			if ( cc_subtitles.GetBool() )
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionSubtitles" );
			}
			else
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOn" );
			}
		}

		FlyoutMenu *pFlyout = m_drpCaptioning->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpLanguage )
	{
#if defined( _DEMO )
		// not allowing this for the demo, can't reboot to force english
		bool bIsLocalized = false;
#else
		bool bIsLocalized = XBX_IsAudioLocalized();
#endif
		if ( !bIsLocalized )
		{
			// hidden if we don't have an audio localization for our current non-english language
			// the audio is in english, there is no other choice for their audio
			m_drpLanguage->SetVisible( false );
		}
		else
		{
			// We're in a language other than english that has full audio localization (not all of them do)
			// let them select either their native language or english for thier audio if they're not in game
			m_drpLanguage->SetFlyout( "FlmLanguage" );

			char szLanguage[ 256 ];
			Q_snprintf( szLanguage, sizeof( szLanguage ), "#GameUI_Language_%s", XBX_GetLanguageString() );

			FlyoutMenu *pFlyout = m_drpLanguage->GetCurrentFlyout();
			if ( pFlyout )
			{
				Button *pCurrentLanguageButton = pFlyout->FindChildButtonByCommand( "CurrentXBXLanguage" );

				if ( pCurrentLanguageButton )
				{
					pCurrentLanguageButton->SetText( szLanguage );
					pCurrentLanguageButton->SetCommand( szLanguage );
					pFlyout->SetListener( this );
				}
			}

			m_drpLanguage->SetCurrentSelection( ( x360_audio_english.GetBool() ) ? ( "#GameUI_Language_English" ) : ( szLanguage ) );

			// Can't change language while in game
			m_drpLanguage->SetEnabled( !engine->IsInGame() || GameUI().IsInBackgroundLevel() );
		}
	}
	
	if ( m_drpGore )
	{
		CGameUIConVarRef z_wound_client_disabled ( "z_wound_client_disabled" );

		if ( z_wound_client_disabled.GetBool() )
		{
			m_drpGore->SetCurrentSelection( "#L4D360UI_Gore_Low" );
		}
		else
		{
			m_drpGore->SetCurrentSelection( "#L4D360UI_Gore_High" );
		}

		FlyoutMenu *pFlyout = m_drpGore->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	m_bDirtyVideoConfig = false;

	UpdateFooter();
}
//=============================================================================
void InGameChapterSelect::ApplySchemeSettings(vgui::IScheme *pScheme)
{
	BaseClass::ApplySchemeSettings(pScheme);

	SetPaintBackgroundEnabled( true );

	// Determine current game settings
	KeyValues *pGameSettings = g_pMatchFramework->GetMatchNetworkMsgController()->GetActiveServerGameDetails( NULL );
	KeyValues::AutoDelete autodelete_pGameSettings( pGameSettings );

	char const *szGameMode = pGameSettings->GetString( "game/mode", "campaign" );

	if ( !GameModeIsSingleChapter( szGameMode ) )
		pGameSettings->SetInt( "game/chapter", 1 );

	// Get mission and campaign info
	KeyValues *pInfoMission = NULL;
	KeyValues *pInfoChapter = g_pMatchExtSwarm->GetMapInfo( pGameSettings, &pInfoMission );

	// Check if this is a custom mission?
	if ( pInfoMission && !pInfoMission->GetBool( "builtin" ) )
		pInfoChapter = pInfoMission = NULL;	// trigger to use another builtin mission

	if ( !pInfoMission || !pInfoChapter )
	{
		KeyValues *pAllMissions = g_pMatchExtSwarm->GetAllMissions();
		for ( pInfoMission = pAllMissions ? pAllMissions->GetFirstTrueSubKey() : NULL;
			  pInfoMission; pInfoMission = pInfoMission->GetNextTrueSubKey() )
		{
			if ( !pInfoMission->GetBool( "builtin" ) )
				continue;

			pInfoChapter = pInfoMission->FindKey( CFmtStr( "modes/%s/1", szGameMode ) );
			if ( pInfoChapter )
				break;
		}
	}

	Assert( pInfoMission && pInfoChapter );

	// set the dropdowns
	DropDownMenu *pMissionDropDown = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpMission" ) );
	DropDownMenu *pChapterDropDown = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpChapter" ) );
	if( pMissionDropDown && pChapterDropDown ) //missions change what the available campaigns are, we should listen on that flyout as well
	{
		pMissionDropDown->SetFlyout( CFmtStr( "FlmMission%s", szGameMode ) );

		if ( pInfoMission && pInfoChapter )
		{
			pMissionDropDown->SetCurrentSelection( CFmtStr( "cmd_campaign_%s", pInfoMission->GetString( "name" ) ) );
			Q_strncpy( m_chCampaign, pInfoMission->GetString( "name" ), ARRAYSIZE( m_chCampaign ) );

			// Set this after setting the mission dropdown, as that will default the chapter to the first in the campaign
			pChapterDropDown->SetCurrentSelection( CFmtStr( "#L4D360UI_Chapter_%d", pInfoChapter->GetInt( "chapter" ) ) );
			m_nChapter = pInfoChapter->GetInt( "chapter" );
		}

		FlyoutMenu *flyout = pMissionDropDown->GetCurrentFlyout();
		if( flyout )
		{
			flyout->CloseMenu( NULL );
		}

		flyout = pChapterDropDown->GetCurrentFlyout();
		if( flyout )
		{
			flyout->CloseMenu( NULL );
		}

		if ( m_ActiveControl )
		{
			m_ActiveControl->NavigateFrom( );
		}
		pMissionDropDown->NavigateTo();
		m_ActiveControl = pMissionDropDown;

		// Chapters are directly selectable only in some game modes
		pChapterDropDown->SetEnabled( GameModeIsSingleChapter( szGameMode ) );
	}

	SetPaintBackgroundEnabled( true );
	SetupAsDialogStyle();
}
Example #10
0
void Multiplayer::InitLogoList()
{
	if ( !m_drpSpraypaint )
	{
		return;
	}

	FlyoutMenu *pFlyout = m_drpSpraypaint->GetCurrentFlyout();

	char szCurrentButton[ 32 ];
	Q_strncpy( szCurrentButton, MULTIPLAYER_SPRAYPAINT_COMMAND_PREFIX, sizeof( szCurrentButton ) );

	int iCommandNumberPosition = Q_strlen( szCurrentButton );
	szCurrentButton[ iCommandNumberPosition + 1 ] = '\0';

	// Find our logos
	int initialItem = 0;

	CGameUIConVarRef cl_logofile( "cl_logofile", true );
	if ( !cl_logofile.IsValid() )
		return;

	const char *logofile = cl_logofile.GetString();

	m_nNumSpraypaintLogos = 0;

	KeyValues *pSpraysManifest = new KeyValues( "sprays_manifest" );
	KeyValues::AutoDelete autoDelete( pSpraysManifest );

	pSpraysManifest->LoadFromFile( g_pFullFileSystem, "scripts/sprays_manifest.txt", NULL );

	KeyValues *pSprayKey = pSpraysManifest->GetFirstSubKey();

	while ( m_nNumSpraypaintLogos < MAX_SPRAYPAINT_LOGOS - 1 && pSprayKey )
	{
		char filename[ MAX_PATH ];
		Q_snprintf( filename, sizeof(filename), MULTIPLAYER_SPRAY_FOLDER "%s", pSprayKey->GetString() );

		if ( g_pFullFileSystem->FileExists( filename, "GAME" ) )
		{
			Q_SetExtension( filename, ".vmt", sizeof( filename ) );

			if ( g_pFullFileSystem->FileExists( filename, "GAME" ) )
			{
				Q_strncpy( filename, pSprayKey->GetString(), sizeof(filename) );

				Q_StripExtension( filename, m_nSpraypaint[ m_nNumSpraypaintLogos ].m_szFilename, sizeof(m_nSpraypaint[ m_nNumSpraypaintLogos ].m_szFilename) );
				m_nSpraypaint[ m_nNumSpraypaintLogos ].m_bCustom = false;

				szCurrentButton[ iCommandNumberPosition ] = m_nNumSpraypaintLogos + '0';
				SetFlyoutButtonText( szCurrentButton, pFlyout, pSprayKey->GetName() );

				// check to see if this is the one we have set
				Q_snprintf( filename, sizeof(filename), MULTIPLAYER_SPRAY_FOLDER "%s", pSprayKey->GetString() );
				if (!Q_stricmp(filename, logofile))
				{
					initialItem = m_nNumSpraypaintLogos;
				}

				++m_nNumSpraypaintLogos;
			}
		}

		pSprayKey = pSprayKey->GetNextKey();
	}

	// Look for custom sprays
	char directory[ MAX_PATH ];
	Q_strncpy( directory, MULTIPLAYER_SPRAY_FOLDER MULTIPLAYER_CUSTOM_SPRAY_FOLDER "*.vtf", sizeof( directory ) );

	FileFindHandle_t fh;
	const char *fn = g_pFullFileSystem->FindFirst( directory, &fh );

	if ( fn )
	{
		char filename[ MAX_PATH ];
		Q_snprintf( filename, sizeof(filename), MULTIPLAYER_SPRAY_FOLDER MULTIPLAYER_CUSTOM_SPRAY_FOLDER "%s", fn );
		Q_SetExtension( filename, ".vmt", sizeof( filename ) );

		if ( g_pFullFileSystem->FileExists( filename, "GAME" ) )
		{
			// Found at least one custom logo
			szCurrentButton[ iCommandNumberPosition ] = m_nNumSpraypaintLogos + '0';
			SetFlyoutButtonText( szCurrentButton, pFlyout, "#L4D360UI_Multiplayer_Cutsom_Logo" );
			m_nSpraypaint[ m_nNumSpraypaintLogos ].m_szFilename[ 0 ] = '\0';
			m_nSpraypaint[ m_nNumSpraypaintLogos ].m_bCustom = true;

			++m_nNumSpraypaintLogos;

			Q_strncpy( filename, logofile, sizeof(filename) );
			Q_StripFilename( filename );
			Q_strncat( filename, "/", sizeof(filename) );

			// If their current spray is one of the custom ones
			if ( Q_stricmp( filename, MULTIPLAYER_SPRAY_FOLDER MULTIPLAYER_CUSTOM_SPRAY_FOLDER ) == 0 )
			{
				// Check if the file exists
				if ( g_pFullFileSystem->FileExists( logofile, "GAME" ) )
				{
					// Check if it has a matching VMT
					Q_strncpy( filename, logofile, sizeof( filename ) );
					Q_SetExtension( filename, ".vmt", sizeof( filename ) );

					if ( g_pFullFileSystem->FileExists( filename, "GAME" ) )
					{
						// Set this custom logo as our initial item
						const char *pchShortName = Q_UnqualifiedFileName( logofile );

						initialItem = m_nNumSpraypaintLogos - 1;
						Q_StripExtension( pchShortName, m_nSpraypaint[ initialItem ].m_szFilename, sizeof(m_nSpraypaint[ initialItem ].m_szFilename) );
					}
				}
			}
		}
	}

	g_pFullFileSystem->FindClose( fh );

	// Change the height to fit the active items
	pFlyout->SetBGTall( m_nNumSpraypaintLogos * 20 + 5 );

	// Disable the remaining possible choices
	for ( int i = m_nNumSpraypaintLogos; i < MAX_SPRAYPAINT_LOGOS; ++i )
	{
		szCurrentButton[ iCommandNumberPosition ] = i + '0';

		Button *pButton = pFlyout->FindChildButtonByCommand( szCurrentButton );
		if ( pButton )
		{
			pButton->SetVisible( false );
		}
	}

	szCurrentButton[ iCommandNumberPosition ] = initialItem + '0';
	m_drpSpraypaint->SetCurrentSelection( szCurrentButton );
}
Example #11
0
//=============================================================================
void MainMenu::ApplySchemeSettings( IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	int screenWide, screenTall;
	surface()->GetScreenSize( screenWide, screenTall );
	float aspectRatio = (float)screenWide/(float)screenTall;
	bool bIsWidescreen = aspectRatio >= 1.5999f;

	DevMsg("Aspect Ratio: %f\n", aspectRatio);

	const char *pSettings = "Resource/UI/BaseModUI/MainMenu.res";

	if ( bIsWidescreen )
	{
		// use the widescreen version
		pSettings = "Resource/UI/BaseModUI/MainMenu_widescreen.res";
		Msg("Using widescreen scheme scheme file: %s\n", pSettings);
	}
	else
	{
		DevMsg("Using non-widescreen scheme file: %s\n", pSettings);
	}

	LoadControlSettings( pSettings );

/*	BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnPlaySolo" ) );
	if ( button )
	{

	}*/

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			bool bUsesCloud = false;

#ifdef IS_WINDOWS_PC
			ISteamRemoteStorage *pRemoteStorage = SteamClient()?(ISteamRemoteStorage *)SteamClient()->GetISteamGenericInterface(
				SteamAPI_GetHSteamUser(), SteamAPI_GetHSteamPipe(), STEAMREMOTESTORAGE_INTERFACE_VERSION ):NULL;
#else
			ISteamRemoteStorage *pRemoteStorage =  NULL; 
			AssertMsg( false, "This branch run on a PC build without IS_WINDOWS_PC defined." );
#endif

			int32 availableBytes, totalBytes = 0;
			if ( pRemoteStorage && pRemoteStorage->GetQuota( &totalBytes, &availableBytes ) )
			{
				if ( totalBytes > 0 )
				{
					bUsesCloud = true;
				}
			}

			pFlyout->SetControlEnabled( "BtnCloud", bUsesCloud );
		}
	}

	SetFooterState();

	if ( IsPC() )
	{
		vgui::Panel *firstPanel = FindChildByName( "BtnCoOp" );
		if ( firstPanel )
		{
			if ( m_ActiveControl )
			{
				m_ActiveControl->NavigateFrom( );
			}
			firstPanel->NavigateTo();
		}
	}
}
Example #12
0
//=============================================================================
void Audio::Activate()
{
	BaseClass::Activate();

	if ( m_sldGameVolume )
	{
		m_sldGameVolume->Reset();
	}

	if ( m_sldMusicVolume )
	{
		m_sldMusicVolume->Reset();
	}

	if ( m_sldVoiceThreshold )
	{
		m_sldVoiceThreshold->Reset();
	}

	if ( m_drpSpeakerConfiguration )
	{
		CGameUIConVarRef snd_surround_speakers("Snd_Surround_Speakers");

		switch ( snd_surround_speakers.GetInt() )
		{
		case 2:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_2Speakers" );
			break;
		case 4:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_4Speakers" );
			break;
		case 5:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_5Speakers" );
			break;
		case 0:
		default:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_Headphones" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpSpeakerConfiguration->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpSoundQuality )
	{
		CGameUIConVarRef Snd_PitchQuality("Snd_PitchQuality");
		CGameUIConVarRef dsp_slow_cpu("dsp_slow_cpu");

		int quality = 0;
		if ( dsp_slow_cpu.GetBool() == false )
		{
			quality = 1;
		}
		if ( Snd_PitchQuality.GetBool() )
		{
			quality = 2;
		}

		switch ( quality )
		{
		case 1:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_Medium" );
			break;
		case 2:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_High" );
			break;
		case 0:
		default:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_Low" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpSoundQuality->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpCaptioning )
	{
		CGameUIConVarRef closecaption("closecaption");
		CGameUIConVarRef cc_subtitles("cc_subtitles");

		if ( !closecaption.GetBool() )
		{
			m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOff" );
		}
		else
		{
			if ( cc_subtitles.GetBool() )
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionSubtitles" );
			}
			else
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOn" );
			}
		}

		FlyoutMenu *pFlyout = m_drpCaptioning->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpLanguage )
	{
		char szCurrentLanguage[50] = "";
		char szAvailableLanguages[512] = "";
		szAvailableLanguages[0] = '\0';

		// Fallback to current engine language
		engine->GetUILanguage( szCurrentLanguage, sizeof( szCurrentLanguage ));

		// In a Steam environment we get the current language 
#if !defined( NO_STEAM )
		// When Steam isn't running we can't get the language info... 
		if ( steamapicontext->SteamApps() )
		{
			Q_strncpy( szCurrentLanguage, steamapicontext->SteamApps()->GetCurrentGameLanguage(), sizeof(szCurrentLanguage) );
			Q_strncpy( szAvailableLanguages, steamapicontext->SteamApps()->GetAvailableGameLanguages(), sizeof(szAvailableLanguages) );
		}
#endif

		// Get the spoken language and store it for comparison purposes
		m_nCurrentAudioLanguage = PchLanguageToELanguage( szCurrentLanguage );

		// Set up the base string for each button command
		char szCurrentButton[ 32 ];
		Q_strncpy( szCurrentButton, VIDEO_LANGUAGE_COMMAND_PREFIX, sizeof( szCurrentButton ) );

		int iCommandNumberPosition = Q_strlen( szCurrentButton );
		szCurrentButton[ iCommandNumberPosition + 1 ] = '\0';

		// Check to see if we have a list of languages from Steam
		if ( szAvailableLanguages[0] != '\0' )
		{
			int iSelectedLanguage = 0;

			FlyoutMenu *pLanguageFlyout = m_drpLanguage->GetCurrentFlyout();

			// Loop through all the languages
			CSplitString languagesList( szAvailableLanguages, "," );

			for ( m_nNumAudioLanguages = 0; m_nNumAudioLanguages < languagesList.Count() && m_nNumAudioLanguages < MAX_DYNAMIC_AUDIO_LANGUAGES; ++m_nNumAudioLanguages )
			{
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAudioLanguages + '0';
				m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode = PchLanguageToELanguage( languagesList[ m_nNumAudioLanguages ] );

				SetFlyoutButtonText( szCurrentButton, pLanguageFlyout, GetLanguageVGUILocalization( m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode ) );

				if ( m_nCurrentAudioLanguage == m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode )
				{
					iSelectedLanguage = m_nNumAudioLanguages;
				}
			}

			// Change the height to fit the active items
			pLanguageFlyout->SetBGTall( m_nNumAudioLanguages * 20 + 5 );

			// Disable the remaining possible choices
			for ( int i = m_nNumAudioLanguages; i < MAX_DYNAMIC_AUDIO_LANGUAGES; ++i )
			{
				szCurrentButton[ iCommandNumberPosition ] = i + '0';

				Button *pButton = pLanguageFlyout->FindChildButtonByCommand( szCurrentButton );
				if ( pButton )
				{
					pButton->SetVisible( false );
				}
			}

			// Set the current selection
			szCurrentButton[ iCommandNumberPosition ] = iSelectedLanguage + '0';

			m_drpLanguage->SetCurrentSelection( szCurrentButton );

			m_nSelectedAudioLanguage = m_nAudioLanguages[ iSelectedLanguage ].languageCode;
		}

		m_drpLanguage->SetVisible( m_nNumAudioLanguages > 1 );
	}

	if ( !m_pVoiceTweak )
	{
		SetControlVisible( "DrpVoiceCommunication", false );
		SetControlVisible( "SldVoiceTransmitVolume", false );
		SetControlVisible( "SldVoiceReceiveVolume", false );
		SetControlVisible( "DrpBoostMicrophone", false );
		SetControlVisible( "BtnTestMicrophone", false );
		SetControlVisible( "MicMeter", false );
		SetControlVisible( "MicMeter2", false );
	}
	else
	{
		CGameUIConVarRef voice_modenable("voice_modenable");
		CGameUIConVarRef voice_enable("voice_enable");

		bool bVoiceEnabled = voice_enable.GetBool() && voice_modenable.GetBool();

		if ( m_drpVoiceCommunication )
		{
			if ( bVoiceEnabled )
			{
				m_drpVoiceCommunication->SetCurrentSelection( "#L4D360UI_Enabled" );
			}
			else
			{
				m_drpVoiceCommunication->SetCurrentSelection( "#L4D360UI_Disabled" );
			}

			FlyoutMenu *pFlyout = m_drpVoiceCommunication->GetCurrentFlyout();
			if ( pFlyout )
			{
				pFlyout->SetListener( this );
			}
		}

		CGameUIConVarRef voice_vox("voice_vox");

		if ( m_drpVoiceCommunicationStyle )
		{
			m_drpVoiceCommunicationStyle->SetEnabled( bVoiceEnabled );

			if ( voice_vox.GetBool() )
			{
				m_drpVoiceCommunicationStyle->SetCurrentSelection( "#L4D360UI_OpenMic" );
				SetControlEnabled( "SldVoiceVoxThreshold", bVoiceEnabled );
			}
			else
			{
				m_drpVoiceCommunicationStyle->SetCurrentSelection( "#L4D360UI_PushToTalk" );
				SetControlEnabled( "SldVoiceVoxThreshold", false );
			}

			FlyoutMenu *pFlyout = m_drpVoiceCommunicationStyle->GetCurrentFlyout();
			if ( pFlyout )
			{
				pFlyout->SetListener( this );
			}
		}

		if ( m_sldTransmitVolume )
		{
			bool bMicVolumeFound = m_pVoiceTweak->IsControlFound( MicrophoneVolume );
			float micVolume = m_pVoiceTweak->GetControlFloat( MicrophoneVolume );
			m_sldTransmitVolume->SetCurrentValue( (int)( 100.0f * micVolume ) );
			m_sldTransmitVolume->ResetSliderPosAndDefaultMarkers();
			m_sldTransmitVolume->SetEnabled( bVoiceEnabled && bMicVolumeFound );
		}

		if ( m_sldRecieveVolume )
		{
			float flRecVolume = m_pVoiceTweak->GetControlFloat( OtherSpeakerScale );
			m_sldRecieveVolume->Reset();
			m_sldRecieveVolume->SetCurrentValue( flRecVolume );
			m_sldRecieveVolume->SetEnabled( bVoiceEnabled );
		}

		if ( m_drpBoostMicrophoneGain )
		{
			float fMicBoost = m_pVoiceTweak->GetControlFloat( MicBoost );

			if ( fMicBoost != 0.0f )
			{
				m_drpBoostMicrophoneGain->SetCurrentSelection( "#L4D360UI_Enabled" );
			}
			else
			{
				m_drpBoostMicrophoneGain->SetCurrentSelection( "#L4D360UI_Disabled" );
			}

			m_drpBoostMicrophoneGain->SetEnabled( bVoiceEnabled );

			FlyoutMenu *pFlyout = m_drpBoostMicrophoneGain->GetCurrentFlyout();
			if ( pFlyout )
			{
				pFlyout->SetListener( this );
			}
		}

		if ( m_pMicMeter )
		{
			m_pMicMeter->SetVisible( bVoiceEnabled );
		}

		if ( m_pMicMeter2 )
		{
			m_pMicMeter2->SetVisible( false );
		}

		if ( m_pMicMeterIndicator )
		{
			m_pMicMeterIndicator->SetVisible( false );
		}
	}

	UpdateFooter( true );

	if ( m_sldGameVolume )
	{
		if ( m_ActiveControl )
			m_ActiveControl->NavigateFrom( );
		m_sldGameVolume->NavigateTo();
		m_ActiveControl = m_sldGameVolume;
	}
}
Example #13
0
void InGameMainMenu::OnThink()
{
	int iSlot = GetGameUIActiveSplitScreenPlayerSlot();

	GAMEUI_ACTIVE_SPLITSCREEN_PLAYER_GUARD( iSlot );

	{
		BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnOptions" ) );
		if ( button )
		{
			BaseModUI::FlyoutMenu *flyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );

			if ( flyout )
			{
#ifdef _X360
				bool bIsSplitscreen = ( XBX_GetNumGameUsers() > 1 );
#else
				bool bIsSplitscreen = false;
#endif

				Button *pButton = flyout->FindChildButtonByCommand( "EnableSplitscreen" );
				if ( pButton )
				{
					pButton->SetVisible( !bIsSplitscreen );
				}

				pButton = flyout->FindChildButtonByCommand( "DisableSplitscreen" );
				if ( pButton )
				{
					pButton->SetVisible( bIsSplitscreen );
				}
			}
		}
	}

	if ( IsPC() )
	{
		FlyoutMenu *pFlyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) );
		if ( pFlyout )
		{
			const MaterialSystem_Config_t &config = materials->GetCurrentConfigForVideoCard();
			pFlyout->SetControlEnabled( "BtnBrightness", !config.Windowed() );
		}
	}

	BaseClass::OnThink();

	if ( IsVisible() )
	{
		// Yield to generic wait screen or message box if one of those is present
		WINDOW_TYPE arrYield[] = { WT_GENERICWAITSCREEN, WT_GENERICCONFIRMATION };
		for ( int j = 0; j < ARRAYSIZE( arrYield ); ++ j )
		{
			CBaseModFrame *pYield = CBaseModPanel::GetSingleton().GetWindow( arrYield[j] );
			if ( pYield && pYield->IsVisible() && !pYield->HasFocus() )
			{
				pYield->Activate();
				pYield->RequestFocus();
			}
		}
	}
}
Example #14
0
// 0 = Deprecated CA buttons
// 1 = Normal Button
// 2 = MainMenu Button or InGameMenu Butto
// 3 = Flyout button
void BaseModHybridButton::PaintButtonEx()
{
	vgui::IScheme *pScheme = vgui::scheme()->GetIScheme( GetScheme() );
	Color blotchColor = pScheme->GetColor( "HybridButton.BlotchColor", Color( 0, 0, 0, 255 ) );
	Color borderColor = pScheme->GetColor( "HybridButton.BorderColor", Color( 0, 0, 0, 255 ) );

	int x, y;
	int wide, tall;
	GetSize( wide, tall );

	x = 0;

	// due to vertical resizing, center within the control
	y = ( tall - m_originalTall ) / 2;
	tall = m_originalTall;

	if ( m_nStyle == BUTTON_GAMEMODE )
	{
		y = 0;
	}

	if ( ( m_nStyle == BUTTON_DROPDOWN || m_nStyle == BUTTON_GAMEMODE ) && GetCurrentState() == Open && m_nWideAtOpen )
	{
		wide = m_nWideAtOpen;
	}

	bool bAnimateGlow = false;
	bool bDrawGlow = false;
	bool bDrawCursor = false;
	bool bDrawText = true;
	Color col;
	State curState = GetCurrentState();
	switch ( curState )
	{
		case Enabled:
			// selectable, just not highlighted
			if ( m_nStyle == BUTTON_RED || m_nStyle == BUTTON_REDMAIN )
			{
				//col.SetColor( 0, 128, 128, 255 );
				col.SetColor( 169, 213, 255, 255 );
			}
			else if ( m_nStyle == BUTTON_ALIENSWARMMENUBUTTON || m_nStyle == BUTTON_ALIENSWARMMENUBUTTONSMALL )
			{
				col.SetColor( 135, 170, 193, 255 );
			}
			else
			{
				//col.SetColor( 125, 125, 125, 255 );
				col.SetColor( 83, 148, 192, 255 );
			}
			break;
		case Disabled:
			//col.SetColor( 88, 97, 104, 255 );
			//col.SetColor( 65, 74, 96, 255 );
			col.SetColor( 32, 59, 82, 255 );
			bDrawText = true;
			bDrawGlow = false;
			break;
		case FocusDisabled:
			col.SetColor( 182, 189, 194, 255 );
			bDrawText = false;
			bDrawGlow = true;
			break;
		case Open:
			// flyout menu is attached
			//col.SetColor( 200, 200, 200, 255 );
			col.SetColor( 169, 213, 255, 255 );
			bDrawGlow = true;
			bDrawCursor = true;
			break;
		case Focus:
			// active item
			col.SetColor( 255, 255, 255, 255 );
			bDrawGlow = true;
			bAnimateGlow = true;
			if ( m_nStyle == BUTTON_SIMPLE ||
				 m_nStyle == BUTTON_DROPDOWN ||
				 m_nStyle == BUTTON_DIALOG ||
				 m_nStyle == BUTTON_RED )
			{
				bDrawCursor = true;
			}
			break;
	}

	wchar_t szUnicode[512];
	GetText( szUnicode, sizeof( szUnicode ) );
	int len = V_wcslen( szUnicode );

	int textWide, textTall;
	surface()->GetTextSize( m_hTextFont, szUnicode, textWide, textTall );

	textWide = clamp( textWide, 0, wide - m_textInsetX * 2 );
	textTall = clamp( textTall, 0, tall - m_textInsetX * 2 );

	int textInsetX = m_textInsetX;
	if ( m_nStyle == BUTTON_DIALOG )
	{
		// dialog buttons are centered
		textInsetX = ( wide - textWide ) / 2;
	}

	if ( FlyoutMenu::GetActiveMenu() && FlyoutMenu::GetActiveMenu()->GetNavFrom() != this )
	{
		bDrawCursor = false;
	}

	if ( bDrawCursor )
	{
		// draw backing rectangle
		if ( curState == Open )
		{
			surface()->DrawSetColor( Color( 0, 0, 0, 255 ) );
			surface()->DrawFilledRectFade( x, y, x+wide, y+tall, 0, 255, true );
		}

		// draw blotch
		surface()->DrawSetColor( blotchColor );
		if ( m_nStyle == BUTTON_DIALOG )
		{
			int blotchWide = textWide;
			int blotchX = x + textInsetX;
			surface()->DrawFilledRectFade( blotchX, y, blotchX + 0.50f * blotchWide, y+tall, 0, 150, true );
			surface()->DrawFilledRectFade( blotchX + 0.50f * blotchWide, y, blotchX + blotchWide, y+tall, 150, 0, true );
		}
		else
		{
			int blotchWide = textWide + vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), 40 );
			int blotchX = x + textInsetX;
			surface()->DrawFilledRectFade( blotchX, y, blotchX + 0.25f * blotchWide, y+tall, 0, 150, true );
			surface()->DrawFilledRectFade( blotchX + 0.25f * blotchWide, y, blotchX + blotchWide, y+tall, 150, 0, true );
		}

		// draw border lines
		surface()->DrawSetColor( borderColor );
		if ( curState == Open )
		{
			FlyoutMenu *pActiveFlyout = FlyoutMenu::GetActiveMenu();
			BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( pActiveFlyout ? pActiveFlyout->GetNavFrom() : NULL );
			if ( pActiveFlyout && pActiveFlyout->GetOriginalTall() == 0 && button && button == this )
			{
				surface()->DrawFilledRectFade( x, y, x + wide, y+2, 255, 0, true );
			}
			else
			{
				// the border lines end at the beginning of the flyout
				// the flyout will draw to complete the look
				surface()->DrawFilledRectFade( x, y, x + wide, y+2, 0, 255, true );
				surface()->DrawFilledRectFade( x, y+tall-2, x + wide, y+tall, 0, 255, true );
			}
		}
		else
		{
			// top and bottom border lines
			surface()->DrawFilledRectFade( x, y, x + 0.5f * wide, y+2, 0, 255, true );
			surface()->DrawFilledRectFade( x + 0.5f * wide, y, x + wide, y+2, 255, 0, true );
			surface()->DrawFilledRectFade( x, y+tall-2, x + 0.5f * wide, y+tall, 0, 255, true );
			surface()->DrawFilledRectFade( x + 0.5f * wide, y+tall-2, x + wide, y+tall, 255, 0, true );
		}
	}

	// assume drawn, unless otherwise shortened with ellipsis
	int iLabelCharsDrawn = len;

	// draw the text
	if ( bDrawText )
	{
		int availableWidth = GetWide() - x - textInsetX;

		if ( m_bShowDropDownIndicator )
		{
			int textTall = vgui::surface()->GetFontTall( m_hTextFont );
			int textLen = 0;

			int len = wcslen( szUnicode );
			for ( int i=0;i<len;i++ )
			{
				textLen += vgui::surface()->GetCharacterWidth( m_hTextFont, szUnicode[i] );
			}

			int imageX = x + textInsetX + textLen + m_iSelectedArrowSize / 2;
			int imageY = y + ( textTall - m_iSelectedArrowSize ) / 2;

			if ( ( imageX + m_iSelectedArrowSize ) > GetWide() )
			{
				imageX = GetWide() - m_iSelectedArrowSize;
			}

			if ( curState == Open || m_bOverrideDropDownIndicator )
			{
				vgui::surface()->DrawSetTexture( m_iSelectedArrow );
			}
			else
			{
				vgui::surface()->DrawSetTexture( m_iUnselectedArrow );
			}

			vgui::surface()->DrawSetColor( col );
			vgui::surface()->DrawTexturedRect( imageX, imageY, imageX + m_iSelectedArrowSize, imageY + m_iSelectedArrowSize );
			vgui::surface()->DrawSetTexture( 0 );

			availableWidth -= m_iSelectedArrowSize * 2;
		}

		vgui::surface()->DrawSetTextFont( m_hTextFont );
		vgui::surface()->DrawSetTextPos( x + textInsetX, y + m_textInsetY  );
		vgui::surface()->DrawSetTextColor( col );

		if ( textWide > availableWidth )
		{
			// length of 3 dots
			int ellipsesLen = 3 * vgui::surface()->GetCharacterWidth( m_hTextFont, L'.' );

			availableWidth -= ellipsesLen;

			iLabelCharsDrawn = 0;
			int charX = x + textInsetX;
			for ( int i=0; i < len; i++ )
			{
				vgui::surface()->DrawUnicodeChar( szUnicode[i] );
				iLabelCharsDrawn++;

				charX += vgui::surface()->GetCharacterWidth( m_hTextFont, szUnicode[i] );
				if ( charX >= ( x + textInsetX + availableWidth ) )
					break;
			}
			
			vgui::surface()->DrawPrintText( L"...", 3 );
		}
		else
		{
			vgui::surface()->DrawUnicodeString( szUnicode );
		}
	}
	else if ( GetCurrentState() == Disabled || GetCurrentState() == FocusDisabled )
	{
		Color textcol = col;
		textcol[ 3 ] = 64;

		vgui::surface()->DrawSetTextFont( m_hTextFont );
		vgui::surface()->DrawSetTextPos( x + textInsetX, y + m_textInsetY  );
		vgui::surface()->DrawSetTextColor( textcol );
		vgui::surface()->DrawPrintText( szUnicode, len );
	}

	// draw the help text
	if ( m_nStyle == BUTTON_GAMEMODE && curState != Open )
	{
		const char *pHelpText = GetHelpText( IsEnabled() );
		wchar_t szHelpUnicode[512];
		wchar_t *pUnicodeString;
		if ( pHelpText && pHelpText[0] == '#' )
		{
			pUnicodeString = g_pVGuiLocalize->Find( pHelpText );
		}
		else
		{
			g_pVGuiLocalize->ConvertANSIToUnicode( pHelpText, szHelpUnicode, sizeof( szHelpUnicode ) );
			pUnicodeString = szHelpUnicode;
		}	
		vgui::surface()->DrawSetTextFont( m_hHintTextFont );
		vgui::surface()->DrawSetTextPos( x + textInsetX, y + m_textInsetY + m_nTextFontHeight );
		vgui::surface()->DrawSetTextColor( col );
		vgui::surface()->DrawPrintText( pUnicodeString, wcslen( pUnicodeString ) );
	}

	// draw the pulsing glow
	if ( bDrawGlow )
	{
		if ( !bDrawText )
		{
			vgui::surface()->DrawSetTextColor( col );
		}
		else
		{
			int alpha = bAnimateGlow ? 60.0f + 30.0f * sin( Plat_FloatTime() * 4.0f ) : 30;
			Color glowColor( 255, 255, 255, alpha );
			vgui::surface()->DrawSetTextColor( glowColor );
		}
		vgui::surface()->DrawSetTextFont( m_hTextBlurFont );
		vgui::surface()->DrawSetTextPos( x + textInsetX, y + m_textInsetY );

		for ( int i=0; i<len && i < iLabelCharsDrawn; i++ )
		{
			vgui::surface()->DrawUnicodeChar( szUnicode[i] );
		}
	}

	if ( m_nStyle == BUTTON_DROPDOWN && curState != Open )
	{
		// draw right justified item
		wchar_t *pUnicodeString = g_pVGuiLocalize->Find( m_DropDownSelection.String() );
		if ( !pUnicodeString )
		{
			g_pVGuiLocalize->ConvertANSIToUnicode( m_DropDownSelection.String(), szUnicode, sizeof( szUnicode ) );
			pUnicodeString = szUnicode;
		}
		int len = V_wcslen( pUnicodeString );

		int textWide, textTall;
		surface()->GetTextSize( m_hSelectionFont, pUnicodeString, textWide, textTall );

		// horizontal right justify
		int xx = wide - textWide - textInsetX;
		// vertical center within
		int yy = ( tall - textTall )/2;

		// draw the drop down selection text
		vgui::surface()->DrawSetTextFont( m_hSelectionFont );
		vgui::surface()->DrawSetTextPos( xx, yy );
		vgui::surface()->DrawSetTextColor( col );
		vgui::surface()->DrawPrintText( pUnicodeString, len );

		if ( bDrawGlow )
		{
			int alpha = bAnimateGlow ? 60.0f + 30.0f * sin( Plat_FloatTime() * 4.0f ) : 30;
			vgui::surface()->DrawSetTextColor( Color( 255, 255, 255, alpha ) );
			vgui::surface()->DrawSetTextFont( m_hSelectionBlurFont );
			vgui::surface()->DrawSetTextPos( xx, yy );
			vgui::surface()->DrawPrintText( pUnicodeString, len );
		}
	}
}
Example #15
0
//=============================================================================
void Audio::Activate()
{
	BaseClass::Activate();

	if ( m_sldGameVolume )
	{
		m_sldGameVolume->Reset();
	}

	if ( m_sldMusicVolume )
	{
		m_sldMusicVolume->Reset();
	}

	if ( m_drpSpeakerConfiguration )
	{
		CGameUIConVarRef snd_surround_speakers("Snd_Surround_Speakers");

		switch ( snd_surround_speakers.GetInt() )
		{
		case 2:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_2Speakers" );
			break;
		case 4:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_4Speakers" );
			break;
		case 5:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_5Speakers" );
			break;
		case 0:
		default:
			m_drpSpeakerConfiguration->SetCurrentSelection( "#GameUI_Headphones" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpSpeakerConfiguration->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpSoundQuality )
	{
		CGameUIConVarRef Snd_PitchQuality("Snd_PitchQuality");
		CGameUIConVarRef dsp_slow_cpu("dsp_slow_cpu");

		int quality = 0;
		if ( dsp_slow_cpu.GetBool() == false )
		{
			quality = 1;
		}
		if ( Snd_PitchQuality.GetBool() )
		{
			quality = 2;
		}

		switch ( quality )
		{
		case 1:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_Medium" );
			break;
		case 2:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_High" );
			break;
		case 0:
		default:
			m_drpSoundQuality->SetCurrentSelection( "#GameUI_Low" );
			break;
		}

		FlyoutMenu *pFlyout = m_drpSoundQuality->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpCaptioning )
	{
		CGameUIConVarRef closecaption("closecaption");
		CGameUIConVarRef cc_subtitles("cc_subtitles");

		if ( !closecaption.GetBool() )
		{
			m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOff" );
		}
		else
		{
			if ( cc_subtitles.GetBool() )
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionSubtitles" );
			}
			else
			{
				m_drpCaptioning->SetCurrentSelection( "#L4D360UI_AudioOptions_CaptionOn" );
			}
		}

		FlyoutMenu *pFlyout = m_drpCaptioning->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpLanguage )
	{
		char szCurrentLanguage[50] = "";
		char szAvailableLanguages[512] = "";
		szAvailableLanguages[0] = '\0';

		// Fallback to current engine language
		engine->GetUILanguage( szCurrentLanguage, sizeof( szCurrentLanguage ));

		// In a Steam environment we get the current language 
#if !defined( NO_STEAM )
		// When Steam isn't running we can't get the language info... 
		if ( steamapicontext->SteamApps() )
		{
			Q_strncpy( szCurrentLanguage, steamapicontext->SteamApps()->GetCurrentGameLanguage(), sizeof(szCurrentLanguage) );
			Q_strncpy( szAvailableLanguages, steamapicontext->SteamApps()->GetAvailableGameLanguages(), sizeof(szAvailableLanguages) );
		}
#endif

		// Get the spoken language and store it for comparison purposes
		m_nCurrentAudioLanguage = PchLanguageToELanguage( szCurrentLanguage );

		// Set up the base string for each button command
		char szCurrentButton[ 32 ];
		Q_strncpy( szCurrentButton, VIDEO_LANGUAGE_COMMAND_PREFIX, sizeof( szCurrentButton ) );

		int iCommandNumberPosition = Q_strlen( szCurrentButton );
		szCurrentButton[ iCommandNumberPosition + 1 ] = '\0';

		// Check to see if we have a list of languages from Steam
		if ( szAvailableLanguages[0] != '\0' )
		{
			int iSelectedLanguage = 0;

			FlyoutMenu *pLanguageFlyout = m_drpLanguage->GetCurrentFlyout();

			// Loop through all the languages
			CSplitString languagesList( szAvailableLanguages, "," );

			for ( m_nNumAudioLanguages = 0; m_nNumAudioLanguages < languagesList.Count() && m_nNumAudioLanguages < MAX_DYNAMIC_AUDIO_LANGUAGES; ++m_nNumAudioLanguages )
			{
				szCurrentButton[ iCommandNumberPosition ] = m_nNumAudioLanguages + '0';
				m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode = PchLanguageToELanguage( languagesList[ m_nNumAudioLanguages ] );

				SetFlyoutButtonText( szCurrentButton, pLanguageFlyout, GetLanguageVGUILocalization( m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode ) );

				if ( m_nCurrentAudioLanguage == m_nAudioLanguages[ m_nNumAudioLanguages ].languageCode )
				{
					iSelectedLanguage = m_nNumAudioLanguages;
				}
			}

			// Change the height to fit the active items
			pLanguageFlyout->SetBGTall( m_nNumAudioLanguages * 20 + 5 );

			// Disable the remaining possible choices
			for ( int i = m_nNumAudioLanguages; i < MAX_DYNAMIC_AUDIO_LANGUAGES; ++i )
			{
				szCurrentButton[ iCommandNumberPosition ] = i + '0';

				Button *pButton = pLanguageFlyout->FindChildButtonByCommand( szCurrentButton );
				if ( pButton )
				{
					pButton->SetVisible( false );
				}
			}

			// Set the current selection
			szCurrentButton[ iCommandNumberPosition ] = iSelectedLanguage + '0';

			m_drpLanguage->SetCurrentSelection( szCurrentButton );

			m_nSelectedAudioLanguage = m_nAudioLanguages[ iSelectedLanguage ].languageCode;
		}

		m_drpLanguage->SetVisible( m_nNumAudioLanguages > 1 );
	}



	UpdateFooter( true );

	if ( m_sldGameVolume )
	{
		if ( m_ActiveControl )
			m_ActiveControl->NavigateFrom( );
		m_sldGameVolume->NavigateTo();
		m_ActiveControl = m_sldGameVolume;
	}
}
//=============================================================================
void ControllerOptions::ResetControlValues( void )
{
    // labels for button config and stick config
    CGameUIConVarRef joy_cfg_preset( "joy_cfg_preset" );
    int iButtonSetting = clamp( joy_cfg_preset.GetInt(), 0, 3 );
    if ( m_pEditButtons )
    {
        m_pEditButtons->SetDropdownSelection( pszButtonSettingsDisplayName[iButtonSetting] );
    }

    CGameUIConVarRef joy_movement_stick("joy_movement_stick");
    int iStickSetting = ( joy_movement_stick.GetInt() > 0 ) ? 1 : 0;
    if ( m_pEditSticks )
    {
        static CGameUIConVarRef s_joy_legacy( "joy_legacy" );
        if ( s_joy_legacy.IsValid() && s_joy_legacy.GetBool() )
        {
            iStickSetting += 2; // Go to the legacy version of the default/southpaw string.
        }

        m_pEditSticks->SetDropdownSelection( pszStickSettingsDisplayName[iStickSetting] );
    }

    if( m_pVerticalSensitivity )
    {
        m_pVerticalSensitivity->Reset();
    }

    if( m_pHorizontalSensitivity )
    {
        m_pHorizontalSensitivity->Reset();
    }

    if( m_pLookType )
    {
        m_pLookType->SetFlyout( "FlmLookType" );

        CGameUIConVarRef joy_inverty("joy_inverty");

        int iInvert = ( joy_inverty.GetInt() > 0 ) ? CONTROLLER_LOOK_TYPE_INVERTED : CONTROLLER_LOOK_TYPE_NORMAL;
        m_pLookType->SetCurrentSelection( pszLookTypes[iInvert] );

        FlyoutMenu *pFlyout = m_pLookType->GetCurrentFlyout();
        if ( pFlyout )
        {
            pFlyout->SetListener( this );
        }
    }

    if( m_pDuckMode )
    {
        m_pDuckMode->SetFlyout( "FlmDuckMode" );

        CGameUIConVarRef option_duck_method("option_duck_method");

        int iDuckMode = ( option_duck_method.GetInt() > 0 ) ? DUCK_MODE_TOGGLE : DUCK_MODE_HOLD;
        m_pDuckMode->SetCurrentSelection( pszDuckModes[iDuckMode] );

        FlyoutMenu *pFlyout = m_pDuckMode->GetCurrentFlyout();
        if ( pFlyout )
        {
            pFlyout->SetListener( this );
        }
    }
}
//=============================================================================
void InGameChapterSelect::OnCommand(const char *command)
{
	if ( const char* szMissionItem = StringAfterPrefix( command, "cmd_campaign_" ) )
	{
		if ( !Q_stricmp( szMissionItem, m_chCampaign ) )
			return;	// Setting to same mission

		Q_strncpy( m_chCampaign, szMissionItem, ARRAYSIZE( m_chCampaign ) );

		// Determine current game settings
		KeyValues *pGameSettings = g_pMatchFramework->GetMatchNetworkMsgController()->GetActiveServerGameDetails( NULL );
		KeyValues::AutoDelete autodelete_pGameSettings( pGameSettings );
		if ( !pGameSettings )
			return;

		DropDownMenu *pMissionDropDown = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpMission" ) );
		if( pMissionDropDown ) //we should become a listener for events pertaining to the mission flyout
		{
			FlyoutMenu* missionFlyout = pMissionDropDown->GetCurrentFlyout();
			if( missionFlyout )
			{
				missionFlyout->SetListener( this );
				if ( vgui::Button *pAddonBtn = missionFlyout->FindChildButtonByCommand( "cmd_addoncampaign" ) )
				{
					pAddonBtn->SetEnabled( false );
				}

				// Disable all other campaigns that cannot be used for a vote
				for ( int k = 0, kNum = missionFlyout->GetChildCount(); k < kNum; ++ k )
				{
					Panel *child = missionFlyout->GetChild( k );
					if ( BaseModHybridButton* button = dynamic_cast< BaseModHybridButton* >( child ) )
					{
						if ( const char* commandValue = button->GetCommand()->GetString( "command", NULL ) )
						{
							if ( char const *szMissionName = StringAfterPrefix( commandValue, "cmd_campaign_" ) )
							{
								pGameSettings->SetString( "game/campaign", szMissionName );
								pGameSettings->SetInt( "game/chapter", 1 );
								if ( !g_pMatchExtSwarm->GetMapInfo( pGameSettings ) )
								{
									button->SetEnabled( false );
								}
							}
						}
					}
				}
			}
		}

	}
	else if ( char const *szChapterSelected = StringAfterPrefix( command, "#L4D360UI_Chapter_" ) )
	{
		m_nChapter = atoi( szChapterSelected );
		UpdateChapterImage( m_chCampaign, m_nChapter );
	}
	else if ( !Q_stricmp( command, "Select" ) )
	{
		KeyValues *pGameSettings = g_pMatchFramework->GetMatchNetworkMsgController()->GetActiveServerGameDetails( NULL );
		KeyValues::AutoDelete autodelete_pGameSettings( pGameSettings );

		if ( !GameModeIsSingleChapter( pGameSettings->GetString( "game/mode" ) ) )
			m_nChapter = 1;

		pGameSettings->SetString( "game/campaign", m_chCampaign );
		pGameSettings->SetInt( "game/chapter", m_nChapter );

		char const *szVoteCommand = "ChangeChapter";

		int iUser = GetGameUIActiveSplitScreenPlayerSlot();
		GAMEUI_ACTIVE_SPLITSCREEN_PLAYER_GUARD( iUser );

		Panel *pDrpChapter = FindChildByName( "DrpChapter" );
		if ( !pDrpChapter || !pDrpChapter->IsEnabled() )
		{
			szVoteCommand = "ChangeMission";
			m_nChapter = 1;

			engine->ClientCmd( CFmtStr( "callvote %s %s;", szVoteCommand, m_chCampaign ) );
		}
		else if ( KeyValues *pInfoMap = g_pMatchExtSwarm->GetMapInfo( pGameSettings ) )
		{
			engine->ClientCmd( CFmtStr( "callvote %s %s;", szVoteCommand, pInfoMap->GetString( "map" ) ) );
		}

		GameUI().AllowEngineHideGameUI();
		engine->ClientCmd( "gameui_hide" );
		Close();
	}	
	else if ( !Q_strcmp( command, "Cancel" ) )
	{
		GameUI().AllowEngineHideGameUI();
		engine->ClientCmd("gameui_hide");
		Close();
	}
}
Example #18
0
//=============================================================================
void KeyboardMouse::Activate()
{
	BaseClass::Activate();

	if ( m_drpMouseYInvert )
	{
		CGameUIConVarRef m_pitch("m_pitch");

		if ( m_pitch.GetFloat() > 0.0f )
		{
			m_drpMouseYInvert->SetCurrentSelection( "MouseYInvertDisabled" );
		}
		else
		{
			m_drpMouseYInvert->SetCurrentSelection( "MouseYInvertEnabled" );
		}

		FlyoutMenu *pFlyout = m_drpMouseYInvert->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpMouseFilter )
	{
		CGameUIConVarRef m_filter("m_filter");

		if ( !m_filter.GetBool() )
		{
			m_drpMouseFilter->SetCurrentSelection( "MouseFilterDisabled" );
		}
		else
		{
			m_drpMouseFilter->SetCurrentSelection( "MouseFilterEnabled" );
		}

		FlyoutMenu *pFlyout = m_drpMouseFilter->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_sldMouseSensitivity )
	{
		m_sldMouseSensitivity->Reset();
	}

	if ( m_drpDeveloperConsole )
	{
		CGameUIConVarRef con_enable("con_enable");

		if ( !con_enable.GetBool() )
		{
			m_drpDeveloperConsole->SetCurrentSelection( "DeveloperConsoleDisabled" );
		}
		else
		{
			m_drpDeveloperConsole->SetCurrentSelection( "DeveloperConsoleEnabled" );
		}

		FlyoutMenu *pFlyout = m_drpDeveloperConsole->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	CGameUIConVarRef joystick("joystick");

	if ( m_drpGamepadEnable )
	{
		if ( !joystick.GetBool() )
		{
			m_drpGamepadEnable->SetCurrentSelection( "GamepadDisabled" );
		}
		else
		{
			m_drpGamepadEnable->SetCurrentSelection( "GamepadEnabled" );
		}

		FlyoutMenu *pFlyout = m_drpGamepadEnable->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_sldGamepadHSensitivity )
	{
		m_sldGamepadHSensitivity->Reset();

		m_sldGamepadHSensitivity->SetEnabled( joystick.GetBool() );
	}

	if ( m_sldGamepadVSensitivity )
	{
		m_sldGamepadVSensitivity->Reset();

		m_sldGamepadVSensitivity->SetEnabled( joystick.GetBool() );
	}

	if ( m_drpGamepadYInvert )
	{
		CGameUIConVarRef joy_inverty("joy_inverty");

		if ( !joy_inverty.GetBool() )
		{
			m_drpGamepadYInvert->SetCurrentSelection( "GamepadYInvertDisabled" );
		}
		else
		{
			m_drpGamepadYInvert->SetCurrentSelection( "GamepadYInvertEnabled" );
		}

		m_drpGamepadYInvert->SetEnabled( joystick.GetBool() );

		FlyoutMenu *pFlyout = m_drpGamepadYInvert->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpGamepadSwapSticks )
	{
		CGameUIConVarRef joy_movement_stick("joy_movement_stick");

		if ( !joy_movement_stick.GetBool() )
		{
			m_drpGamepadSwapSticks->SetCurrentSelection( "GamepadSwapSticksDisabled" );
		}
		else
		{
			m_drpGamepadSwapSticks->SetCurrentSelection( "GamepadSwapSticksEnabled" );
		}

		m_drpGamepadSwapSticks->SetEnabled( joystick.GetBool() );

		FlyoutMenu *pFlyout = m_drpGamepadSwapSticks->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	UpdateFooter( true );

	if ( m_btnEditBindings )
	{
		if ( m_ActiveControl )
			m_ActiveControl->NavigateFrom( );
		m_btnEditBindings->NavigateTo();
		m_ActiveControl = m_btnEditBindings;
	}
}
Example #19
0
//=============================================================================
void Multiplayer::Activate()
{
	BaseClass::Activate();

	if ( m_drpAllowLanGames )
	{
		CGameUIConVarRef net_allow_multicast( "net_allow_multicast" );

		m_drpAllowLanGames->SetCurrentSelection( CFmtStr( "MpLanGames%sabled", net_allow_multicast.GetBool() ? "En" : "Dis" ) );

		FlyoutMenu *pFlyout = m_drpAllowLanGames->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpAllowCustomContent )
	{
		CGameUIConVarRef cl_downloadfilter( "cl_downloadfilter" );
		m_drpAllowCustomContent->SetCurrentSelection( CFmtStr( "#GameUI_DownloadFilter_%s", cl_downloadfilter.GetString() ) );

		FlyoutMenu *pFlyout = m_drpAllowCustomContent->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpColorBlind )
	{
		CGameUIConVarRef cl_colorblind( "cl_colorblind" );
		m_drpColorBlind->SetCurrentSelection( CFmtStr( "ColorBlind%d", cl_colorblind.GetInt() ) );

		FlyoutMenu *pFlyout = m_drpColorBlind->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpGameInstructor )
	{
		CGameUIConVarRef gameinstructor_enable( "gameinstructor_enable" );

		if ( gameinstructor_enable.GetBool() )
		{
			m_drpGameInstructor->SetCurrentSelection( "GameInstructorEnabled" );
		}
		else
		{
			m_drpGameInstructor->SetCurrentSelection( "GameInstructorDisabled" );
		}

		FlyoutMenu *pFlyout = m_drpGameInstructor->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpAllowFreeLook )
	{
		CGameUIConVarRef spec_allowroaming( "spec_allowroaming" );

		if ( spec_allowroaming.GetBool() )
		{
			m_drpAllowFreeLook->SetCurrentSelection( "AllowFreeLookEnabled" );
		}
		else
		{
			m_drpAllowFreeLook->SetCurrentSelection( "AllowFreeLookDisabled" );
		}

		FlyoutMenu *pFlyout = m_drpAllowFreeLook->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpSpraypaint )
	{
		InitLogoList();

		FlyoutMenu *pFlyout = m_drpSpraypaint->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	if ( m_drpAllowLanGames )
	{
		if ( m_ActiveControl )
			m_ActiveControl->NavigateFrom( );
		m_drpAllowLanGames->NavigateTo();
		m_ActiveControl = m_drpAllowLanGames;
	}

	if ( m_drpGore )
	{
		CGameUIConVarRef z_wound_client_disabled ( "z_wound_client_disabled" );

		if ( z_wound_client_disabled.GetBool() )
		{
			m_drpGore->SetCurrentSelection( "#L4D360UI_Gore_Low" );
		}
		else
		{
			m_drpGore->SetCurrentSelection( "#L4D360UI_Gore_High" );
		}

		FlyoutMenu *pFlyout = m_drpGore->GetCurrentFlyout();
		if ( pFlyout )
		{
			pFlyout->SetListener( this );
		}
	}

	UpdateFooter( true );
}