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
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Clients CBaseObject
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef OBJECTCONTROLPANEL_H
  8. #define OBJECTCONTROLPANEL_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "c_vguiscreen.h"
  13. namespace vgui
  14. {
  15. class Panel;
  16. class Label;
  17. class Button;
  18. }
  19. class C_BaseObject;
  20. class CRotationSlider;
  21. class C_TFPlayer;
  22. //-----------------------------------------------------------------------------
  23. // Base class for all vgui screens on objects:
  24. //-----------------------------------------------------------------------------
  25. class CObjectControlPanel : public CVGuiScreenPanel
  26. {
  27. DECLARE_CLASS( CObjectControlPanel, CVGuiScreenPanel );
  28. public:
  29. CObjectControlPanel( vgui::Panel *parent, const char *panelName );
  30. virtual bool Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData );
  31. virtual void OnCommand( const char *command );
  32. virtual void OnTick();
  33. protected:
  34. // Method to add controls to particular panels
  35. vgui::Panel *GetActivePanel() { return m_pActivePanel; }
  36. // Override these to deal with various controls in various modes
  37. virtual void OnTickActive( C_BaseObject *pObj, C_TFPlayer *pLocalPlayer );
  38. C_BaseObject *GetOwningObject() const;
  39. // This should update the current panel and return that panel.
  40. virtual vgui::Panel* TickCurrentPanel();
  41. // Send a message to the owner.
  42. void SendToServerObject( const char *pMsg );
  43. private:
  44. vgui::EditablePanel *m_pActivePanel;
  45. vgui::Panel *m_pCurrentPanel;
  46. };
  47. // This is used for child panels. It forwards the messages to the parent panel.
  48. class CCommandChainingPanel : public vgui::EditablePanel
  49. {
  50. typedef vgui::EditablePanel BaseClass;
  51. public:
  52. CCommandChainingPanel( vgui::Panel *parent, const char *panelName ) :
  53. BaseClass( parent, panelName )
  54. {
  55. SetPaintBackgroundEnabled( false );
  56. }
  57. void OnCommand( const char *command )
  58. {
  59. BaseClass::OnCommand( command );
  60. if (GetParent())
  61. {
  62. GetParent()->OnCommand(command);
  63. }
  64. }
  65. };
  66. //-----------------------------------------------------------------------------
  67. // This is a panel for an object that has rotational controls
  68. //-----------------------------------------------------------------------------
  69. class CRotatingObjectControlPanel : public CObjectControlPanel
  70. {
  71. DECLARE_CLASS( CRotatingObjectControlPanel, CObjectControlPanel );
  72. public:
  73. CRotatingObjectControlPanel( vgui::Panel *parent, const char *panelName );
  74. virtual bool Init( KeyValues* pKeyValues, VGuiScreenInitData_t* pInitData );
  75. protected:
  76. virtual void OnTickActive( C_BaseObject *pObj, C_TFPlayer *pLocalPlayer );
  77. private:
  78. CRotationSlider *m_pRotationSlider;
  79. vgui::Label *m_pRotationLabel;
  80. };
  81. #endif // OBJECTCONTROLPANEL_H