Skip to content

Commit

Permalink
Rainbow fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SollyBunny committed Nov 23, 2024
1 parent b7bd334 commit 7c04c1a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/engine/shared/tater_variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ MACRO_CONFIG_INT(ClAutoVerify, tc_auto_verify, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG
// Rainbow
MACRO_CONFIG_INT(ClRainbow, tc_rainbow, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Turn on rainbow client side")
MACRO_CONFIG_INT(ClRainbowOthers, tc_rainbow_others, 0, 0, 1, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Turn on rainbow client side for others")
MACRO_CONFIG_INT(ClRainbowMode, tc_rainbow_mode, 1, 1, 4, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow mode (1: rainbow, 2: pulse, 3: darkness)")
MACRO_CONFIG_INT(ClRainbowMode, tc_rainbow_mode, 1, 1, 4, CFGFLAG_CLIENT | CFGFLAG_SAVE, "Rainbow mode (1: rainbow, 2: pulse, 3: darkness, 4: random)")

// AAAAAAA
MACRO_CONFIG_INT(ClAmIFrozen, EEEfrz, 0, 0, 1, CFGFLAG_CLIENT, "")
2 changes: 1 addition & 1 deletion src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@ void CMenus::RenderSettingsTClient(CUIRect MainView)
Ui()->DoLabel(&Label, Localize("Rainbow"), HeadlineFontSize, TEXTALIGN_ML);
Column.HSplitTop(MarginSmall, nullptr, &Column);

static std::vector<const char *> s_DropDownNames = {Localize("Rainbow"), Localize("Pulse"), Localize("Black")};
static std::vector<const char *> s_DropDownNames = {Localize("Rainbow"), Localize("Pulse"), Localize("Black"), Localize("Random")};
static CUi::SDropDownState s_RainbowDropDownState;
static CScrollRegion s_RainbowDropDownScrollRegion;
s_RainbowDropDownState.m_SelectionPopupContext.m_pScrollRegion = &s_RainbowDropDownScrollRegion;
Expand Down
78 changes: 39 additions & 39 deletions src/game/client/components/rainbow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,67 @@

#include "rainbow.h"

void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pinfo)
template <typename T>
T color_lerp(T a, T b, float c) {
T result;
for(size_t i = 0; i < 4; ++i)
result[i] = a[i] + c * (b[i] - a[i]);
return result;
}

void CRainbow::TransformColor(unsigned char Mode, int Tick, CTeeRenderInfo *pInfo)
{
if(!Mode)
return;

int DefTick = Tick % 255;

const ColorHSLA PlayerColBody = ColorHSLA(g_Config.m_ClPlayerColorBody);
const ColorHSLA PlayerColFeet = ColorHSLA(g_Config.m_ClPlayerColorFeet);
int DefTick = Tick % 256;

pinfo->m_CustomColoredSkin = true;
ColorRGBA Col;
if(Mode == COLORMODE_RAINBOW)
{
const ColorRGBA Col = color_cast<ColorRGBA>(ColorHSLA((float)DefTick / 255.0f, 1.0f, 0.5f));
pinfo->m_ColorBody = Col;
pinfo->m_ColorFeet = Col;
pinfo->m_BloodColor = Col;
}
Col = color_cast<ColorRGBA>(ColorHSLA((float)DefTick / 256.0f, 1.0f, 0.5f));
else if(Mode == COLORMODE_PULSE)
{
pinfo->m_ColorBody.s = 1.0f;
pinfo->m_ColorFeet.s = 1.0f;
pinfo->m_BloodColor.s = 1.0f;
pinfo->m_ColorBody.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_ColorFeet.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_BloodColor.l = 0.5f + std::fabs(((float)DefTick / 255.0f) - 0.5f);
pinfo->m_ColorBody.h = (float)DefTick / 255.0f;
pinfo->m_ColorFeet.h = (float)DefTick / 255.0f;
pinfo->m_BloodColor.h = (float)DefTick / 255.0f;
}
Col = color_cast<ColorRGBA>(ColorHSLA((float)DefTick / 256.0f, 1.0f, 0.5f + std::fabs(((float)DefTick / 256.0f) - 0.5f)));
else if(Mode == COLORMODE_DARKNESS)
Col = ColorRGBA(0.0f, 0.0f, 0.0f);
else if(Mode == COLORMODE_RANDOM)
{
pinfo->m_ColorBody = ColorRGBA(0.0f, 0.0f, 0.0f);
pinfo->m_ColorFeet = ColorRGBA(0.0f, 0.0f, 0.0f);
pinfo->m_BloodColor = ColorRGBA(0.0f, 0.0f, 0.0f);
}
else
{
pinfo->m_CustomColoredSkin = true;
pinfo->m_ColorBody = color_cast<ColorRGBA>(PlayerColBody);
pinfo->m_ColorFeet = color_cast<ColorRGBA>(PlayerColFeet);
// pinfo->m_BloodColor = pinfo->m_BloodColor; // TODO reset blood color
static ColorHSLA Col1 = ColorHSLA(0.0f, 0.0f, 0.0f, 0.0f), Col2 = ColorHSLA(0.0f, 0.0f, 0.0f, 0.0f);
if(Col2.a == 0.0f) // Create first target
{
Col2 = ColorHSLA((float)rand() / (float)RAND_MAX, 1.0f, (float)rand() / (float)RAND_MAX, 1.0f);
}
if(Col1.a == 0.0f) // Shift target to source, create new target
{
Col1 = Col2;
Col2 = ColorHSLA((float)rand() / (float)RAND_MAX, 1.0f, (float)rand() / (float)RAND_MAX, 1.0f);
}
Col = color_cast<ColorRGBA>(color_lerp(Col1, Col2, (float)DefTick / 256.0f));
if (DefTick == 255)
Col1.a = 0.0f;
}
pInfo->m_BloodColor = Col;
pInfo->m_ColorBody = Col;
pInfo->m_ColorFeet = Col;
pInfo->m_CustomColoredSkin = true;
}

void CRainbow::OnRender()
{
static int Tick = 0;
++Tick;
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(!m_pClient->m_Snap.m_aCharacters[i].m_Active)
continue;

// check if local player
bool Local = m_pClient->m_Snap.m_LocalClientId == i;

CTeeRenderInfo *RenderInfo = &m_pClient->m_aClients[i].m_RenderInfo;
// check if rainbow is enabled
if(g_Config.m_ClRainbow && Local) // rainbow is enabled and is own player
{
TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo);
}
TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo);
else if(g_Config.m_ClRainbowOthers && !Local) // rainbow is enabled and is not own player
{
TransformColor(g_Config.m_ClRainbowMode, m_pClient->m_GameWorld.m_GameTick, RenderInfo);
}
TransformColor(g_Config.m_ClRainbowMode, Tick, RenderInfo);
}
}
1 change: 1 addition & 0 deletions src/game/client/components/rainbow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CRainbow : public CComponent
COLORMODE_RAINBOW = 1,
COLORMODE_PULSE,
COLORMODE_DARKNESS,
COLORMODE_RANDOM
};
};

Expand Down

0 comments on commit 7c04c1a

Please sign in to comment.