Display 0.7 skins in chat

This commit is contained in:
ChillerDragon 2024-04-25 09:04:58 +08:00 committed by Dennis Felsing
parent 8903f49716
commit 399075c339
2 changed files with 56 additions and 0 deletions

View file

@ -9,6 +9,7 @@
#include <engine/textrender.h>
#include <game/generated/protocol.h>
#include <game/generated/protocol7.h>
#include <game/client/animstate.h>
#include <game/client/components/scoreboard.h>
@ -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;

View file

@ -12,6 +12,7 @@
#include <game/client/component.h>
#include <game/client/lineinput.h>
#include <game/client/skin.h>
#include <game/generated/protocol7.h>
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;