mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Get rid of more magic constants, adapt to 0.7
This commit is contained in:
parent
d200ef0bb0
commit
75e96aa5d3
|
@ -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<ColorHSVA>
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -414,8 +414,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(*UseCustomColor)
|
||||
{
|
||||
OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;
|
||||
OwnSkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(*ColorBody).UnclampLighting(CSkins::DARKEST_LGT));
|
||||
OwnSkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(*ColorFeet).UnclampLighting(CSkins::DARKEST_LGT));
|
||||
OwnSkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(*ColorBody).UnclampLighting());
|
||||
OwnSkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(*ColorFeet).UnclampLighting());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
class CSkins : public CComponent
|
||||
{
|
||||
public:
|
||||
constexpr static const float DARKEST_LGT = 0.5f;
|
||||
// do this better and nicer
|
||||
struct CSkin
|
||||
{
|
||||
|
|
|
@ -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<ColorRGBA>(ColorHSLA(m_aClients[ClientID].m_ColorBody).UnclampLighting(CSkins::DARKEST_LGT));
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(m_aClients[ClientID].m_ColorFeet).UnclampLighting(CSkins::DARKEST_LGT));
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(m_aClients[ClientID].m_ColorBody).UnclampLighting());
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(m_aClients[ClientID].m_ColorFeet).UnclampLighting());
|
||||
m_aClients[ClientID].m_SkinInfo.m_Size = 64;
|
||||
|
||||
// find new skin
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue