From 399075c3397e89db19d3271779081855e7acf59a Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Thu, 25 Apr 2024 09:04:58 +0800 Subject: [PATCH] Display 0.7 skins in chat --- src/game/client/components/chat.cpp | 41 +++++++++++++++++++++++++++++ src/game/client/components/chat.h | 15 +++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index d4a25f2c4..b94339dfa 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -816,6 +817,38 @@ void CChat::AddLine(int ClientId, int Team, const char *pLine) pCurrentLine->m_RenderSkinMetrics = LineAuthor.m_RenderInfo.m_SkinMetrics; pCurrentLine->m_HasRenderTee = true; + + // 0.7 + if(Client()->IsSixup()) + { + for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) + { + const char *pPartName = LineAuthor.m_Sixup.m_aaSkinPartNames[Part]; + int Id = m_pClient->m_Skins7.FindSkinPart(Part, pPartName, false); + const CSkins7::CSkinPart *pSkinPart = m_pClient->m_Skins7.GetSkinPart(Part, Id); + if(LineAuthor.m_Sixup.m_aUseCustomColors[Part]) + { + pCurrentLine->m_Sixup.m_aTextures[Part] = pSkinPart->m_ColorTexture; + pCurrentLine->m_Sixup.m_aColors[Part] = m_pClient->m_Skins7.GetColor( + LineAuthor.m_Sixup.m_aSkinPartColors[Part], + Part == protocol7::SKINPART_MARKING); + } + else + { + pCurrentLine->m_Sixup.m_aTextures[Part] = pSkinPart->m_OrgTexture; + pCurrentLine->m_Sixup.m_aColors[Part] = vec4(1.0f, 1.0f, 1.0f, 1.0f); + } + + if(LineAuthor.m_SkinInfo.m_Sixup.m_HatTexture.IsValid()) + { + if(Part == protocol7::SKINPART_BODY && str_comp(pPartName, "standard")) + pCurrentLine->m_Sixup.m_HatSpriteIndex = CSkins7::HAT_OFFSET_SIDE + (ClientId % CSkins7::HAT_NUM); + if(Part == protocol7::SKINPART_DECORATION && str_comp(pPartName, "twinbopp")) + pCurrentLine->m_Sixup.m_HatSpriteIndex = CSkins7::HAT_OFFSET_SIDE + (ClientId % CSkins7::HAT_NUM); + pCurrentLine->m_Sixup.m_HatTexture = LineAuthor.m_SkinInfo.m_Sixup.m_HatTexture; + } + } + } } } } @@ -1270,6 +1303,14 @@ void CChat::OnRender() RenderInfo.m_ColorFeet = Line.m_ColorFeet; RenderInfo.m_Size = TeeSize; + for(int Part = 0; Part < protocol7::NUM_SKINPARTS; Part++) + { + RenderInfo.m_Sixup.m_aColors[Part] = Line.m_Sixup.m_aColors[Part]; + RenderInfo.m_Sixup.m_aTextures[Part] = Line.m_Sixup.m_aTextures[Part]; + RenderInfo.m_Sixup.m_HatSpriteIndex = Line.m_Sixup.m_HatSpriteIndex; + RenderInfo.m_Sixup.m_HatTexture = Line.m_Sixup.m_HatTexture; + } + float RowHeight = FontSize() + RealMsgPaddingY; float OffsetTeeY = TeeSize / 2.0f; float FullHeightMinusTee = RowHeight - TeeSize; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index c22af4eab..28a8007ee 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -12,6 +12,7 @@ #include #include #include +#include class CChat : public CComponent { @@ -54,6 +55,20 @@ class CChat : public CComponent float m_TextYOffset; int m_TimesRepeated; + + class CSixup + { + public: + IGraphics::CTextureHandle m_aTextures[protocol7::NUM_SKINPARTS]; + IGraphics::CTextureHandle m_HatTexture; + IGraphics::CTextureHandle m_BotTexture; + int m_HatSpriteIndex; + ColorRGBA m_BotColor; + ColorRGBA m_aColors[protocol7::NUM_SKINPARTS]; + }; + + // 0.7 Skin + CSixup m_Sixup; }; bool m_PrevScoreBoardShowed;