Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "halloween_offering_panel.h"
  8. #include "cdll_client_int.h"
  9. #include "ienginevgui.h"
  10. #include "econ_item_tools.h"
  11. #include "econ_ui.h"
  12. #include <vgui_controls/AnimationController.h>
  13. #include "clientmode_tf.h"
  14. #include "softline.h"
  15. #include "drawing_panel.h"
  16. #include "tf_item_inventory.h"
  17. // memdbgon must be the last include file in a .cpp file!!!
  18. #include <tier0/memdbgon.h>
  19. //-----------------------------------------------------------------------------
  20. // Purpose:
  21. //-----------------------------------------------------------------------------
  22. CHalloweenOfferingPanel::CHalloweenOfferingPanel( vgui::Panel *parent, CItemModelPanelToolTip* pTooltip )
  23. : BaseClass( parent, pTooltip )
  24. {
  25. }
  26. //-----------------------------------------------------------------------------
  27. // Purpose:
  28. //-----------------------------------------------------------------------------
  29. CHalloweenOfferingPanel::~CHalloweenOfferingPanel( void )
  30. {
  31. }
  32. //-----------------------------------------------------------------------------
  33. void CHalloweenOfferingPanel::CreateSelectionPanel()
  34. {
  35. CHalloweenOfferingSelectionPanel *pSelectionPanel = new CHalloweenOfferingSelectionPanel( this );
  36. m_hSelectionPanel = (CCollectionCraftingSelectionPanel*)pSelectionPanel;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. void CHalloweenOfferingPanel::OnCommand( const char *command )
  42. {
  43. if ( FStrEq( "envelopesend", command ) )
  44. {
  45. GCSDK::CProtoBufMsg<CMsgCraftHalloweenOffering> msg( k_EMsgGCCraftHalloweenOffering );
  46. // Find the Garygoyle 'tool' item for this
  47. static CSchemaItemDefHandle pItemDef_Gargoyle( "Activated Halloween Pass" );
  48. Assert( pItemDef_Gargoyle );
  49. if ( !pItemDef_Gargoyle )
  50. return;
  51. // Find out if the user owns this item or not and place in the proper bucket
  52. CPlayerInventory *pLocalInv = TFInventoryManager()->GetLocalInventory();
  53. if ( !pLocalInv )
  54. return;
  55. const CEconItemView *pRefItem = pLocalInv->FindFirstItembyItemDef( pItemDef_Gargoyle->GetDefinitionIndex() );
  56. if ( !pRefItem )
  57. return;
  58. msg.Body().set_tool_id( pRefItem->GetItemID() );
  59. FOR_EACH_VEC( m_vecItemPanels, i )
  60. {
  61. if ( m_vecItemPanels[ i ]->GetItem() == NULL )
  62. return;
  63. msg.Body().add_item_id( m_vecItemPanels[ i ]->GetItem()->GetItemID() );
  64. }
  65. // Send if off
  66. GCClientSystem()->BSendMessage( msg );
  67. m_bWaitingForGCResponse = true;
  68. m_nFoundItemID.Purge();
  69. m_timerResponse.Start( 5.f );
  70. g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( this, "CollectionCrafting_LetterSend" );
  71. return;
  72. }
  73. BaseClass::OnCommand( command );
  74. }