summaryrefslogtreecommitdiff
path: root/game/client/tf/vgui/halloween_offering_panel.cpp
blob: 9cc3d1c8ffd53311d17dbbd587a40eb5cfcf9988 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//

#include "cbase.h"
#include "halloween_offering_panel.h"
#include "cdll_client_int.h"
#include "ienginevgui.h"
#include "econ_item_tools.h"
#include "econ_ui.h"
#include <vgui_controls/AnimationController.h>
#include "clientmode_tf.h"
#include "softline.h"
#include "drawing_panel.h"
#include "tf_item_inventory.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>


//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CHalloweenOfferingPanel::CHalloweenOfferingPanel( vgui::Panel *parent, CItemModelPanelToolTip* pTooltip ) 
	: BaseClass( parent, pTooltip )
{
	
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
CHalloweenOfferingPanel::~CHalloweenOfferingPanel( void )
{

}

//-----------------------------------------------------------------------------
void CHalloweenOfferingPanel::CreateSelectionPanel()
{
	CHalloweenOfferingSelectionPanel *pSelectionPanel = new CHalloweenOfferingSelectionPanel( this );
	m_hSelectionPanel = (CCollectionCraftingSelectionPanel*)pSelectionPanel;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHalloweenOfferingPanel::OnCommand( const char *command )
{
	if ( FStrEq( "envelopesend", command ) )
	{
		GCSDK::CProtoBufMsg<CMsgCraftHalloweenOffering> msg( k_EMsgGCCraftHalloweenOffering );

		// Find the Garygoyle 'tool' item for this
		static CSchemaItemDefHandle pItemDef_Gargoyle( "Activated Halloween Pass" );
		Assert( pItemDef_Gargoyle );
		if ( !pItemDef_Gargoyle )
			return;
		// Find out if the user owns this item or not and place in the proper bucket
		CPlayerInventory *pLocalInv = TFInventoryManager()->GetLocalInventory();
		if ( !pLocalInv )
			return;

		const CEconItemView *pRefItem = pLocalInv->FindFirstItembyItemDef( pItemDef_Gargoyle->GetDefinitionIndex() );
		if ( !pRefItem )
			return;

		msg.Body().set_tool_id( pRefItem->GetItemID() );

		FOR_EACH_VEC( m_vecItemPanels, i )
		{
			 if ( m_vecItemPanels[ i ]->GetItem() == NULL )
				 return;

			msg.Body().add_item_id( m_vecItemPanels[ i ]->GetItem()->GetItemID() );
		}
		 // Send if off
		GCClientSystem()->BSendMessage( msg );

		m_bWaitingForGCResponse = true;
		m_nFoundItemID.Purge();
		m_timerResponse.Start( 5.f );
		g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "CollectionCrafting_LetterSend" );	
		return;
	}

	BaseClass::OnCommand( command );
}