forked from sears2424/Source-PlusPlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacifier.cpp
99 lines (85 loc) · 2.12 KB
/
pacifier.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include <stdio.h>
#include "basetypes.h"
#include "pacifier.h"
#include "tier0/dbg.h"
#include "strtools.h"
#include "winlite.h"
#include "ShObjIdl.h"
#include "comdef.h"
#include "tier0/memdbgon.h"
static ITaskbarList3* g_pTaskbar = NULL;
void InitTaskBar()
{
if ( g_pTaskbar )
return;
const DWORD ver = GetVersion();
const DWORD dwMajor = LOBYTE( LOWORD( ver ) );
const DWORD dwMinor = HIBYTE( LOWORD( ver ) );
if ( dwMajor > 6 || ( dwMajor == 6 && dwMinor > 0 ) )
{
CoInitialize( NULL );
CoCreateInstance( CLSID_TaskbarList, NULL, CLSCTX_ALL, IID_ITaskbarList3, reinterpret_cast<LPVOID*>( &g_pTaskbar ) );
}
}
static int g_LastPacifierDrawn = -1;
static bool g_bPacifierSuppressed = false;
void StartPacifier( char const *pPrefix )
{
Msg( "%s", pPrefix );
g_LastPacifierDrawn = -1;
if ( g_pTaskbar )
{
g_pTaskbar->SetProgressState( GetConsoleWindow(), TBPF_NORMAL );
/*if ( pPrefix && *pPrefix )
{
char text[MAX_PATH];
V_strncpy( text, pPrefix, V_strlen( pPrefix ) - 1 );
g_pTaskbar->SetThumbnailTooltip( GetConsoleWindow(), CStrAutoEncode( text ).ToWString() );
}*/
}
UpdatePacifier( 0.001f );
}
void UpdatePacifier( float flPercent )
{
int iCur = (int)(flPercent * 40.f );
if ( g_bPacifierSuppressed || g_LastPacifierDrawn == iCur )
return;
for( int i=g_LastPacifierDrawn+1; i <= iCur; i++ )
{
if ( !( i % 4 ) )
{
Msg("%d", i/4);
}
else
{
if( i != 40 )
{
Msg(".");
}
}
}
g_LastPacifierDrawn = iCur;
if ( g_pTaskbar )
g_pTaskbar->SetProgressValue( GetConsoleWindow(), flPercent * 100, 100 );
}
void EndPacifier( bool bCarriageReturn )
{
UpdatePacifier(1);
if( bCarriageReturn && !g_bPacifierSuppressed )
Msg("\n");
if ( g_pTaskbar )
{
g_pTaskbar->SetProgressState( GetConsoleWindow(), TBPF_NOPROGRESS );
//g_pTaskbar->SetThumbnailTooltip( GetConsoleWindow(), NULL );
}
}
void SuppressPacifier( bool bSuppress )
{
g_bPacifierSuppressed = bSuppress;
}