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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
#include "cbase.h"
#include "econ_item_tools.h"
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
const char *IEconTool::GetUseCommandLocalizationToken( const IEconItemInterface *pItem, int i ) const
{
Assert( i == 0 ); // Default only has 1 use, so this should be 0.
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
// If we have a custom schema-specified use string, use that.
return GetUseString();
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
const char* IEconTool::GetUseCommand( const IEconItemInterface *pItem, int i ) const
{
Assert( i == 0 ); // Default only has 1 use, so this should be 0.
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
const bool bIsGCConsumable = ( ( pItem->GetItemDefinition()->GetCapabilities() & ITEM_CAP_USABLE_GC ) != 0 );
return bIsGCConsumable ? "Context_UseConsumableItem" : "Context_ApplyOnItem";
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
bool IsLocalPlayerWrappedGift( const IEconItemInterface *pItem )
{
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetTypedEconTool<CEconTool_WrappedGift>() );
static CSchemaAttributeDefHandle pAttr_GifterAccountID( "gifter account id" );
uint32 unGifterAccountID;
if ( !pItem->FindAttribute( pAttr_GifterAccountID, &unGifterAccountID ) )
return false;
const uint32 unLocalAccountID = steamapicontext->SteamUser()->GetSteamID().GetAccountID();
return unGifterAccountID == unLocalAccountID;
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
bool CEconTool_WrappedGift::CanBeUsedNow( const IEconItemInterface *pItem ) const
{
static CSchemaItemDefHandle pItemDef_WrappedGiftapultPackage( "Wrapped Giftapult Package" );
static CSchemaItemDefHandle pItemDef_DeliveredGiftapultPackage( "Delivered Giftapult Package" );
static CSchemaItemDefHandle pItemDef_CompetitiveBetaPassGift( "Competitive Matchmaking Beta Giftable Invite" );
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
if ( ( pItem->GetItemDefinition() == pItemDef_WrappedGiftapultPackage ) ||
( pItem->GetItemDefinition() == pItemDef_CompetitiveBetaPassGift ) ||
( pItem->GetItemDefinition() == pItemDef_DeliveredGiftapultPackage ) )
return true;
return pItem->IsTradable();
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
bool CEconTool_WrappedGift::ShouldShowContainedItemPanel( const IEconItemInterface *pItem ) const
{
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
return IsLocalPlayerWrappedGift( pItem );
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
const char *CEconTool_WrappedGift::GetUseCommandLocalizationToken( const IEconItemInterface *pItem, int i ) const
{
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
Assert( i == 0 || ( IsLocalPlayerWrappedGift( pItem ) && i == 1 ) );
// NOTE! Keep in sync with CEconTool_WrappedGift::GetUseCommand
if ( BIsDirectGift() ||
( IsLocalPlayerWrappedGift( pItem ) && i == 0 ) )
return "#DeliverGift";
return "#UnwrapGift";
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
int CEconTool_WrappedGift::GetUseCommandCount( const IEconItemInterface *pItem ) const
{
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
if ( IsLocalPlayerWrappedGift( pItem ) )
return 2;
return 1;
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
const char* CEconTool_WrappedGift::GetUseCommand( const IEconItemInterface *pItem, int i ) const
{
// NOTE! Keep in sync with CEconTool_WrappedGift::GetUseCommandLocalizationToken
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
Assert( i == 0 || ( IsLocalPlayerWrappedGift( pItem ) && i == 1 ) );
// NOTE! Keep in sync with CEconTool_WrappedGift::GetUseCommand
if ( BIsDirectGift() ||
( IsLocalPlayerWrappedGift( pItem ) && i == 0 ) )
return "Context_DeliverItem";
return "Context_UnwrapItem";
}
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
const char *CEconTool_WeddingRing::GetUseCommandLocalizationToken( const IEconItemInterface *pItem, int i ) const
{
Assert( i == 0 ); // We only have one action.
Assert( pItem );
Assert( pItem->GetItemDefinition() );
Assert( pItem->GetItemDefinition()->GetEconTool() == this );
// If the wedding ring has been gifted to us, we can use it to accept/reject the proposal.
// If it hasn't been gifted we can't use it at all.
static CSchemaAttributeDefHandle pAttrDef_GifterAccountID( "gifter account id" );
if ( !pItem->FindAttribute( pAttrDef_GifterAccountID ) )
return NULL;
return "#ToolAction_WeddingRing_AcceptReject";
}
#ifndef TF_CLIENT_DLL
//---------------------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------------------
void CEconTool_Noisemaker::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_Noisemaker::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_WrappedGift::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_WrappedGift::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_WeddingRing::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_WeddingRing::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_BackpackExpander::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_BackpackExpander::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_AccountUpgradeToPremium::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_AccountUpgradeToPremium::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_ClaimCode::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_ClaimCode::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_Collection::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_Collection::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_StrangifierBase::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_StrangifierBase::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_PaintCan::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_PaintCan::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_Gift::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_Gift::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_DuelingMinigame::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_DuelingMinigame::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
void CEconTool_DuckToken::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_DuckToken::OnClientUseConsumable() is unimplemented!" );
}
//-----------------------------------------------------------------------------
void CEconTool_GrantOperationPass::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_DuckToken::CEconTool_GrantOperationPass() is unimplemented!" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CEconTool_Default::OnClientUseConsumable( CEconItemView *pItem, vgui::Panel *pParent ) const
{
Assert( !"CEconTool_Default::OnClientUseConsumable() is unimplemented!" );
}
#endif // !defined( TF_CLIENT_DLL )
|