diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/utils/common/pacifier.cpp | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/utils/common/pacifier.cpp')
| -rw-r--r-- | mp/src/utils/common/pacifier.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/mp/src/utils/common/pacifier.cpp b/mp/src/utils/common/pacifier.cpp new file mode 100644 index 00000000..6d9c73f2 --- /dev/null +++ b/mp/src/utils/common/pacifier.cpp @@ -0,0 +1,63 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include <stdio.h>
+#include "basetypes.h"
+#include "pacifier.h"
+#include "tier0/dbg.h"
+
+
+static int g_LastPacifierDrawn = -1;
+static bool g_bPacifierSuppressed = false;
+
+#define clamp(a,b,c) ( (a) > (c) ? (c) : ( (a) < (b) ? (b) : (a) ) )
+
+void StartPacifier( char const *pPrefix )
+{
+ Msg( "%s", pPrefix );
+ g_LastPacifierDrawn = -1;
+ UpdatePacifier( 0.001f );
+}
+
+void UpdatePacifier( float flPercent )
+{
+ int iCur = (int)(flPercent * 40.0f);
+ iCur = clamp( iCur, g_LastPacifierDrawn, 40 );
+
+ if( iCur != g_LastPacifierDrawn && !g_bPacifierSuppressed )
+ {
+ for( int i=g_LastPacifierDrawn+1; i <= iCur; i++ )
+ {
+ if ( !( i % 4 ) )
+ {
+ Msg("%d", i/4);
+ }
+ else
+ {
+ if( i != 40 )
+ {
+ Msg(".");
+ }
+ }
+ }
+
+ g_LastPacifierDrawn = iCur;
+ }
+}
+
+void EndPacifier( bool bCarriageReturn )
+{
+ UpdatePacifier(1);
+
+ if( bCarriageReturn && !g_bPacifierSuppressed )
+ Msg("\n");
+}
+
+void SuppressPacifier( bool bSuppress )
+{
+ g_bPacifierSuppressed = bSuppress;
+}
|