From b2f66978c981351727ded03bca5d87b1b990b2d6 Mon Sep 17 00:00:00 2001 From: oy Date: Wed, 16 Feb 2011 12:36:51 +0100 Subject: fixed overlapping image names in the editor. Closes #442 --- src/game/editor/ed_editor.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/game/editor/ed_editor.cpp') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 69040499..bbe321cf 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -381,9 +381,13 @@ int CEditor::DoButton_Editor_Common(const void *pID, const char *pText, int Chec int CEditor::DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip) { RenderTools()->DrawUIRect(pRect, GetButtonColor(pID, Checked), CUI::CORNER_ALL, 3.0f); - CUIRect NewRect = *pRect; - NewRect.y += NewRect.h/2.0f-7.0f; - UI()->DoLabel(&NewRect, pText, 10, 0, -1); + CUIRect NewRect = *pRect; + NewRect.y += NewRect.h/2.0f-7.0f; + float tw = min(TextRender()->TextWidth(0, 10.0f, pText, -1), NewRect.w); + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, NewRect.x + NewRect.w/2-tw/2, NewRect.y - 1.0f, 10.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = NewRect.w; + TextRender()->TextEx(&Cursor, pText, -1); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } @@ -416,7 +420,10 @@ int CEditor::DoButton_MenuItem(const void *pID, const char *pText, int Checked, CUIRect t = *pRect; t.VMargin(5.0f, &t); - UI()->DoLabel(&t, pText, 10, -1, -1); + CTextCursor Cursor; + TextRender()->SetCursor(&Cursor, t.x, t.y - 1.0f, 10.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); + Cursor.m_LineWidth = t.w; + TextRender()->TextEx(&Cursor, pText, -1); return DoButton_Editor_Common(pID, pText, Checked, pRect, Flags, pToolTip); } -- cgit 1.4.1