summaryrefslogtreecommitdiff
path: root/game/client/cstrike/VGUI/stat_card.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/cstrike/VGUI/stat_card.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/cstrike/VGUI/stat_card.cpp')
-rw-r--r--game/client/cstrike/VGUI/stat_card.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/game/client/cstrike/VGUI/stat_card.cpp b/game/client/cstrike/VGUI/stat_card.cpp
new file mode 100644
index 0000000..648b286
--- /dev/null
+++ b/game/client/cstrike/VGUI/stat_card.cpp
@@ -0,0 +1,106 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Create and display a win panel at the end of a round displaying interesting stats and info about the round.
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "stat_card.h"
+#include "vgui_controls/AnimationController.h"
+#include "iclientmode.h"
+#include "c_playerresource.h"
+#include <vgui_controls/Label.h>
+#include <vgui/ILocalize.h>
+#include <vgui/ISurface.h>
+#include "fmtstr.h"
+#include "../../public/steam/steam_api.h"
+#include "c_cs_player.h"
+#include "cs_gamestats_shared.h"
+#include "cs_client_gamestats.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+StatCard::StatCard(vgui::Panel *parent, const char *name) : BaseClass(parent, "CSStatCard")
+{
+ //m_pAvatarDefault = new ImagePanel(this, "");
+ //m_pBackgroundArt = new ImagePanel(this, "BackgroundArt");
+ m_pAvatar = new CAvatarImagePanel(this, "Avatar");
+ m_pAvatar->SetShouldScaleImage(true);
+ m_pAvatar->SetShouldDrawFriendIcon(false);
+ m_pAvatar->SetSize(64,64);
+
+ m_pName= new Label(this, "Name", "Name");
+ m_pKillToDeathRatio = new Label(this, "KillToDeath", "KillToDeath");
+ m_pStars = new Label(this, "Stars", "Stars");
+}
+
+StatCard::~StatCard()
+{
+
+}
+
+
+void StatCard::ApplySchemeSettings( vgui::IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+
+ LoadControlSettings("Resource/UI/CSStatCard.res");
+
+ //m_pBackgroundArt->SetShouldScaleImage(true);
+ //m_pBackgroundArt->SetImage("../VGUI/achievements/achievement-btn-up");
+
+ SetBgColor(Color(0,0,0,0));
+
+ UpdateInfo();
+}
+
+void StatCard::UpdateInfo()
+{
+ const StatsCollection_t& personalLifetimeStats = g_CSClientGameStats.GetLifetimeStats();
+
+ int stars = personalLifetimeStats[CSSTAT_MVPS];
+ float kills = personalLifetimeStats[CSSTAT_KILLS];
+ float deaths = personalLifetimeStats[CSSTAT_DEATHS];
+ wchar_t buf[64], numBuf[64];
+
+ if (deaths > 0)
+ {
+ float killToDeath = kills / deaths;
+
+ _snwprintf( numBuf, ARRAYSIZE( numBuf ), L"%.2f", killToDeath);
+ g_pVGuiLocalize->ConstructString( buf, sizeof(buf),
+ g_pVGuiLocalize->Find( "#GameUI_Stats_LastMatch_KDRatio" ), 1, numBuf );
+ m_pKillToDeathRatio->SetText( buf );
+ }
+ else
+ {
+ m_pKillToDeathRatio->SetText("");
+ }
+
+ _snwprintf( numBuf, ARRAYSIZE( numBuf ), L"%i", stars);
+ g_pVGuiLocalize->ConstructString( buf, sizeof(buf),
+ g_pVGuiLocalize->Find( "#GameUI_Stats_LastMatch_MVPS" ), 1, numBuf );
+ m_pStars->SetText( buf );
+
+ if (steamapicontext)
+ {
+ ISteamFriends* friends = steamapicontext->SteamFriends();
+ if (friends)
+ {
+ m_pName->SetText(friends->GetPersonaName());
+ }
+ }
+
+ // Display the player avatar
+ if (m_pAvatar && steamapicontext && steamapicontext->SteamUser())
+ {
+ m_pAvatar->SetPlayer( steamapicontext->SteamUser()->GetSteamID(), k_EAvatarSize64x64 );
+ m_pAvatar->SetVisible( true );
+ }
+}