diff options
| author | oy <Tom_Adams@web.de> | 2010-11-24 01:11:56 +0100 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-11-24 01:11:56 +0100 |
| commit | e6698b111873e5c8584343eb511aa40c7052f99b (patch) | |
| tree | f140b5f801bd65a69adada60b55b3bf34e30a47b | |
| parent | bc5f3fc8396c7521bd261bc4ef69e52f6d91af12 (diff) | |
| download | zcatch-e6698b111873e5c8584343eb511aa40c7052f99b.tar.gz zcatch-e6698b111873e5c8584343eb511aa40c7052f99b.zip | |
apply custom colour to blood colour. Closes #314
| -rw-r--r-- | src/game/client/components/effects.cpp | 12 | ||||
| -rw-r--r-- | src/game/client/components/menus_settings.cpp | 11 | ||||
| -rw-r--r-- | src/game/client/components/skins.cpp | 7 | ||||
| -rw-r--r-- | src/game/client/components/skins.h | 3 | ||||
| -rw-r--r-- | src/game/client/gameclient.cpp | 8 |
5 files changed, 27 insertions, 14 deletions
diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index 79117d30..45dd856e 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -1,6 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include <engine/demo.h> +#include <engine/shared/config.h> #include <game/generated/client_data.h> @@ -153,9 +154,14 @@ void CEffects::PlayerDeath(vec2 Pos, int Cid) if(Cid >= 0) { - const CSkins::CSkin *s = m_pClient->m_pSkins->Get(m_pClient->m_aClients[Cid].m_SkinId); - if(s) - BloodColor = s->m_BloodColor; + if(g_Config.m_PlayerUseCustomColor) + BloodColor = m_pClient->m_pSkins->GetColorV3(g_Config.m_PlayerColorBody); + else + { + const CSkins::CSkin *s = m_pClient->m_pSkins->Get(m_pClient->m_aClients[Cid].m_SkinId); + if(s) + BloodColor = s->m_BloodColor; + } } for(int i = 0; i < 64; i++) diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 3c134cce..119dc2f5 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -116,8 +116,8 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) if(g_Config.m_PlayerUseCustomColor) { - OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColor(g_Config.m_PlayerColorBody); - OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColor(g_Config.m_PlayerColorFeet); + OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody); + OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet); OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture; } @@ -250,8 +250,8 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) if(g_Config.m_PlayerUseCustomColor) { - Info.m_ColorBody = m_pClient->m_pSkins->GetColor(g_Config.m_PlayerColorBody); - Info.m_ColorFeet = m_pClient->m_pSkins->GetColor(g_Config.m_PlayerColorFeet); + Info.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody); + Info.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet); Info.m_Texture = s->m_ColorTexture; } @@ -261,9 +261,10 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) if(g_Config.m_Debug) { + vec3 BloodColor = g_Config.m_PlayerUseCustomColor ? m_pClient->m_pSkins->GetColorV3(g_Config.m_PlayerColorBody) : s->m_BloodColor; Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); - Graphics()->SetColor(s->m_BloodColor.r, s->m_BloodColor.g, s->m_BloodColor.b, 1.0f); + Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f); IGraphics::CQuadItem QuadItem(Item.m_Rect.x, Item.m_Rect.y, 12, 12); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 638baeae..9c39e9ad 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -179,7 +179,12 @@ static vec3 HslToRgb(vec3 in) return Out; } -vec4 CSkins::GetColor(int v) +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 = HslToRgb(vec3(((v>>16)&0xff)/255.0f, ((v>>8)&0xff)/255.0f, 0.5f+(v&0xff)/255.0f*0.5f)); return vec4(r.r, r.g, r.b, 1.0f); diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index 519f2e73..9e20ba37 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -22,7 +22,8 @@ public: void Init(); - vec4 GetColor(int v); + vec3 GetColorV3(int v); + vec4 GetColorV4(int v); int Num(); const CSkin *Get(int Index); int Find(const char *pName); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 5dea0876..2b94b10b 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -708,8 +708,8 @@ void CGameClient::OnNewSnapshot() if(m_aClients[Cid].m_aSkinName[0] == 'x' || m_aClients[Cid].m_aSkinName[1] == '_') str_copy(m_aClients[Cid].m_aSkinName, "default", 64); - m_aClients[Cid].m_SkinInfo.m_ColorBody = m_pSkins->GetColor(m_aClients[Cid].m_ColorBody); - m_aClients[Cid].m_SkinInfo.m_ColorFeet = m_pSkins->GetColor(m_aClients[Cid].m_ColorFeet); + m_aClients[Cid].m_SkinInfo.m_ColorBody = m_pSkins->GetColorV4(m_aClients[Cid].m_ColorBody); + m_aClients[Cid].m_SkinInfo.m_ColorFeet = m_pSkins->GetColorV4(m_aClients[Cid].m_ColorFeet); m_aClients[Cid].m_SkinInfo.m_Size = 64; // find new skin @@ -948,8 +948,8 @@ void CGameClient::CClientData::UpdateRenderInfo() if(m_Team >= 0 && m_Team <= 1) { m_RenderInfo.m_Texture = g_GameClient.m_pSkins->Get(m_SkinId)->m_ColorTexture; - m_RenderInfo.m_ColorBody = g_GameClient.m_pSkins->GetColor(TeamColors[m_Team]); - m_RenderInfo.m_ColorFeet = g_GameClient.m_pSkins->GetColor(TeamColors[m_Team]); + m_RenderInfo.m_ColorBody = g_GameClient.m_pSkins->GetColorV4(TeamColors[m_Team]); + m_RenderInfo.m_ColorFeet = g_GameClient.m_pSkins->GetColorV4(TeamColors[m_Team]); } } } |