mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-18 05:58:19 +00:00
Improve color config variable handling
- Add separate `CFGFLAG_COLLIGHT7` for 0.7 color config variables, which use `61/255` as darkest lighting value. In comparison, `CFGFLAG_COLLIGHT` uses `0.5` darkest lighting, so the color values being shown for 0.7 color variables were incorrect. Closes #8775. - Pass darkest lighting as parameter directly instead of using `bool`s to avoid duplicating the logic. - Add `ColorHSLA::DARKEST_LGT7` constant to replace existing `CTeeInfo::ms_DarkestLGT7` and `CSkins7::DARKEST_COLOR_LGT` constants. - Round color components before printing them in config variable command handler, as color components are generally also rounded before being packed and before rendering. - Remove default value of `ColorHSLA::UnclampLighting` function, to avoid incorrect usage.
This commit is contained in:
parent
217103a0ee
commit
aa5a24abc4
|
@ -176,8 +176,9 @@ public:
|
|||
ColorHSLA(){};
|
||||
|
||||
constexpr static const float DARKEST_LGT = 0.5f;
|
||||
constexpr static const float DARKEST_LGT7 = 61.0f / 255.0f;
|
||||
|
||||
ColorHSLA UnclampLighting(float Darkest = DARKEST_LGT) const
|
||||
ColorHSLA UnclampLighting(float Darkest) const
|
||||
{
|
||||
ColorHSLA col = *this;
|
||||
col.l = Darkest + col.l * (1.0f - Darkest);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
virtual int GetInteger(unsigned Index) const = 0;
|
||||
virtual float GetFloat(unsigned Index) const = 0;
|
||||
virtual const char *GetString(unsigned Index) const = 0;
|
||||
virtual std::optional<ColorHSLA> GetColor(unsigned Index, bool Light) const = 0;
|
||||
virtual std::optional<ColorHSLA> GetColor(unsigned Index, float DarkestLighting) const = 0;
|
||||
|
||||
virtual void RemoveArgument(unsigned Index) = 0;
|
||||
|
||||
|
|
|
@ -177,29 +177,29 @@ mod ffi {
|
|||
/// # unsafe { *user.cast_mut::<bool>() = true; }
|
||||
/// let result: &IConsole_IResult /* = `command "$f00" $ffa500 $12345 shiny cyan -16777216 $f008 $00ffff80` */;
|
||||
/// # result = result_param;
|
||||
/// assert_eq!(result.GetColor(0, false), ColorHSLA { h: 0.0, s: 1.0, l: 0.5, a: 1.0 }); // red
|
||||
/// assert_eq!(result.GetColor(1, false), ColorHSLA { h: 0.10784314, s: 1.0, l: 0.5, a: 1.0 }); // DDNet logo color
|
||||
/// assert_eq!(result.GetColor(2, false), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // cannot be parsed => black
|
||||
/// assert_eq!(result.GetColor(3, false), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // unknown color name => black
|
||||
/// assert_eq!(result.GetColor(4, false), ColorHSLA { h: 0.5, s: 1.0, l: 0.5, a: 1.0 }); // cyan
|
||||
/// assert_eq!(result.GetColor(5, false), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // black
|
||||
/// assert_eq!(result.GetColor(6, false), ColorHSLA { h: 0.0, s: 1.0, l: 0.5, a: 0.53333336 }); // red with alpha specified
|
||||
/// assert_eq!(result.GetColor(7, false), ColorHSLA { h: 0.5, s: 1.0, l: 0.5, a: 0.5019608 }); // cyan with alpha specified
|
||||
/// assert_eq!(result.GetColor(8, false), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // out of range => black
|
||||
/// assert_eq!(result.GetColor(0, 0.0), ColorHSLA { h: 0.0, s: 1.0, l: 0.5, a: 1.0 }); // red
|
||||
/// assert_eq!(result.GetColor(1, 0.0), ColorHSLA { h: 0.10784314, s: 1.0, l: 0.5, a: 1.0 }); // DDNet logo color
|
||||
/// assert_eq!(result.GetColor(2, 0.0), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // cannot be parsed => black
|
||||
/// assert_eq!(result.GetColor(3, 0.0), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // unknown color name => black
|
||||
/// assert_eq!(result.GetColor(4, 0.0), ColorHSLA { h: 0.5, s: 1.0, l: 0.5, a: 1.0 }); // cyan
|
||||
/// assert_eq!(result.GetColor(5, 0.0), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // black
|
||||
/// assert_eq!(result.GetColor(6, 0.0), ColorHSLA { h: 0.0, s: 1.0, l: 0.5, a: 0.53333336 }); // red with alpha specified
|
||||
/// assert_eq!(result.GetColor(7, 0.0), ColorHSLA { h: 0.5, s: 1.0, l: 0.5, a: 0.5019608 }); // cyan with alpha specified
|
||||
/// assert_eq!(result.GetColor(8, 0.0), ColorHSLA { h: 0.0, s: 0.0, l: 0.0, a: 1.0 }); // out of range => black
|
||||
///
|
||||
/// assert_eq!(result.GetColor(0, true), result.GetColor(0, false));
|
||||
/// assert_eq!(result.GetColor(1, true), result.GetColor(1, false));
|
||||
/// assert_eq!(result.GetColor(2, true), result.GetColor(2, false));
|
||||
/// assert_eq!(result.GetColor(3, true), result.GetColor(3, false));
|
||||
/// assert_eq!(result.GetColor(4, true), result.GetColor(4, false));
|
||||
/// assert_eq!(result.GetColor(5, true), ColorHSLA { h: 0.0, s: 0.0, l: 0.5, a: 1.0 }); // black, but has the `Light` parameter set
|
||||
/// assert_eq!(result.GetColor(6, true), result.GetColor(6, false));
|
||||
/// assert_eq!(result.GetColor(7, true), result.GetColor(7, false));
|
||||
/// assert_eq!(result.GetColor(8, true), result.GetColor(8, false));
|
||||
/// assert_eq!(result.GetColor(0, 0.5), result.GetColor(0, 0.0));
|
||||
/// assert_eq!(result.GetColor(1, 0.5), result.GetColor(1, 0.0));
|
||||
/// assert_eq!(result.GetColor(2, 0.5), result.GetColor(2, 0.0));
|
||||
/// assert_eq!(result.GetColor(3, 0.5), result.GetColor(3, 0.0));
|
||||
/// assert_eq!(result.GetColor(4, 0.5), result.GetColor(4, 0.0));
|
||||
/// assert_eq!(result.GetColor(5, 0.5), ColorHSLA { h: 0.0, s: 0.0, l: 0.5, a: 1.0 }); // black, but has the `Light` parameter set
|
||||
/// assert_eq!(result.GetColor(6, 0.5), result.GetColor(6, 0.0));
|
||||
/// assert_eq!(result.GetColor(7, 0.5), result.GetColor(7, 0.0));
|
||||
/// assert_eq!(result.GetColor(8, 0.5), result.GetColor(8, 0.0));
|
||||
/// # }
|
||||
/// # assert!(executed);
|
||||
/// ```
|
||||
pub fn GetColor(self: &IConsole_IResult, Index: u32, Light: bool) -> ColorHSLA;
|
||||
pub fn GetColor(self: &IConsole_IResult, Index: u32, DarkestLighting: f32) -> ColorHSLA;
|
||||
|
||||
/// Get the number of parameters passed.
|
||||
///
|
||||
|
|
|
@ -117,10 +117,10 @@ void SColorConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pUs
|
|||
if(pData->CheckReadOnly())
|
||||
return;
|
||||
|
||||
const auto Color = pResult->GetColor(0, pData->m_Light);
|
||||
const auto Color = pResult->GetColor(0, pData->m_DarkestLighting);
|
||||
if(Color)
|
||||
{
|
||||
const unsigned Value = Color->Pack(pData->m_Light ? 0.5f : 0.0f, pData->m_Alpha);
|
||||
const unsigned Value = Color->Pack(pData->m_DarkestLighting, pData->m_Alpha);
|
||||
|
||||
*pData->m_pVariable = Value;
|
||||
if(pResult->m_ClientId != IConsole::CLIENT_ID_GAME)
|
||||
|
@ -137,19 +137,17 @@ void SColorConfigVariable::CommandCallback(IConsole::IResult *pResult, void *pUs
|
|||
str_format(aBuf, sizeof(aBuf), "Value: %u", *pData->m_pVariable);
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "config", aBuf);
|
||||
|
||||
ColorHSLA Hsla = ColorHSLA(*pData->m_pVariable, true);
|
||||
if(pData->m_Light)
|
||||
Hsla = Hsla.UnclampLighting();
|
||||
str_format(aBuf, sizeof(aBuf), "H: %d°, S: %d%%, L: %d%%", round_truncate(Hsla.h * 360), round_truncate(Hsla.s * 100), round_truncate(Hsla.l * 100));
|
||||
const ColorHSLA Hsla = ColorHSLA(*pData->m_pVariable, true).UnclampLighting(pData->m_DarkestLighting);
|
||||
str_format(aBuf, sizeof(aBuf), "H: %d°, S: %d%%, L: %d%%", round_to_int(Hsla.h * 360), round_to_int(Hsla.s * 100), round_to_int(Hsla.l * 100));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "config", aBuf);
|
||||
|
||||
const ColorRGBA Rgba = color_cast<ColorRGBA>(Hsla);
|
||||
str_format(aBuf, sizeof(aBuf), "R: %d, G: %d, B: %d, #%06X", round_truncate(Rgba.r * 255), round_truncate(Rgba.g * 255), round_truncate(Rgba.b * 255), Rgba.Pack(false));
|
||||
str_format(aBuf, sizeof(aBuf), "R: %d, G: %d, B: %d, #%06X", round_to_int(Rgba.r * 255), round_to_int(Rgba.g * 255), round_to_int(Rgba.b * 255), Rgba.Pack(false));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "config", aBuf);
|
||||
|
||||
if(pData->m_Alpha)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "A: %d%%", round_truncate(Hsla.a * 100));
|
||||
str_format(aBuf, sizeof(aBuf), "A: %d%%", round_to_int(Hsla.a * 100));
|
||||
pData->m_pConsole->Print(IConsole::OUTPUT_LEVEL_STANDARD, "config", aBuf);
|
||||
}
|
||||
}
|
||||
|
@ -494,19 +492,19 @@ void CConfigManager::Con_Toggle(IConsole::IResult *pResult, void *pUserData)
|
|||
if(pVariable->m_Type == SConfigVariable::VAR_INT)
|
||||
{
|
||||
SIntConfigVariable *pIntVariable = static_cast<SIntConfigVariable *>(pVariable);
|
||||
pIntVariable->SetValue(*pIntVariable->m_pVariable == pResult->GetInteger(1) ? pResult->GetInteger(2) : pResult->GetInteger(1));
|
||||
pIntVariable->SetValue(*pIntVariable->m_pVariable == pResult->GetInteger(pResult->GetInteger(1) ? 2 : 1));
|
||||
}
|
||||
else if(pVariable->m_Type == SConfigVariable::VAR_COLOR)
|
||||
{
|
||||
SColorConfigVariable *pColorVariable = static_cast<SColorConfigVariable *>(pVariable);
|
||||
const float Darkest = pColorVariable->m_Light ? 0.5f : 0.0f;
|
||||
const std::optional<ColorHSLA> Value = *pColorVariable->m_pVariable == pResult->GetColor(1, pColorVariable->m_Light).value_or(ColorHSLA(0, 0, 0)).Pack(Darkest, pColorVariable->m_Alpha) ? pResult->GetColor(2, pColorVariable->m_Light) : pResult->GetColor(1, pColorVariable->m_Light);
|
||||
pColorVariable->SetValue(Value.value_or(ColorHSLA(0, 0, 0)).Pack(Darkest, pColorVariable->m_Alpha));
|
||||
const bool EqualToFirst = *pColorVariable->m_pVariable == pResult->GetColor(1, pColorVariable->m_DarkestLighting).value_or(ColorHSLA(0, 0, 0)).Pack(pColorVariable->m_DarkestLighting, pColorVariable->m_Alpha);
|
||||
const std::optional<ColorHSLA> Value = pResult->GetColor(EqualToFirst ? 2 : 1, pColorVariable->m_DarkestLighting);
|
||||
pColorVariable->SetValue(Value.value_or(ColorHSLA(0, 0, 0)).Pack(pColorVariable->m_DarkestLighting, pColorVariable->m_Alpha));
|
||||
}
|
||||
else if(pVariable->m_Type == SConfigVariable::VAR_STRING)
|
||||
{
|
||||
SStringConfigVariable *pStringVariable = static_cast<SStringConfigVariable *>(pVariable);
|
||||
pStringVariable->SetValue(str_comp(pStringVariable->m_pStr, pResult->GetString(1)) == 0 ? pResult->GetString(2) : pResult->GetString(1));
|
||||
pStringVariable->SetValue(pResult->GetString(str_comp(pStringVariable->m_pStr, pResult->GetString(1)) == 0 ? 2 : 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,9 +54,10 @@ enum
|
|||
CFGFLAG_GAME = 1 << 8,
|
||||
CFGFLAG_NONTEEHISTORIC = 1 << 9,
|
||||
CFGFLAG_COLLIGHT = 1 << 10,
|
||||
CFGFLAG_COLALPHA = 1 << 11,
|
||||
CFGFLAG_INSENSITIVE = 1 << 12,
|
||||
CMDFLAG_PRACTICE = 1 << 13,
|
||||
CFGFLAG_COLLIGHT7 = 1 << 11,
|
||||
CFGFLAG_COLALPHA = 1 << 12,
|
||||
CFGFLAG_INSENSITIVE = 1 << 13,
|
||||
CMDFLAG_PRACTICE = 1 << 14,
|
||||
};
|
||||
|
||||
struct SConfigVariable
|
||||
|
@ -133,7 +134,7 @@ struct SColorConfigVariable : public SConfigVariable
|
|||
{
|
||||
unsigned *m_pVariable;
|
||||
unsigned m_Default;
|
||||
bool m_Light;
|
||||
float m_DarkestLighting;
|
||||
bool m_Alpha;
|
||||
unsigned m_OldValue;
|
||||
|
||||
|
@ -141,11 +142,22 @@ struct SColorConfigVariable : public SConfigVariable
|
|||
SConfigVariable(pConsole, pScriptName, Type, Flags, pHelp),
|
||||
m_pVariable(pVariable),
|
||||
m_Default(Default),
|
||||
m_Light(Flags & CFGFLAG_COLLIGHT),
|
||||
m_Alpha(Flags & CFGFLAG_COLALPHA),
|
||||
m_OldValue(Default)
|
||||
{
|
||||
*m_pVariable = m_Default;
|
||||
if(Flags & CFGFLAG_COLLIGHT)
|
||||
{
|
||||
m_DarkestLighting = ColorHSLA::DARKEST_LGT;
|
||||
}
|
||||
else if(Flags & CFGFLAG_COLLIGHT7)
|
||||
{
|
||||
m_DarkestLighting = ColorHSLA::DARKEST_LGT7;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DarkestLighting = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
~SColorConfigVariable() override = default;
|
||||
|
|
|
@ -45,13 +45,21 @@ pub const CFGFLAG_NONTEEHISTORIC: i32 = 1 << 9;
|
|||
/// Has no effect on other commands or config variables.
|
||||
pub const CFGFLAG_COLLIGHT: i32 = 1 << 10;
|
||||
|
||||
/// Color config variable that can only have lightness (61/255) to 1.0.
|
||||
///
|
||||
/// This is achieved by dividing the lightness channel by and adding (61/255), i.e.
|
||||
/// remapping all the colors.
|
||||
///
|
||||
/// Has no effect on other commands or config variables.
|
||||
pub const CFGFLAG_COLLIGHT7: i32 = 1 << 11;
|
||||
|
||||
/// Color config variable that includes an alpha (opacity) value.
|
||||
///
|
||||
/// Has no effect on other commands or config variables.
|
||||
pub const CFGFLAG_COLALPHA: i32 = 1 << 11;
|
||||
pub const CFGFLAG_COLALPHA: i32 = 1 << 12;
|
||||
|
||||
/// Config variable with insensitive data that can be included in client
|
||||
/// integrity checks.
|
||||
///
|
||||
/// This should only be set on config variables the server could observe anyway.
|
||||
pub const CFGFLAG_INSENSITIVE: i32 = 1 << 12;
|
||||
pub const CFGFLAG_INSENSITIVE: i32 = 1 << 13;
|
||||
|
|
|
@ -138,13 +138,13 @@ MACRO_CONFIG_INT(ClPlayerDefaultEyes, player_default_eyes, 0, 0, 5, CFGFLAG_CLIE
|
|||
MACRO_CONFIG_STR(ClSkinPrefix, cl_skin_prefix, 12, "", CFGFLAG_CLIENT | CFGFLAG_SAVE, "Replace the skins by skins with this prefix (e.g. kitty, santa)")
|
||||
MACRO_CONFIG_INT(ClFatSkins, cl_fat_skins, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Enable fat skins")
|
||||
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorBody, player7_color_body, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player body color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorFeet, player7_color_feet, 0x1C873E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player feet color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorBody, player7_color_body, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Player body color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorFeet, player7_color_feet, 0x1C873E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Player feet color")
|
||||
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorMarking, player7_color_marking, 0xFF0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_COLALPHA | CFGFLAG_INSENSITIVE, "Player marking color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorDecoration, player7_color_decoration, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player decoration color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorHands, player7_color_hands, 0x1B759E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player hands color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorEyes, player7_color_eyes, 0x0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Player eyes color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorMarking, player7_color_marking, 0xFF0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_COLALPHA | CFGFLAG_INSENSITIVE, "Player marking color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorDecoration, player7_color_decoration, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Player decoration color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorHands, player7_color_hands, 0x1B759E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Player hands color")
|
||||
MACRO_CONFIG_COL(ClPlayer7ColorEyes, player7_color_eyes, 0x0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Player eyes color")
|
||||
MACRO_CONFIG_INT(ClPlayer7UseCustomColorBody, player7_use_custom_color_body, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for body")
|
||||
MACRO_CONFIG_INT(ClPlayer7UseCustomColorMarking, player7_use_custom_color_marking, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for marking")
|
||||
MACRO_CONFIG_INT(ClPlayer7UseCustomColorDecoration, player7_use_custom_color_decoration, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for decoration")
|
||||
|
@ -159,13 +159,13 @@ MACRO_CONFIG_STR(ClPlayer7SkinHands, player7_skin_hands, protocol7::MAX_SKIN_ARR
|
|||
MACRO_CONFIG_STR(ClPlayer7SkinFeet, player7_skin_feet, protocol7::MAX_SKIN_ARRAY_SIZE, "standard", CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Player skin feet")
|
||||
MACRO_CONFIG_STR(ClPlayer7SkinEyes, player7_skin_eyes, protocol7::MAX_SKIN_ARRAY_SIZE, "standard", CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Player skin eyes")
|
||||
|
||||
MACRO_CONFIG_COL(ClDummy7ColorBody, dummy7_color_body, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Dummy body color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorFeet, dummy7_color_feet, 0x1C873E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Dummy feet color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorBody, dummy7_color_body, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Dummy body color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorFeet, dummy7_color_feet, 0x1C873E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Dummy feet color")
|
||||
|
||||
MACRO_CONFIG_COL(ClDummy7ColorMarking, dummy7_color_marking, 0xFF0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_COLALPHA | CFGFLAG_INSENSITIVE, "Dummy marking color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorDecoration, dummy7_color_decoration, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Dummy decoration color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorHands, dummy7_color_hands, 0x1B759E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Dummy hands color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorEyes, dummy7_color_eyes, 0x0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT | CFGFLAG_INSENSITIVE, "Dummy eyes color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorMarking, dummy7_color_marking, 0xFF0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_COLALPHA | CFGFLAG_INSENSITIVE, "Dummy marking color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorDecoration, dummy7_color_decoration, 0x1B6F74, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Dummy decoration color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorHands, dummy7_color_hands, 0x1B759E, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Dummy hands color")
|
||||
MACRO_CONFIG_COL(ClDummy7ColorEyes, dummy7_color_eyes, 0x0000FF, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_COLLIGHT7 | CFGFLAG_INSENSITIVE, "Dummy eyes color")
|
||||
MACRO_CONFIG_INT(ClDummy7UseCustomColorBody, dummy7_use_custom_color_body, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for body")
|
||||
MACRO_CONFIG_INT(ClDummy7UseCustomColorMarking, dummy7_use_custom_color_marking, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for marking")
|
||||
MACRO_CONFIG_INT(ClDummy7UseCustomColorDecoration, dummy7_use_custom_color_decoration, 1, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE | CFGFLAG_INSENSITIVE, "Toggles usage of custom colors for decoration")
|
||||
|
|
|
@ -40,7 +40,7 @@ float CConsole::CResult::GetFloat(unsigned Index) const
|
|||
return str_tofloat(m_apArgs[Index]);
|
||||
}
|
||||
|
||||
std::optional<ColorHSLA> CConsole::CResult::GetColor(unsigned Index, bool Light) const
|
||||
std::optional<ColorHSLA> CConsole::CResult::GetColor(unsigned Index, float DarkestLighting) const
|
||||
{
|
||||
if(Index >= m_NumArgs)
|
||||
return std::nullopt;
|
||||
|
@ -51,10 +51,7 @@ std::optional<ColorHSLA> CConsole::CResult::GetColor(unsigned Index, bool Light)
|
|||
unsigned long Value = str_toulong_base(pStr, 10);
|
||||
if(Value == std::numeric_limits<unsigned long>::max())
|
||||
return std::nullopt;
|
||||
const ColorHSLA Hsla = ColorHSLA(Value, true);
|
||||
if(Light)
|
||||
return Hsla.UnclampLighting();
|
||||
return Hsla;
|
||||
return ColorHSLA(Value, true).UnclampLighting(DarkestLighting);
|
||||
}
|
||||
else if(*pStr == '$') // Hex RGB/RGBA
|
||||
{
|
||||
|
|
|
@ -115,7 +115,7 @@ class CConsole : public IConsole
|
|||
const char *GetString(unsigned Index) const override;
|
||||
int GetInteger(unsigned Index) const override;
|
||||
float GetFloat(unsigned Index) const override;
|
||||
std::optional<ColorHSLA> GetColor(unsigned Index, bool Light) const override;
|
||||
std::optional<ColorHSLA> GetColor(unsigned Index, float DarkestLighting) const override;
|
||||
|
||||
void RemoveArgument(unsigned Index) override
|
||||
{
|
||||
|
|
|
@ -393,8 +393,8 @@ void CGhost::InitRenderInfos(CGhostItem *pGhost)
|
|||
pRenderInfo->m_CustomColoredSkin = pGhost->m_Skin.m_UseCustomColor;
|
||||
if(pGhost->m_Skin.m_UseCustomColor)
|
||||
{
|
||||
pRenderInfo->m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(pGhost->m_Skin.m_ColorBody).UnclampLighting());
|
||||
pRenderInfo->m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(pGhost->m_Skin.m_ColorFeet).UnclampLighting());
|
||||
pRenderInfo->m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(pGhost->m_Skin.m_ColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
pRenderInfo->m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(pGhost->m_Skin.m_ColorFeet).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1828,8 +1828,8 @@ CTeeRenderInfo CMenus::GetTeeRenderInfo(vec2 Size, const char *pSkinName, bool C
|
|||
TeeInfo.m_CustomColoredSkin = CustomSkinColors;
|
||||
if(CustomSkinColors)
|
||||
{
|
||||
TeeInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(CustomSkinColorBody).UnclampLighting());
|
||||
TeeInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(CustomSkinColorFeet).UnclampLighting());
|
||||
TeeInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(CustomSkinColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
TeeInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(CustomSkinColorFeet).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -638,8 +638,8 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
OwnSkinInfo.m_CustomColoredSkin = *pUseCustomColor;
|
||||
if(*pUseCustomColor)
|
||||
{
|
||||
OwnSkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(*pColorBody).UnclampLighting());
|
||||
OwnSkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(*pColorFeet).UnclampLighting());
|
||||
OwnSkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(*pColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
OwnSkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(*pColorFeet).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -843,7 +843,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
const ColorRGBA BloodColor = *pUseCustomColor ? color_cast<ColorRGBA>(ColorHSLA(*pColorBody).UnclampLighting()) : pSkinToBeDraw->m_BloodColor;
|
||||
const ColorRGBA BloodColor = *pUseCustomColor ? color_cast<ColorRGBA>(ColorHSLA(*pColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT)) : pSkinToBeDraw->m_BloodColor;
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f);
|
||||
|
|
|
@ -299,7 +299,7 @@ void CMenus::RenderSettingsTeeCustom7(CUIRect MainView)
|
|||
CustomColors.HSplitTop(5.0f, nullptr, &CustomColors);
|
||||
CustomColors.HSplitTop(95.0f, &CustomColorScrollbars, &CustomColors);
|
||||
|
||||
if(RenderHslaScrollbars(&CustomColorScrollbars, CSkins7::ms_apColorVariables[(int)m_Dummy][m_TeePartSelected], m_TeePartSelected == protocol7::SKINPART_MARKING, CSkins7::DARKEST_COLOR_LGT))
|
||||
if(RenderHslaScrollbars(&CustomColorScrollbars, CSkins7::ms_apColorVariables[(int)m_Dummy][m_TeePartSelected], m_TeePartSelected == protocol7::SKINPART_MARKING, ColorHSLA::DARKEST_LGT7))
|
||||
{
|
||||
SetNeedSendInfo();
|
||||
}
|
||||
|
|
|
@ -477,7 +477,7 @@ void CSkins7::RandomizeSkin(int Dummy)
|
|||
|
||||
ColorRGBA CSkins7::GetColor(int Value, bool UseAlpha) const
|
||||
{
|
||||
return color_cast<ColorRGBA>(ColorHSLA(Value, UseAlpha).UnclampLighting(DARKEST_COLOR_LGT));
|
||||
return color_cast<ColorRGBA>(ColorHSLA(Value, UseAlpha).UnclampLighting(ColorHSLA::DARKEST_LGT7));
|
||||
}
|
||||
|
||||
ColorRGBA CSkins7::GetTeamColor(int UseCustomColors, int PartColor, int Team, int Part) const
|
||||
|
@ -501,7 +501,7 @@ ColorRGBA CSkins7::GetTeamColor(int UseCustomColors, int PartColor, int Team, in
|
|||
|
||||
int h = TeamHue;
|
||||
int s = clamp(mix(TeamSat, PartSat, 0.2), MinSat, MaxSat);
|
||||
int l = clamp(mix(TeamLgt, PartLgt, 0.2), (int)DARKEST_COLOR_LGT, 200);
|
||||
int l = clamp(mix(TeamLgt, PartLgt, 0.2), (int)ColorHSLA::DARKEST_LGT7, 200);
|
||||
|
||||
int ColorVal = (h << 16) + (s << 8) + l;
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ public:
|
|||
HAT_OFFSET_SIDE = 2,
|
||||
};
|
||||
|
||||
static constexpr float DARKEST_COLOR_LGT = 61.0f / 255.0f;
|
||||
|
||||
struct CSkinPart
|
||||
{
|
||||
int m_Flags;
|
||||
|
|
|
@ -1551,8 +1551,8 @@ void CGameClient::OnNewSnapshot()
|
|||
if(!m_GameInfo.m_AllowXSkins && (pClient->m_aSkinName[0] == 'x' && pClient->m_aSkinName[1] == '_'))
|
||||
str_copy(pClient->m_aSkinName, "default");
|
||||
|
||||
pClient->m_SkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(pClient->m_ColorBody).UnclampLighting());
|
||||
pClient->m_SkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(pClient->m_ColorFeet).UnclampLighting());
|
||||
pClient->m_SkinInfo.m_ColorBody = color_cast<ColorRGBA>(ColorHSLA(pClient->m_ColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
pClient->m_SkinInfo.m_ColorFeet = color_cast<ColorRGBA>(ColorHSLA(pClient->m_ColorFeet).UnclampLighting(ColorHSLA::DARKEST_LGT));
|
||||
pClient->m_SkinInfo.m_Size = 64;
|
||||
|
||||
// find new skin
|
||||
|
|
|
@ -76,8 +76,8 @@ void CTeeInfo::ToSixup()
|
|||
|
||||
if(m_UseCustomColor)
|
||||
{
|
||||
int ColorBody = ColorHSLA(m_ColorBody).UnclampLighting().Pack(ms_DarkestLGT7);
|
||||
int ColorFeet = ColorHSLA(m_ColorFeet).UnclampLighting().Pack(ms_DarkestLGT7);
|
||||
int ColorBody = ColorHSLA(m_ColorBody).UnclampLighting(ColorHSLA::DARKEST_LGT).Pack(ColorHSLA::DARKEST_LGT7);
|
||||
int ColorFeet = ColorHSLA(m_ColorFeet).UnclampLighting(ColorHSLA::DARKEST_LGT).Pack(ColorHSLA::DARKEST_LGT7);
|
||||
m_aUseCustomColors[protocol7::SKINPART_BODY] = true;
|
||||
m_aUseCustomColors[protocol7::SKINPART_MARKING] = true;
|
||||
m_aUseCustomColors[protocol7::SKINPART_DECORATION] = true;
|
||||
|
@ -138,9 +138,9 @@ void CTeeInfo::FromSixup()
|
|||
str_copy(m_aSkinName, g_aStdSkins[BestSkin].m_aSkinName, sizeof(m_aSkinName));
|
||||
m_UseCustomColor = true;
|
||||
m_ColorBody = ColorHSLA(m_aUseCustomColors[protocol7::SKINPART_BODY] ? m_aSkinPartColors[protocol7::SKINPART_BODY] : 255)
|
||||
.UnclampLighting(ms_DarkestLGT7)
|
||||
.UnclampLighting(ColorHSLA::DARKEST_LGT7)
|
||||
.Pack(ColorHSLA::DARKEST_LGT);
|
||||
m_ColorFeet = ColorHSLA(m_aUseCustomColors[protocol7::SKINPART_FEET] ? m_aSkinPartColors[protocol7::SKINPART_FEET] : 255)
|
||||
.UnclampLighting(ms_DarkestLGT7)
|
||||
.UnclampLighting(ColorHSLA::DARKEST_LGT7)
|
||||
.Pack(ColorHSLA::DARKEST_LGT);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
class CTeeInfo
|
||||
{
|
||||
public:
|
||||
constexpr static const float ms_DarkestLGT7 = 61 / 255.0f;
|
||||
|
||||
char m_aSkinName[24] = {'\0'};
|
||||
int m_UseCustomColor = 0;
|
||||
int m_ColorBody = 0;
|
||||
|
|
|
@ -108,9 +108,9 @@ void cxxbridge1$IConsole_IResult$GetString(const ::IConsole_IResult &self, ::std
|
|||
new (return$) ::StrRef((self.*GetString$)(Index));
|
||||
}
|
||||
|
||||
void cxxbridge1$IConsole_IResult$GetColor(const ::IConsole_IResult &self, ::std::uint32_t Index, bool Light, ::ColorHSLA *return$) noexcept {
|
||||
std::optional<::ColorHSLA> (::IConsole_IResult::*GetColor$)(::std::uint32_t, bool) const = &::IConsole_IResult::GetColor;
|
||||
new(return$)::ColorHSLA((self.*GetColor$)(Index, Light).value_or(::ColorHSLA(0, 0, 0)));
|
||||
void cxxbridge1$IConsole_IResult$GetColor(const ::IConsole_IResult &self, ::std::uint32_t Index, float DarkestLighting, ::ColorHSLA *return$) noexcept {
|
||||
std::optional<::ColorHSLA> (::IConsole_IResult::*GetColor$)(::std::uint32_t, float) const = &::IConsole_IResult::GetColor;
|
||||
new(return$)::ColorHSLA((self.*GetColor$)(Index, DarkestLighting).value_or(::ColorHSLA(0, 0, 0)));
|
||||
}
|
||||
|
||||
::std::int32_t cxxbridge1$IConsole_IResult$NumArguments(const ::IConsole_IResult &self) noexcept {
|
||||
|
|
Loading…
Reference in a new issue