From f56bb35301836e56582a575a75864392a0177875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 2 Dec 2013 19:31:46 -0800 Subject: Fix line endings. WHAMMY. --- mp/src/game/client/hud_numericdisplay.cpp | 398 +++++++++++++++--------------- 1 file changed, 199 insertions(+), 199 deletions(-) (limited to 'mp/src/game/client/hud_numericdisplay.cpp') diff --git a/mp/src/game/client/hud_numericdisplay.cpp b/mp/src/game/client/hud_numericdisplay.cpp index 3e84614f..de9c84f1 100644 --- a/mp/src/game/client/hud_numericdisplay.cpp +++ b/mp/src/game/client/hud_numericdisplay.cpp @@ -1,199 +1,199 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include "cbase.h" -#include "hud_numericdisplay.h" -#include "iclientmode.h" - -#include -#include -#include -#include -#include - -// memdbgon must be the last include file in a .cpp file!!! -#include "tier0/memdbgon.h" - -using namespace vgui; - -//----------------------------------------------------------------------------- -// Purpose: Constructor -//----------------------------------------------------------------------------- -CHudNumericDisplay::CHudNumericDisplay(vgui::Panel *parent, const char *name) : BaseClass(parent, name) -{ - vgui::Panel *pParent = g_pClientMode->GetViewport(); - SetParent( pParent ); - - m_iValue = 0; - m_LabelText[0] = 0; - m_iSecondaryValue = 0; - m_bDisplayValue = true; - m_bDisplaySecondaryValue = false; - m_bIndent = false; - m_bIsTime = false; -} - -//----------------------------------------------------------------------------- -// Purpose: Resets values on restore/new map -//----------------------------------------------------------------------------- -void CHudNumericDisplay::Reset() -{ - m_flBlur = 0.0f; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetDisplayValue(int value) -{ - m_iValue = value; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetSecondaryValue(int value) -{ - m_iSecondaryValue = value; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetShouldDisplayValue(bool state) -{ - m_bDisplayValue = state; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetShouldDisplaySecondaryValue(bool state) -{ - m_bDisplaySecondaryValue = state; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetLabelText(const wchar_t *text) -{ - wcsncpy(m_LabelText, text, sizeof(m_LabelText) / sizeof(wchar_t)); - m_LabelText[(sizeof(m_LabelText) / sizeof(wchar_t)) - 1] = 0; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetIndent(bool state) -{ - m_bIndent = state; -} - -//----------------------------------------------------------------------------- -// Purpose: data accessor -//----------------------------------------------------------------------------- -void CHudNumericDisplay::SetIsTime(bool state) -{ - m_bIsTime = state; -} - -//----------------------------------------------------------------------------- -// Purpose: paints a number at the specified position -//----------------------------------------------------------------------------- -void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value) -{ - surface()->DrawSetTextFont(font); - wchar_t unicode[6]; - if ( !m_bIsTime ) - { - V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); - } - else - { - int iMinutes = value / 60; - int iSeconds = value - iMinutes * 60; -#ifdef PORTAL - // portal uses a normal font for numbers so we need the seperate to be a renderable ':' char - if ( iSeconds < 10 ) - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:0%d", iMinutes, iSeconds ); - else - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:%d", iMinutes, iSeconds ); -#else - if ( iSeconds < 10 ) - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`0%d", iMinutes, iSeconds ); - else - V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`%d", iMinutes, iSeconds ); -#endif - } - - // adjust the position to take into account 3 characters - int charWidth = surface()->GetCharacterWidth(font, '0'); - if (value < 100 && m_bIndent) - { - xpos += charWidth; - } - if (value < 10 && m_bIndent) - { - xpos += charWidth; - } - - surface()->DrawSetTextPos(xpos, ypos); - surface()->DrawUnicodeString( unicode ); -} - -//----------------------------------------------------------------------------- -// Purpose: draws the text -//----------------------------------------------------------------------------- -void CHudNumericDisplay::PaintLabel( void ) -{ - surface()->DrawSetTextFont(m_hTextFont); - surface()->DrawSetTextColor(GetFgColor()); - surface()->DrawSetTextPos(text_xpos, text_ypos); - surface()->DrawUnicodeString( m_LabelText ); -} - -//----------------------------------------------------------------------------- -// Purpose: renders the vgui panel -//----------------------------------------------------------------------------- -void CHudNumericDisplay::Paint() -{ - if (m_bDisplayValue) - { - // draw our numbers - surface()->DrawSetTextColor(GetFgColor()); - PaintNumbers(m_hNumberFont, digit_xpos, digit_ypos, m_iValue); - - // draw the overbright blur - for (float fl = m_flBlur; fl > 0.0f; fl -= 1.0f) - { - if (fl >= 1.0f) - { - PaintNumbers(m_hNumberGlowFont, digit_xpos, digit_ypos, m_iValue); - } - else - { - // draw a percentage of the last one - Color col = GetFgColor(); - col[3] *= fl; - surface()->DrawSetTextColor(col); - PaintNumbers(m_hNumberGlowFont, digit_xpos, digit_ypos, m_iValue); - } - } - } - - // total ammo - if (m_bDisplaySecondaryValue) - { - surface()->DrawSetTextColor(GetFgColor()); - PaintNumbers(m_hSmallNumberFont, digit2_xpos, digit2_ypos, m_iSecondaryValue); - } - - PaintLabel(); -} - - - +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#include "cbase.h" +#include "hud_numericdisplay.h" +#include "iclientmode.h" + +#include +#include +#include +#include +#include + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +using namespace vgui; + +//----------------------------------------------------------------------------- +// Purpose: Constructor +//----------------------------------------------------------------------------- +CHudNumericDisplay::CHudNumericDisplay(vgui::Panel *parent, const char *name) : BaseClass(parent, name) +{ + vgui::Panel *pParent = g_pClientMode->GetViewport(); + SetParent( pParent ); + + m_iValue = 0; + m_LabelText[0] = 0; + m_iSecondaryValue = 0; + m_bDisplayValue = true; + m_bDisplaySecondaryValue = false; + m_bIndent = false; + m_bIsTime = false; +} + +//----------------------------------------------------------------------------- +// Purpose: Resets values on restore/new map +//----------------------------------------------------------------------------- +void CHudNumericDisplay::Reset() +{ + m_flBlur = 0.0f; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetDisplayValue(int value) +{ + m_iValue = value; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetSecondaryValue(int value) +{ + m_iSecondaryValue = value; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetShouldDisplayValue(bool state) +{ + m_bDisplayValue = state; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetShouldDisplaySecondaryValue(bool state) +{ + m_bDisplaySecondaryValue = state; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetLabelText(const wchar_t *text) +{ + wcsncpy(m_LabelText, text, sizeof(m_LabelText) / sizeof(wchar_t)); + m_LabelText[(sizeof(m_LabelText) / sizeof(wchar_t)) - 1] = 0; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetIndent(bool state) +{ + m_bIndent = state; +} + +//----------------------------------------------------------------------------- +// Purpose: data accessor +//----------------------------------------------------------------------------- +void CHudNumericDisplay::SetIsTime(bool state) +{ + m_bIsTime = state; +} + +//----------------------------------------------------------------------------- +// Purpose: paints a number at the specified position +//----------------------------------------------------------------------------- +void CHudNumericDisplay::PaintNumbers(HFont font, int xpos, int ypos, int value) +{ + surface()->DrawSetTextFont(font); + wchar_t unicode[6]; + if ( !m_bIsTime ) + { + V_snwprintf(unicode, ARRAYSIZE(unicode), L"%d", value); + } + else + { + int iMinutes = value / 60; + int iSeconds = value - iMinutes * 60; +#ifdef PORTAL + // portal uses a normal font for numbers so we need the seperate to be a renderable ':' char + if ( iSeconds < 10 ) + V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:0%d", iMinutes, iSeconds ); + else + V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d:%d", iMinutes, iSeconds ); +#else + if ( iSeconds < 10 ) + V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`0%d", iMinutes, iSeconds ); + else + V_snwprintf( unicode, ARRAYSIZE(unicode), L"%d`%d", iMinutes, iSeconds ); +#endif + } + + // adjust the position to take into account 3 characters + int charWidth = surface()->GetCharacterWidth(font, '0'); + if (value < 100 && m_bIndent) + { + xpos += charWidth; + } + if (value < 10 && m_bIndent) + { + xpos += charWidth; + } + + surface()->DrawSetTextPos(xpos, ypos); + surface()->DrawUnicodeString( unicode ); +} + +//----------------------------------------------------------------------------- +// Purpose: draws the text +//----------------------------------------------------------------------------- +void CHudNumericDisplay::PaintLabel( void ) +{ + surface()->DrawSetTextFont(m_hTextFont); + surface()->DrawSetTextColor(GetFgColor()); + surface()->DrawSetTextPos(text_xpos, text_ypos); + surface()->DrawUnicodeString( m_LabelText ); +} + +//----------------------------------------------------------------------------- +// Purpose: renders the vgui panel +//----------------------------------------------------------------------------- +void CHudNumericDisplay::Paint() +{ + if (m_bDisplayValue) + { + // draw our numbers + surface()->DrawSetTextColor(GetFgColor()); + PaintNumbers(m_hNumberFont, digit_xpos, digit_ypos, m_iValue); + + // draw the overbright blur + for (float fl = m_flBlur; fl > 0.0f; fl -= 1.0f) + { + if (fl >= 1.0f) + { + PaintNumbers(m_hNumberGlowFont, digit_xpos, digit_ypos, m_iValue); + } + else + { + // draw a percentage of the last one + Color col = GetFgColor(); + col[3] *= fl; + surface()->DrawSetTextColor(col); + PaintNumbers(m_hNumberGlowFont, digit_xpos, digit_ypos, m_iValue); + } + } + } + + // total ammo + if (m_bDisplaySecondaryValue) + { + surface()->DrawSetTextColor(GetFgColor()); + PaintNumbers(m_hSmallNumberFont, digit2_xpos, digit2_ypos, m_iSecondaryValue); + } + + PaintLabel(); +} + + + -- cgit v1.2.3