Refactor CSkins7::GetColor function

Use existing color constructor to conditionally unpack the alpha component instead of doing this separately.

Make `DARKEST_COLOR_LGT` a `float` constant instead of using an `enum` to simplify the usage.
This commit is contained in:
Robert Müller 2024-08-21 17:39:07 +02:00
parent abf8fac568
commit ce0e52851c
2 changed files with 3 additions and 7 deletions

View file

@ -476,11 +476,7 @@ void CSkins7::RandomizeSkin(int Dummy)
ColorRGBA CSkins7::GetColor(int Value, bool UseAlpha) const
{
float Dark = DARKEST_COLOR_LGT / 255.0f;
ColorRGBA Color = color_cast<ColorRGBA>(ColorHSLA(Value).UnclampLighting(Dark));
float Alpha = UseAlpha ? ((Value >> 24) & 0xff) / 255.0f : 1.0f;
Color.a = Alpha;
return Color;
return color_cast<ColorRGBA>(ColorHSLA(Value, UseAlpha).UnclampLighting(DARKEST_COLOR_LGT));
}
ColorRGBA CSkins7::GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const

View file

@ -20,14 +20,14 @@ public:
SKINFLAG_SPECIAL = 1 << 0,
SKINFLAG_STANDARD = 1 << 1,
DARKEST_COLOR_LGT = 61,
NUM_COLOR_COMPONENTS = 4,
HAT_NUM = 2,
HAT_OFFSET_SIDE = 2,
};
static constexpr float DARKEST_COLOR_LGT = 61.0f / 255.0f;
struct CSkinPart
{
int m_Flags;