From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- tracker/AdminServer/GraphPanel.cpp | 731 +++++++++++++++++++++++++++++++++++++ 1 file changed, 731 insertions(+) create mode 100644 tracker/AdminServer/GraphPanel.cpp (limited to 'tracker/AdminServer/GraphPanel.cpp') diff --git a/tracker/AdminServer/GraphPanel.cpp b/tracker/AdminServer/GraphPanel.cpp new file mode 100644 index 0000000..59ba15d --- /dev/null +++ b/tracker/AdminServer/GraphPanel.cpp @@ -0,0 +1,731 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#include + +#include "GraphPanel.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define max(a,b) (((a) > (b)) ? (a) : (b)) + +#define STATS_UPDATE_RATE 5.0f + + +// colors for the various graph lines+controls +Color CGraphPanel::CGraphsImage::CPUColor= Color(0,255,0,255); // green +Color CGraphPanel::CGraphsImage::FPSColor= Color(255,0,0,255); // red +Color CGraphPanel::CGraphsImage::NetInColor = Color(255,255,0,255); // yellow +Color CGraphPanel::CGraphsImage::NetOutColor = Color(0,255,255,255); // light blue +Color CGraphPanel::CGraphsImage::PlayersColor = Color(255,0,255,255); // purple +Color CGraphPanel::CGraphsImage::PingColor = Color(0,0,0,255); // black +//Color CGraphPanel::CGraphsImage::lineColor = Color(76,88,68,255); + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CGraphPanel::CGraphPanel(vgui::Panel *parent, const char *name) : PropertyPage(parent, name) +{ + SetMinimumSize(300,200); + + m_pGraphsPanel = new ImagePanel(this,"Graphs"); + m_pGraphs = new CGraphsImage(); + m_pGraphsPanel->SetImage(m_pGraphs); + + m_pInButton = new CheckButton(this,"InCheck","#Graph_In"); + m_pOutButton = new CheckButton(this,"OutCheck","#Graph_Out"); + m_pFPSButton = new CheckButton(this,"FPSCheck","#Graph_FPS"); + m_pCPUButton = new CheckButton(this,"CPUCheck","#Graph_CPU"); + m_pPINGButton = new CheckButton(this,"PingCheck","#Graph_Ping"); + m_pPlayerButton = new CheckButton(this,"PlayersCheck","#Graph_Players"); + + m_pTimeCombo = new ComboBox(this, "TimeCombo",3,false); + m_pTimeCombo->AddItem("#Graph_Minutes", NULL); + int defaultItem = m_pTimeCombo->AddItem("#Graph_Hours", NULL); + m_pTimeCombo->AddItem("#Graph_Day", NULL); + m_pTimeCombo->ActivateItem(defaultItem); + + m_pVertCombo = new ComboBox(this, "VertCombo",6,false); + m_pVertCombo->AddItem("#Graph_In", NULL); + m_pVertCombo->AddItem("#Graph_Out", NULL); + m_pVertCombo->AddItem("#Graph_FPS", NULL); + defaultItem = m_pVertCombo->AddItem("#Graph_CPU", NULL); + m_pVertCombo->AddItem("#Graph_Ping", NULL); + m_pVertCombo->AddItem("#Graph_Players", NULL); + m_pVertCombo->ActivateItem(defaultItem); + + // now setup defaults + m_pCPUButton->SetSelected(true); + m_pInButton->SetSelected(false); + m_pOutButton->SetSelected(false); + m_pFPSButton->SetSelected(false); + m_pPINGButton->SetSelected(false); + + LoadControlSettings("Admin/GraphPanel.res", "PLATFORM"); + + int w,h; + m_pGraphsPanel->GetSize(w,h); + m_pGraphs->SaveSize(w,h); + m_pGraphs->SetDraw(m_pCPUButton->IsSelected(),m_pFPSButton->IsSelected(), + m_pInButton->IsSelected(),m_pOutButton->IsSelected(),m_pPINGButton->IsSelected(),m_pPlayerButton->IsSelected()); + + m_pPINGButton->SetFgColor(m_pGraphs->GetPingColor()); + m_pCPUButton->SetFgColor(m_pGraphs->GetCPUColor()); + m_pFPSButton->SetFgColor(m_pGraphs->GetFPSColor()); + m_pInButton->SetFgColor(m_pGraphs->GetInColor()); + m_pOutButton->SetFgColor(m_pGraphs->GetOutColor()); + m_pPlayerButton->SetFgColor(m_pGraphs->GetPlayersColor()); + + ivgui()->AddTickSignal(GetVPanel()); + m_flNextStatsUpdateTime = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: Destructor +//----------------------------------------------------------------------------- +CGraphPanel::~CGraphPanel() +{ + +} + +void CGraphPanel::ApplySchemeSettings( IScheme *pScheme ) +{ + BaseClass::ApplySchemeSettings( pScheme ); + m_pGraphsPanel->SetBorder( pScheme->GetBorder("ButtonDepressedBorder")); + m_pGraphs->SetBgColor(GetSchemeColor("WindowBG", pScheme)); + m_pGraphs->SetAxisColor(Color(76,88,68,255)); + +} + +//----------------------------------------------------------------------------- +// Purpose: Activates the page +//----------------------------------------------------------------------------- +void CGraphPanel::OnPageShow() +{ + BaseClass::OnPageShow(); +} + +//----------------------------------------------------------------------------- +// Purpose: Hides the page +//----------------------------------------------------------------------------- +void CGraphPanel::OnPageHide() +{ + BaseClass::OnPageHide(); +} + +//----------------------------------------------------------------------------- +// Purpose: called every frame to update stats page +//----------------------------------------------------------------------------- +void CGraphPanel::OnTick() +{ + if (m_flNextStatsUpdateTime > system()->GetFrameTime()) + return; + + m_flNextStatsUpdateTime = (float)system()->GetFrameTime() + STATS_UPDATE_RATE; + RemoteServer().RequestValue(this, "stats"); +} + +//----------------------------------------------------------------------------- +// Purpose: tells the image about the new size +//----------------------------------------------------------------------------- +void CGraphPanel::PerformLayout() +{ + BaseClass::PerformLayout(); + int w,h,x,y; + m_pGraphsPanel->GetBounds(x,y,w,h); + + m_pGraphs->SaveSize(w,h); // tell the image about the resize + + // push the mid axis label to the middle of the image + Label *entry = dynamic_cast