//============================================================================= void InGameMainMenu::ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); // We cant remove button and resize flyout menu from code, but we can use another .res file for base menu. #ifdef UI_USING_GAMEPLAYCONFIGDIALOG if ( demo_ui_enable.GetString()[0] ) { LoadControlSettings( CFmtStr( "Resource/UI/BaseModUI/InGameMainMenu_%s.res", demo_ui_enable.GetString() ) ); } else { LoadControlSettings( "Resource/UI/BaseModUI/InGameMainMenu.res" ); } #else // all that "demoui" stuff confuse me [str] const char *pSettings = "Resource/UI/BaseModUI/InGameMainMenu_NoGameplay.res"; #endif BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnDeveloperCommentaries" ) ); if ( button ) { #ifdef UI_USING_DEVCOMMENTARIES button->SetEnabled( true ); // we're not just removing button, because of ASWUI flyout system [str] // thought: maybe just use different control setting #endif } SetPaintBackgroundEnabled( true ); SetFooterState(); }
//============================================================================= void InGameDifficultySelect::LoadLayout() { BaseClass::LoadLayout(); CGameUIConVarRef z_difficulty("z_difficulty"); if ( z_difficulty.IsValid() ) { // set a label that tells us what the current difficulty is char chBuffer[64]; Q_snprintf( chBuffer, ARRAYSIZE( chBuffer ), "#L4D360UI_Difficulty_%s", z_difficulty.GetString() ); const char *pszDifficultyLoc = chBuffer; wchar_t *pwcDifficulty = g_pVGuiLocalize->Find( pszDifficultyLoc ); if ( pwcDifficulty ) { wchar_t szWideBuff[200]; g_pVGuiLocalize->ConstructString( szWideBuff, sizeof( szWideBuff ), g_pVGuiLocalize->Find( "#L4D360UI_GameSettings_Current_Difficulty" ), 1, pwcDifficulty ); SetControlString( "LblCurrentDifficulty", szWideBuff ); } // Disable the current difficulty's button, and navigate to it. BaseModHybridButton *pButton = dynamic_cast< BaseModHybridButton* >( FindChildByName( VarArgs( "Btn%s", z_difficulty.GetString() ) ) ); if ( pButton ) { pButton->SetEnabled( false ); pButton->NavigateTo(); } } }
void Demo_DisableButton( Button *pButton ) { BaseModHybridButton *pHybridButton = dynamic_cast<BaseModHybridButton *>(pButton); if (pHybridButton) { pHybridButton->SetEnabled( false ); char szTooltip[512]; wchar_t *wUnicode = g_pVGuiLocalize->Find( "#L4D360UI_MainMenu_DemoVersion" ); if ( !wUnicode ) wUnicode = L""; g_pVGuiLocalize->ConvertUnicodeToANSI( wUnicode, szTooltip, sizeof( szTooltip ) ); pHybridButton->SetHelpText( szTooltip , false ); } }
void GameSettings::UpdateSelectMissionButton() { DropDownMenu *menu = dynamic_cast< DropDownMenu* >( FindChildByName( "DrpSelectMission", true ) ); if ( !menu ) return; BaseModHybridButton *button = menu->GetButton(); //dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnSelectMission", true ) ); if ( m_pSettings && button ) { const char *szGameType = m_pSettings->GetString( "game/mode", "sdk" ); if ( !Q_stricmp( szGameType, "campaign" ) ) { button->SetText( "#ASUI_Select_Campaign" ); button->SetHelpText( "#ASUI_Select_Campaign_tt" ); } else if ( !Q_stricmp( szGameType, "single_mission" ) ) { button->SetText( "#ASUI_Select_Mission" ); button->SetHelpText( "#ASUI_Select_Mission_tt" ); } else if( !Q_stricmp( szGameType, "sdk" ) ) { button->SetText( "Select Map" ); button->SetHelpText( "SDK select map example" ); } else if( !Q_stricmp( szGameType, "swarmkeeper" ) ) { button->SetText( "Select level" ); button->SetHelpText( "Select a Swarm Keeper level" ); } } /* BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnSelectMission" ) ); if ( m_pSettings && button ) { const char *szGameType = m_pSettings->GetString( "game/mode", "campaign" ); if ( !Q_stricmp( szGameType, "campaign" ) ) { button->SetText( "#ASUI_Select_Campaign" ); button->SetHelpText( "#ASUI_Select_Campaign_tt" ); } else if ( !Q_stricmp( szGameType, "single_mission" ) ) { button->SetText( "#ASUI_Select_Mission" ); button->SetHelpText( "#ASUI_Select_Mission_tt" ); } } */ }
//============================================================================= 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(); }
void QuickJoinPanel::UpdateNumGamesFoundLabel( void ) { BaseModHybridButton *title = dynamic_cast< BaseModHybridButton* >( FindChildByName( "LblTitle" ) ); if ( title ) { wchar_t* wFormatString = g_pVGuiLocalize->Find( GetTitle() ); if( wFormatString ) { char gameCountTxt[ 4 ]; itoa( m_FriendInfo.Count(), gameCountTxt, 10 ); wchar_t wGameCountTxt[ 4 ]; g_pVGuiLocalize->ConvertANSIToUnicode( gameCountTxt, wGameCountTxt, sizeof( wGameCountTxt ) ); wchar_t wMessage[ 256 ]; g_pVGuiLocalize->ConstructString( wMessage, sizeof( wMessage ), wFormatString, 1, wGameCountTxt ); title->SetText( wMessage ); } } }
//============================================================================= void InGameMainMenu::PerformLayout( void ) { BaseClass::PerformLayout(); BaseModUI::FlyoutMenu *flyout = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmIngameSingleplayerFlyout" ) ); if ( flyout ) { flyout->SetListener( this ); } BaseModUI::FlyoutMenu *flyout2 = dynamic_cast< FlyoutMenu* >( FindChildByName( "FlmOptionsFlyout" ) ); if ( flyout2 ) { flyout2->SetListener( this ); } BaseModHybridButton *button = dynamic_cast< BaseModHybridButton* >( FindChildByName( "BtnReturnToGame" ) ); if ( button ) { if( m_ActiveControl ) m_ActiveControl->NavigateFrom(); button->NavigateTo(); } }
//============================================================================= void DownloadCampaign::UpdateText() { wchar_t s1[MAX_PATH]; wchar_t s2[MAX_PATH]; wchar_t text[MAX_PATH]; g_pVGuiLocalize->ConvertANSIToUnicode( m_campaignName.Get(), s1, sizeof( s1 ) ); g_pVGuiLocalize->ConvertANSIToUnicode( m_author.Get(), s2, sizeof( s2 ) ); const wchar_t * downloadCampaignText = g_pVGuiLocalize->Find( "#L4D360UI_DownloadCampaign_Campaign" ); if ( downloadCampaignText ) { g_pVGuiLocalize->ConstructString( text, sizeof( text ), downloadCampaignText, 2, s1, s2 ); vgui::Label *LblDownloadCampaign = dynamic_cast< vgui::Label * > ( FindChildByName( "LblDownloadCampaign" ) ); if ( LblDownloadCampaign ) { LblDownloadCampaign->SetText( text ); } } g_pVGuiLocalize->ConvertANSIToUnicode( m_webSite.Get(), s1, sizeof( s1 ) ); BaseModHybridButton *BtnURL = dynamic_cast< BaseModHybridButton * > ( FindChildByName( "BtnURL" ) ); if ( BtnURL ) { BtnURL->SetText( s1 ); } if ( m_fromLobby ) { vgui::Label *LblDownloadText = dynamic_cast< vgui::Label * > ( FindChildByName( "LblDownloadText" ) ); if ( LblDownloadText ) { LblDownloadText->SetText( "#L4D360UI_DownloadCampaign_Text_FromLobby" ); } } }
void QuickJoinPanel::NavigateTo() { BaseClass::NavigateTo(); SetHasMouseover( true ); BaseModHybridButton *title = dynamic_cast< BaseModHybridButton* >( FindChildByName( "LblTitle" ) ); if ( title ) { title->SetNavUp( GetNavUp() ); title->SetNavDown( GetNavDown() ); if ( m_bHasMouseover && title->IsVisible() && ( title->GetCurrentState() == BaseModHybridButton::Enabled || title->GetCurrentState() == BaseModHybridButton::Disabled ) ) { title->NavigateTo(); } } #ifdef _X360 m_GplQuickJoinList->NavigateTo(); #endif }
//============================================================================= void MainMenu::OnCommand( const char *command ) { int iUserSlot = CBaseModPanel::GetSingleton().GetLastActiveUserId(); if ( UI_IsDebug() ) { Msg("[GAMEUI] Handling main menu command %s from user%d ctrlr%d\n", command, iUserSlot, XBX_GetUserId( iUserSlot ) ); } bool bOpeningFlyout = false; if ( char const *szQuickMatch = StringAfterPrefix( command, "QuickMatch_" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() || CUIGameData::Get()->CheckAndDisplayErrorIfNotSignedInToLive( this ) ) return; KeyValues *pSettings = KeyValues::FromString( "settings", " system { " " network LIVE " " } " " game { " " mode = " " } " " options { " " action quickmatch " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "game/mode", szQuickMatch ); // TCR: We need to respect the default difficulty if ( GameModeHasDifficulty( szQuickMatch ) ) pSettings->SetString( "game/difficulty", GameModeGetDefaultDifficulty( szQuickMatch ) ); g_pMatchFramework->MatchSession( pSettings ); } else if ( char const *szCustomMatch = StringAfterPrefix( command, "CustomMatch_" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() || CUIGameData::Get()->CheckAndDisplayErrorIfNotSignedInToLive( this ) ) return; KeyValues *pSettings = KeyValues::FromString( "settings", " system { " " network LIVE " " } " " game { " " mode = " " } " " options { " " action custommatch " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "game/mode", szCustomMatch ); CBaseModPanel::GetSingleton().OpenWindow( ui_play_online_browser.GetBool() ? WT_FOUNDPUBLICGAMES : WT_GAMESETTINGS, this, true, pSettings ); } else if ( char const *szFriendsMatch = StringAfterPrefix( command, "FriendsMatch_" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; if ( StringHasPrefix( szFriendsMatch, "team" ) && CUIGameData::Get()->CheckAndDisplayErrorIfNotSignedInToLive( this ) ) // Team games require to be signed in to LIVE return; KeyValues *pSettings = KeyValues::FromString( "settings", " game { " " mode = " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "game/mode", szFriendsMatch ); if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow( WT_ALLGAMESEARCHRESULTS, this, true, pSettings ); } else if ( char const *szGroupServer = StringAfterPrefix( command, "GroupServer_" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; KeyValues *pSettings = KeyValues::FromString( "settings", " game { " // " mode = " " } " " options { " " action groupserver " " } " ); KeyValues::AutoDelete autodelete( pSettings ); if ( *szGroupServer ) pSettings->SetString( "game/mode", szGroupServer ); if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow( WT_STEAMGROUPSERVERS, this, true, pSettings ); } else if ( char const *szLeaderboards = StringAfterPrefix( command, "Leaderboards_" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() || CUIGameData::Get()->CheckAndDisplayErrorIfOffline( this, "#L4D360UI_MainMenu_SurvivalLeaderboards_Tip_Disabled" ) ) return; KeyValues *pSettings = KeyValues::FromString( "settings", " game { " " mode = " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "game/mode", szLeaderboards ); if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow( WT_LEADERBOARD, this, true, pSettings ); } else if( !Q_strcmp( command, "VersusSoftLock" ) ) { OnCommand( "FlmVersusFlyout" ); return; } else if ( !Q_strcmp( command, "SurvivalCheck" ) ) { OnCommand( "FlmSurvivalFlyout" ); return; } else if ( !Q_strcmp( command, "ScavengeCheck" ) ) { OnCommand( "FlmScavengeFlyout" ); return; } else if ( !Q_strcmp( command, "SoloPlay" ) ) { if ( !asw_show_all_singleplayer_maps.GetBool() ) { KeyValues *pSettings = KeyValues::FromString( "settings", " system { " " network offline " " } " " game { " " mode sdk " " mission sdk_teams_hdr " " } " ); KeyValues::AutoDelete autodelete( pSettings ); pSettings->SetString( "Game/difficulty", GameModeGetDefaultDifficulty( pSettings->GetString( "Game/mode" ) ) ); g_pMatchFramework->CreateSession( pSettings ); // Automatically start the credits session, no configuration required if ( IMatchSession *pMatchSession = g_pMatchFramework->GetMatchSession() ) { pMatchSession->Command( KeyValues::AutoDeleteInline( new KeyValues( "Start" ) ) ); } } else { KeyValues *pSettings = KeyValues::FromString( "Settings", " System { " " network offline " " } " " Game { " " mode sdk " " mission sdk_teams_hdr " " } " ); KeyValues::AutoDelete autodelete( pSettings ); // TCR: We need to respect the default difficulty pSettings->SetString( "Game/difficulty", GameModeGetDefaultDifficulty( pSettings->GetString( "Game/mode" ) ) ); g_pMatchFramework->CreateSession( pSettings ); } } else if ( !Q_strcmp( command, "DeveloperCommentary" ) ) { // Explain the rules of commentary GenericConfirmation* confirmation = static_cast< GenericConfirmation* >( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, this, false ) ); GenericConfirmation::Data_t data; data.pWindowTitle = "#GAMEUI_CommentaryDialogTitle"; data.pMessageText = "#L4D360UI_Commentary_Explanation"; data.bOkButtonEnabled = true; data.pfnOkCallback = &AcceptCommentaryRulesCallback; data.bCancelButtonEnabled = true; confirmation->SetUsageData(data); NavigateFrom(); } else if ( !Q_strcmp( command, "StatsAndAchievements" ) ) { // If PC make sure that the Steam user is logged in if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow( WT_ACHIEVEMENTS, this, true ); } else if ( !Q_strcmp( command, "FlmExtrasFlyoutCheck" ) ) { if ( IsX360() && CUIGameData::Get()->SignedInToLive() ) OnCommand( "FlmExtrasFlyout_Live" ); else OnCommand( "FlmExtrasFlyout_Simple" ); return; } else if ( char const *szInviteType = StringAfterPrefix( command, "InviteUI_" ) ) { if ( IsX360() ) { CUIGameData::Get()->OpenInviteUI( szInviteType ); } else { CUIGameData::Get()->ExecuteOverlayCommand( "LobbyInvite" ); } } else if (!Q_strcmp(command, "Game")) { if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_GAMEOPTIONS, this, true ); } else if (!Q_strcmp(command, "AudioVideo")) { if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_AUDIOVIDEO, this, true ); } else if (!Q_strcmp(command, "Controller")) { if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_CONTROLLER, this, true ); } else if (!Q_strcmp(command, "Storage")) { if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } // Trigger storage device selector CUIGameData::Get()->SelectStorageDevice( new CChangeStorageDevice( XBX_GetUserId( iUserSlot ) ) ); } else if (!Q_strcmp(command, "Credits")) { KeyValues *pSettings = KeyValues::FromString( "settings", " system { " " network offline " " } " " game { " " mode single_mission " " } " " options { " " play credits " " } " ); KeyValues::AutoDelete autodelete( pSettings ); g_pMatchFramework->CreateSession( pSettings ); // Automatically start the credits session, no configuration required if ( IMatchSession *pMatchSession = g_pMatchFramework->GetMatchSession() ) { pMatchSession->Command( KeyValues::AutoDeleteInline( new KeyValues( "Start" ) ) ); } } else if (!Q_strcmp(command, "QuitGame")) { if ( IsPC() ) { GenericConfirmation* confirmation = static_cast< GenericConfirmation* >( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, this, false ) ); GenericConfirmation::Data_t data; data.pWindowTitle = "#L4D360UI_MainMenu_Quit_Confirm"; data.pMessageText = "#L4D360UI_MainMenu_Quit_ConfirmMsg"; data.bOkButtonEnabled = true; data.pfnOkCallback = &AcceptQuitGameCallback; data.bCancelButtonEnabled = true; confirmation->SetUsageData(data); NavigateFrom(); } } else if ( !Q_stricmp( command, "QuitGame_NoConfirm" ) ) { if ( IsPC() ) { engine->ClientCmd( "quit" ); } } else if ( !Q_strcmp( command, "EnableSplitscreen" ) ) { Msg( "Enabling splitscreen from main menu...\n" ); CBaseModPanel::GetSingleton().CloseAllWindows(); CAttractScreen::SetAttractMode( CAttractScreen::ATTRACT_GOSPLITSCREEN ); CBaseModPanel::GetSingleton().OpenWindow( WT_ATTRACTSCREEN, NULL, true ); } else if ( !Q_strcmp( command, "DisableSplitscreen" ) ) { GenericConfirmation* confirmation = static_cast< GenericConfirmation* >( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, this, false ) ); GenericConfirmation::Data_t data; data.pWindowTitle = "#L4D360UI_MainMenu_SplitscreenDisableConf"; data.pMessageText = "#L4D360UI_MainMenu_SplitscreenDisableConfMsg"; data.bOkButtonEnabled = true; data.pfnOkCallback = &AcceptSplitscreenDisableCallback; data.bCancelButtonEnabled = true; confirmation->SetUsageData(data); } else if ( !Q_strcmp( command, "DisableSplitscreen_NoConfirm" ) ) { Msg( "Disabling splitscreen from main menu...\n" ); CAttractScreen::SetAttractMode( CAttractScreen::ATTRACT_GAMESTART ); OnCommand( "ActivateAttractScreen" ); } else if (!Q_strcmp(command, "Audio")) { if ( ui_old_options_menu.GetBool() ) { CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); } else { // audio options dialog, PC only if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_AUDIO, this, true ); } } else if (!Q_strcmp(command, "Video")) { if ( ui_old_options_menu.GetBool() ) { CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); } else { // video options dialog, PC only if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_VIDEO, this, true ); } } else if (!Q_strcmp(command, "Brightness")) { if ( ui_old_options_menu.GetBool() ) { CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); } else { // brightness options dialog, PC only OpenGammaDialog( GetVParent() ); } } else if (!Q_strcmp(command, "KeyboardMouse")) { if ( ui_old_options_menu.GetBool() ) { CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); } else { // standalone keyboard/mouse dialog, PC only if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_KEYBOARDMOUSE, this, true ); } } else if( Q_stricmp( "#L4D360UI_Controller_Edit_Keys_Buttons", command ) == 0 ) { FlyoutMenu::CloseActiveMenu(); CBaseModPanel::GetSingleton().OpenKeyBindingsDialog( this ); } else if (!Q_strcmp(command, "MultiplayerSettings")) { if ( ui_old_options_menu.GetBool() ) { CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); } else { // standalone multiplayer settings dialog, PC only if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_MULTIPLAYER, this, true ); } } else if (!Q_strcmp(command, "CloudSettings")) { // standalone cloud settings dialog, PC only if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow(WT_CLOUD, this, true ); } else if (!Q_strcmp(command, "SeeAll")) { if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; KeyValues *pSettings = KeyValues::FromString( "settings", " game { " // passing empty game settings to indicate no preference " } " ); KeyValues::AutoDelete autodelete( pSettings ); if ( m_ActiveControl ) { m_ActiveControl->NavigateFrom( ); } CBaseModPanel::GetSingleton().OpenWindow( WT_ALLGAMESEARCHRESULTS, this, true, pSettings ); CBaseModPanel::GetSingleton().PlayUISound( UISOUND_ACCEPT ); } else if ( !Q_strcmp( command, "OpenServerBrowser" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; // on PC, bring up the server browser and switch it to the LAN tab (tab #5) engine->ClientCmd( "openserverbrowser" ); } else if ( !Q_strcmp( command, "DemoConnect" ) ) { g_pMatchFramework->GetMatchTitle()->PrepareClientForConnect( NULL ); engine->ClientCmd( CFmtStr( "connect %s", demo_connect_string.GetString() ) ); } else if (command && command[0] == '#') { // Pass it straight to the engine as a command engine->ClientCmd( command+1 ); } else if( !Q_strcmp( command, "Addons" ) ) { CBaseModPanel::GetSingleton().OpenWindow( WT_ADDONS, this, true ); } else if( !Q_strcmp( command, "CreateGame" ) ) { KeyValues *pSettings = KeyValues::FromString( "settings", " system { " " network LIVE " " access public " " } " " game { " " mode = " " sdk = " " mission = " " } " " options { " " action create " " } " ); KeyValues::AutoDelete autodelete( pSettings ); char const *szGameMode = "sdk"; pSettings->SetString( "game/mode", szGameMode ); pSettings->SetString( "game/campaign", "jacob" ); pSettings->SetString( "game/mission", "sdk_teams_hdr" ); if ( !CUIGameData::Get()->SignedInToLive() ) { pSettings->SetString( "system/network", "lan" ); pSettings->SetString( "system/access", "public" ); } if ( StringHasPrefix( szGameMode, "team" ) ) { pSettings->SetString( "system/netflag", "teamlobby" ); } // else if ( !Q_stricmp( "custommatch", m_pDataSettings->GetString( "options/action", "" ) ) ) // { // pSettings->SetString( "system/access", "public" ); // } // TCR: We need to respect the default difficulty pSettings->SetString( "game/difficulty", GameModeGetDefaultDifficulty( szGameMode ) ); CBaseModPanel::GetSingleton().PlayUISound( UISOUND_ACCEPT ); CBaseModPanel::GetSingleton().CloseAllWindows(); CBaseModPanel::GetSingleton().OpenWindow( WT_GAMESETTINGS, NULL, true, pSettings ); } else { const char *pchCommand = command; if ( !Q_strcmp(command, "FlmOptionsFlyout") ) { #ifdef _X360 if ( XBX_GetPrimaryUserIsGuest() ) { pchCommand = "FlmOptionsGuestFlyout"; } #endif } else if ( !Q_strcmp(command, "FlmVersusFlyout") ) { command = "VersusSoftLock"; } else if ( !Q_strcmp( command, "FlmSurvivalFlyout" ) ) { command = "SurvivalCheck"; } else if ( !Q_strcmp( command, "FlmScavengeFlyout" ) ) { command = "ScavengeCheck"; } else if ( StringHasPrefix( command, "FlmExtrasFlyout_" ) ) { command = "FlmExtrasFlyoutCheck"; } // does this command match a flyout menu? BaseModUI::FlyoutMenu *flyout = dynamic_cast< FlyoutMenu* >( FindChildByName( pchCommand ) ); if ( flyout ) { bOpeningFlyout = true; // If so, enumerate the buttons on the menu and find the button that issues this command. // (No other way to determine which button got pressed; no notion of "current" button on PC.) for ( int iChild = 0; iChild < GetChildCount(); iChild++ ) { bool bFound = false; GameModes *pGameModes = dynamic_cast< GameModes *>( GetChild( iChild ) ); if ( pGameModes ) { for ( int iGameMode = 0; iGameMode < pGameModes->GetNumGameInfos(); iGameMode++ ) { BaseModHybridButton *pHybrid = pGameModes->GetHybridButton( iGameMode ); if ( pHybrid && pHybrid->GetCommand() && !Q_strcmp( pHybrid->GetCommand()->GetString( "command"), command ) ) { pHybrid->NavigateFrom(); // open the menu next to the button that got clicked flyout->OpenMenu( pHybrid ); flyout->SetListener( this ); bFound = true; break; } } } if ( !bFound ) { BaseModHybridButton *hybrid = dynamic_cast<BaseModHybridButton *>( GetChild( iChild ) ); if ( hybrid && hybrid->GetCommand() && !Q_strcmp( hybrid->GetCommand()->GetString( "command"), command ) ) { hybrid->NavigateFrom(); // open the menu next to the button that got clicked flyout->OpenMenu( hybrid ); flyout->SetListener( this ); break; } } } } else { BaseClass::OnCommand( command ); } } if( !bOpeningFlyout ) { FlyoutMenu::CloseActiveMenu(); //due to unpredictability of mouse navigation over keyboard, we should just close any flyouts that may still be open anywhere. } }
//============================================================================= 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 }
//============================================================================= void InGameMainMenu::OnCommand( const char *command ) { int iUserSlot = CBaseModPanel::GetSingleton().GetLastActiveUserId(); if ( UI_IsDebug() ) { Msg("[GAMEUI] Handling ingame menu command %s from user%d ctrlr%d\n", command, iUserSlot, XBX_GetUserId( iUserSlot ) ); } int iOldSlot = GetGameUIActiveSplitScreenPlayerSlot(); SetGameUIActiveSplitScreenPlayerSlot( iUserSlot ); GAMEUI_ACTIVE_SPLITSCREEN_PLAYER_GUARD( iUserSlot ); if ( !Q_strcmp( command, "ReturnToGame" ) ) { engine->ClientCmd("gameui_hide"); } // -- // SINGLEPLAYER else if ( !Q_strcmp( command, "StartNewGame" ) ) { #ifdef UI_USING_OLDDIALOGS CBaseModPanel::GetSingleton().OpenOptionsDialog( this ); #else m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow( WT_NEWGAME, this, true ); #endif } else if ( !Q_strcmp( command, "SaveGame" ) ) { m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow( WT_SAVEGAME, this, true ); } else if ( !Q_strcmp( command, "LoadGame" ) ) { m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow( WT_LOADGAME, this, true ); } else if (!Q_strcmp(command, "Gameplay")) { m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow(WT_GAMEPLAYSETTINGS, this, true ); } else if ( !Q_strcmp( command, "StatsAndAchievements" ) ) { if ( CheckAndDisplayErrorIfNotLoggedIn() ) return; m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow( WT_ACHIEVEMENTS, this, true ); } else if (!Q_strcmp(command, "Controller")) { CBaseModPanel::GetSingleton().OpenWindow(WT_CONTROLLER, this, true ); } else if (!Q_strcmp(command, "Audio")) { // audio options dialog, PC only m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow(WT_AUDIO, this, true ); } else if (!Q_strcmp(command, "Video")) { // video options dialog, PC only m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow(WT_VIDEO, this, true ); } else if (!Q_strcmp(command, "Brightness")) { // brightness options dialog, PC only OpenGammaDialog( GetVParent() ); } else if (!Q_strcmp(command, "KeyboardMouse")) { // standalone keyboard/mouse dialog, PC only m_ActiveControl->NavigateFrom( ); CBaseModPanel::GetSingleton().OpenWindow(WT_KEYBOARDMOUSE, this, true ); } else if( Q_stricmp( "#L4D360UI_Controller_Edit_Keys_Buttons", command ) == 0 ) { FlyoutMenu::CloseActiveMenu(); CBaseModPanel::GetSingleton().OpenKeyBindingsDialog( this ); } else if ( !Q_strcmp( command, "EnableSplitscreen" ) || !Q_strcmp( command, "DisableSplitscreen" ) ) { GenericConfirmation* confirmation = static_cast< GenericConfirmation* >( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, this, true ) ); GenericConfirmation::Data_t data; data.pWindowTitle = "#L4D360UI_LeaveMultiplayerConf"; data.pMessageText = "#L4D360UI_MainMenu_SplitscreenChangeConfMsg"; data.bOkButtonEnabled = true; data.pfnOkCallback = &LeaveGameOkCallback; data.bCancelButtonEnabled = true; confirmation->SetUsageData(data); } else if( !Q_strcmp( command, "ExitToMainMenu" ) ) { GenericConfirmation* confirmation = static_cast< GenericConfirmation* >( CBaseModPanel::GetSingleton().OpenWindow( WT_GENERICCONFIRMATION, this, true ) ); GenericConfirmation::Data_t data; data.pWindowTitle = "#L4D360UI_LeaveMultiplayerConf"; data.pMessageText = "#L4D360UI_LeaveMultiplayerConfMsg"; data.bOkButtonEnabled = true; data.pfnOkCallback = &LeaveGameOkCallback; data.bCancelButtonEnabled = true; confirmation->SetUsageData(data); } else { const char *pchCommand = command; // does this command match a flyout menu? BaseModUI::FlyoutMenu *flyout = dynamic_cast< FlyoutMenu* >( FindChildByName( pchCommand ) ); if ( flyout ) { // If so, enumerate the buttons on the menu and find the button that issues this command. // (No other way to determine which button got pressed; no notion of "current" button on PC.) for ( int iChild = 0; iChild < GetChildCount(); iChild++ ) { BaseModHybridButton *hybrid = dynamic_cast<BaseModHybridButton *>( GetChild( iChild ) ); if ( hybrid && hybrid->GetCommand() && !Q_strcmp( hybrid->GetCommand()->GetString( "command"), command ) ) { #ifdef _X360 hybrid->NavigateFrom( ); #endif //_X360 // open the menu next to the button that got clicked flyout->OpenMenu( hybrid ); break; } } } } SetGameUIActiveSplitScreenPlayerSlot( iOldSlot ); }
//============================================================================= void InGameKickPlayerList::LoadLayout() { BaseClass::LoadLayout(); //int iLocalPlayerTeam; if ( false ) // TODO: !GameClientExports()->GetPlayerTeamIdByUserId( -1, iLocalPlayerTeam ) ) { // no local player? Assert( 0 ); // hide all the buttons, weird state for ( int i=0;i<KICK_PLAYER_LIST_MAX_PLAYERS; i++ ) { BaseModHybridButton *pButton = dynamic_cast< BaseModHybridButton* >( FindChildByName( VarArgs( "BtnPlayer%d", i ) ) ); if ( pButton ) { pButton->SetVisible( false ); } } return; } // get a list of players that we can kick m_KickablePlayersUserIDs.Purge(); for( int i = 1; i <= engine->GetMaxClients(); ++i) { player_info_t playerInfo; if( engine->GetPlayerInfo(i, &playerInfo) && !playerInfo.fakeplayer ) { if ( true ) // TODO: GameClientExports()->IsPlayerKickableByLocalPlayer( i ) ) { m_KickablePlayersUserIDs.AddToTail( playerInfo.userID ); } } } int iKickablePlayers = m_KickablePlayersUserIDs.Count(); // If there are no players to be kicked, hide the description and show the label explaining why // there are no players to choose SetControlVisible( "LblDescription", iKickablePlayers > 0 ); SetControlVisible( "LblNoPlayers", iKickablePlayers == 0 ); for ( int i=0;i<KICK_PLAYER_LIST_MAX_PLAYERS; i++ ) { BaseModHybridButton *pButton = dynamic_cast< BaseModHybridButton* >( FindChildByName( VarArgs( "BtnPlayer%d", i+1 ) ) ); if ( pButton ) { if ( i < iKickablePlayers ) { int userID = m_KickablePlayersUserIDs.Element(i); player_info_t playerInfo; if( engine->GetPlayerInfo( engine->GetPlayerForUserID(userID), &playerInfo ) ) { pButton->SetVisible( true ); pButton->SetText( playerInfo.name ); pButton->SetCommand( VarArgs( "KickPlayer%d", userID ) ); } else { pButton->SetVisible( false ); } } else { pButton->SetVisible( false ); } } } }
void GameModes::OnMousePressed( vgui::MouseCode code ) { BaseClass::OnMousePressed( code ); if ( code != MOUSE_LEFT ) return; if ( IsScrollBusy() ) return; int iPosX; int iPosY; input()->GetCursorPos( iPosX, iPosY ); ScreenToLocal( iPosX, iPosY ); if ( m_nSubPics ) { bool bRightScroll = false; bool bLeftScroll = false; int nSubPic = 0; if ( ( iPosX >= m_nPicOffsetX && iPosX <= m_nPicOffsetX + m_nPicWidth ) && ( iPosY >= 0 && iPosY <= m_nPicHeight ) ) { BaseModHybridButton *pHybridButton = GetHybridButton( m_nActive ); if ( pHybridButton && pHybridButton->GetCurrentState() != BaseModHybridButton::Open ) { // open it if ( pHybridButton->IsEnabled() ) { pHybridButton->DoClick(); } } } else if ( ( iPosX >= m_nLeftArrowX && iPosX <= m_nLeftArrowX + m_nArrowWidth ) && ( iPosY >= m_nLeftArrowY && iPosY <= m_nLeftArrowY + m_nArrowHeight ) ) { bLeftScroll = true; } else if ( ( iPosX >= m_nRightArrowX && iPosX <= m_nRightArrowX + m_nArrowWidth ) && ( iPosY >= m_nRightArrowY && iPosY <= m_nRightArrowY + m_nArrowHeight ) ) { bRightScroll = true; } else { // determine if sub pic selected if ( iPosY >= m_nSubPicY && iPosY <= m_nSubPicY + m_nSubPicHeight ) { int x = m_nSubPicX; for ( int i = 1; i <= m_nSubPics; i++ ) { if ( iPosX >= x && iPosX <= x + m_nSubPicWidth ) { nSubPic = i; break; } x += m_nSubPicWidth + m_nSubPicGap; } } } if ( bLeftScroll || bRightScroll || nSubPic ) { // close any active flyout if ( FlyoutMenu::GetActiveMenu() ) { FlyoutMenu::CloseActiveMenu( this ); } if ( bLeftScroll ) { ScrollLeft(); } else if ( bRightScroll ) { ScrollRight(); } else if ( nSubPic ) { ScrollRight( nSubPic ); } } } }
void GameModes::PaintBackground() { if ( !m_GameModeInfos.Count() ) return; BaseModHybridButton *pHybridButton = m_GameModeInfos[m_nActive].m_pHybridButton; bool bHasFocus = pHybridButton->HasFocus() || ( pHybridButton->GetCurrentState() == BaseModHybridButton::Focus ) || ( pHybridButton->GetCurrentState() == BaseModHybridButton::FocusDisabled ); bool bIsOpen = ( pHybridButton->GetCurrentState() == BaseModHybridButton::Open ); // update scroll // varies between [0..1] or [1..0] float t = 0; if ( m_startScrollTime ) { float rate = ( m_nScrollMultipleCount >= 1 ) ? 8.0f : 5.0f; t = ( Plat_FloatTime() - m_startScrollTime ) * rate; if ( t >= 1.0f ) { // finished, scroll is circular warp around t = 1.0f; m_startScrollTime = 0; int nNewActive = 0; if ( m_bLeftScroll ) { nNewActive = ( m_nActive + 1 ) % m_GameModeInfos.Count(); } else { nNewActive = ( m_nActive - 1 + m_GameModeInfos.Count() ) % m_GameModeInfos.Count(); } SetActiveGameMode( nNewActive, bHasFocus ); if ( --m_nScrollMultipleCount > 0 ) { m_startScrollTime = Plat_FloatTime(); t = 0; } } } int panelWidth, panelHeight; GetSize( panelWidth, panelHeight ); // need this to see panel bounds during debugging //vgui::surface()->DrawSetColor( Color( 255, 0, 0, 255 ) ); //vgui::surface()->DrawFilledRect( 0, 0, panelWidth, panelHeight ); // the main pic and all the subpics int nPicCount = 1 + m_nSubPics; if ( m_startScrollTime && m_bLeftScroll ) { // scrolling means one extra sub pic must be drawn at the far right edge // either coming/going nPicCount++; } int nOffscreenSubPicX = m_nPicOffsetX - m_nSubPicOffsetX - m_nSubPicWidth; int nOffscreenSubPicY = m_nSubPicY; int nOffscreenSubPicW = m_nSubPicWidth; int nOffscreenSubPicH = m_nSubPicHeight; int nActivePicX = m_nPicOffsetX; int nActivePicY = 0; int nActivePicW = m_nPicWidth; int nActivePicH = m_nPicHeight; float nActiveAngle = 0; //-3; int x, y; int w, h; int iPrevActiveMode = ( m_nActive - 1 + m_GameModeInfos.Count() ) % m_GameModeInfos.Count(); int iNextActiveMode = ( m_nActive + 1 ) % m_GameModeInfos.Count(); // center the vertical smear y = nActivePicY + nActivePicH + m_nMenuTitleY + ( m_nMenuTitleActualTall - m_nMenuTitleTall )/2; vgui::surface()->DrawSetColor( m_smearColor ); DrawSmearBackgroundFade( m_nMenuTitleX - ( 0.30f * m_nMenuTitleX ), y, m_nSubPicX + m_nSubPics * ( m_nSubPicWidth + m_nSubPicGap ), y + m_nMenuTitleTall ); // cyclical carousel // the first pic to be drawn is the active main pic, followed by all the sub pics for ( int i = 0; i < nPicCount; i++ ) { int iGameMode = ( m_nActive + i ) % m_GameModeInfos.Count(); // in between scrolling, this image transition gets handled by specialized lerp drawing bool bSkipSubPicDraw = m_startScrollTime && ( m_bLeftScroll && ( iGameMode == iNextActiveMode ) ); if ( !i ) { // active pic x = nActivePicX; y = nActivePicY; w = nActivePicW; h = nActivePicH; if ( !m_startScrollTime ) { Color picColor; picColor.SetColor( 255, 255, 255, 255 ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[m_nActive].m_nImageId ); DrawTexturedRectParms_t parms; parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.angle = nActiveAngle; vgui::surface()->DrawTexturedRectEx( &parms ); if ( bHasFocus || bIsOpen ) { picColor.SetColor( 255, 255, 255, 255 ); } else { picColor.SetColor( 0, 0, 0, 255 ); } vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_nBorderImageId ); //vgui::surface()->DrawTexturedRectEx( &parms ); } else { // draw the lerping pics // lerp active pic to sub pic on left edge int iMode = m_nActive; float tt = 1 - t; if ( !m_bLeftScroll ) { tt = t; iMode = iPrevActiveMode; } x = (float)nOffscreenSubPicX + tt * ( (float)nActivePicX - nOffscreenSubPicX ); y = (float)nOffscreenSubPicY + tt * ( (float)nActivePicY - nOffscreenSubPicY ); w = (float)nOffscreenSubPicW + tt * ( (float)nActivePicW - nOffscreenSubPicW ); h = (float)nOffscreenSubPicH + tt * ( (float)nActivePicH - nOffscreenSubPicH ); float a = tt * 255.0f; float ang = tt * nActiveAngle; Color picColor; picColor.SetColor( 255, 255, 255, a ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iMode].m_nImageId ); DrawTexturedRectParms_t parms; parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.angle = ang; vgui::surface()->DrawTexturedRectEx( &parms ); vgui::surface()->DrawSetTexture( m_nBorderImageId ); //vgui::surface()->DrawTexturedRectEx( &parms ); // lerp active pic to sub pic on right edge iMode = iNextActiveMode; tt = t; if ( !m_bLeftScroll ) { tt = 1 - t; iMode = m_nActive; } x = (float)m_nSubPicX + tt * ( (float)nActivePicX - m_nSubPicX ); y = (float)m_nSubPicY + tt * ( (float)nActivePicY - m_nSubPicY ); w = (float)m_nSubPicWidth + tt * ( (float)nActivePicW - m_nSubPicWidth ); h = (float)m_nSubPicHeight + tt * ( (float)nActivePicH - m_nSubPicHeight ); float c = 125.0f + tt * ( 255.0f - 125.0f ); ang = tt * nActiveAngle; picColor.SetColor( c, c, c, 255 ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iMode].m_nImageId ); parms.x0 = x; parms.y0 = y; parms.x1 = x+w; parms.y1 = y+h; parms.s0 = 0; parms.s1 = 1; parms.t0 = 0; parms.t1 = 1; parms.angle = ang; vgui::surface()->DrawTexturedRectEx( &parms ); } } else if ( !bSkipSubPicDraw ) { // sub pics x = m_nSubPicX + ( i - 1 ) * ( m_nSubPicWidth + m_nSubPicGap ); y = m_nSubPicY; w = m_nSubPicWidth; h = m_nSubPicHeight; int alpha = 255; int focusColor = ( bHasFocus || bIsOpen ) ? 255 : 125; if ( m_startScrollTime ) { int x1 = x; if ( m_bLeftScroll ) { x1 -= m_nSubPicWidth + m_nSubPicGap; } else { x1 += m_nSubPicWidth + m_nSubPicGap; } x = (float)x + t * (float)( x1 - x ); if ( i == nPicCount - 1 ) { if ( m_bLeftScroll ) { alpha = t * (float)alpha; } else { alpha = ( 1 - t ) * (float)alpha; } } } Color picColor; picColor.SetColor( focusColor, focusColor, focusColor, alpha ); vgui::surface()->DrawSetColor( picColor ); vgui::surface()->DrawSetTexture( m_GameModeInfos[iGameMode].m_nImageId ); vgui::surface()->DrawTexturedSubRect( x, y, x+w, y+h, 0.0f, 0.0f, 1.0f, 1.0f ); if ( !m_bHideLabels ) { // sub pics have a label on top of an inscribed rect vgui::surface()->DrawSetColor( Color( 0, 0, 0, alpha ) ); vgui::surface()->DrawFilledRect( x, y + m_nSubPicHeight - m_nNameFontHeight, x + w, y + m_nSubPicHeight ); Color textColor( focusColor, focusColor, focusColor, alpha ); int gap = vgui::surface()->GetCharacterWidth( m_hNameFont, ' ' ); DrawColoredText( m_hNameFont, x + gap, y + m_nSubPicHeight - m_nNameFontHeight/2, textColor, m_GameModeInfos[iGameMode].m_NameText ); } } } // draw arrows if ( m_nSubPics ) { // pc always shows the arrows because mouse can move over them at any time // xbox hides the arrows when the control does not have focus if ( IsPC() || ( IsX360() && bHasFocus && !bIsOpen ) ) { // xbox highlight when scroll active bool bLeftHighlight = IsX360() && m_startScrollTime && !m_bLeftScroll; bool bRightHightlight = IsX360() && m_startScrollTime && m_bLeftScroll; // pc highlights when mouse over if ( IsPC() && !m_startScrollTime ) { int iPosX; int iPosY; input()->GetCursorPos( iPosX, iPosY ); ScreenToLocal( iPosX, iPosY ); if ( ( iPosX >= m_nLeftArrowX && iPosX <= m_nLeftArrowX + m_nArrowWidth ) && ( iPosY >= m_nLeftArrowY && iPosY <= m_nLeftArrowY + m_nArrowHeight ) ) { bLeftHighlight = true; } else if ( ( iPosX >= m_nRightArrowX && iPosX <= m_nRightArrowX + m_nArrowWidth ) && ( iPosY >= m_nRightArrowY && iPosY <= m_nRightArrowY + m_nArrowHeight ) ) { bRightHightlight = true; } } Color leftArrowColor; leftArrowColor.SetColor( 125, 125, 125, 255 ); if ( bLeftHighlight ) { leftArrowColor.SetColor( 255, 255, 255, 255 ); } vgui::surface()->DrawSetColor( leftArrowColor ); vgui::surface()->DrawSetTexture( m_nLeftArrowId ); vgui::surface()->DrawTexturedRect( m_nLeftArrowX, m_nLeftArrowY, m_nLeftArrowX + m_nArrowWidth, m_nLeftArrowY + m_nArrowHeight ); Color rightArrowColor; rightArrowColor.SetColor( 125, 125, 125, 255 ); if ( bRightHightlight ) { rightArrowColor.SetColor( 255, 255, 255, 255 ); } vgui::surface()->DrawSetColor( rightArrowColor ); vgui::surface()->DrawSetTexture( m_nRightArrowId ); vgui::surface()->DrawTexturedRect( m_nRightArrowX, m_nRightArrowY, m_nRightArrowX + m_nArrowWidth, m_nRightArrowY + m_nArrowHeight ); } } }