summaryrefslogtreecommitdiff
path: root/game/client/cstrike/VGUI/achievement_stats_summary.cpp
blob: 81ef2983732a61d7453c6f9b9e778e6602fe675e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "achievement_stats_summary.h"
#include "achievements_page.h"
#include "lifetime_stats_page.h"
#include "match_stats_page.h"
#include "stats_summary.h"

#include <stdio.h>

using namespace vgui;

#include <vgui/ILocalize.h>
#include "vgui/ISurface.h"

#include "filesystem.h"
#include <KeyValues.h>

// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>


const int cDialogWidth = 900;


//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CAchievementAndStatsSummary::CAchievementAndStatsSummary(vgui::Panel *parent) : BaseClass(parent, "AchievementAndStatsSummary")
{
    SetDeleteSelfOnClose(false);
    //SetBounds(0, 0, 640, 384);
    SetBounds(0, 0, 900, 780);
    SetMinimumSize( 640, 780 );
    SetSizeable( false );

    SetTitle("#GameUI_CreateAchievementsAndStats", true);
    SetOKButtonText("#GameUI_Close");
    SetCancelButtonVisible(false);

	m_pStatsSummary = new CStatsSummary( this, "StatsSummary" );
    m_pAchievementsPage = new CAchievementsPage(this, "AchievementsPage");
    m_pLifetimeStatsPage = new CLifetimeStatsPage(this, "StatsPage");
	m_pMatchStatsPage = new CMatchStatsPage(this, "MatchStatsPage");

	AddPage(m_pStatsSummary, "#GameUI_Stats_Summary");
	AddPage(m_pAchievementsPage, "#GameUI_Achievements_Tab");    
	AddPage(m_pMatchStatsPage, "#GameUI_MatchStats");
	AddPage(m_pLifetimeStatsPage, "#GameUI_LifetimeStats");
}

//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CAchievementAndStatsSummary::~CAchievementAndStatsSummary()
{
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CAchievementAndStatsSummary::ApplySchemeSettings( vgui::IScheme *pScheme )
{
	BaseClass::ApplySchemeSettings( pScheme );

	int screenWide, screenTall;
	surface()->GetScreenSize( screenWide, screenTall );

	// [smessick] Close the achievements dialog for a low resolution screen.
	if ( screenWide < cAchievementsDialogMinWidth )
	{
		OnOK( true );
		Close();
	}
}

//-----------------------------------------------------------------------------
// Purpose: runs the server when the OK button is pressed
//-----------------------------------------------------------------------------
bool CAchievementAndStatsSummary::OnOK(bool applyOnly)
{
    BaseClass::OnOK(applyOnly);

    return true;
}

//----------------------------------------------------------
// Purpose: Preserve our width to the one in the .res file
//----------------------------------------------------------
void CAchievementAndStatsSummary::OnSizeChanged(int newWide, int newTall)
{
    // Lock the width, but allow height scaling
    if ( newWide != cDialogWidth )
    {
        SetSize( cDialogWidth, newTall );
        return;
    }

    BaseClass::OnSizeChanged(newWide, newTall);
}

//----------------------------------------------------------
// Purpose: Processes when summary dialog is activated.
//----------------------------------------------------------
void CAchievementAndStatsSummary::Activate()
{
	m_pStatsSummary->MakeReadyForUse();
	m_pStatsSummary->UpdateStatsData();
    m_pAchievementsPage->UpdateAchievementDialogInfo();
    m_pLifetimeStatsPage->UpdateStatsData();
	m_pMatchStatsPage->UpdateStatsData();

    BaseClass::Activate();
}