Merge pull request #8949 from MilkeeyCat/pr_fix_color_speed_values

Fix colored speed values after connecting to a server
This commit is contained in:
Dennis Felsing 2024-09-15 21:42:02 +00:00 committed by GitHub
commit a5138c078e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 10 deletions

View file

@ -76,6 +76,8 @@ void CHud::OnReset()
m_ServerRecord = -1.0f;
m_aPlayerRecord[0] = -1.0f;
m_aPlayerRecord[1] = -1.0f;
m_aLastPlayerSpeedChange[0] = ESpeedChange::NONE;
m_aLastPlayerSpeedChange[1] = ESpeedChange::NONE;
ResetHudContainers();
}
@ -1275,11 +1277,11 @@ void CHud::UpdateMovementInformationTextContainer(STextContainerIndex &TextConta
}
}
void CHud::RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, float X, float Y)
void CHud::RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, const ColorRGBA &Color, float X, float Y)
{
if(TextContainer.Valid())
{
TextRender()->RenderTextContainer(TextContainer, TextRender()->DefaultTextColor(), TextRender()->DefaultTextOutlineColor(), X - TextRender()->GetBoundingBoxTextContainer(TextContainer).m_W, Y);
TextRender()->RenderTextContainer(TextContainer, Color, TextRender()->DefaultTextOutlineColor(), X - TextRender()->GetBoundingBoxTextContainer(TextContainer).m_W, Y);
}
}
@ -1352,12 +1354,12 @@ void CHud::RenderMovementInformation(const int ClientId)
TextRender()->Text(xl, y, Fontsize, "X:", -1.0f);
UpdateMovementInformationTextContainer(m_aPlayerPositionContainers[0], Fontsize, Pos.x, m_aaPlayerPositionText[0], sizeof(m_aaPlayerPositionText[0]));
RenderMovementInformationTextContainer(m_aPlayerPositionContainers[0], xr, y);
RenderMovementInformationTextContainer(m_aPlayerPositionContainers[0], TextRender()->DefaultTextColor(), xr, y);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
TextRender()->Text(xl, y, Fontsize, "Y:", -1.0f);
UpdateMovementInformationTextContainer(m_aPlayerPositionContainers[1], Fontsize, Pos.y, m_aaPlayerPositionText[1], sizeof(m_aaPlayerPositionText[1]));
RenderMovementInformationTextContainer(m_aPlayerPositionContainers[1], xr, y);
RenderMovementInformationTextContainer(m_aPlayerPositionContainers[1], TextRender()->DefaultTextColor(), xr, y);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
}
@ -1369,14 +1371,14 @@ void CHud::RenderMovementInformation(const int ClientId)
const char aaCoordinates[][4] = {"X:", "Y:"};
for(int i = 0; i < 2; i++)
{
TextRender()->TextColor(ColorRGBA(1, 1, 1, 1));
ColorRGBA Color(1, 1, 1, 1);
if(m_aLastPlayerSpeedChange[i] == ESpeedChange::INCREASE)
TextRender()->TextColor(ColorRGBA(0, 1, 0, 1));
Color = ColorRGBA(0, 1, 0, 1);
if(m_aLastPlayerSpeedChange[i] == ESpeedChange::DECREASE)
TextRender()->TextColor(ColorRGBA(1, 0.5f, 0.5f, 1));
Color = ColorRGBA(1, 0.5f, 0.5f, 1);
TextRender()->Text(xl, y, Fontsize, aaCoordinates[i], -1.0f);
UpdateMovementInformationTextContainer(m_aPlayerSpeedTextContainers[i], Fontsize, i == 0 ? DisplaySpeedX : DisplaySpeedY, m_aaPlayerSpeedText[i], sizeof(m_aaPlayerSpeedText[i]));
RenderMovementInformationTextContainer(m_aPlayerSpeedTextContainers[i], xr, y);
RenderMovementInformationTextContainer(m_aPlayerSpeedTextContainers[i], Color, xr, y);
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
}
@ -1389,7 +1391,7 @@ void CHud::RenderMovementInformation(const int ClientId)
y += MOVEMENT_INFORMATION_LINE_HEIGHT;
UpdateMovementInformationTextContainer(m_PlayerAngleTextContainerIndex, Fontsize, DisplayAngle, m_aPlayerAngleText, sizeof(m_aPlayerAngleText));
RenderMovementInformationTextContainer(m_PlayerAngleTextContainerIndex, xr, y);
RenderMovementInformationTextContainer(m_PlayerAngleTextContainerIndex, TextRender()->DefaultTextColor(), xr, y);
}
}

View file

@ -80,7 +80,7 @@ class CHud : public CComponent
void RenderMovementInformation(const int ClientId);
void UpdateMovementInformationTextContainer(STextContainerIndex &TextContainer, float FontSize, float Value, char *pPrevValue, size_t Size);
void RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, float X, float Y);
void RenderMovementInformationTextContainer(STextContainerIndex &TextContainer, const ColorRGBA &Color, float X, float Y);
void RenderGameTimer();
void RenderPauseNotification();