void DropDownMenu::CloseDropDown() { FlyoutMenu* flyout = GetCurrentFlyout(); if ( flyout && flyout->IsVisible() ) { flyout->CloseMenu( m_pButton ); } }
//============================================================================= 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(); }