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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef BACKPACK_PANEL_H
#define BACKPACK_PANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "base_loadout_panel.h"
#include "tf_item_inspection_panel.h"
#define BACKPACK_SLOTS_PER_PAGE 50
#define BACKPACK_ROWS 5
#define BACKPACK_COLUMNS (BACKPACK_SLOTS_PER_PAGE / BACKPACK_ROWS)
#define BACKPACK_MAX_PAGES (MAX_NUM_BACKPACK_SLOTS / BACKPACK_SLOTS_PER_PAGE)
class CDynamicRecipePanel;
class CItemSlotPanel;
class CStrangeCountTransferPanel;
class CCollectionCraftingPanel;
class CHalloweenOfferingPanel;
class CCraftCommonStatClockPanel;
class CTFStorePreviewItemPanel2;
//-----------------------------------------------------------------------------
// An inventory screen that handles displaying the backpack
//-----------------------------------------------------------------------------
class CBackpackPanel : public CBaseLoadoutPanel
{
DECLARE_CLASS_SIMPLE( CBackpackPanel, CBaseLoadoutPanel );
public:
CBackpackPanel( vgui::Panel *parent, const char *panelName );
virtual ~CBackpackPanel();
virtual const char *GetResFile( void ) { return "Resource/UI/econ/BackpackPanel.res"; }
virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) OVERRIDE;
virtual void ApplySettings( KeyValues *inResourceData ) OVERRIDE;
virtual void PerformLayout( void ) OVERRIDE;
virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
virtual void UpdateModelPanels( void );
virtual int GetNumItemPanels( void ) { return BACKPACK_SLOTS_PER_PAGE; };
virtual void OnShowPanel( bool bVisible, bool bReturningFromArmory );
virtual void PostShowPanel( bool bVisible );
virtual bool UsesRarityControls( void ) { return true; }
virtual bool AllowSelection( void ) { return true; }
virtual bool AllowDragging( CItemModelPanel *panel ) { return true; }
virtual int GetNumSlotsPerPage( void ) OVERRIDE { return BACKPACK_SLOTS_PER_PAGE; }
virtual int GetNumColumns( void ) OVERRIDE { return BACKPACK_COLUMNS; }
virtual int GetNumRows( void ) OVERRIDE { return BACKPACK_ROWS; }
virtual int GetNumPages( void ) OVERRIDE;
virtual void SetCurrentPage( int nNewPage ) OVERRIDE;
virtual void AssignItemToPanel( CItemModelPanel *pPanel, int iIndex );
virtual void OnItemPanelEntered( vgui::Panel *panel ) OVERRIDE;
virtual void OpenContextMenu();
MESSAGE_FUNC_PTR( OnItemPanelMousePressed, "ItemPanelMousePressed", panel );
MESSAGE_FUNC_PTR( OnItemPanelMouseReleased, "ItemPanelMouseReleased", panel );
MESSAGE_FUNC_PTR( OnItemPanelMouseRightRelease, "ItemPanelMouseRightRelease", panel );
MESSAGE_FUNC_INT_INT( OnCursorMoved, "OnCursorMoved", x, y );
MESSAGE_FUNC_INT_INT( OnItemPanelCursorMoved, "ItemPanelCursorMoved", x, y );
MESSAGE_FUNC_PARAMS( OnConfirmDelete, "ConfirmDlgResult", data );
MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
MESSAGE_FUNC_PARAMS( OnButtonChecked, "CheckButtonChecked", pData );
MESSAGE_FUNC( OnCancelSelection, "CancelSelection" );
MESSAGE_FUNC( DoTradeToPlayer, "DoTradeToPlayer" );
MESSAGE_FUNC( DoSellMarketplace, "DoSellMarketplace" );
MESSAGE_FUNC( DoDescription, "DoDescription" );
MESSAGE_FUNC( DoRename, "DoRename" );
MESSAGE_FUNC( DoDelete, "DoDelete" );
MESSAGE_FUNC( DoApplyOnItem, "Context_ApplyOnItem" );
MESSAGE_FUNC( DoUseConsumableItem, "Context_UseConsumableItem" );
MESSAGE_FUNC( DoUnwrapItem, "Context_UnwrapItem" );
MESSAGE_FUNC( DoDeliverItem, "Context_DeliverItem" );
MESSAGE_FUNC( DoApplyByItem, "Context_ApplyByItem" );
MESSAGE_FUNC( DoShuffle, "Context_Shuffle" );
MESSAGE_FUNC( DoEditSlot, "Context_EditSlot" );
MESSAGE_FUNC( DoRefurbishItem, "Context_RefurbishItem" );
MESSAGE_FUNC( DoGetItemFromStore, "Context_GetItemFromStore" );
MESSAGE_FUNC( DoOpenDuckLeaderboards, "Context_OpenDuckLeaderboards" );
MESSAGE_FUNC( DoInspectModel, "Context_InspectModel" );
MESSAGE_FUNC( DoBuyKeyAndOpenCrate, "Context_BuyKeyAndOpenCrate" );
MESSAGE_FUNC( DoOpenCrateWithKey, "Context_OpenCrateWithKey" );
MESSAGE_FUNC( DoStrangeCountTransfer, "Context_OpenStrangeCountTransfer" );
MESSAGE_FUNC( DoCraftUpCollection, "Context_CraftUpCollection" );
MESSAGE_FUNC( DoHalloweenOffering, "Context_HalloweenOffering" );
MESSAGE_FUNC( DoCraftCommonStatClock, "Context_CraftCommonStatClock" );
void DoEquipForClass( int nClass );
void DoPaint( int nPaintItemIndex, bool bUseStore, bool bUseMarket );
void DoStrangePart( int nStrangePartIndex, bool bUseMarket );
enum ESelection
{
SELECT_FIRST,
SELECT_ALL
};
bool AttemptToUseItem( item_definition_index_t iItemDefIndex );
void AttemptToShowItemInStore( item_definition_index_t iItemDefIndex );
void AttemptToShowItemInMarket( item_definition_index_t iItemDefIndex );
void GetSelectedPanels( ESelection eSelection, CUtlVector< CItemModelPanel* >& m_vecSelected ) const;
virtual void OnCommand( const char *command );
virtual void OnTick( void );
virtual void OnThink( void );
virtual void OnKeyCodePressed( vgui::KeyCode code ) OVERRIDE;
virtual void OnKeyCodeReleased( vgui::KeyCode code ) OVERRIDE;
virtual void OnKeyCodeTyped(vgui::KeyCode code) OVERRIDE;
virtual void OnMouseReleased(vgui::MouseCode code) OVERRIDE;
virtual void OnMouseMismatchedRelease( vgui::MouseCode code, Panel* pPressedPanel ) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
void OnItemContentsChanged( CEconItemView *pEconItemView );
virtual void OpenArmory( CEconItemView* item );
void ToggleSelectBackpackItemPanel( CItemModelPanel *pPanel );
void DeSelectAllBackpackItemPanels( void );
CEconItemView* GetComboBoxOverlayUISeletionItem() { return &m_ComboBoxOverlaySelectionItem; }
void SetComboBoxOverlaySelectionItem( const CEconItemView *pEconItemView ) { m_ComboBoxOverlaySelectionItem = *pEconItemView; }
void SetCurrentTransactionID( uint64 nTxnID );
void CheckForQuickOpenKey();
void MarkItemIDDirty( itemid_t itemID );
void OpenInspectModelPanelAndCopyItem( CEconItemView *pItemView );
CCollectionCraftingPanel *GetCollectionCraftPanel();
protected:
virtual void StartDrag( int x, int y );
virtual void StopDrag( bool bSucceeded );
virtual bool CanDragTo( CItemModelPanel *pItemPanel, int iPanelIndex ) { return true; }
virtual void HandleDragTo( CItemModelPanel *pItemPanel, int iPanelIndex );
virtual int GetBackpackPosForPanelIndex( int iPanelIndex ) { return iPanelIndex + 1 + (GetCurrentPage() * GetNumSlotsPerPage()); }
virtual bool NeedsDerivedTickSignal( void ) { return false; }
int GetBackpackPositionForPanel( CItemModelPanel *pItemPanel );
virtual const char *GetGreyOutItemPanelReason( CItemModelPanel *pItemPanel );
virtual void SetBorderForItem( CItemModelPanel *pItemPanel, bool bMouseOver );
virtual bool IsIgnoringItemPanelEnters( void ) { return m_bDragging; }
virtual void AddNewItemPanel( int iPanelIndex );
virtual CItemModelPanel *GetItemPanelAtPos( int x, int y );
virtual void PositionItemPanel( CItemModelPanel *pPanel, int iIndex );
void CancelToolSelection( void );
void SetShowBaseItems( bool bShow );
virtual ConVar *GetExplanationConVar( void );
bool ShouldShowExplanations( void ) { return (!m_bItemsOnly && !InToolSelectionMode()); }
bool InToolSelectionMode() const { return m_eSelectionMode != StandardSelection; }
void SetupToolSelectionItem();
void HandleToolItemSelection( CEconItemView *pItem );
void ClearNameFilter( bool bUpdateModelPanels );
bool HasNameFilter() const { return m_wNameFilter.Count() > 0; }
const wchar_t* GetNameFilter() const { return HasNameFilter() ? m_wNameFilter.Base() : NULL; }
void UpdateFilteringItems();
int GetItemQualityForBorder( CItemModelPanel* pItemPanel ) const;
int GetNumMaxPages() const { return BACKPACK_MAX_PAGES; }
int GetPageButtonIndexAtPos( int x, int y );
void SetPageButtonTextColorBasedOnContents();
void AddPaintToContextMenu( Menu *pPaintSubMenu, item_definition_index_t iPaintDef, bool bAddCommerce );
void AddCommerceToContextMenu( Menu *pMenu, const char* pszActionFmt, item_definition_index_t iItemDefIndex, bool bAddMarket, bool bAddStore );
void AddCommerceSubmenus( Menu *pSubMenu, item_definition_index_t iItemDef, const char* pszActionFmt );
void DoGiftToPlayer( );
protected:
vgui::TextEntry *m_pNameFilterTextEntry;
CUtlVector<wchar_t> m_wNameFilter;
float m_flFilterItemTime;
CUtlMap< int, CEconItemView*, int > m_mapFilteringItems;
CUtlMap< itemid_t, char > m_mapSeenItems;
bool m_bInitializedSeenItems;
CUtlVector< itemid_t > m_vecDirtyItems;
CExButton *m_pNextPageButton;
CExButton *m_pPrevPageButton;
CExButton *m_pShowExplanationsButton;
vgui::Label *m_pCurPageLabel;
vgui::ComboBox *m_pSortByComboBox;
vgui::ComboBox *m_pShowRarityComboBox;
vgui::CheckButton *m_pShowBaseItemsCheckbox;
CExButton *m_pDragToNextPageButton;
CExButton *m_pDragToPrevPageButton;
float m_flPreventDragPageSwitchUntil;
float m_flStartExplanationsAt;
// Dragging support
float m_flMouseDownTime;
int m_iMouseDownX;
int m_iMouseDownY;
CItemModelPanel *m_pItemDraggedFromPanel;
int m_iDraggedFromPage;
bool m_bMouseDownOnItemPanel;
bool m_bDragging;
CItemModelPanel *m_pMouseDragItemPanel;
int m_iDragOffsetX;
int m_iDragOffsetY;
CItemModelPanel *m_pPrevDragOverItemPanel;
// Deletion
vgui::EditablePanel *m_pConfirmDeleteDialog;
// Tool support
enum SelectionMode_t
{
StandardSelection,
ToolSelection,
};
SelectionMode_t m_eSelectionMode;
int m_nLastToolPage;
CEconItemView m_ToolSelectionItem;
CExButton *m_pCancelToolButton;
vgui::ScalableImagePanel *m_pToolIcon;
CEconItemView m_ComboBoxOverlaySelectionItem;
CExButton *m_pCraftButton;
// base items or backpack items
bool m_bShowBaseItems;
// positions of all our item panels, so we can handle drag & drop
struct backpackitempos_t
{
int x,y;
};
CUtlVector<backpackitempos_t> m_ItemModelPanelPos;
KeyValues *m_pPageButtonKVs;
int m_nNumActivePages;
CUtlVector< EditablePanel* > m_Pages;
CUtlVector<backpackitempos_t> m_PageButtonPos;
CDynamicRecipePanel* m_pDynamicRecipePanel;
CItemSlotPanel* m_pItemSlotPanel;
CUtlVector< item_definition_index_t > m_vecPaintCans;
CUtlVector< item_definition_index_t > m_vecStrangeParts;
DHANDLE<CStrangeCountTransferPanel> m_pStrangeToolPanel;
DHANDLE<CCollectionCraftingPanel> m_pCollectionCraftPanel;
DHANDLE<CHalloweenOfferingPanel> m_pHalloweenOfferingPanel;
DHANDLE<CCraftCommonStatClockPanel> m_pMannCoTradePanel; // Make this Panel Generic
CTFItemInspectionPanel *m_pInspectPanel;
CTFStorePreviewItemPanel2 *m_pInspectCosmeticPanel;
vgui::Menu *m_pContextMenu;
CEconItemViewHandle m_hQuickOpenCrate;
uint64 m_nQuickOpenTxn;
CPanelAnimationVarAliasType( int, m_iPageButtonYPos, "page_button_y", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iPageButtonXDelta, "page_button_x_delta", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iPageButtonYDelta, "page_button_y_delta", "0", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iPageButtonPerRow, "page_button_per_row", "20", "int" );
CPanelAnimationVarAliasType( int, m_iPageButtonHeight, "page_button_height", "0", "proportional_int" );
};
#endif // BACKPACK_PANEL_H
|