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.

98 lines
2.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "dodbutton.h"
  9. #include <vgui/ISurface.h>
  10. #include <vgui_controls/EditablePanel.h>
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include <tier0/memdbgon.h>
  13. using namespace vgui;
  14. //===============================================
  15. // CDODButtonShape - drawing class for dod button shape
  16. //===============================================
  17. void CDODButtonShape::DrawShapedBorder( int x, int y, int wide, int tall, Color fgcolor )
  18. {
  19. int halfheight = tall / 3;
  20. surface()->DrawSetColor(fgcolor);
  21. // top
  22. surface()->DrawLine( 0, 1, wide-1, 1 );
  23. // left
  24. surface()->DrawLine( 1, 1, 1, tall-1 );
  25. // bottom
  26. surface()->DrawLine( 0, tall-1, wide-halfheight, tall-1 );
  27. // right
  28. surface()->DrawLine( wide-1, 0, wide-1, tall-halfheight );
  29. // diagonal
  30. surface()->DrawLine( wide-1, tall-halfheight-1, wide-halfheight-1, tall-1 );
  31. }
  32. void CDODButtonShape::DrawShapedBackground( int x, int y, int wide, int tall, Color bgcolor )
  33. {
  34. int halfheight = tall / 3;
  35. if ( m_iWhiteTexture < 0 )
  36. {
  37. m_iWhiteTexture = vgui::surface()->CreateNewTextureID();
  38. vgui::surface()->DrawSetTextureFile( m_iWhiteTexture, "vgui/white" , true, false);
  39. }
  40. surface()->DrawSetColor(bgcolor);
  41. surface()->DrawSetTexture( m_iWhiteTexture );
  42. Vertex_t verts[5];
  43. verts[0].Init( Vector2D( 0, 0 ) );
  44. verts[1].Init( Vector2D( wide-1, 0 ) );
  45. verts[2].Init( Vector2D( wide-1, tall-halfheight ) );
  46. verts[3].Init( Vector2D( wide-halfheight, tall-1 ) );
  47. verts[4].Init( Vector2D( 0, tall-1 ) );
  48. surface()->DrawTexturedPolygon(5, verts);
  49. surface()->DrawSetTexture(0);
  50. }
  51. //===============================================
  52. // CDODButton - shaped button
  53. //===============================================
  54. void CDODButton::PaintBackground()
  55. {
  56. int wide, tall;
  57. GetSize(wide,tall);
  58. DrawShapedBackground( 0, 0, wide, tall, GetBgColor() );
  59. }
  60. void CDODButton::PaintBorder()
  61. {
  62. int wide, tall;
  63. GetSize(wide,tall);
  64. DrawShapedBorder( 0, 0, wide, tall, GetFgColor() );
  65. }
  66. //===============================================
  67. // CDODProgressBar - used for weapon stat bars
  68. //===============================================
  69. void CDODProgressBar::ApplySchemeSettings(IScheme *pScheme)
  70. {
  71. BaseClass::ApplySchemeSettings(pScheme);
  72. SetFgColor( GetSchemeColor("ClassMenuLight", pScheme ) );
  73. SetBgColor( GetSchemeColor("ClassMenuDark", pScheme ) );
  74. SetBarInset(0);
  75. SetSegmentInfo( 0, 1 );
  76. SetBorder(NULL);
  77. }