Skip to content

Commit

Permalink
more more war list progress
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Dec 21, 2024
1 parent bf1988a commit 22c1431
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 9 deletions.
78 changes: 69 additions & 9 deletions src/game/client/components/nameplates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ void CNamePlates::RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlay

const float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f;
const float FontSizeClan = 18.0f + 20.0f * g_Config.m_ClNameplatesClanSize / 100.0f;
//TClient
bool ClanPlateOverride = g_Config.m_ClWarList && g_Config.m_ClWarListShowClan && GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).IsWarClan;

TextRender()->SetRenderFlags(ETextRenderFlags::TEXT_RENDER_FLAG_NO_FIRST_CHARACTER_X_BEARING | ETextRenderFlags::TEXT_RENDER_FLAG_NO_LAST_CHARACTER_ADVANCE);
float YOffset = Position.y - 38;
Expand Down Expand Up @@ -126,7 +128,7 @@ void CNamePlates::RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlay
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
}

if(g_Config.m_ClNameplatesClan)
if(g_Config.m_ClNameplatesClan || ClanPlateOverride)
{
if(str_comp(ClientData.m_aClan, NamePlate.m_aClan) != 0 || FontSizeClan != NamePlate.m_ClanTextFontSize)
{
Expand Down Expand Up @@ -178,6 +180,8 @@ void CNamePlates::RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlay
TOutlineColor.a *= Alpha;
TColor.a *= Alpha;

bool ShowingClanWar = (ClanPlateOverride) || g_Config.m_ClNameplatesClan;
bool ShowClanWarInName = !ShowingClanWar && GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).IsWarClan && !GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).IsWarName;
if(NamePlate.m_NameTextContainerIndex.Valid())
{
YOffset -= FontSize;
Expand All @@ -191,24 +195,80 @@ void CNamePlates::RenderNameplate(vec2 Position, const CNetObj_PlayerInfo *pPlay
Graphics()->DrawCircle(Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_NameTextContainerIndex).m_W / 2.0f - CircleSize, YOffset + FontSize / 2.0f + 1.4f, CircleSize, 24);
Graphics()->QuadsEnd();
}
TextRender()->RenderTextContainer(NamePlate.m_NameTextContainerIndex, TColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_NameTextContainerIndex).m_W / 2.0f, YOffset);
if(ShowClanWarInName)
{
ColorRGBA WarColor = GameClient()->m_WarList.GetClanColor(pPlayerInfo->m_ClientId);
WarColor.a *= Alpha;
TextRender()->RenderTextContainer(NamePlate.m_NameTextContainerIndex, WarColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_NameTextContainerIndex).m_W / 2.0f, YOffset);
}
else if (GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).IsWarName)
{
ColorRGBA WarColor = GameClient()->m_WarList.GetNameplateColor(pPlayerInfo->m_ClientId);
WarColor.a *= Alpha;
TextRender()->RenderTextContainer(NamePlate.m_NameTextContainerIndex, WarColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_NameTextContainerIndex).m_W / 2.0f, YOffset);
}
else
TextRender()->RenderTextContainer(NamePlate.m_NameTextContainerIndex, TColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_NameTextContainerIndex).m_W / 2.0f, YOffset);
}

if(g_Config.m_ClNameplatesClan)
if(g_Config.m_ClNameplatesClan || ShowingClanWar)
{
YOffset -= FontSizeClan;
if(NamePlate.m_ClanTextContainerIndex.Valid())
TextRender()->RenderTextContainer(NamePlate.m_ClanTextContainerIndex, TColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_ClanTextContainerIndex).m_W / 2.0f, YOffset);
{
if(GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).IsWarClan)
{
ColorRGBA WarColor = GameClient()->m_WarList.GetClanColor(pPlayerInfo->m_ClientId);
WarColor.a *= Alpha;
TextRender()->RenderTextContainer(NamePlate.m_ClanTextContainerIndex, WarColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_ClanTextContainerIndex).m_W / 2.0f, YOffset);
}
else
TextRender()->RenderTextContainer(NamePlate.m_ClanTextContainerIndex, TColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_ClanTextContainerIndex).m_W / 2.0f, YOffset);
}
}
// TClient
if(g_Config.m_ClWarList && g_Config.m_ClWarListReason)
{
if(str_comp(GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).m_aReason, NamePlate.m_aWarReason) != 0)
{
str_copy(NamePlate.m_aWarReason, GameClient()->m_WarList.GetWarData(pPlayerInfo->m_ClientId).m_aReason);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSizeClan, TEXTFLAG_RENDER);
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
TextRender()->RecreateTextContainer(NamePlate.m_WarReasonConIndex, &Cursor, NamePlate.m_aWarReason);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
}
}

if(g_Config.m_ClWarList && g_Config.m_ClWarListReason && NamePlate.m_WarReasonConIndex.Valid())
{
YOffset -= FontSizeClan;
ColorRGBA RColor = TColor, ROColor = TOutlineColor;
RColor.a *= 0.5f, ROColor.a *= 0.5f;
TextRender()->RenderTextContainer(NamePlate.m_WarReasonConIndex, RColor, ROColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_WarReasonConIndex).m_W / 2.0f, YOffset);
}

if(g_Config.m_ClShowSkinName)
{
if(str_comp(m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aSkinName, NamePlate.m_aSkinName) != 0)
{
str_copy(NamePlate.m_aSkinName, m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aSkinName);
CTextCursor Cursor;
TextRender()->SetCursor(&Cursor, 0, 0, FontSizeClan, TEXTFLAG_RENDER);
float ScreenX0, ScreenY0, ScreenX1, ScreenY1;
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
RenderTools()->MapScreenToInterface(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y);
TextRender()->RecreateTextContainer(NamePlate.m_SkinNameConIndex, &Cursor, NamePlate.m_aSkinName);
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
}
}

if(g_Config.m_ClShowSkinName && NamePlate.m_SkinNameConIndex.Valid())
{
YOffset -= FontSizeClan;
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "%s", m_pClient->m_aClients[pPlayerInfo->m_ClientId].m_aSkinName);
float XOffset = TextRender()->TextWidth(FontSize, aBuf, -1, -1.0f) / 2.0f;
TextRender()->TextColor(rgb);
TextRender()->Text(Position.x - XOffset, YOffset, FontSize, aBuf, -1.0f);
TextRender()->RenderTextContainer(NamePlate.m_SkinNameConIndex, TColor, TOutlineColor, Position.x - TextRender()->GetBoundingBoxTextContainer(NamePlate.m_SkinNameConIndex).m_W / 2.0f, YOffset);
}

if(g_Config.m_ClNameplatesFriendMark && ClientData.m_Friend)
Expand Down
7 changes: 7 additions & 0 deletions src/game/client/components/nameplates.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ struct SPlayerNamePlate
char m_aClan[MAX_CLAN_LENGTH];
STextContainerIndex m_ClanTextContainerIndex;
float m_ClanTextFontSize;

// TClient
STextContainerIndex m_SkinNameConIndex;
char m_aSkinName[MAX_SKIN_LENGTH] = "";

STextContainerIndex m_WarReasonConIndex;
char m_aWarReason[MAX_WARLIST_REASON_LENGTH] = "";
};

class CNamePlates : public CComponent
Expand Down

0 comments on commit 22c1431

Please sign in to comment.