Counter Strike : Global Offensive Source Code
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.

125 lines
3.3 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=====================================================================================//
  6. #include "tier1/keyvalues.h"
  7. #include "vgui_basepanel.h"
  8. #include <vgui/IVGui.h>
  9. #include <vgui/ILocalize.h>
  10. #include <vgui/ISurface.h>
  11. #include "../common/xbox/xboxstubs.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Watermark panel visible for pre-release builds
  16. //-----------------------------------------------------------------------------
  17. class CWatermarkPanel : public CBasePanel
  18. {
  19. typedef CBasePanel BaseClass;
  20. public:
  21. CWatermarkPanel( vgui::Panel *parent );
  22. virtual ~CWatermarkPanel( void );
  23. virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
  24. virtual void Paint();
  25. virtual bool ShouldDraw( void ) { return true; };
  26. private:
  27. void ComputeSize( void );
  28. vgui::HFont m_hFont;
  29. bool m_bLastDraw;
  30. int m_nLinesNeeded;
  31. };
  32. #define WATERMARK_PANEL_WIDTH 400
  33. //-----------------------------------------------------------------------------
  34. // Purpose:
  35. // Input : *parent -
  36. //-----------------------------------------------------------------------------
  37. CWatermarkPanel::CWatermarkPanel( vgui::Panel *parent ) : BaseClass( NULL, "CWatermarkPanel" )
  38. {
  39. SetParent( parent );
  40. SetVisible( true );
  41. SetCursor( 0 );
  42. SetFgColor( Color( 0, 0, 0, 255 ) );
  43. SetPaintBackgroundEnabled( false );
  44. m_hFont = 0;
  45. m_nLinesNeeded = 5;
  46. ComputeSize();
  47. vgui::ivgui()->AddTickSignal( GetVPanel(), 250 );
  48. m_bLastDraw = false;
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. //-----------------------------------------------------------------------------
  53. CWatermarkPanel::~CWatermarkPanel( void )
  54. {
  55. }
  56. //-----------------------------------------------------------------------------
  57. // Purpose: Computes panel's desired size and position
  58. //-----------------------------------------------------------------------------
  59. void CWatermarkPanel::ComputeSize( void )
  60. {
  61. int wide, tall;
  62. vgui::ipanel()->GetSize(GetVParent(), wide, tall );
  63. int x = 0;;
  64. int y = 0;
  65. if ( IsX360() )
  66. {
  67. x += XBOX_MINBORDERSAFE * wide;
  68. y += XBOX_MINBORDERSAFE * tall;
  69. }
  70. SetPos( x, y );
  71. SetSize( WATERMARK_PANEL_WIDTH, ( m_nLinesNeeded + 2 ) * vgui::surface()->GetFontTall( m_hFont ) + 4 );
  72. }
  73. void CWatermarkPanel::ApplySchemeSettings(vgui::IScheme *pScheme)
  74. {
  75. BaseClass::ApplySchemeSettings(pScheme);
  76. m_hFont = pScheme->GetFont( "DefaultFixedOutline" );
  77. Assert( m_hFont );
  78. ComputeSize();
  79. }
  80. //-----------------------------------------------------------------------------
  81. // Purpose:
  82. // Input :
  83. //-----------------------------------------------------------------------------
  84. void CWatermarkPanel::Paint()
  85. {
  86. wchar_t unicode[ 200 ];
  87. g_pVGuiLocalize->ConvertANSIToUnicode( "PRE-RELEASE BUILD - DO NOT REDISTRIBUTE", unicode, sizeof( unicode ) );
  88. DrawColoredText( m_hFont, 100, 42, 0, 255, 0, 255, unicode );
  89. }
  90. static CWatermarkPanel *watermarkPanel = NULL;
  91. void CreateWatermarkPanel( vgui::Panel *parent )
  92. {
  93. watermarkPanel = new CWatermarkPanel( parent );
  94. if (watermarkPanel)
  95. {
  96. watermarkPanel->SetVisible(true);
  97. }
  98. }