Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "achievement_stats_summary.h"
  9. #include "achievements_page.h"
  10. #include "lifetime_stats_page.h"
  11. #include "match_stats_page.h"
  12. #include "stats_summary.h"
  13. #include <stdio.h>
  14. using namespace vgui;
  15. #include <vgui/ILocalize.h>
  16. #include "vgui/ISurface.h"
  17. #include "filesystem.h"
  18. #include <KeyValues.h>
  19. // memdbgon must be the last include file in a .cpp file!!!
  20. #include <tier0/memdbgon.h>
  21. const int cDialogWidth = 900;
  22. //-----------------------------------------------------------------------------
  23. // Purpose: Constructor
  24. //-----------------------------------------------------------------------------
  25. CAchievementAndStatsSummary::CAchievementAndStatsSummary(vgui::Panel *parent) : BaseClass(parent, "AchievementAndStatsSummary")
  26. {
  27. SetDeleteSelfOnClose(false);
  28. //SetBounds(0, 0, 640, 384);
  29. SetBounds(0, 0, 900, 780);
  30. SetMinimumSize( 640, 780 );
  31. SetSizeable( false );
  32. SetTitle("#GameUI_CreateAchievementsAndStats", true);
  33. SetOKButtonText("#GameUI_Close");
  34. SetCancelButtonVisible(false);
  35. m_pStatsSummary = new CStatsSummary( this, "StatsSummary" );
  36. m_pAchievementsPage = new CAchievementsPage(this, "AchievementsPage");
  37. m_pLifetimeStatsPage = new CLifetimeStatsPage(this, "StatsPage");
  38. m_pMatchStatsPage = new CMatchStatsPage(this, "MatchStatsPage");
  39. AddPage(m_pStatsSummary, "#GameUI_Stats_Summary");
  40. AddPage(m_pAchievementsPage, "#GameUI_Achievements_Tab");
  41. AddPage(m_pMatchStatsPage, "#GameUI_MatchStats");
  42. AddPage(m_pLifetimeStatsPage, "#GameUI_LifetimeStats");
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose: Destructor
  46. //-----------------------------------------------------------------------------
  47. CAchievementAndStatsSummary::~CAchievementAndStatsSummary()
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. //-----------------------------------------------------------------------------
  53. void CAchievementAndStatsSummary::ApplySchemeSettings( vgui::IScheme *pScheme )
  54. {
  55. BaseClass::ApplySchemeSettings( pScheme );
  56. int screenWide, screenTall;
  57. surface()->GetScreenSize( screenWide, screenTall );
  58. // [smessick] Close the achievements dialog for a low resolution screen.
  59. if ( screenWide < cAchievementsDialogMinWidth )
  60. {
  61. OnOK( true );
  62. Close();
  63. }
  64. }
  65. //-----------------------------------------------------------------------------
  66. // Purpose: runs the server when the OK button is pressed
  67. //-----------------------------------------------------------------------------
  68. bool CAchievementAndStatsSummary::OnOK(bool applyOnly)
  69. {
  70. BaseClass::OnOK(applyOnly);
  71. return true;
  72. }
  73. //----------------------------------------------------------
  74. // Purpose: Preserve our width to the one in the .res file
  75. //----------------------------------------------------------
  76. void CAchievementAndStatsSummary::OnSizeChanged(int newWide, int newTall)
  77. {
  78. // Lock the width, but allow height scaling
  79. if ( newWide != cDialogWidth )
  80. {
  81. SetSize( cDialogWidth, newTall );
  82. return;
  83. }
  84. BaseClass::OnSizeChanged(newWide, newTall);
  85. }
  86. //----------------------------------------------------------
  87. // Purpose: Processes when summary dialog is activated.
  88. //----------------------------------------------------------
  89. void CAchievementAndStatsSummary::Activate()
  90. {
  91. m_pStatsSummary->MakeReadyForUse();
  92. m_pStatsSummary->UpdateStatsData();
  93. m_pAchievementsPage->UpdateAchievementDialogInfo();
  94. m_pLifetimeStatsPage->UpdateStatsData();
  95. m_pMatchStatsPage->UpdateStatsData();
  96. BaseClass::Activate();
  97. }