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.

137 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "NavProgress.h"
  9. #include <vgui/IScheme.h>
  10. #include <vgui/ILocalize.h>
  11. #include <vgui/ISurface.h>
  12. #include <filesystem.h>
  13. #include <KeyValues.h>
  14. #include <convar.h>
  15. #include <vgui_controls/Label.h>
  16. #include <game/client/iviewport.h>
  17. // memdbgon must be the last include file in a .cpp file!!!
  18. #include "tier0/memdbgon.h"
  19. using namespace vgui;
  20. //--------------------------------------------------------------------------------------------------------------
  21. CNavProgress::CNavProgress( IViewPort *pViewPort ) : Frame( NULL, PANEL_NAV_PROGRESS )
  22. {
  23. // initialize dialog
  24. m_pViewPort = pViewPort;
  25. // load the new scheme early!!
  26. SetScheme("ClientScheme");
  27. SetMoveable(false);
  28. SetSizeable(false);
  29. SetProportional(true);
  30. // hide the system buttons
  31. SetTitleBarVisible( false );
  32. m_pTitle = new Label( this, "TitleLabel", "" );
  33. m_pText = new Label( this, "TextLabel", "" );
  34. m_pProgressBarBorder = new Panel( this, "ProgressBarBorder" );
  35. m_pProgressBar = new Panel( this, "ProgressBar" );
  36. m_pProgressBarSizer = new Panel( this, "ProgressBarSizer" );
  37. LoadControlSettings("Resource/UI/NavProgress.res");
  38. Reset();
  39. }
  40. //--------------------------------------------------------------------------------------------------------------
  41. CNavProgress::~CNavProgress()
  42. {
  43. }
  44. //--------------------------------------------------------------------------------------------------------------
  45. void CNavProgress::ApplySchemeSettings(IScheme *pScheme)
  46. {
  47. BaseClass::ApplySchemeSettings( pScheme );
  48. SetPaintBackgroundType( 2 );
  49. m_pProgressBarSizer->SetVisible( false );
  50. m_pProgressBarBorder->SetBorder( pScheme->GetBorder( "ButtonDepressedBorder" ) );
  51. m_pProgressBarBorder->SetBgColor( Color( 0, 0, 0, 0 ) );
  52. m_pProgressBar->SetBorder( pScheme->GetBorder( "ButtonBorder" ) );
  53. m_pProgressBar->SetBgColor( pScheme->GetColor( "ProgressBar.FgColor", Color( 0, 0, 0, 0 ) ) );
  54. }
  55. //--------------------------------------------------------------------------------------------------------------
  56. void CNavProgress::PerformLayout()
  57. {
  58. BaseClass::PerformLayout();
  59. if ( m_numTicks )
  60. {
  61. int w = m_pProgressBarSizer->GetWide();
  62. w = w * m_currentTick / m_numTicks;
  63. m_pProgressBar->SetWide( w );
  64. }
  65. }
  66. //--------------------------------------------------------------------------------------------------------------
  67. void CNavProgress::Init( const char *title, int numTicks, int startTick )
  68. {
  69. m_pText->SetText( title );
  70. m_numTicks = MAX( 1, numTicks ); // non-zero, since we'll divide by this
  71. m_currentTick = MAX( 0, MIN( m_numTicks, startTick ) );
  72. InvalidateLayout();
  73. }
  74. //--------------------------------------------------------------------------------------------------------------
  75. void CNavProgress::SetData(KeyValues *data)
  76. {
  77. Init( data->GetString( "msg" ),
  78. data->GetInt( "total" ),
  79. data->GetInt( "current" ) );
  80. }
  81. //--------------------------------------------------------------------------------------------------------------
  82. void CNavProgress::ShowPanel( bool bShow )
  83. {
  84. if ( BaseClass::IsVisible() == bShow )
  85. return;
  86. m_pViewPort->ShowBackGround( bShow );
  87. if ( bShow )
  88. {
  89. Activate();
  90. SetMouseInputEnabled( true );
  91. }
  92. else
  93. {
  94. SetVisible( false );
  95. SetMouseInputEnabled( false );
  96. }
  97. }
  98. //--------------------------------------------------------------------------------------------------------------
  99. void CNavProgress::Reset( void )
  100. {
  101. }
  102. //--------------------------------------------------------------------------------------------------------------
  103. void CNavProgress::Update( void )
  104. {
  105. }
  106. //--------------------------------------------------------------------------------------------------------------