Skip to content

Commit

Permalink
FFQuantityItem: Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWillden committed Oct 26, 2020
1 parent 3061bd8 commit 100f45f
Showing 1 changed file with 36 additions and 54 deletions.
90 changes: 36 additions & 54 deletions cl_dll/ff/vgui/ff_quantityitem.cpp
Expand Up @@ -616,38 +616,56 @@ namespace vgui

void FFQuantityItem::SetBarColor( Color newBarColor )
{
m_clrBarCustomColor = newBarColor;
RecalculateColor(m_ColorBar, m_iBarColorMode, m_clrBarCustomColor);
if(m_clrBarCustomColor != newBarColor)
{
m_clrBarCustomColor = newBarColor;
RecalculateColor(m_ColorBar, m_iBarColorMode, m_clrBarCustomColor);
}
}

void FFQuantityItem::SetBarBorderColor( Color newBarBorderColor )
{
m_clrBarBorderCustomColor = newBarBorderColor;
RecalculateColor(m_ColorBarBorder, m_iBarBorderColorMode, m_clrBarBorderCustomColor);
if(m_clrBarBorderCustomColor != newBarBorderColor)
{
m_clrBarBorderCustomColor = newBarBorderColor;
RecalculateColor(m_ColorBarBorder, m_iBarBorderColorMode, m_clrBarBorderCustomColor);
}
}

void FFQuantityItem::SetBarBackgroundColor( Color newBarBackgroundColor )
{
m_clrBarBackgroundCustomColor = newBarBackgroundColor;
RecalculateColor(m_ColorBarBackground, m_iBarBackgroundColorMode, m_clrBarBackgroundCustomColor);
if(m_clrBarBackgroundCustomColor != newBarBackgroundColor)
{
m_clrBarBackgroundCustomColor = newBarBackgroundColor;
RecalculateColor(m_ColorBarBackground, m_iBarBackgroundColorMode, m_clrBarBackgroundCustomColor);
}
}

void FFQuantityItem::SetAmountColor( Color newAmountColor )
{
m_clrAmountCustomColor = newAmountColor;
RecalculateColor(m_ColorAmount, m_iAmountColorMode, m_clrAmountCustomColor);
if(m_clrAmountCustomColor != newAmountColor)
{
m_clrAmountCustomColor = newAmountColor;
RecalculateColor(m_ColorAmount, m_iAmountColorMode, m_clrAmountCustomColor);
}
}

void FFQuantityItem::SetIconColor( Color newIconColor )
{
m_clrIconCustomColor = newIconColor;
RecalculateColor(m_ColorIcon, m_iIconColorMode, m_clrIconCustomColor);
if(m_clrIconCustomColor != newIconColor)
{
m_clrIconCustomColor = newIconColor;
RecalculateColor(m_ColorIcon, m_iIconColorMode, m_clrIconCustomColor);
}
}

void FFQuantityItem::SetLabelColor( Color newLabelColor )
{
m_clrLabelCustomColor = newLabelColor;
RecalculateColor(m_ColorLabel, m_iLabelColorMode, m_clrLabelCustomColor);
if(m_clrLabelCustomColor != newLabelColor)
{
m_clrLabelCustomColor = newLabelColor;
RecalculateColor(m_ColorLabel, m_iLabelColorMode, m_clrLabelCustomColor);
}
}

void FFQuantityItem::SetTeamColor( Color newTeamColor )
Expand Down Expand Up @@ -982,15 +1000,9 @@ namespace vgui
SetBarColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrBarCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetBarColor(color);
}
}
Expand Down Expand Up @@ -1022,15 +1034,9 @@ namespace vgui
SetBarBorderColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrBarBorderCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetBarBorderColor(color);
}
}
Expand Down Expand Up @@ -1062,15 +1068,9 @@ namespace vgui
SetBarBackgroundColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrBarBackgroundCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetBarBackgroundColor(color);
}
}
Expand Down Expand Up @@ -1112,15 +1112,9 @@ namespace vgui
SetIconColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrIconCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetIconColor(color);
}

Expand Down Expand Up @@ -1205,15 +1199,9 @@ namespace vgui
SetLabelColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrLabelCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetLabelColor(color);
}

Expand Down Expand Up @@ -1303,15 +1291,9 @@ namespace vgui
SetAmountColorMode(iColorMode);
}

bool bValidColor = false;
Color color = Color(iRed, iGreen, iBlue, iAlpha);
if(iRed != -1 && iGreen != -1 && iBlue != -1 && iAlpha != -1)
{
bValidColor = true;
}

if(m_clrAmountCustomColor != color && bValidColor)
{
Color color = Color(iRed, iGreen, iBlue, iAlpha);
SetAmountColor(color);
}

Expand Down

0 comments on commit 100f45f

Please sign in to comment.