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.

88 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ECON_SAMPLE_ROOTUI_H
  8. #define ECON_SAMPLE_ROOTUI_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "econ_ui.h"
  13. #include "vgui_controls/Frame.h"
  14. #include "GameEventListener.h"
  15. #include "backpack_panel.h"
  16. //-----------------------------------------------------------------------------
  17. // Purpose:
  18. //-----------------------------------------------------------------------------
  19. class CEconSampleRootUI : public vgui::Frame, public IEconRootUI, public CGameEventListener
  20. {
  21. DECLARE_CLASS_SIMPLE( CEconSampleRootUI, vgui::Frame );
  22. public:
  23. CEconSampleRootUI( vgui::Panel *parent );
  24. virtual ~CEconSampleRootUI();
  25. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  26. virtual void PerformLayout( void );
  27. virtual void OnCommand( const char *command );
  28. virtual void ShowPanel( bool bShow );
  29. virtual void OnKeyCodeTyped(vgui::KeyCode code);
  30. void SetCheckForRoomOnExit( bool bCheck ) { m_bCheckForRoomOnExit = bCheck; }
  31. void FireGameEvent( IGameEvent *event );
  32. //---------------------------------------
  33. // IEconRootUI
  34. virtual IEconRootUI *OpenEconUI( int iDirectToPage = 0, bool bCheckForInventorySpaceOnExit = false );
  35. virtual void CloseEconUI( void );
  36. virtual bool IsUIPanelVisible( EconBaseUIPanels_t iPanel );
  37. virtual void SetPreventClosure( bool bPrevent ) { m_bPreventClosure = bPrevent; }
  38. // Sub panel access.
  39. // These are panels that are parented to the root EconUI.
  40. virtual CBackpackPanel *GetBackpackPanel( void ) { return NULL; }
  41. virtual CCraftingPanel *GetCraftingPanel( void ) { return NULL; }
  42. // Gamestats access
  43. virtual void Gamestats_ItemTransaction( int eventID, CEconItemView *item, const char *pszReason = NULL, int iQuality = 0 ) { return; }
  44. virtual void Gamestats_Store( int eventID, CEconItemView* item=NULL, const char* panelName=NULL,
  45. int classId=0, const cart_item_t* in_cartItem=NULL, int in_checkoutAttempts=0, const char* storeError=NULL, int in_totalPrice=0, int in_currencyCode=0 ) { return; }
  46. virtual void SetExperimentValue( uint64 experimentValue ) { return; }
  47. // Open separate economy panels (they're not parented to the root EconUI)
  48. // This is here so that games can customize the implementation of these panels.
  49. CItemPickupPanel *OpenItemPickupPanel( void );
  50. CItemDiscardPanel *OpenItemDiscardPanel( void );
  51. // Store
  52. virtual void CreateStorePanel( void );
  53. virtual CStorePanel *OpenStorePanel( int iItemDef, bool bAddToCart );
  54. virtual CStorePanel *GetStorePanel( void );
  55. // When the root UI is closed, send an "EconUIClosed" message to pListener.
  56. virtual void AddPanelCloseListener( vgui::Panel *pListener ) { AssertMsg( 0, "Implement me!" ); }
  57. // The panel at which we want back to actually close the UI - defaults to the root panel - a negative value can be passed in for class loadout panels
  58. virtual void SetClosePanel( int iPanel ) { AssertMsg( 0, "Implement me!" ); }
  59. // Call this to set which team the class loadout should display
  60. virtual void SetDefaultTeam( int iTeam ) { AssertMsg( 0, "Implement me!" ); }
  61. protected:
  62. void OpenSubPanel( EconBaseUIPanels_t nPanel );
  63. void UpdateSubPanelVisibility( void );
  64. void OpenTradingStartDialog( void );
  65. private:
  66. bool m_bPreventClosure;
  67. bool m_bCheckForRoomOnExit;
  68. EconBaseUIPanels_t m_nVisiblePanel;
  69. CBackpackPanel *m_pBackpackPanel;
  70. };
  71. #endif // ECON_SAMPLE_ROOTUI_H