Skip to content

Commit

Permalink
FFQuantityItem: Reduce nesting
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWillden committed Oct 19, 2020
1 parent b1f230f commit f3258aa
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions cl_dll/ff/vgui/ff_quantityitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,27 +1547,24 @@ namespace vgui
m_ColorIntensityStepped = GetIntensityColor(m_iAmount, m_iMaxAmount, 1, 255, m_iIntensityRed, m_iIntensityOrange, m_iIntensityYellow, m_iIntensityGreen, m_bIntensityInvertScale);
}

if(!m_bShowAmountMax)
if(m_bShowAmountMax)
{
if(m_iMaxAmount == 100)// already same as a percentage so no need to convert
{
_snwprintf( m_wszAmountString, 255, L"%s%%", m_wszAmount );
}
else
{
char szPercent[ 5 ];
wchar_t wszPercent[ 10 ];
float percent = ((float)m_iAmount/(float)m_iMaxAmount*100.0f);
Q_snprintf( szPercent, 5, "%i%", (int)percent);

localize()->ConvertANSIToUnicode( szPercent, wszPercent, sizeof( wszPercent ) );

_snwprintf( m_wszAmountString, 9, L"%s%%", wszPercent );
}
_snwprintf( m_wszAmountString, 9, L"%s/%s", m_wszAmount, m_wszAmountMax );
}
else if(m_iMaxAmount == 100)// already same as a percentage so no need to convert
{
_snwprintf( m_wszAmountString, 255, L"%s%%", m_wszAmount );
}
else
{
_snwprintf( m_wszAmountString, 9, L"%s/%s", m_wszAmount, m_wszAmountMax );
char szPercent[ 5 ];
wchar_t wszPercent[ 10 ];
float percent = ((float)m_iAmount/(float)m_iMaxAmount*100.0f);
Q_snprintf( szPercent, 5, "%i%", (int)percent);

localize()->ConvertANSIToUnicode( szPercent, wszPercent, sizeof( wszPercent ) );

_snwprintf( m_wszAmountString, 9, L"%s%%", wszPercent );
}

RecalculateAmountPosition();
Expand Down

0 comments on commit f3258aa

Please sign in to comment.