mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Lighten tee colors
This commit is contained in:
parent
54afd2c5af
commit
69d78c21b4
|
@ -97,12 +97,14 @@ public:
|
|||
|
||||
class ColorHSLA : public color4_base
|
||||
{
|
||||
public:
|
||||
using color4_base::color4_base;
|
||||
void ClampLighting()
|
||||
ColorHSLA Lighten()
|
||||
{
|
||||
if(l < 0.5f)
|
||||
l = 0.5f + l * 0.5f;
|
||||
}
|
||||
ColorHSLA col = *this;
|
||||
col.l = 0.5f + l * 0.5f;
|
||||
return col;
|
||||
};
|
||||
};
|
||||
|
||||
class ColorHSVA : public color4_base
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
virtual int GetInteger(unsigned Index) = 0;
|
||||
virtual float GetFloat(unsigned Index) = 0;
|
||||
virtual const char *GetString(unsigned Index) = 0;
|
||||
virtual ColorHSLA GetColor(unsigned Index) = 0;
|
||||
virtual ColorHSLA GetColor(unsigned Index, bool Light) = 0;
|
||||
|
||||
int NumArguments() const { return m_NumArgs; }
|
||||
int m_ClientID;
|
||||
|
|
|
@ -24,18 +24,19 @@ extern CConfiguration g_Config;
|
|||
|
||||
enum
|
||||
{
|
||||
CFGFLAG_SAVE=1,
|
||||
CFGFLAG_CLIENT=2,
|
||||
CFGFLAG_SERVER=4,
|
||||
CFGFLAG_STORE=8,
|
||||
CFGFLAG_MASTER=16,
|
||||
CFGFLAG_ECON=32,
|
||||
CFGFLAG_SAVE=1<<0,
|
||||
CFGFLAG_CLIENT=1<<1,
|
||||
CFGFLAG_SERVER=1<<2,
|
||||
CFGFLAG_STORE=1<<3,
|
||||
CFGFLAG_MASTER=1<<4,
|
||||
CFGFLAG_ECON=1<<5,
|
||||
// DDRace
|
||||
|
||||
CMDFLAG_TEST=64,
|
||||
CFGFLAG_CHAT=128,
|
||||
CFGFLAG_GAME=256,
|
||||
CFGFLAG_NONTEEHISTORIC=512,
|
||||
CMDFLAG_TEST=1<<6,
|
||||
CFGFLAG_CHAT=1<<7,
|
||||
CFGFLAG_GAME=1<<8,
|
||||
CFGFLAG_NONTEEHISTORIC=1<<9,
|
||||
CFGFLAG_COLLIGHT=1<<10,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -37,10 +37,11 @@ float CConsole::CResult::GetFloat(unsigned Index)
|
|||
return str_tofloat(m_apArgs[Index]);
|
||||
}
|
||||
|
||||
ColorHSLA CConsole::CResult::GetColor(unsigned Index)
|
||||
ColorHSLA CConsole::CResult::GetColor(unsigned Index, bool Light)
|
||||
{
|
||||
ColorHSLA hsl = ColorHSLA(0, 0, 0).Lighten();
|
||||
if(Index >= m_NumArgs)
|
||||
return -1;
|
||||
return hsl;
|
||||
|
||||
const char *pStr = m_apArgs[Index];
|
||||
if(str_isallnum(pStr)) // Teeworlds Color (Packed HSL)
|
||||
|
@ -67,31 +68,31 @@ ColorHSLA CConsole::CResult::GetColor(unsigned Index)
|
|||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
return hsl;
|
||||
}
|
||||
|
||||
return color_cast<ColorHSLA>(rgb);
|
||||
hsl = color_cast<ColorHSLA>(rgb);
|
||||
}
|
||||
else if(!str_comp_nocase(pStr, "red"))
|
||||
return ColorHSLA(0.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(0.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "yellow"))
|
||||
return ColorHSLA(1.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(1.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "green"))
|
||||
return ColorHSLA(2.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(2.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "cyan"))
|
||||
return ColorHSLA(3.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(3.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "blue"))
|
||||
return ColorHSLA(4.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(4.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "magenta"))
|
||||
return ColorHSLA(5.0f/6.0f, 1, .5f);
|
||||
hsl = ColorHSLA(5.0f/6.0f, 1, .5f);
|
||||
else if(!str_comp_nocase(pStr, "white"))
|
||||
return ColorHSLA(0, 0, 1);
|
||||
hsl = ColorHSLA(0, 0, 1);
|
||||
else if(!str_comp_nocase(pStr, "gray"))
|
||||
return ColorHSLA(0, 0, .5f);
|
||||
hsl = ColorHSLA(0, 0, .5f);
|
||||
else if(!str_comp_nocase(pStr, "black"))
|
||||
return ColorHSLA(0, 0, 0);
|
||||
hsl = ColorHSLA(0, 0, 0);
|
||||
|
||||
return -1;
|
||||
return hsl.Lighten();
|
||||
}
|
||||
|
||||
const IConsole::CCommandInfo *CConsole::CCommand::NextCommandInfo(int AccessLevel, int FlagMask) const
|
||||
|
@ -704,6 +705,12 @@ struct CIntVariableData
|
|||
int m_OldValue;
|
||||
};
|
||||
|
||||
struct CColVariableData : public CIntVariableData
|
||||
{
|
||||
template<class... T> CColVariableData(bool b, T... t) : CIntVariableData{t...}, m_Light(b) {}
|
||||
bool m_Light;
|
||||
};
|
||||
|
||||
struct CStrVariableData
|
||||
{
|
||||
IConsole *m_pConsole;
|
||||
|
@ -743,11 +750,11 @@ static void IntVariableCommand(IConsole::IResult *pResult, void *pUserData)
|
|||
|
||||
static void ColVariableCommand(IConsole::IResult *pResult, void *pUserData)
|
||||
{
|
||||
CIntVariableData *pData = (CIntVariableData *)pUserData;
|
||||
CColVariableData *pData = (CColVariableData *)pUserData;
|
||||
|
||||
if(pResult->NumArguments())
|
||||
{
|
||||
int Val = pResult->GetColor(0).Pack() & 0xFFFFFF;
|
||||
int Val = pResult->GetColor(0, pData->m_Light).Pack() & 0xFFFFFF;
|
||||
|
||||
// do clamping
|
||||
if(pData->m_Min != pData->m_Max)
|
||||
|
@ -937,7 +944,7 @@ CConsole::CConsole(int FlagMask)
|
|||
|
||||
#define MACRO_CONFIG_COL(Name,ScriptName,Def,Min,Max,Flags,Desc) \
|
||||
{ \
|
||||
static CIntVariableData Data = { this, &g_Config.m_##Name, Min, Max, Def }; \
|
||||
static CColVariableData Data = { static_cast<bool>(Flags & CFGFLAG_COLLIGHT), this, &g_Config.m_##Name, Min, Max, Def }; \
|
||||
Register(#ScriptName, "?i", Flags, ColVariableCommand, &Data, Desc); \
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class CConsole : public IConsole
|
|||
virtual const char *GetString(unsigned Index);
|
||||
virtual int GetInteger(unsigned Index);
|
||||
virtual float GetFloat(unsigned Index);
|
||||
virtual ColorHSLA GetColor(unsigned Index);
|
||||
virtual ColorHSLA GetColor(unsigned Index, bool Light = false);
|
||||
|
||||
// DDRace
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ MACRO_CONFIG_INT(ClAutoStatboardScreenshotMax, cl_auto_statboard_screenshot_max,
|
|||
MACRO_CONFIG_INT(ClDefaultZoom, cl_default_zoom, 10, 0, 20, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Default zoom level (10 default, min 0, max 20)")
|
||||
|
||||
MACRO_CONFIG_INT(ClPlayerUseCustomColor, player_use_custom_color, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Toggles usage of custom colors")
|
||||
MACRO_CONFIG_COL(ClPlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player body color")
|
||||
MACRO_CONFIG_COL(ClPlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player feet color")
|
||||
MACRO_CONFIG_COL(ClPlayerColorBody, player_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE|CFGFLAG_COLLIGHT, "Player body color")
|
||||
MACRO_CONFIG_COL(ClPlayerColorFeet, player_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE|CFGFLAG_COLLIGHT, "Player feet color")
|
||||
MACRO_CONFIG_STR(ClPlayerSkin, player_skin, 24, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Player skin")
|
||||
MACRO_CONFIG_STR(ClSkinPrefix, cl_skin_prefix, 100, "", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Replace the skins by skins with this prefix (e.g. kitty, coala, santa)")
|
||||
MACRO_CONFIG_INT(ClFatSkins, cl_fat_skins, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Enable fat skins")
|
||||
|
|
Loading…
Reference in a new issue