diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 2b77e9dc8..1dfb8dd2c 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -42,6 +42,8 @@ #include "menus.h" #include "skins.h" +#include + ColorRGBA CMenus::ms_GuiColor; ColorRGBA CMenus::ms_ColorTabbarInactiveOutgame; ColorRGBA CMenus::ms_ColorTabbarActiveOutgame; @@ -351,7 +353,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS for(int i = 1; i <= Len; i++) { - if(TextRender()->TextWidth(0, FontSize, pStr, i, -1.0f) - *Offset > MxRel) + if(TextRender()->TextWidth(0, FontSize, pStr, i, std::numeric_limits::max()) - *Offset > MxRel) { s_AtIndex = i - 1; break; @@ -473,11 +475,11 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS // check if the text has to be moved if(UI()->LastActiveItem() == pID && !JustGotActive && (UpdateOffset || m_NumInputEvents)) { - float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, -1.0f); + float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, std::numeric_limits::max()); if(w - *Offset > Textbox.w) { // move to the left - float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, -1.0f); + float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, std::numeric_limits::max()); do { *Offset += minimum(wt - *Offset - Textbox.w, Textbox.w / 3); @@ -506,10 +508,8 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS // render the cursor if(UI()->LastActiveItem() == pID && !JustGotActive) { - float OffsetGlyph = TextRender()->GetGlyphOffsetX(FontSize, '|'); - - float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, -1); - Textbox.x += w + OffsetGlyph; + float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, DispCursorPos, std::numeric_limits::max()); + Textbox.x += w; if((2 * time_get() / time_freq()) % 2) { diff --git a/src/game/client/ui.cpp b/src/game/client/ui.cpp index e2d0bb754..0f445db9c 100644 --- a/src/game/client/ui.cpp +++ b/src/game/client/ui.cpp @@ -441,7 +441,7 @@ int CUI::DoButton(const void *id, const char *text, int checked, const CUIRect * return ret; }*/ -void CUI::DoLabel(const CUIRect *r, const char *pText, float Size, int Align, int MaxWidth, int AlignVertically) +void CUI::DoLabel(const CUIRect *r, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically) { float AlignedSize = 0; float MaxCharacterHeightInLine = 0; @@ -465,12 +465,12 @@ void CUI::DoLabel(const CUIRect *r, const char *pText, float Size, int Align, in } } -void CUI::DoLabelScaled(const CUIRect *r, const char *pText, float Size, int Align, int MaxWidth, int AlignVertically) +void CUI::DoLabelScaled(const CUIRect *r, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically) { DoLabel(r, pText, Size * Scale(), Align, MaxWidth, AlignVertically); } -void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor) +void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor) { float AlignedSize = 0; float MaxCharacterHeightInLine = 0; @@ -515,7 +515,7 @@ void CUI::DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, cons RectEl.m_TextOutlineColor = TextRender()->GetTextOutlineColor(); } -void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor) +void CUI::DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth, int AlignVertically, bool StopAtEnd, int StrLen, CTextCursor *pReadCursor) { bool NeedsRecreate = false; bool ColorChanged = RectEl.m_TextColor != TextRender()->GetTextColor() || RectEl.m_TextOutlineColor != TextRender()->GetTextOutlineColor(); diff --git a/src/game/client/ui.h b/src/game/client/ui.h index 6ab98544f..604ea72b6 100644 --- a/src/game/client/ui.h +++ b/src/game/client/ui.h @@ -258,11 +258,11 @@ public: int DoPickerLogic(const void *pID, const CUIRect *pRect, float *pX, float *pY); // TODO: Refactor: Remove this? - void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1, int AlignVertically = 1); - void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1, int AlignVertically = 1); + void DoLabel(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1); + void DoLabelScaled(const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1); - void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL); - void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, int MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL); + void DoLabel(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL); + void DoLabelStreamed(CUIElement::SUIElementRect &RectEl, const CUIRect *pRect, const char *pText, float Size, int Align, float MaxWidth = -1, int AlignVertically = 1, bool StopAtEnd = false, int StrLen = -1, class CTextCursor *pReadCursor = NULL); }; #endif diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 6e3f51730..0377626ed 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -35,6 +35,8 @@ #include "auto_map.h" #include "editor.h" +#include + static const char *VANILLA_IMAGES[] = { "bg_cloud1", "bg_cloud2", @@ -352,7 +354,7 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str for(int i = 1; i <= Len; i++) { - if(TextRender()->TextWidth(0, FontSize, pStr, i, -1.0f) - *Offset > MxRel) + if(TextRender()->TextWidth(0, FontSize, pStr, i, std::numeric_limits::max()) - *Offset > MxRel) { s_AtIndex = i - 1; break; @@ -451,11 +453,11 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str // check if the text has to be moved if(UI()->LastActiveItem() == pID && !JustGotActive && (UpdateOffset || Input()->NumEvents())) { - float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex, -1.0f); + float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex, std::numeric_limits::max()); if(w - *Offset > Textbox.w) { // move to the left - float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, -1.0f); + float wt = TextRender()->TextWidth(0, FontSize, pDisplayStr, -1, std::numeric_limits::max()); do { *Offset += minimum(wt - *Offset - Textbox.w, Textbox.w / 3); @@ -473,18 +475,18 @@ int CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned Str UI()->ClipEnable(pRect); Textbox.x -= *Offset; - UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1, Textbox.w * 2.0f); + UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1, std::numeric_limits::max()); // render the cursor if(UI()->LastActiveItem() == pID && !JustGotActive) { - float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex, Textbox.w * 2.0f); + float w = TextRender()->TextWidth(0, FontSize, pDisplayStr, s_AtIndex, std::numeric_limits::max()); Textbox = *pRect; Textbox.VSplitLeft(2.0f, 0, &Textbox); - Textbox.x += (w - *Offset - TextRender()->TextWidth(0, FontSize, "|", -1, Textbox.w * 2.0f) / 2); + Textbox.x += (w - *Offset - TextRender()->TextWidth(0, FontSize, "|", -1, std::numeric_limits::max()) / 2); if((2 * time_get() / time_freq()) % 2) // make it blink - UI()->DoLabel(&Textbox, "|", FontSize, -1, Textbox.w * 2.0f); + UI()->DoLabel(&Textbox, "|", FontSize, -1, std::numeric_limits::max()); } UI()->ClipDisable();