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.

63 lines
1.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <stdio.h>
  8. #include "basetypes.h"
  9. #include "pacifier.h"
  10. #include "tier0/dbg.h"
  11. static int g_LastPacifierDrawn = -1;
  12. static bool g_bPacifierSuppressed = false;
  13. #define clamp(a,b,c) ( (a) > (c) ? (c) : ( (a) < (b) ? (b) : (a) ) )
  14. void StartPacifier( char const *pPrefix )
  15. {
  16. Msg( "%s", pPrefix );
  17. g_LastPacifierDrawn = -1;
  18. UpdatePacifier( 0.001f );
  19. }
  20. void UpdatePacifier( float flPercent )
  21. {
  22. int iCur = (int)(flPercent * 40.0f);
  23. iCur = clamp( iCur, g_LastPacifierDrawn, 40 );
  24. if( iCur != g_LastPacifierDrawn && !g_bPacifierSuppressed )
  25. {
  26. for( int i=g_LastPacifierDrawn+1; i <= iCur; i++ )
  27. {
  28. if ( !( i % 4 ) )
  29. {
  30. Msg("%d", i/4);
  31. }
  32. else
  33. {
  34. if( i != 40 )
  35. {
  36. Msg(".");
  37. }
  38. }
  39. }
  40. g_LastPacifierDrawn = iCur;
  41. }
  42. }
  43. void EndPacifier( bool bCarriageReturn )
  44. {
  45. UpdatePacifier(1);
  46. if( bCarriageReturn && !g_bPacifierSuppressed )
  47. Msg("\n");
  48. }
  49. void SuppressPacifier( bool bSuppress )
  50. {
  51. g_bPacifierSuppressed = bSuppress;
  52. }