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.

89 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include <vgui/ISurface.h>
  9. #include "dodmenubackground.h"
  10. using namespace vgui;
  11. //-----------------------------------------------------------------------------
  12. // Purpose: Constructor
  13. //-----------------------------------------------------------------------------
  14. CDODMenuBackground::CDODMenuBackground(Panel *parent) : EditablePanel(parent, "MenuBackground")
  15. {
  16. SetProportional(true);
  17. SetVisible(true);
  18. SetZPos( -1 );
  19. LoadControlSettings("Resource/UI/MenuBackground.res");
  20. }
  21. void CDODMenuBackground::Init( void )
  22. {
  23. m_iBackgroundTexture = vgui::surface()->CreateNewTextureID();
  24. vgui::surface()->DrawSetTextureFile( m_iBackgroundTexture, "vgui/white", true, false);
  25. }
  26. void CDODMenuBackground::ApplySchemeSettings( IScheme *pScheme )
  27. {
  28. int top[8];
  29. int main[8];
  30. int box[8];
  31. int i;
  32. for( i=0;i<8;i++ )
  33. {
  34. top[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iTopDims[i]);
  35. main[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iMainDims[i]);
  36. box[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iBoxDims[i]);
  37. if ( i < 6 )
  38. m_LineDims[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iLineDims[i]);
  39. }
  40. m_BackgroundTopVerts[0].Init( Vector2D( top[0], top[1] ) );
  41. m_BackgroundTopVerts[1].Init( Vector2D( top[2], top[3] ) );
  42. m_BackgroundTopVerts[2].Init( Vector2D( top[4], top[5] ) );
  43. m_BackgroundTopVerts[3].Init( Vector2D( top[6], top[7] ) );
  44. m_BackgroundMainVerts[0].Init( Vector2D( main[0], main[1] ) );
  45. m_BackgroundMainVerts[1].Init( Vector2D( main[2], main[3] ) );
  46. m_BackgroundMainVerts[2].Init( Vector2D( main[4], main[5] ) );
  47. m_BackgroundMainVerts[3].Init( Vector2D( main[6], main[7] ) );
  48. m_BoxVerts[0].Init( Vector2D( box[0], box[1] ) );
  49. m_BoxVerts[1].Init( Vector2D( box[2], box[3] ) );
  50. m_BoxVerts[2].Init( Vector2D( box[4], box[5] ) );
  51. m_BoxVerts[3].Init( Vector2D( box[6], box[7] ) );
  52. BaseClass::ApplySchemeSettings(pScheme);
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose: paint the dod style background
  56. //-----------------------------------------------------------------------------
  57. void CDODMenuBackground::Paint(void)
  58. {
  59. vgui::surface()->DrawSetColor(128,110,53,235);
  60. vgui::surface()->DrawSetTexture( m_iBackgroundTexture );
  61. //top background
  62. vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundTopVerts );
  63. //main background
  64. vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundMainVerts );
  65. // top white line
  66. vgui::surface()->DrawSetColor(255,255,255,196);
  67. vgui::surface()->DrawLine( m_LineDims[0], m_LineDims[1], m_LineDims[2], m_LineDims[3] );
  68. vgui::surface()->DrawLine( m_LineDims[2], m_LineDims[3], m_LineDims[4], m_LineDims[5] );
  69. // top white box
  70. vgui::surface()->DrawTexturedPolygon( 4, m_BoxVerts );
  71. }