summaryrefslogtreecommitdiff
path: root/game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp')
-rw-r--r--game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp94
1 files changed, 94 insertions, 0 deletions
diff --git a/game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp b/game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp
new file mode 100644
index 0000000..1658fb0
--- /dev/null
+++ b/game/client/tf/vgui/tf_matchmaking_dashboard_next_map_winner.cpp
@@ -0,0 +1,94 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+
+#include "cbase.h"
+#include "tf_matchmaking_dashboard.h"
+#include "tf_gamerules.h"
+#include "tf_gc_client.h"
+#include <vgui/ISurface.h>
+
+using namespace vgui;
+using namespace GCSDK;
+
+#ifdef STAGING_ONLY
+extern ConVar tf_mm_popup_state_override;
+#endif
+
+class CNextMapWinnerDashboardState : public CTFMatchmakingPopup
+{
+public:
+
+ CNextMapWinnerDashboardState( const char* pszName, const char* pszResFile )
+ : CTFMatchmakingPopup( pszName, pszResFile )
+ {
+ }
+
+ virtual bool ShouldBeActve() const OVERRIDE
+ {
+#ifdef STAGING_ONLY
+ if ( FStrEq( const_cast<CNextMapWinnerDashboardState*>(this)->GetName(), tf_mm_popup_state_override.GetString() ) )
+ return true;
+#endif
+
+ int nVotes[ CTFGameRules::EUserNextMapVote::NUM_VOTE_STATES ];
+ CTFGameRules::EUserNextMapVote eWinningVote = TFGameRules()->GetWinningVote( nVotes );
+
+ if ( BInEndOfMatch() &&
+ TFGameRules() &&
+ TFGameRules()->GetCurrentNextMapVotingState() == CTFGameRules::NEXT_MAP_VOTE_STATE_MAP_CHOSEN_PAUSE &&
+ eWinningVote != CTFGameRules::USER_NEXT_MAP_VOTE_UNDECIDED &&
+ GTFGCClientSystem()->BConnectedToMatchServer( false ) )
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+private:
+
+ virtual void OnEnter() OVERRIDE
+ {
+ CTFMatchmakingPopup::OnEnter();
+
+ MapDefIndex_t nWinningDefIndex;
+ if ( TFGameRules() )
+ {
+ int nVotes[ CTFGameRules::EUserNextMapVote::NUM_VOTE_STATES ];
+ CTFGameRules::EUserNextMapVote eWinningVote = TFGameRules()->GetWinningVote( nVotes );
+ nWinningDefIndex = TFGameRules()->GetNextMapVoteOption( eWinningVote );
+ }
+ else
+ {
+ Assert( false );
+ nWinningDefIndex = RandomInt( 1, GetItemSchema()->GetMapCount() - 1 );
+ }
+
+ // Sound effect for success
+ surface()->PlaySound( UTIL_GetRandomSoundFromEntry( "Vote.Passed" ) );
+
+ const MapDef_t *pMapDef = GetItemSchema()->GetMasterMapDefByIndex( nWinningDefIndex );
+ if ( pMapDef )
+ {
+ Label* pMapNameLabel = FindControl< Label >( "NameLabel", true );
+ if ( pMapNameLabel )
+ {
+ pMapNameLabel->SetText( g_pVGuiLocalize->Find( pMapDef->pszMapNameLocKey ) );
+ }
+
+ ScalableImagePanel* pMapImage = FindControl< ScalableImagePanel >( "MapImage", true );
+ if ( pMapImage )
+ {
+ char imagename[ 512 ];
+ Q_snprintf( imagename, sizeof( imagename ), "..\\vgui\\maps\\menu_thumb_%s", pMapDef->pszMapName );
+ pMapImage->SetImage( imagename );
+ }
+ }
+ }
+};
+
+REG_MM_POPUP_FACTORY( CNextMapWinnerDashboardState, "NextMapWinner", "resource/UI/MatchMakingDashboardPopup_NextMapWinner.res" ) \ No newline at end of file