From c7114e734ce4e0c1a22d85a8504018da7a0d8f39 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Wed, 4 Apr 2018 02:40:30 +0200 Subject: [PATCH] more ui text positioning fixes --- src/game/client/components/console.cpp | 4 ++-- src/game/client/components/hud.cpp | 3 ++- src/game/client/components/menus_browser.cpp | 6 ++--- src/game/client/components/menus_demo.cpp | 2 +- src/game/client/components/menus_ingame.cpp | 4 ++-- src/game/client/components/menus_settings.cpp | 10 ++++---- src/game/client/components/scoreboard.cpp | 7 +++--- src/game/client/components/statboard.cpp | 24 +++++++++---------- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 978360dc4..5ab4d9ebb 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -643,12 +643,12 @@ void CGameConsole::OnRender() char aBuf[128]; TextRender()->TextColor(1,1,1,1); str_format(aBuf, sizeof(aBuf), Localize("-Page %d-"), pConsole->m_BacklogActPage+1); - TextRender()->Text(0, 10.0f, 0.0f, FontSize, aBuf, -1); + TextRender()->Text(0, 10.0f, FontSize / 2.f, FontSize, aBuf, -1); // render version str_format(aBuf, sizeof(aBuf), "v%s", GAME_VERSION); float Width = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, Screen.w-Width-10.0f, 0.0f, FontSize, aBuf, -1); + TextRender()->Text(0, Screen.w-Width-10.0f, FontSize / 2.f, FontSize, aBuf, -1); } } diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index afc3a7e1d..e6e023d9b 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -688,7 +688,8 @@ void CHud::RenderVoting() const char *pYesKey = m_pClient->m_pBinds->GetKey("vote yes"); const char *pNoKey = m_pClient->m_pBinds->GetKey("vote no"); str_format(aBuf, sizeof(aBuf), "%s - %s", pYesKey, Localize("Vote yes")); - Base.y += Base.h+1; + Base.y += Base.h; + Base.h = 11.f; UI()->DoLabel(&Base, aBuf, 6.0f, -1); str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), pNoKey); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index d13e7fd0b..0586765c3 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -961,19 +961,19 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View) } RightColumn.HSplitTop(15.0f, &Row, &RightColumn); - TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, Row.x, Row.y + (15.f - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Row.w; TextRender()->TextEx(&Cursor, pSelectedServer->m_aVersion, -1); RightColumn.HSplitTop(15.0f, &Row, &RightColumn); - TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, Row.x, Row.y + (15.f - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Row.w; TextRender()->TextEx(&Cursor, pSelectedServer->m_aGameType, -1); char aTemp[16]; str_format(aTemp, sizeof(aTemp), "%d", pSelectedServer->m_Latency); RightColumn.HSplitTop(15.0f, &Row, &RightColumn); - TextRender()->SetCursor(&Cursor, Row.x, Row.y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, Row.x, Row.y + (15.f - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Row.w; TextRender()->TextEx(&Cursor, aTemp, -1); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 2ed03f7c4..0dcd4d01b 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -430,7 +430,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) char aBuf[128]; str_format(aBuf, sizeof(aBuf), Localize("Demofile: %s"), aDemoName); CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y, Button.h*0.5f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, NameBar.x, NameBar.y + (NameBar.h - (Button.h*0.5f)) / 2.f, Button.h*0.5f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = MainView.w; TextRender()->TextEx(&Cursor, aBuf, -1); diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 65a5026f6..5bdc42178 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -249,11 +249,11 @@ void CMenus::RenderPlayers(CUIRect MainView) Player.VSplitMid(&Player, &Button); Item.m_Rect.VSplitRight(200.0f, &Button2, &Item.m_Rect); CTextCursor Cursor; - TextRender()->SetCursor(&Cursor, Player.x, Player.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, Player.x, Player.y + (Player.h - 14.f) / 2.f, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Player.w; TextRender()->TextEx(&Cursor, m_pClient->m_aClients[Index].m_aName, -1); - TextRender()->SetCursor(&Cursor, Button.x,Button.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, Button.x,Button.y + (Button.h - 14.f) / 2.f, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Button.w; TextRender()->TextEx(&Cursor, m_pClient->m_aClients[Index].m_aClan, -1); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index df598658b..473916f42 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -787,7 +787,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) RenderTools()->DrawUIRect(&MovementSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); MovementSettings.VMargin(10.0f, &MovementSettings); - TextRender()->Text(0, MovementSettings.x, MovementSettings.y, 14.0f*UI()->Scale(), Localize("Movement"), -1); + TextRender()->Text(0, MovementSettings.x, MovementSettings.y + (14.0f + 5.0f + 10.0f - 14.0f*UI()->Scale()) / 2.f, 14.0f*UI()->Scale(), Localize("Movement"), -1); MovementSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MovementSettings); @@ -828,7 +828,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) RenderTools()->DrawUIRect(&WeaponSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); WeaponSettings.VMargin(10.0f, &WeaponSettings); - TextRender()->Text(0, WeaponSettings.x, WeaponSettings.y, 14.0f*UI()->Scale(), Localize("Weapon"), -1); + TextRender()->Text(0, WeaponSettings.x, WeaponSettings.y + (14.0f + 5.0f + 10.0f - 14.0f*UI()->Scale()) / 2.f, 14.0f*UI()->Scale(), Localize("Weapon"), -1); WeaponSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &WeaponSettings); UiDoGetButtons(18, 25, WeaponSettings, MainView); @@ -854,7 +854,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) RenderTools()->DrawUIRect(&VotingSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); VotingSettings.VMargin(10.0f, &VotingSettings); - TextRender()->Text(0, VotingSettings.x, VotingSettings.y, 14.0f*UI()->Scale(), Localize("Voting"), -1); + TextRender()->Text(0, VotingSettings.x, VotingSettings.y + (14.0f + 5.0f + 10.0f - 14.0f*UI()->Scale()) / 2.f, 14.0f*UI()->Scale(), Localize("Voting"), -1); VotingSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &VotingSettings); UiDoGetButtons(25, 27, VotingSettings, MainView); @@ -867,7 +867,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) RenderTools()->DrawUIRect(&ChatSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); ChatSettings.VMargin(10.0f, &ChatSettings); - TextRender()->Text(0, ChatSettings.x, ChatSettings.y, 14.0f*UI()->Scale(), Localize("Chat"), -1); + TextRender()->Text(0, ChatSettings.x, ChatSettings.y + (14.0f + 5.0f + 10.0f - 14.0f*UI()->Scale()) / 2.f, 14.0f*UI()->Scale(), Localize("Chat"), -1); ChatSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &ChatSettings); UiDoGetButtons(27, 31, ChatSettings, MainView); @@ -880,7 +880,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) RenderTools()->DrawUIRect(&MiscSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); MiscSettings.VMargin(10.0f, &MiscSettings); - TextRender()->Text(0, MiscSettings.x, MiscSettings.y, 14.0f*UI()->Scale(), Localize("Miscellaneous"), -1); + TextRender()->Text(0, MiscSettings.x, MiscSettings.y + (14.0f + 5.0f + 10.0f - 14.0f*UI()->Scale()) / 2.f, 14.0f*UI()->Scale(), Localize("Miscellaneous"), -1); MiscSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MiscSettings); UiDoGetButtons(31, 43, MiscSettings, MainView); diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 85497f2b2..41a0298ec 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -74,27 +74,26 @@ void CScoreboard::RenderGoals(float x, float y, float w) Graphics()->QuadsEnd(); // render goals - y += 10.0f; if(m_pClient->m_Snap.m_pGameInfoObj) { if(m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s: %d", Localize("Score limit"), m_pClient->m_Snap.m_pGameInfoObj->m_ScoreLimit); - TextRender()->Text(0, x+10.0f, y, 20.0f, aBuf, -1); + TextRender()->Text(0, x+10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1); } if(m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), Localize("Time limit: %d min"), m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit); - TextRender()->Text(0, x+230.0f, y, 20.0f, aBuf, -1); + TextRender()->Text(0, x+230.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1); } if(m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum && m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent) { char aBuf[64]; str_format(aBuf, sizeof(aBuf), "%s %d/%d", Localize("Round"), m_pClient->m_Snap.m_pGameInfoObj->m_RoundCurrent, m_pClient->m_Snap.m_pGameInfoObj->m_RoundNum); float tw = TextRender()->TextWidth(0, 20.0f, aBuf, -1); - TextRender()->Text(0, x+w-tw-10.0f, y, 20.0f, aBuf, -1); + TextRender()->Text(0, x+w-tw-10.0f, y + (h - 20.f) / 2.f, 20.0f, aBuf, -1); } } } diff --git a/src/game/client/components/statboard.cpp b/src/game/client/components/statboard.cpp index e577cdf53..cb1dfbaac 100644 --- a/src/game/client/components/statboard.cpp +++ b/src/game/client/components/statboard.cpp @@ -303,7 +303,7 @@ void CStatboard::RenderGlobalStats() char aBuf[128]; CTextCursor Cursor; tw = TextRender()->TextWidth(0, FontSize, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1); - TextRender()->SetCursor(&Cursor, x+64, y, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + TextRender()->SetCursor(&Cursor, x+64, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = 220; TextRender()->TextEx(&Cursor, m_pClient->m_aClients[pInfo->m_ClientID].m_aName, -1); @@ -313,14 +313,14 @@ void CStatboard::RenderGlobalStats() { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Frags); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // DEATHS { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Deaths); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // SUICIDES @@ -328,7 +328,7 @@ void CStatboard::RenderGlobalStats() px += 10; str_format(aBuf, sizeof(aBuf), "%d", pStats->m_Suicides); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // RATIO @@ -338,14 +338,14 @@ void CStatboard::RenderGlobalStats() else str_format(aBuf, sizeof(aBuf), "%.2f", (float)(pStats->m_Frags)/pStats->m_Deaths); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // NET { str_format(aBuf, sizeof(aBuf), "%+d", pStats->m_Frags-pStats->m_Deaths); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // FPM @@ -353,21 +353,21 @@ void CStatboard::RenderGlobalStats() float Fpm = pStats->GetFPM(Client()->GameTick(), Client()->GameTickSpeed()); str_format(aBuf, sizeof(aBuf), "%.1f", Fpm); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // SPREE { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_CurrentSpree); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // BEST SPREE { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_BestSpree); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // GRABS @@ -375,7 +375,7 @@ void CStatboard::RenderGlobalStats() { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagGrabs); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } // WEAPONS @@ -387,7 +387,7 @@ void CStatboard::RenderGlobalStats() str_format(aBuf, sizeof(aBuf), "%d/%d", pStats->m_aFragsWith[i], pStats->m_aDeathsFrom[i]); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x+px-tw/2, y, FontSize, aBuf, -1); + TextRender()->Text(0, x+px-tw/2, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 80; } // FLAGS @@ -395,7 +395,7 @@ void CStatboard::RenderGlobalStats() { str_format(aBuf, sizeof(aBuf), "%d", pStats->m_FlagCaptures); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); - TextRender()->Text(0, x-tw+px, y, FontSize, aBuf, -1); + TextRender()->Text(0, x-tw+px, y + (LineHeight*0.95f - FontSize) / 2.f, FontSize, aBuf, -1); px += 85; } y += LineHeight;