From 8cc0de8d31167335cdcfa5c9278501d2cb15ba5d Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Wed, 11 Apr 2018 12:19:30 +0200 Subject: [PATCH] Some text positioning --- src/game/client/components/killmessages.cpp | 4 ++-- src/game/client/components/scoreboard.cpp | 14 +++++++------- src/game/client/render_map.cpp | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index ee149f312..b14ad336a 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -166,7 +166,7 @@ void CKillMessages::OnRender() } if(m_aKillmsgs[r].m_VictimTextContainerIndex != -1) - TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, &TColor, &TOutlineColor, x, y); + TextRender()->RenderTextContainer(m_aKillmsgs[r].m_VictimTextContainerIndex, &TColor, &TOutlineColor, x, y + (46.f - 36.f) / 2.f); // render victim tee x -= 24.0f; @@ -221,7 +221,7 @@ void CKillMessages::OnRender() x -= m_aKillmsgs[r].m_KillerTextWidth; if(m_aKillmsgs[r].m_KillerTextContainerIndex != -1) - TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, &TColor, &TOutlineColor, x, y); + TextRender()->RenderTextContainer(m_aKillmsgs[r].m_KillerTextContainerIndex, &TColor, &TOutlineColor, x, y + (46.f - 36.f) / 2.f); } y += 46.0f; diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 41a0298ec..c4804c666 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -112,7 +112,7 @@ void CScoreboard::RenderSpectators(float x, float y, float w) // Headline y += 10.0f; - TextRender()->Text(0, x+10.0f, y, 28.0f, Localize("Spectators"), w-20.0f); + TextRender()->Text(0, x+10.0f, y + (30.f - 28.f) / 2.f, 28.0f, Localize("Spectators"), w-20.0f); // spectator names y += 30.0f; @@ -195,7 +195,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch else pTitle = Localize("Score board"); } - TextRender()->Text(0, x+20.0f, y, TitleFontsize, pTitle, -1); + TextRender()->Text(0, x+20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, pTitle, -1); char aBuf[128] = {0}; @@ -237,7 +237,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch if (!lower16 && !lower32 && !lower24) { tw = TextRender()->TextWidth(0, TitleFontsize, aBuf, -1); - TextRender()->Text(0, x+w-tw-20.0f, y, TitleFontsize, aBuf, -1); + TextRender()->Text(0, x+w-tw-20.0f, y + (50.f - TitleFontsize) / 2.f, TitleFontsize, aBuf, -1); } // calculate measurements @@ -287,15 +287,15 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch float HeadlineFontsize = 22.0f; float ScoreWidth = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Score"), -1); tw = ScoreLength > ScoreWidth ? ScoreLength : ScoreWidth; - TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y, HeadlineFontsize, Localize("Score"), -1); + TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Score"), -1); - TextRender()->Text(0, NameOffset, y, HeadlineFontsize, Localize("Name"), -1); + TextRender()->Text(0, NameOffset, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Name"), -1); tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Clan"), -1); - TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y, HeadlineFontsize, Localize("Clan"), -1); + TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Clan"), -1); tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Ping"), -1); - TextRender()->Text(0, PingOffset+PingLength-tw, y, HeadlineFontsize, Localize("Ping"), -1); + TextRender()->Text(0, PingOffset+PingLength-tw, y + (HeadlineFontsize * 2.f - HeadlineFontsize) / 2.f, HeadlineFontsize, Localize("Ping"), -1); // render player entries y += HeadlineFontsize*2.0f; diff --git a/src/game/client/render_map.cpp b/src/game/client/render_map.cpp index e0b7984bc..01eaa5566 100644 --- a/src/game/client/render_map.cpp +++ b/src/game/client/render_map.cpp @@ -439,7 +439,7 @@ void CRenderTools::RenderTeleOverlay(CTeleTile *pTele, int w, int h, float Scale char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Index); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale-2, my*Scale-4, Scale-5, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale - 3.f, my*Scale, Scale - 5.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -498,13 +498,13 @@ void CRenderTools::RenderSpeedupOverlay(CSpeedupTile *pSpeedup, int w, int h, fl char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Force); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, (my*Scale) + 16.f + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); if(MaxSpeed) { str_format(aBuf, sizeof(aBuf), "%d", MaxSpeed); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, (my*Scale) + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } } @@ -553,7 +553,7 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Index); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale+16, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, my*Scale + 16.f + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } @@ -563,7 +563,7 @@ void CRenderTools::RenderSwitchOverlay(CSwitchTile *pSwitch, int w, int h, float char aBuf[16]; str_format(aBuf, sizeof(aBuf), "%d", Delay); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, Alpha); - UI()->TextRender()->Text(0, mx*Scale, my*Scale-2, Scale-20, aBuf, -1); + UI()->TextRender()->Text(0, mx*Scale, my*Scale + ((16.f - (Scale - 20.f)) / 2.f), Scale - 20.f, aBuf, -1); UI()->TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); } }