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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Wave Loss Screen for MvM
//
// $NoKeywords: $
//=============================================================================
#include "cbase.h"
#include "tf_hud_mann_vs_machine_loss.h"
using namespace vgui;
#ifdef STAGING_ONLY
ConVar tf_tips_show_captain_canteen( "tf_tips_show_captain_canteen", 0, FCVAR_NONE, "Show Captain Canteen when displaying tips" );
#endif
const char *g_pszInactiveClassPortraits[] =
{
"", // TF_CLASS_UNDEFINED = 0,
"class_sel_sm_scout_inactive",
"class_sel_sm_soldier_inactive",
"class_sel_sm_pyro_inactive",
"class_sel_sm_demo_inactive",
"class_sel_sm_heavy_inactive",
"class_sel_sm_engineer_inactive",
"class_sel_sm_medic_inactive",
"class_sel_sm_sniper_inactive",
"class_sel_sm_spy_inactive",
"class_sel_sm_random_inactive", // Random
};
//-----------------------------------------------------------------------------
// CMvMVictoryPanelContainer
//-----------------------------------------------------------------------------
DECLARE_BUILD_FACTORY( CMvMWaveLossPanel );
CMvMWaveLossPanel::CMvMWaveLossPanel( Panel *parent, const char *pName ) : vgui::EditablePanel( parent, pName )
{
SetMouseInputEnabled( true );
MakePopup();
MoveToFront();
m_pVoteButton = new CExImageButton( this, "VoteButton", g_pVGuiLocalize->Find( "#TF_PVE_Vote_MissionRestart" ), this );
m_pCloseButton = new CExImageButton( this, "ContinueButton", g_pVGuiLocalize->Find( "#ConfirmButtonText" ), this );
m_pHintContainer = NULL;
m_pCollectionContainer = NULL;
m_pUsageContainer = NULL;
m_pCaptainCanteenBody = NULL;
m_pCaptainCanteenMisc = NULL;
m_pCaptainCanteenHat = NULL;
m_pHintImage1 = NULL;
m_pHintImage2 = NULL;
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
// load control settings...
LoadControlSettings( "resource/UI/MvMWaveLossPanel.res" );
m_pHintContainer = dynamic_cast<vgui::EditablePanel*>( FindChildByName( "HintContainer" ) );
m_pCollectionContainer = dynamic_cast<vgui::EditablePanel*>( FindChildByName( "CollectionContainer" ) );
m_pUsageContainer = dynamic_cast<vgui::EditablePanel*>( FindChildByName( "UsageContainer" ) );
if ( m_pHintContainer )
{
m_pCaptainCanteenBody = dynamic_cast<vgui::ImagePanel*>( m_pHintContainer->FindChildByName( "CptCntnBody" ) );
m_pCaptainCanteenMisc = dynamic_cast<vgui::ImagePanel*>( m_pHintContainer->FindChildByName( "CptCntnMisc" ) );
m_pCaptainCanteenHat = dynamic_cast<vgui::ImagePanel*>( m_pHintContainer->FindChildByName( "CptCntnHat" ) );
m_pHintImage1 = dynamic_cast<vgui::ImagePanel*>( m_pHintContainer->FindChildByName( "HintImage1" ) );
m_pHintImage2 = dynamic_cast<vgui::ImagePanel*>( m_pHintContainer->FindChildByName( "HintImage2" ) );
}
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::FireGameEvent( IGameEvent * event )
{
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::OnTick( void )
{
if ( !IsVisible() )
return;
if ( TFObjectiveResource() && !TFObjectiveResource()->GetMannVsMachineIsBetweenWaves() )
{
// Close it if the mission starts
SetMouseInputEnabled( false );
SetVisible( false );
}
// Display Credit Usage Stats
CMannVsMachineStats *pMVMStats = MannVsMachineStats_GetInstance();
if ( pMVMStats != NULL )
{
if ( m_pCollectionContainer )
{
m_pCollectionContainer->SetDialogVariable( "creditscollected", (int)pMVMStats->GetAcquiredCredits( -1, false ) );
m_pCollectionContainer->SetDialogVariable( "creditsmissed", (int)pMVMStats->GetMissedCredits( -1 ) );
m_pCollectionContainer->SetDialogVariable( "creditbonus", (int)pMVMStats->GetBonusCredits( -1 ) );
}
if ( m_pUsageContainer )
{
// Local Player
m_pUsageContainer->SetDialogVariable( "buybacksyou", (int)pMVMStats->GetLocalPlayerBuyBackSpending( -1 ) );
m_pUsageContainer->SetDialogVariable( "bottlesyou", (int)pMVMStats->GetLocalPlayerBottleSpending( -1 ) );
int nTotalUpgradeCosts = (int)pMVMStats->GetLocalPlayerUpgradeSpending( -1 );
CSteamID steamID;
int nActiveUpgradeCosts = 0;
if ( C_TFPlayer::GetLocalTFPlayer()->GetSteamID( &steamID ) )
{
nActiveUpgradeCosts = (int)pMVMStats->GetPlayerActiveUpgradeCosts( steamID.ConvertToUint64() );
}
m_pUsageContainer->SetDialogVariable( "inactiveupgradesyou", nTotalUpgradeCosts - nActiveUpgradeCosts );
// Team
nTotalUpgradeCosts = (int)pMVMStats->GetUpgradeSpending();
nActiveUpgradeCosts = (int)pMVMStats->GetPlayerActiveUpgradeCosts( 0 );
m_pUsageContainer->SetDialogVariable( "buybacksteam", (int)pMVMStats->GetBuyBackSpending() );
m_pUsageContainer->SetDialogVariable( "bottlesteam", (int)pMVMStats->GetBottleSpending() );
m_pUsageContainer->SetDialogVariable( "inactiveupgradesteam", nTotalUpgradeCosts - nActiveUpgradeCosts );
}
}
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::OnCommand( const char *command )
{
if ( !Q_stricmp( command, "vote_restart" ) )
{
engine->ClientCmd( "callvote RestartGame;" );
SetMouseInputEnabled( false );
SetVisible( false );
}
else if ( !Q_stricmp( command, "continue" ) )
{
SetMouseInputEnabled( false );
SetVisible( false );
}
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::ShowPanel()
{
SetVisible( true );
SetKeyBoardInputEnabled( false );
SetMouseInputEnabled( true );
MoveToFront();
ClearContents();
if ( TFObjectiveResource() )
{
// Get the WaveNumber
int iWaveNumber = TFObjectiveResource()->GetMannVsMachineWaveCount();
wchar_t wszWaveNumber[16];
_snwprintf( wszWaveNumber, ARRAYSIZE( wszWaveNumber ), L"%d", MAX( 1, iWaveNumber ) );
wchar_t wszLocalizedWave[512];
g_pVGuiLocalize->ConstructString_safe( wszLocalizedWave, g_pVGuiLocalize->Find( "#TF_PVE_WaveCountFail" ), 1, wszWaveNumber );
SetDialogVariable( "waveheader", wszLocalizedWave );
// Pop file
char szTempName[MAX_PATH];
V_FileBase( TFObjectiveResource()->GetMvMPopFileName(), szTempName, sizeof( szTempName ) );
int iChallengeIndex = GetItemSchema()->FindMvmMissionByName( szTempName );
wchar_t wszLocalizedSummary[ MAX_PATH ];
if ( GetItemSchema()->GetMvmMissions().IsValidIndex( iChallengeIndex ) )
{
const MvMMission_t &mission = GetItemSchema()->GetMvmMissions()[ iChallengeIndex ];
g_pVGuiLocalize->ConstructString_safe( wszLocalizedSummary, g_pVGuiLocalize->Find( "#TF_PVE_MissionSummaryScheme" ), 2,
g_pVGuiLocalize->Find( mission.m_sDisplayName.Get() ), g_pVGuiLocalize->Find( mission.m_sMode.Get() ) );
}
else
{
wchar_t wszName[256];
g_pVGuiLocalize->ConvertANSIToUnicode( GetMapDisplayName( szTempName ), wszName, sizeof(wszName) );
g_pVGuiLocalize->ConstructString_safe( wszLocalizedSummary, g_pVGuiLocalize->Find( "#TF_PVE_MissionSummaryDefault" ), 1,
wszName );
}
SetDialogVariable( "summaryheader", wszLocalizedSummary );
}
// Tips
if ( m_pHintContainer )
{
int iClassUsed;
m_pHintContainer->SetDialogVariable( "hint1", g_TFTips.GetRandomMvMTip( iClassUsed ) );
#ifdef STAGING_ONLY
bool bShowCaptainCanteen = tf_tips_show_captain_canteen.GetBool();
if ( tf_tips_show_captain_canteen.GetInt() > 1 )
{
// Force Captain Canteen on to test
iClassUsed = TF_LAST_NORMAL_CLASS;
}
#else
bool bShowCaptainCanteen = false;
#endif
if ( m_pHintImage1 )
{
SetHintImage( m_pHintImage1, iClassUsed, bShowCaptainCanteen );
}
// Make sure we only use captain canteen once
bool bUsedCaptainCanteen = ( iClassUsed == TF_LAST_NORMAL_CLASS );
m_pHintContainer->SetDialogVariable( "hint2", g_TFTips.GetRandomMvMTip( iClassUsed ) );
if ( m_pHintImage2 )
{
SetHintImage( m_pHintImage2, iClassUsed, bShowCaptainCanteen && !bUsedCaptainCanteen );
}
if ( !bUsedCaptainCanteen && iClassUsed != TF_LAST_NORMAL_CLASS )
{
// We didn't use captain canteen, hide him
if ( m_pCaptainCanteenBody )
{
m_pCaptainCanteenBody->SetVisible( false );
}
if ( m_pCaptainCanteenMisc )
{
m_pCaptainCanteenMisc->SetVisible( false );
}
if ( m_pCaptainCanteenHat )
{
m_pCaptainCanteenHat->SetVisible( false );
}
}
}
/*waveheader
summaryheader
creditscollected
creditsmissed
creditbonus
buybacks
bottles
activeupgrades
inactiveupgrades
hint1
hint2*/
}
void CMvMWaveLossPanel::SetCaptainCanteenImage( vgui::ImagePanel *panel, const char *pchImage, int nNewX )
{
if ( !panel )
return;
int nX, nY;
panel->SetVisible( true );
panel->SetImage( pchImage );
panel->GetPos( nX, nY );
panel->SetPos( nNewX, nY );
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::SetHintImage( vgui::ImagePanel *panel, int iClassUsed, bool bAllowCaptainCanteen )
{
if ( !panel )
return;
if ( bAllowCaptainCanteen && iClassUsed == TF_LAST_NORMAL_CLASS )
{
// Hide the normal tip image
panel->SetVisible( false );
// Get the asset images
const char *pchCaptainCanteenBody;
const char *pchCaptainCanteenMisc;
const char *pchCaptainCanteenHat;
g_TFTips.GetRandomCaptainCanteenImages( &pchCaptainCanteenBody, &pchCaptainCanteenMisc, &pchCaptainCanteenHat );
// Get the destination X position
int nX, nY;
panel->GetPos( nX, nY );
// Set up the canteen images
if ( m_pCaptainCanteenBody )
{
SetCaptainCanteenImage( m_pCaptainCanteenBody, pchCaptainCanteenBody, nX );
}
if ( m_pCaptainCanteenMisc )
{
SetCaptainCanteenImage( m_pCaptainCanteenMisc, pchCaptainCanteenMisc, nX );
}
if ( m_pCaptainCanteenHat )
{
SetCaptainCanteenImage( m_pCaptainCanteenHat, pchCaptainCanteenHat, nX );
}
}
else
{
panel->SetVisible( true );
panel->SetImage( g_pszInactiveClassPortraits[ iClassUsed ] );
}
}
//-----------------------------------------------------------------------------
void CMvMWaveLossPanel::ClearContents()
{
SetDialogVariable( "waveheader", "" );
SetDialogVariable( "summaryheader", "" );
if ( m_pCollectionContainer )
{
m_pCollectionContainer->SetDialogVariable( "creditscollected", "" );
m_pCollectionContainer->SetDialogVariable( "creditsmissed", "" );
m_pCollectionContainer->SetDialogVariable( "creditbonus", "" );
}
if ( m_pUsageContainer )
{
m_pUsageContainer->SetDialogVariable( "buybacksyou", "" );
m_pUsageContainer->SetDialogVariable( "bottlesyou", "" );
m_pUsageContainer->SetDialogVariable( "activeupgradesyou", "" );
m_pUsageContainer->SetDialogVariable( "inactiveupgradesyou", "" );
m_pUsageContainer->SetDialogVariable( "buybacksteam", "" );
m_pUsageContainer->SetDialogVariable( "bottlesteam", "" );
m_pUsageContainer->SetDialogVariable( "activeupgradesteam", "" );
m_pUsageContainer->SetDialogVariable( "inactiveupgradesteam", "" );
}
// Tips
if ( m_pHintContainer )
{
m_pHintContainer->SetDialogVariable( "hint1", "" );
m_pHintContainer->SetDialogVariable( "hint2", "" );
}
}
|