diff --git a/src/base/color.h b/src/base/color.h index db54d1d86..dff296861 100644 --- a/src/base/color.h +++ b/src/base/color.h @@ -105,7 +105,9 @@ public: using color4_base::color4_base; ColorHSLA() {}; - ColorHSLA UnclampLighting(float Darkest) + constexpr static const float DARKEST_LGT = 0.5f; + + ColorHSLA UnclampLighting(float Darkest = DARKEST_LGT) { ColorHSLA col = *this; col.l = Darkest + col.l * (1.0f - Darkest); @@ -124,20 +126,6 @@ public: col.l = clamp(col.l, 0.0f, 1.0f); return col.Pack(Alpha); } - - unsigned Pack7() - { - if(m_Lit) - { - float Darkest = 61.0f/255.0f; - ColorHSLA Dark = *this; - Dark.l = (l - Darkest)/(1 - Darkest); - Dark.m_Lit = false; - return Dark.Pack7(); - } - else - return color4_base::Pack(false); - } }; class ColorHSVA : public color4_base diff --git a/src/engine/shared/console.cpp b/src/engine/shared/console.cpp index f51731638..488b94690 100644 --- a/src/engine/shared/console.cpp +++ b/src/engine/shared/console.cpp @@ -48,7 +48,7 @@ ColorHSLA CConsole::CResult::GetColor(unsigned Index, bool Light) { hsl = ColorHSLA(str_toulong_base(pStr, 10), true); if(Light) - hsl = hsl.UnclampLighting(0.5f); + hsl = hsl.UnclampLighting(); } else if(*pStr == '$') // Hex RGB { @@ -780,7 +780,7 @@ static void ColVariableCommand(IConsole::IResult *pResult, void *pUserData) ColorHSLA hsl(*(pData->m_pVariable), true); if(pData->m_Light) - hsl = hsl.UnclampLighting(0.5f); + hsl = hsl.UnclampLighting(); str_format(aBuf, sizeof(aBuf), "H: %d°, S: %d%%, L: %d%%", round_truncate(hsl.h * 360), round_truncate(hsl.s * 100), round_truncate(hsl.l * 100)); pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "console", aBuf); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 85e7c22ab..ba9022286 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -414,8 +414,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView) if(*UseCustomColor) { OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture; - OwnSkinInfo.m_ColorBody = color_cast(ColorHSLA(*ColorBody).UnclampLighting(CSkins::DARKEST_LGT)); - OwnSkinInfo.m_ColorFeet = color_cast(ColorHSLA(*ColorFeet).UnclampLighting(CSkins::DARKEST_LGT)); + OwnSkinInfo.m_ColorBody = color_cast(ColorHSLA(*ColorBody).UnclampLighting()); + OwnSkinInfo.m_ColorFeet = color_cast(ColorHSLA(*ColorFeet).UnclampLighting()); } else { diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index e0ff51884..3ba068852 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -10,7 +10,6 @@ class CSkins : public CComponent { public: - constexpr static const float DARKEST_LGT = 0.5f; // do this better and nicer struct CSkin { diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 1d62a8439..d76be8d6e 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1162,8 +1162,8 @@ void CGameClient::OnNewSnapshot() if(m_aClients[ClientID].m_aSkinName[0] == 'x' || m_aClients[ClientID].m_aSkinName[1] == '_') str_copy(m_aClients[ClientID].m_aSkinName, "default", 64); - m_aClients[ClientID].m_SkinInfo.m_ColorBody = color_cast(ColorHSLA(m_aClients[ClientID].m_ColorBody).UnclampLighting(CSkins::DARKEST_LGT)); - m_aClients[ClientID].m_SkinInfo.m_ColorFeet = color_cast(ColorHSLA(m_aClients[ClientID].m_ColorFeet).UnclampLighting(CSkins::DARKEST_LGT)); + m_aClients[ClientID].m_SkinInfo.m_ColorBody = color_cast(ColorHSLA(m_aClients[ClientID].m_ColorBody).UnclampLighting()); + m_aClients[ClientID].m_SkinInfo.m_ColorFeet = color_cast(ColorHSLA(m_aClients[ClientID].m_ColorFeet).UnclampLighting()); m_aClients[ClientID].m_SkinInfo.m_Size = 64; // find new skin diff --git a/src/game/server/teeinfo.cpp b/src/game/server/teeinfo.cpp index 3f77e1246..2228eb177 100644 --- a/src/game/server/teeinfo.cpp +++ b/src/game/server/teeinfo.cpp @@ -74,8 +74,8 @@ void CTeeInfo::ToSixup() if(m_UseCustomColor) { - int ColorBody = ColorHSLA(m_ColorBody).Lighten().Pack7(); - int ColorFeet = ColorHSLA(m_ColorFeet).Lighten().Pack7(); + int ColorBody = ColorHSLA(m_ColorBody).UnclampLighting().Pack(DARKEST_LGT_7); + int ColorFeet = ColorHSLA(m_ColorFeet).UnclampLighting().Pack(DARKEST_LGT_7); m_aUseCustomColors[0] = true; m_aUseCustomColors[1] = true; m_aUseCustomColors[2] = true; @@ -137,6 +137,6 @@ void CTeeInfo::FromSixup() str_copy(m_SkinName, g_StdSkins[best_skin].m_SkinName, sizeof(m_SkinName)); m_UseCustomColor = true; - m_ColorBody = m_aUseCustomColors[0] ? m_aSkinPartColors[0] : 255; - m_ColorFeet = m_aUseCustomColors[4] ? m_aSkinPartColors[4] : 255; + m_ColorBody = ColorHSLA(m_aUseCustomColors[0] ? m_aSkinPartColors[0] : 255).UnclampLighting(DARKEST_LGT_7).Pack(ColorHSLA::DARKEST_LGT); + m_ColorFeet = ColorHSLA(m_aUseCustomColors[4] ? m_aSkinPartColors[4] : 255).UnclampLighting(DARKEST_LGT_7).Pack(ColorHSLA::DARKEST_LGT); } diff --git a/src/game/server/teeinfo.h b/src/game/server/teeinfo.h index ba91921e3..9f15eccfe 100644 --- a/src/game/server/teeinfo.h +++ b/src/game/server/teeinfo.h @@ -4,6 +4,8 @@ class CTeeInfo { public: + constexpr static const float DARKEST_LGT_7 = 61/255.0f; + char m_SkinName[64] = ""; int m_UseCustomColor = 0; int m_ColorBody = 0;