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.

106 lines
3.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VGUITEXTWINDOW_H
  8. #define VGUITEXTWINDOW_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui_controls/Frame.h>
  13. #include <vgui_controls/Button.h>
  14. #include <vgui_controls/HTML.h>
  15. #include <game/client/iviewport.h>
  16. #include "shareddefs.h"
  17. namespace vgui
  18. {
  19. class TextEntry;
  20. }
  21. //-----------------------------------------------------------------------------
  22. // Purpose: displays the MOTD
  23. //-----------------------------------------------------------------------------
  24. class CTextWindow : public vgui::Frame, public IViewPortPanel
  25. {
  26. private:
  27. DECLARE_CLASS_SIMPLE( CTextWindow, vgui::Frame );
  28. public:
  29. CTextWindow(IViewPort *pViewPort);
  30. virtual ~CTextWindow();
  31. virtual const char *GetName( void ) { return PANEL_INFO; }
  32. virtual void SetData(KeyValues *data);
  33. virtual void Reset();
  34. virtual void Update();
  35. virtual bool NeedsUpdate( void ) { return false; }
  36. virtual bool HasInputElements( void ) { return true; }
  37. virtual void ShowPanel( bool bShow );
  38. // both vgui::Frame and IViewPortPanel define these, so explicitly define them here as passthroughs to vgui
  39. vgui::VPANEL GetVPanel( void ) { return BaseClass::GetVPanel(); }
  40. virtual bool IsVisible() { return BaseClass::IsVisible(); }
  41. virtual void SetParent( vgui::VPANEL parent ) { BaseClass::SetParent( parent ); }
  42. public:
  43. virtual void SetData( int type, const char *title, const char *message, const char *message_fallback, int command, bool bUnload );
  44. virtual void ShowFile( const char *filename );
  45. virtual void ShowText( const char *text );
  46. virtual void ShowURL( const char *URL, bool bAllowUserToDisable = true );
  47. virtual void ShowIndex( const char *entry );
  48. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  49. virtual GameActionSet_t GetPreferredActionSet() { return GAME_ACTION_SET_IN_GAME_HUD; }
  50. protected:
  51. // vgui overrides
  52. virtual void OnCommand( const char *command );
  53. void OnKeyCodePressed( vgui::KeyCode code );
  54. IViewPort *m_pViewPort;
  55. char m_szTitle[255];
  56. char m_szMessage[2048];
  57. char m_szMessageFallback[2048];
  58. //=============================================================================
  59. // HPE_BEGIN:
  60. // [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
  61. // of options. Passing a command string is dangerous and allowed a server network
  62. // message to run arbitrary commands on the client.
  63. //=============================================================================
  64. int m_nExitCommand;
  65. //=============================================================================
  66. // HPE_END
  67. //=============================================================================
  68. int m_nContentType;
  69. bool m_bShownURL;
  70. bool m_bUnloadOnDismissal;
  71. vgui::TextEntry *m_pTextMessage;
  72. class CMOTDHTML : public vgui::HTML
  73. {
  74. private:
  75. DECLARE_CLASS_SIMPLE( CMOTDHTML, vgui::HTML );
  76. public:
  77. CMOTDHTML( Panel *parent, const char *pchName ) : vgui::HTML( parent, pchName ) {}
  78. virtual bool OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect ) OVERRIDE;
  79. };
  80. CMOTDHTML *m_pHTMLMessage;
  81. vgui::Button *m_pOK;
  82. vgui::Label *m_pTitleLabel;
  83. };
  84. #endif // VGUITEXTWINDOW_H