From 2d2fe8bf57e64ab13e78505eb345491c9340fcb2 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 2 Jan 2019 19:27:40 +0100 Subject: [PATCH] reverted edit boxes to 0.6 behavior. closes #1937 --- src/game/client/components/menus.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 72d170428..724d9c850 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -448,11 +448,10 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS s_DoScroll = true; s_ScrollStart = UI()->MouseX(); int MxRel = (int)(UI()->MouseX() - pRect->x); - float Offset = pRect->w/2.0f-TextRender()->TextWidth(0, FontSize, pStr, -1)/2.0f; for(int i = 1; i <= Len; i++) { - if(Offset + TextRender()->TextWidth(0, FontSize, pStr, i) - *pOffset > MxRel) + if(TextRender()->TextWidth(0, FontSize, pStr, i) - *pOffset > MxRel) { s_AtIndex = i - 1; break; @@ -562,15 +561,14 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS UI()->ClipEnable(pRect); Textbox.x -= *pOffset; - UI()->DoLabel(&Textbox, pDisplayStr, FontSize, CUI::ALIGN_CENTER); + UI()->DoLabel(&Textbox, pDisplayStr, FontSize, CUI::ALIGN_LEFT); // render the cursor if(UI()->LastActiveItem() == pID && !JustGotActive) { - float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1); + float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex); Textbox = *pRect; - Textbox.x += Textbox.w/2.0f-w/2.0f; - w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex); + Textbox.VSplitLeft(2.0f, 0, &Textbox); Textbox.x += (w-*pOffset-TextRender()->TextWidth(0, FontSize, "|", -1)/2); if((2*time_get()/time_freq()) % 2) // make it blink