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.

108 lines
3.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_GIVEAWAYITEMPANEL_H
  8. #define TF_GIVEAWAYITEMPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Panel.h>
  13. #include <vgui_controls/Frame.h>
  14. #include <game/client/iviewport.h>
  15. #include "GameEventListener.h"
  16. #include "basemodel_panel.h"
  17. #include "basemodelpanel.h"
  18. #include "tf_shareddefs.h"
  19. #include "econ_item_inventory.h"
  20. #include "econ_item_view.h"
  21. #include "item_model_panel.h"
  22. #include "c_tf_player.h"
  23. class CEconItemView;
  24. //-----------------------------------------------------------------------------
  25. // Purpose:
  26. //-----------------------------------------------------------------------------
  27. class CGiveawayPlayerPanel : public vgui::EditablePanel
  28. {
  29. DECLARE_CLASS_SIMPLE( CGiveawayPlayerPanel, vgui::EditablePanel );
  30. public:
  31. CGiveawayPlayerPanel( vgui::Panel *parent, const char *name );
  32. virtual void PerformLayout( void );
  33. void SetPlayer( CTFPlayer *pPlayer );
  34. int GetPlayerIndex( void ) { return m_iPlayerIndex; }
  35. int GetBonus( void ) { return m_iBonus; }
  36. void SpinBonus( void );
  37. void LockBonus( int iRoll );
  38. private:
  39. vgui::Label *m_pNameLabel;
  40. vgui::Label *m_pScoreLabel;
  41. Color m_PlayerColorLocal;
  42. Color m_PlayerColorOther;
  43. int m_iBonus;
  44. int m_iRoll;
  45. int m_iPlayerIndex;
  46. };
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. class CTFGiveawayItemPanel : public vgui::Frame, public IViewPortPanel, public CGameEventListener
  51. {
  52. DECLARE_CLASS_SIMPLE( CTFGiveawayItemPanel, vgui::Frame );
  53. public:
  54. CTFGiveawayItemPanel( IViewPort *pViewPort );
  55. ~CTFGiveawayItemPanel( void );
  56. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  57. virtual void ApplySettings( KeyValues *inResourceData );
  58. virtual void PerformLayout( void );
  59. virtual void OnCommand( const char *command );
  60. virtual void FireGameEvent( IGameEvent *event );
  61. void SetItem( CEconItemView *pItem );
  62. void BuildPlayerList( void );
  63. // IViewPortPanel overrides
  64. virtual const char *GetName( void ){ return PANEL_GIVEAWAY_ITEM; }
  65. virtual void SetData( KeyValues *data ) { return; }
  66. virtual void Reset(){ Update(); }
  67. virtual void Update();
  68. virtual void ShowPanel( bool bShow );
  69. virtual bool NeedsUpdate( void ){ return true; }
  70. virtual bool HasInputElements( void ){ return true; }
  71. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  72. vgui::VPANEL GetVPanel( void ){ return BaseClass::GetVPanel(); }
  73. virtual bool IsVisible(){ return BaseClass::IsVisible(); }
  74. virtual void SetParent( vgui::VPANEL parent ){ BaseClass::SetParent( parent ); }
  75. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_MENUCONTROLS; }
  76. private:
  77. IViewPort *m_pViewPort;
  78. CItemModelPanel *m_pModelPanel;
  79. CUtlVector< CGiveawayPlayerPanel * > m_aPlayerList;
  80. KeyValues *m_pPlayerListPanelKVs;
  81. int m_iNumActivePlayers;
  82. // Animation
  83. bool m_bBuiltPlayerList;
  84. float m_flNextRollStart;
  85. int m_iRollingForPlayer;
  86. CPanelAnimationVarAliasType( int, m_iPlayerYPos, "player_ypos", "0", "proportional_int" );
  87. CPanelAnimationVarAliasType( int, m_iPlayerXOffset, "player_xoffset", "0", "proportional_int" );
  88. };
  89. CTFGiveawayItemPanel *OpenGiveawayItemPanel( CEconItemView *pItem );
  90. #endif // TF_GIVEAWAYITEMPANEL_H