mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Cleanup colors
This commit is contained in:
parent
6cf8999a2f
commit
cc36af73be
|
@ -25,24 +25,22 @@ inline float HueToRgb(float v1, float v2, float h)
|
|||
|
||||
inline float RgbToHue(vec3 rgb)
|
||||
{
|
||||
float h_min = min(min(rgb.r, rgb.g), rgb.b);
|
||||
float h_max = max(max(rgb.r, rgb.g), rgb.b);
|
||||
float h_min = min(rgb.r, rgb.g, rgb.b);
|
||||
float h_max = max(rgb.r, rgb.g, rgb.b);
|
||||
|
||||
float hue = 0.0f;
|
||||
if(h_max != h_min)
|
||||
{
|
||||
float c = h_max - h_min;
|
||||
if(h_max == rgb.r)
|
||||
hue = (rgb.g - rgb.b) / c + (rgb.g < rgb.b ? 6 : 0);
|
||||
else if(h_max == rgb.g)
|
||||
hue = (rgb.b - rgb.r) / c + 2;
|
||||
else
|
||||
hue = (rgb.r - rgb.g) / c + 4;
|
||||
}
|
||||
|
||||
if(h_max == rgb.r)
|
||||
hue = (rgb.g-rgb.b) / (h_max-h_min);
|
||||
else if(h_max == rgb.g)
|
||||
hue = 2.0f + (rgb.b-rgb.r) / (h_max-h_min);
|
||||
else
|
||||
hue = 4.0f + (rgb.r-rgb.g) / (h_max-h_min);
|
||||
|
||||
hue /= 6.0f;
|
||||
|
||||
if(hue < 0.0f)
|
||||
hue += 1.0f;
|
||||
|
||||
return hue;
|
||||
return hue / 6.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -147,6 +145,19 @@ inline vec3 RgbToHsv(vec3 rgb)
|
|||
return vec3(hue, s, l);
|
||||
}
|
||||
|
||||
inline vec3 RgbToHsl(vec3 rgb)
|
||||
{
|
||||
float Min = min(rgb.r, rgb.g, rgb.b);
|
||||
float Max = max(rgb.r, rgb.g, rgb.b);
|
||||
|
||||
float c = Max - Min;
|
||||
float h = RgbToHue(rgb);
|
||||
float l = 0.5f * (Max + Min);
|
||||
float s = (l != 1.0f && l != 0.0f) ? (c/(1 - (absolute(2 * l - 1)))) : 0;
|
||||
|
||||
return vec3(h, s, l);
|
||||
}
|
||||
|
||||
/*
|
||||
Function: HexToRgba
|
||||
Converts Hex to Rgba
|
||||
|
@ -164,4 +175,14 @@ inline vec4 HexToRgba(int hex)
|
|||
return c;
|
||||
}
|
||||
|
||||
inline vec3 UnpackColor(int v)
|
||||
{
|
||||
return vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f);
|
||||
}
|
||||
|
||||
inline vec4 Color3to4(vec3 col)
|
||||
{
|
||||
return vec4(col[0], col[1], col[2], 1.0f);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -64,7 +64,9 @@ public:
|
|||
const float pi = 3.1415926535897932384626433f;
|
||||
|
||||
template <typename T> inline T min(T a, T b) { return a<b?a:b; }
|
||||
template <typename T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
|
||||
template <typename T> inline T max(T a, T b) { return a>b?a:b; }
|
||||
template <typename T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
|
||||
template <typename T> inline T absolute(T a) { return a<T(0)?-a:a; }
|
||||
|
||||
template <typename T> inline T in_range(T a, T lower, T upper) { return lower <= a && a <= upper; }
|
||||
|
|
|
@ -1072,11 +1072,6 @@ void CClient::Render()
|
|||
}
|
||||
}
|
||||
|
||||
vec3 CClient::GetColorV3(int v)
|
||||
{
|
||||
return HslToRgb(vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f));
|
||||
}
|
||||
|
||||
const char *CClient::LoadMap(const char *pName, const char *pFilename, SHA256_DIGEST *pWantedSha256, unsigned WantedCrc)
|
||||
{
|
||||
static char s_aErrorMsg[128];
|
||||
|
|
|
@ -209,7 +209,6 @@ class CClient : public IClient, public CDemoPlayer::IListener
|
|||
volatile int m_GfxState;
|
||||
static void GraphicsThreadProxy(void *pThis) { ((CClient*)pThis)->GraphicsThread(); }
|
||||
void GraphicsThread();
|
||||
vec3 GetColorV3(int v);
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
CFifo m_Fifo;
|
||||
|
@ -361,7 +360,7 @@ public:
|
|||
static void ConchainWindowVSync(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainTimeoutSeed(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
static void ConchainPassword(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData);
|
||||
|
||||
|
||||
static void Con_DemoSlice(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_DemoSliceBegin(IConsole::IResult *pResult, void *pUserData);
|
||||
static void Con_DemoSliceEnd(IConsole::IResult *pResult, void *pUserData);
|
||||
|
|
|
@ -167,7 +167,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID)
|
|||
if(ClientID >= 0)
|
||||
{
|
||||
if(m_pClient->m_aClients[ClientID].m_UseCustomColor)
|
||||
BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_ColorBody);
|
||||
BloodColor = HslToRgb(UnpackColor(m_pClient->m_aClients[ClientID].m_ColorBody));
|
||||
else
|
||||
{
|
||||
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(m_pClient->m_aClients[ClientID].m_SkinID);
|
||||
|
|
|
@ -361,18 +361,16 @@ void CGhost::InitRenderInfos(CGhostItem *pGhost)
|
|||
if(pGhost->m_Skin.m_UseCustomColor)
|
||||
{
|
||||
pRenderInfo->m_Texture = m_pClient->m_pSkins->Get(SkinId)->m_ColorTexture;
|
||||
pRenderInfo->m_ColorBody = m_pClient->m_pSkins->GetColorV4(pGhost->m_Skin.m_ColorBody);
|
||||
pRenderInfo->m_ColorFeet = m_pClient->m_pSkins->GetColorV4(pGhost->m_Skin.m_ColorFeet);
|
||||
pRenderInfo->m_ColorBody = HslToRgb(UnpackColor(pGhost->m_Skin.m_ColorBody));
|
||||
pRenderInfo->m_ColorFeet = HslToRgb(UnpackColor(pGhost->m_Skin.m_ColorFeet));
|
||||
}
|
||||
else
|
||||
{
|
||||
pRenderInfo->m_Texture = m_pClient->m_pSkins->Get(SkinId)->m_OrgTexture;
|
||||
pRenderInfo->m_ColorBody = vec4(1, 1, 1, 1);
|
||||
pRenderInfo->m_ColorFeet = vec4(1, 1, 1, 1);
|
||||
pRenderInfo->m_ColorBody = vec3(1, 1, 1);
|
||||
pRenderInfo->m_ColorFeet = vec3(1, 1, 1);
|
||||
}
|
||||
|
||||
pRenderInfo->m_ColorBody.a = 0.5f;
|
||||
pRenderInfo->m_ColorFeet.a = 0.5f;
|
||||
pRenderInfo->m_Size = 64;
|
||||
}
|
||||
|
||||
|
|
|
@ -799,7 +799,7 @@ int CMenus::RenderMenubar(CUIRect r)
|
|||
Box.VSplitRight(10.0f, &Box, &Button);
|
||||
Box.VSplitRight(33.0f, &Box, &Button);
|
||||
static int s_SettingsButton=0;
|
||||
|
||||
|
||||
if(DoButton_MenuTab(&s_SettingsButton, "\xEE\xA2\xB8", m_ActivePage==PAGE_SETTINGS, &Button, CUI::CORNER_T))
|
||||
NewPage = PAGE_SETTINGS;
|
||||
|
||||
|
@ -1909,7 +1909,7 @@ void CMenus::RenderUpdating(const char *pCaption, int current, int total)
|
|||
|
||||
CUIRect Screen = *UI()->Screen();
|
||||
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
||||
|
||||
|
||||
Graphics()->BlendNormal();
|
||||
RenderBackground();
|
||||
|
||||
|
|
|
@ -391,14 +391,14 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(*UseCustomColor)
|
||||
{
|
||||
OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;
|
||||
OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(*ColorBody);
|
||||
OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(*ColorFeet);
|
||||
OwnSkinInfo.m_ColorBody = HslToRgb(UnpackColor(*ColorBody));
|
||||
OwnSkinInfo.m_ColorFeet = HslToRgb(UnpackColor(*ColorFeet));
|
||||
}
|
||||
else
|
||||
{
|
||||
OwnSkinInfo.m_Texture = pOwnSkin->m_OrgTexture;
|
||||
OwnSkinInfo.m_ColorBody = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
OwnSkinInfo.m_ColorFeet = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
OwnSkinInfo.m_ColorBody = vec3(1.0f, 1.0f, 1.0f);
|
||||
OwnSkinInfo.m_ColorFeet = vec3(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
OwnSkinInfo.m_Size = 50.0f*UI()->Scale();
|
||||
|
||||
|
@ -584,14 +584,14 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
if(*UseCustomColor)
|
||||
{
|
||||
Info.m_Texture = s->m_ColorTexture;
|
||||
Info.m_ColorBody = m_pClient->m_pSkins->GetColorV4(*ColorBody);
|
||||
Info.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(*ColorFeet);
|
||||
Info.m_ColorBody = HslToRgb(UnpackColor(*ColorBody));
|
||||
Info.m_ColorFeet = HslToRgb(UnpackColor(*ColorFeet));
|
||||
}
|
||||
else
|
||||
{
|
||||
Info.m_Texture = s->m_OrgTexture;
|
||||
Info.m_ColorBody = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Info.m_ColorFeet = vec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Info.m_ColorBody = vec3(1.0f, 1.0f, 1.0f);
|
||||
Info.m_ColorFeet = vec3(1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
Info.m_Size = UI()->Scale()*50.0f;
|
||||
|
@ -604,7 +604,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView)
|
|||
RenderTools()->UI()->DoLabelScaled(&Item.m_Rect, aBuf, 12.0f, -1,Item.m_Rect.w);
|
||||
if(g_Config.m_Debug)
|
||||
{
|
||||
vec3 BloodColor = *UseCustomColor ? m_pClient->m_pSkins->GetColorV3(*ColorBody) : s->m_BloodColor;
|
||||
vec3 BloodColor = *UseCustomColor ? HslToRgb(UnpackColor(*ColorBody)) : s->m_BloodColor;
|
||||
Graphics()->TextureSet(-1);
|
||||
Graphics()->QuadsBegin();
|
||||
Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f);
|
||||
|
@ -1055,7 +1055,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
g_Config.m_GfxEnableTextureUnitOptimization ^= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check if the new settings require a restart
|
||||
if(CheckSettings)
|
||||
{
|
||||
|
@ -1513,7 +1513,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 1.0f, 0.5f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 1.0f, 0.5f)) * 255.0f; // default values
|
||||
g_Config.m_ClMessageSystemHue = HSL.h;
|
||||
g_Config.m_ClMessageSystemSat = HSL.s;
|
||||
g_Config.m_ClMessageSystemLht = HSL.l;
|
||||
|
@ -1565,7 +1565,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 0.5f, 0.5f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 0.5f, 0.5f)) * 255.0f; // default values
|
||||
g_Config.m_ClMessageHighlightHue = HSL.h;
|
||||
g_Config.m_ClMessageHighlightSat = HSL.s;
|
||||
g_Config.m_ClMessageHighlightLht = HSL.l;
|
||||
|
@ -1623,7 +1623,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(0.65f, 1.0f, 0.65f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(0.65f, 1.0f, 0.65f)) * 255.0f; // default values
|
||||
g_Config.m_ClMessageTeamHue = HSL.h;
|
||||
g_Config.m_ClMessageTeamSat = HSL.s;
|
||||
g_Config.m_ClMessageTeamLht = HSL.l;
|
||||
|
@ -1738,7 +1738,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 1.0f, 1.0f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(1.0f, 1.0f, 1.0f)) * 255.0f; // default values
|
||||
g_Config.m_ClMessageHue = HSL.h;
|
||||
g_Config.m_ClMessageSat = HSL.s;
|
||||
g_Config.m_ClMessageLht = HSL.l;
|
||||
|
@ -1795,7 +1795,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(0.5f, 0.5f, 1.0f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(0.5f, 0.5f, 1.0f)) * 255.0f; // default values
|
||||
g_Config.m_ClLaserInnerHue = HSL.h;
|
||||
g_Config.m_ClLaserInnerSat = HSL.s;
|
||||
g_Config.m_ClLaserInnerLht = HSL.l;
|
||||
|
@ -1831,7 +1831,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView)
|
|||
static int s_DefaultButton = 0;
|
||||
if(DoButton_Menu(&s_DefaultButton, Localize("Reset"), 0, &Button))
|
||||
{
|
||||
vec3 HSL = RgbToHsl(vec3(0.075f, 0.075f, 0.25f)); // default values
|
||||
vec3 HSL = RgbToHsl(vec3(0.075f, 0.075f, 0.25f)) * 255.0f; // default values
|
||||
g_Config.m_ClLaserOutlineHue = HSL.h;
|
||||
g_Config.m_ClLaserOutlineSat = HSL.s;
|
||||
g_Config.m_ClLaserOutlineLht = HSL.l;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "players.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset)
|
||||
void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset, float Alpha)
|
||||
{
|
||||
vec2 HandPos = CenterPos + Dir;
|
||||
float Angle = GetAngle(Dir);
|
||||
|
@ -48,7 +48,7 @@ void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float
|
|||
|
||||
//Graphics()->TextureSet(data->m_aImages[IMAGE_CHAR_DEFAULT].id);
|
||||
Graphics()->TextureSet(pInfo->m_Texture);
|
||||
Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, pInfo->m_ColorBody.a);
|
||||
Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, Alpha);
|
||||
|
||||
// two passes
|
||||
for(int i = 0; i < 2; i++)
|
||||
|
@ -113,11 +113,11 @@ void CPlayers::RenderHook(
|
|||
else
|
||||
OtherTeam = m_pClient->m_Teams.Team(ClientID) != m_pClient->m_Teams.Team(m_pClient->m_Snap.m_LocalClientID);
|
||||
|
||||
if(OtherTeam)
|
||||
{
|
||||
RenderInfo.m_ColorBody.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
RenderInfo.m_ColorFeet.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
}
|
||||
if(m_pClient->m_aClients[m_pClient->m_Snap.m_LocalClientID].m_Solo && !Local)
|
||||
OtherTeam = true;
|
||||
|
||||
if(!Local && m_pClient->m_aClients[ClientID].m_Solo)
|
||||
OtherTeam = true;
|
||||
|
||||
RenderInfo.m_Size = 64.0f;
|
||||
|
||||
|
@ -131,7 +131,7 @@ void CPlayers::RenderHook(
|
|||
if(Prev.m_HookState>0 && Player.m_HookState>0)
|
||||
{
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id);
|
||||
|
||||
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if(ClientID < 0)
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
@ -173,7 +173,7 @@ void CPlayers::RenderHook(
|
|||
Graphics()->QuadsSetRotation(0);
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
RenderHand(&RenderInfo, Position, normalize(HookPos-Pos), -pi/2, vec2(20, 0));
|
||||
RenderHand(&RenderInfo, Position, normalize(HookPos-Pos), -pi/2, vec2(20, 0), g_Config.m_ClShowOthersAlpha / 100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,17 +516,11 @@ void CPlayers::RenderPlayer(
|
|||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Graphics()->QuadsSetRotation(0);
|
||||
|
||||
if(OtherTeam)
|
||||
{
|
||||
RenderInfo.m_ColorBody.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
RenderInfo.m_ColorFeet.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
}
|
||||
|
||||
switch (Player.m_Weapon)
|
||||
{
|
||||
case WEAPON_GUN: RenderHand(&RenderInfo, p, Direction, -3*pi/4, vec2(-15, 4)); break;
|
||||
case WEAPON_SHOTGUN: RenderHand(&RenderInfo, p, Direction, -pi/2, vec2(-5, 4)); break;
|
||||
case WEAPON_GRENADE: RenderHand(&RenderInfo, p, Direction, -pi/2, vec2(-4, 7)); break;
|
||||
case WEAPON_GUN: RenderHand(&RenderInfo, p, Direction, -3*pi/4, vec2(-15, 4), g_Config.m_ClShowOthersAlpha / 100.0f); break;
|
||||
case WEAPON_SHOTGUN: RenderHand(&RenderInfo, p, Direction, -pi/2, vec2(-5, 4), g_Config.m_ClShowOthersAlpha / 100.0f); break;
|
||||
case WEAPON_GRENADE: RenderHand(&RenderInfo, p, Direction, -pi/2, vec2(-4, 7), g_Config.m_ClShowOthersAlpha / 100.0f); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -542,19 +536,11 @@ void CPlayers::RenderPlayer(
|
|||
Client()->IntraGameTick());
|
||||
|
||||
CTeeRenderInfo Ghost = RenderInfo;
|
||||
Ghost.m_ColorBody.a = 0.5f;
|
||||
Ghost.m_ColorFeet.a = 0.5f;
|
||||
RenderTools()->RenderTee(&State, &Ghost, Player.m_Emote, Direction, GhostPosition, true); // render ghost
|
||||
RenderTools()->RenderTee(&State, &Ghost, Player.m_Emote, Direction, GhostPosition, 0.5f); // render ghost
|
||||
}
|
||||
|
||||
RenderInfo.m_Size = 64.0f; // force some settings
|
||||
|
||||
if(OtherTeam)
|
||||
{
|
||||
RenderInfo.m_ColorBody.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
RenderInfo.m_ColorFeet.a = g_Config.m_ClShowOthersAlpha / 100.0f;
|
||||
}
|
||||
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Graphics()->QuadsSetRotation(0);
|
||||
if(g_Config.m_ClShowDirection && ClientID >= 0 && (!Local || DemoPlayer()->IsPlaying()))
|
||||
|
@ -586,8 +572,11 @@ void CPlayers::RenderPlayer(
|
|||
Graphics()->QuadsSetRotation(0);
|
||||
}
|
||||
|
||||
RenderTools()->RenderTee(&State, &RenderInfo, Player.m_Emote, Direction, Position, OtherTeam || ClientID < 0);
|
||||
|
||||
if(OtherTeam || ClientID < 0)
|
||||
RenderTools()->RenderTee(&State, &RenderInfo, Player.m_Emote, Direction, Position, g_Config.m_ClShowOthersAlpha / 100.0f);
|
||||
else
|
||||
RenderTools()->RenderTee(&State, &RenderInfo, Player.m_Emote, Direction, Position);
|
||||
|
||||
int QuadOffsetToEmoticon = NUM_WEAPONS * 2 + 2 + 2;
|
||||
if(Player.m_PlayerFlags&PLAYERFLAG_CHATTING)
|
||||
{
|
||||
|
@ -660,8 +649,8 @@ void CPlayers::OnRender()
|
|||
else
|
||||
{
|
||||
m_aRenderInfo[i].m_Texture = m_pClient->m_pSkins->Get(Skin)->m_OrgTexture;
|
||||
m_aRenderInfo[i].m_ColorBody = vec4(1,1,1,1);
|
||||
m_aRenderInfo[i].m_ColorFeet = vec4(1,1,1,1);
|
||||
m_aRenderInfo[i].m_ColorBody = vec3(1,1,1);
|
||||
m_aRenderInfo[i].m_ColorFeet = vec3(1,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +731,7 @@ void CPlayers::OnInit()
|
|||
RenderTools()->SelectSprite(SPRITE_OOP + i);
|
||||
RenderTools()->QuadContainerAddSprite(m_WeaponEmoteQuadContainerIndex, 64.f, false);
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < NUM_WEAPONS; ++i)
|
||||
{
|
||||
m_WeaponSpriteMuzzleQuadContainerIndex[i] = Graphics()->CreateQuadContainer();
|
||||
|
|
|
@ -9,7 +9,7 @@ class CPlayers : public CComponent
|
|||
friend class CGhost;
|
||||
|
||||
CTeeRenderInfo m_aRenderInfo[MAX_CLIENTS];
|
||||
void RenderHand(class CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset);
|
||||
void RenderHand(class CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset, float Alpha = 1.0f);
|
||||
void RenderPlayer(
|
||||
const CNetObj_Character *pPrevChar,
|
||||
const CNetObj_Character *pPlayerChar,
|
||||
|
|
|
@ -135,8 +135,8 @@ void CScoreboard::RenderSpectators(float x, float y, float w)
|
|||
|
||||
if(m_pClient->m_aClients[pInfo->m_ClientID].m_AuthLevel)
|
||||
{
|
||||
vec4 Color = m_pClient->m_pSkins->GetColorV4(g_Config.m_ClAuthedPlayerColor);
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, Color.a);
|
||||
vec3 Color = HslToRgb(UnpackColor(g_Config.m_ClAuthedPlayerColor));
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, 1.0f);
|
||||
}
|
||||
|
||||
if(g_Config.m_ClShowIDs)
|
||||
|
@ -456,8 +456,8 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
TextRender()->SetCursor(&Cursor, NameOffset, y + (LineHeight - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
||||
if(m_pClient->m_aClients[pInfo->m_ClientID].m_AuthLevel)
|
||||
{
|
||||
vec4 Color = m_pClient->m_pSkins->GetColorV4(g_Config.m_ClAuthedPlayerColor);
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, Color.a);
|
||||
vec3 Color = HslToRgb(UnpackColor(g_Config.m_ClAuthedPlayerColor));
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, 1.0f);
|
||||
}
|
||||
|
||||
if(g_Config.m_ClShowIDs)
|
||||
|
@ -478,8 +478,8 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
|
|||
if(str_comp(m_pClient->m_aClients[pInfo->m_ClientID].m_aClan,
|
||||
m_pClient->m_aClients[GameClient()->m_LocalIDs[0]].m_aClan) == 0)
|
||||
{
|
||||
vec4 Color = m_pClient->m_pSkins->GetColorV4(g_Config.m_ClSameClanColor);
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, Color.a);
|
||||
vec3 Color = HslToRgb(UnpackColor(g_Config.m_ClSameClanColor));
|
||||
TextRender()->TextColor(Color.r, Color.g, Color.b, 1.0f);
|
||||
}
|
||||
else
|
||||
TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
|
|
@ -229,14 +229,3 @@ int CSkins::FindImpl(const char *pName) const
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
vec3 CSkins::GetColorV3(int v)
|
||||
{
|
||||
return HslToRgb(vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f));
|
||||
}
|
||||
|
||||
vec4 CSkins::GetColorV4(int v)
|
||||
{
|
||||
vec3 r = GetColorV3(v);
|
||||
return vec4(r.r, r.g, r.b, 1.0f);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@ public:
|
|||
|
||||
void OnInit();
|
||||
|
||||
vec3 GetColorV3(int v);
|
||||
vec4 GetColorV4(int v);
|
||||
int Num();
|
||||
const CSkin *Get(int Index);
|
||||
int Find(const char *pName) const;
|
||||
|
|
|
@ -393,10 +393,8 @@ void CSpectator::OnRender()
|
|||
}
|
||||
|
||||
CTeeRenderInfo TeeInfo = m_pClient->m_aClients[m_pClient->m_Snap.m_paInfoByDDTeam[i]->m_ClientID].m_RenderInfo;
|
||||
TeeInfo.m_ColorBody.a = TeeAlpha;
|
||||
TeeInfo.m_ColorFeet.a = TeeAlpha;
|
||||
TeeInfo.m_Size *= TeeSizeMod;
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(Width/2.0f+x+20.0f, Height/2.0f+y+20.0f), true);
|
||||
RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(Width/2.0f+x+20.0f, Height/2.0f+y+20.0f), TeeAlpha);
|
||||
|
||||
y += LineHeight;
|
||||
}
|
||||
|
|
|
@ -1028,8 +1028,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 = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorBody);
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = m_pSkins->GetColorV4(m_aClients[ClientID].m_ColorFeet);
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorBody = HslToRgb(UnpackColor(m_aClients[ClientID].m_ColorBody));
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = HslToRgb(UnpackColor(m_aClients[ClientID].m_ColorFeet));
|
||||
m_aClients[ClientID].m_SkinInfo.m_Size = 64;
|
||||
|
||||
// find new skin
|
||||
|
@ -1040,8 +1040,8 @@ void CGameClient::OnNewSnapshot()
|
|||
else
|
||||
{
|
||||
m_aClients[ClientID].m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(m_aClients[ClientID].m_SkinID)->m_OrgTexture;
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorBody = vec4(1,1,1,1);
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorBody = vec3(1,1,1);
|
||||
m_aClients[ClientID].m_SkinInfo.m_ColorFeet = vec3(1,1,1);
|
||||
}
|
||||
|
||||
m_aClients[ClientID].UpdateRenderInfo();
|
||||
|
@ -1618,13 +1618,13 @@ void CGameClient::CClientData::UpdateRenderInfo()
|
|||
const int TeamColors[2] = {65387, 10223467};
|
||||
if(m_Team >= TEAM_RED && m_Team <= TEAM_BLUE)
|
||||
{
|
||||
m_RenderInfo.m_ColorBody = g_GameClient.m_pSkins->GetColorV4(TeamColors[m_Team]);
|
||||
m_RenderInfo.m_ColorFeet = g_GameClient.m_pSkins->GetColorV4(TeamColors[m_Team]);
|
||||
m_RenderInfo.m_ColorBody = HslToRgb(UnpackColor(TeamColors[m_Team]));
|
||||
m_RenderInfo.m_ColorFeet = HslToRgb(UnpackColor(TeamColors[m_Team]));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_RenderInfo.m_ColorBody = g_GameClient.m_pSkins->GetColorV4(12895054);
|
||||
m_RenderInfo.m_ColorFeet = g_GameClient.m_pSkins->GetColorV4(12895054);
|
||||
m_RenderInfo.m_ColorBody = HslToRgb(UnpackColor(12895054));
|
||||
m_RenderInfo.m_ColorFeet = HslToRgb(UnpackColor(12895054));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1645,10 +1645,9 @@ void CGameClient::CClientData::Reset()
|
|||
m_Foe = false;
|
||||
m_AuthLevel = AUTHED_NO;
|
||||
m_SkinInfo.m_Texture = g_GameClient.m_pSkins->Get(0)->m_ColorTexture;
|
||||
m_SkinInfo.m_ColorBody = vec4(1,1,1,1);
|
||||
m_SkinInfo.m_ColorFeet = vec4(1,1,1,1);
|
||||
m_SkinInfo.m_ColorBody = vec3(1,1,1);
|
||||
m_SkinInfo.m_ColorFeet = vec3(1,1,1);
|
||||
|
||||
// DDNet Character
|
||||
m_Solo = false;
|
||||
m_Jetpack = false;
|
||||
m_NoCollision = false;
|
||||
|
@ -1799,7 +1798,7 @@ void CGameClient::ConColorFromRgb(IConsole::IResult *pResult, void *pUserData)
|
|||
}
|
||||
|
||||
char aBuf[32];
|
||||
Hsl = RgbToHsl(Rgb);
|
||||
Hsl = RgbToHsl(Rgb) * 255.0f;
|
||||
// full lightness range for GUI colors
|
||||
str_format(aBuf, sizeof(aBuf), "Hue: %d, Sat: %d, Lht: %d", (int)Hsl.h, (int)Hsl.s, (int)Hsl.l);
|
||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "color", aBuf);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#ifndef GAME_CLIENT_GAMECLIENT_H
|
||||
#define GAME_CLIENT_GAMECLIENT_H
|
||||
|
||||
#include <base/color.h>
|
||||
#include <base/vmath.h>
|
||||
#include <engine/client.h>
|
||||
#include <engine/console.h>
|
||||
|
@ -18,15 +19,45 @@
|
|||
#include <game/client/prediction/entities/laser.h>
|
||||
#include <game/client/prediction/entities/pickup.h>
|
||||
|
||||
#define MIN3(x,y,z) ((y) <= (z) ? \
|
||||
((x) <= (y) ? (x) : (y)) \
|
||||
: \
|
||||
((x) <= (z) ? (x) : (z)))
|
||||
class CGameClient;
|
||||
|
||||
#define MAX3(x,y,z) ((y) >= (z) ? \
|
||||
((x) >= (y) ? (x) : (y)) \
|
||||
: \
|
||||
((x) >= (z) ? (x) : (z)))
|
||||
class CWeaponData
|
||||
{
|
||||
public:
|
||||
int m_Tick;
|
||||
vec2 m_Pos;
|
||||
vec2 m_Direction;
|
||||
vec2 StartPos() { return m_Pos + m_Direction * 28.0f * 0.75f; }
|
||||
};
|
||||
|
||||
class CLocalProjectile
|
||||
{
|
||||
public:
|
||||
int m_Active;
|
||||
CGameClient *m_pGameClient;
|
||||
CWorldCore *m_pWorld;
|
||||
CCollision *m_pCollision;
|
||||
|
||||
vec2 m_Direction;
|
||||
vec2 m_Pos;
|
||||
int m_StartTick;
|
||||
int m_Type;
|
||||
|
||||
int m_Owner;
|
||||
int m_Weapon;
|
||||
bool m_Explosive;
|
||||
int m_Bouncing;
|
||||
bool m_Freeze;
|
||||
bool m_ExtraInfo;
|
||||
|
||||
vec2 GetPos(float Time);
|
||||
void CreateExplosion(vec2 Pos, int LocalClientID);
|
||||
void Tick(int CurrentTick, int GameTickSpeed, int LocalClientID);
|
||||
void Init(CGameClient *pGameClient, CWorldCore *pWorld, CCollision *pCollision, const CNetObj_Projectile *pProj);
|
||||
void Init(CGameClient *pGameClient, CWorldCore *pWorld, CCollision *pCollision, vec2 Vel, vec2 Pos, int StartTick, int Type, int Owner, int Weapon, bool Explosive, int Bouncing, bool Freeze, bool ExtraInfo);
|
||||
bool GameLayerClipped(vec2 CheckPos);
|
||||
void Deactivate() { m_Active = 0; }
|
||||
};
|
||||
|
||||
class CGameClient : public IGameClient
|
||||
{
|
||||
|
@ -402,63 +433,6 @@ private:
|
|||
class CTeamsCore m_TeamsPredicted;
|
||||
};
|
||||
|
||||
|
||||
inline float HueToRgb(float v1, float v2, float h)
|
||||
{
|
||||
if(h < 0.0f) h += 1;
|
||||
if(h > 1.0f) h -= 1;
|
||||
if((6.0f * h) < 1.0f) return v1 + (v2 - v1) * 6.0f * h;
|
||||
if((2.0f * h) < 1.0f) return v2;
|
||||
if((3.0f * h) < 2.0f) return v1 + (v2 - v1) * ((2.0f/3.0f) - h) * 6.0f;
|
||||
return v1;
|
||||
}
|
||||
|
||||
inline vec3 HslToRgb(vec3 HSL)
|
||||
{
|
||||
if(HSL.s == 0.0f)
|
||||
return vec3(HSL.l, HSL.l, HSL.l);
|
||||
else
|
||||
{
|
||||
float v2 = HSL.l < 0.5f ? HSL.l * (1.0f + HSL.s) : (HSL.l+HSL.s) - (HSL.s*HSL.l);
|
||||
float v1 = 2.0f * HSL.l - v2;
|
||||
|
||||
return vec3(HueToRgb(v1, v2, HSL.h + (1.0f/3.0f)), HueToRgb(v1, v2, HSL.h), HueToRgb(v1, v2, HSL.h - (1.0f/3.0f)));
|
||||
}
|
||||
}
|
||||
|
||||
inline vec3 RgbToHsl(vec3 RGB)
|
||||
{
|
||||
vec3 HSL;
|
||||
float MaxColor = MAX3(RGB.r, RGB.g, RGB.b);
|
||||
float MinColor = MIN3(RGB.r, RGB.g, RGB.b);
|
||||
if (MinColor == MaxColor)
|
||||
return vec3(0.0f, 0.0f, RGB.g * 255.0f);
|
||||
else
|
||||
{
|
||||
HSL.l = (MinColor + MaxColor) / 2;
|
||||
|
||||
if (HSL.l < 0.5)
|
||||
HSL.s = (MaxColor - MinColor) / (MaxColor + MinColor);
|
||||
else
|
||||
HSL.s = (MaxColor - MinColor) / (2.0 - MaxColor - MinColor);
|
||||
|
||||
if (RGB.r == MaxColor)
|
||||
HSL.h = (RGB.g - RGB.b) / (MaxColor - MinColor);
|
||||
else if (RGB.g == MaxColor)
|
||||
HSL.h = 2.0 + (RGB.b - RGB.r) / (MaxColor - MinColor);
|
||||
else
|
||||
HSL.h = 4.0 + (RGB.r - RGB.g) / (MaxColor - MinColor);
|
||||
|
||||
HSL.h /= 6; //to bring it to a number between 0 and 1
|
||||
if (HSL.h < 0) HSL.h++;
|
||||
}
|
||||
HSL.h = int(HSL.h * 255.0);
|
||||
HSL.s = int(HSL.s * 255.0);
|
||||
HSL.l = int(HSL.l * 255.0);
|
||||
return HSL;
|
||||
|
||||
}
|
||||
|
||||
vec3 CalculateNameColor(vec3 TextColorHSL);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -327,7 +327,7 @@ void CRenderTools::DrawCircle(float x, float y, float r, int Segments)
|
|||
Graphics()->QuadsDrawFreeform(Array, NumItems);
|
||||
}
|
||||
|
||||
void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, bool Alpha)
|
||||
void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, float Alpha)
|
||||
{
|
||||
vec2 Direction = Dir;
|
||||
vec2 Position = Pos;
|
||||
|
@ -350,11 +350,7 @@ void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote
|
|||
Graphics()->QuadsSetRotation(pAnim->GetBody()->m_Angle*pi*2);
|
||||
|
||||
// draw body
|
||||
if(Alpha)
|
||||
Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, pInfo->m_ColorBody.a);
|
||||
else
|
||||
Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, 1.0f);
|
||||
|
||||
Graphics()->SetColor(pInfo->m_ColorBody.r, pInfo->m_ColorBody.g, pInfo->m_ColorBody.b, Alpha);
|
||||
vec2 BodyPos = Position + vec2(pAnim->GetBody()->m_X, pAnim->GetBody()->m_Y)*AnimScale;
|
||||
float BodySize = g_Config.m_ClFatSkins ? BaseSize * 1.3 : BaseSize;
|
||||
Graphics()->RenderQuadContainerAsSprite(m_TeeQuadContainerIndex, OutLine, BodyPos.x, BodyPos.y, BodySize / 64.f, BodySize / 64.f);
|
||||
|
@ -413,11 +409,7 @@ void CRenderTools::RenderTee(CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote
|
|||
cs = 0.5f;
|
||||
}
|
||||
|
||||
|
||||
if(Alpha)
|
||||
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, pInfo->m_ColorFeet.a*cs);
|
||||
else
|
||||
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, 1.0f);
|
||||
Graphics()->SetColor(pInfo->m_ColorFeet.r*cs, pInfo->m_ColorFeet.g*cs, pInfo->m_ColorFeet.b*cs, Alpha*cs);
|
||||
|
||||
Graphics()->RenderQuadContainerAsSprite(m_TeeQuadContainerIndex, QuadOffset, Position.x + pFoot->m_X*AnimScale, Position.y + pFoot->m_Y*AnimScale, w / 64.f, h / 32.f);
|
||||
}
|
||||
|
|
|
@ -14,15 +14,15 @@ public:
|
|||
CTeeRenderInfo()
|
||||
{
|
||||
m_Texture = -1;
|
||||
m_ColorBody = vec4(1,1,1,1);
|
||||
m_ColorFeet = vec4(1,1,1,1);
|
||||
m_ColorBody = vec3(1,1,1);
|
||||
m_ColorFeet = vec3(1,1,1);
|
||||
m_Size = 1.0f;
|
||||
m_GotAirJump = 1;
|
||||
};
|
||||
|
||||
int m_Texture;
|
||||
vec4 m_ColorBody;
|
||||
vec4 m_ColorFeet;
|
||||
vec3 m_ColorBody;
|
||||
vec3 m_ColorFeet;
|
||||
float m_Size;
|
||||
int m_GotAirJump;
|
||||
};
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
void RenderTilemapGenerateSkip(class CLayers *pLayers);
|
||||
|
||||
// object render methods (gc_render_obj.cpp)
|
||||
void RenderTee(class CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, bool Alpha = false);
|
||||
void RenderTee(class CAnimState *pAnim, CTeeRenderInfo *pInfo, int Emote, vec2 Dir, vec2 Pos, float Alpha = 1.0f);
|
||||
|
||||
// map render methods (gc_render_map.cpp)
|
||||
static void RenderEvalEnvelope(CEnvPoint *pPoints, int NumPoints, int Channels, float Time, float *pResult);
|
||||
|
|
Loading…
Reference in a new issue