From c7617b06d294ee8cebd3657dc54b3e35753483c2 Mon Sep 17 00:00:00 2001 From: def Date: Sun, 29 Mar 2015 01:32:07 +0100 Subject: [PATCH] Resize font in editor to show full image and sound name --- src/game/editor/editor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index b35f5f03c..bb4d05c1d 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3284,8 +3284,12 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) Selected += 4; // Image should be embedded } - if(int Result = DoButton_Editor(&m_Map.m_lImages[i], aBuf, Selected, &Slot, - BUTTON_CONTEXT, "Select image")) + float FontSize = 10.0f; + while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Slot.w) + FontSize--; + + if(int Result = DoButton_Ex(&m_Map.m_lImages[i], aBuf, Selected, &Slot, + BUTTON_CONTEXT, "Select image", 0, FontSize)) { m_SelectedImage = i; @@ -3436,8 +3440,12 @@ void CEditor::RenderSounds(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) if(Selected < 2 && e == 1) Selected += 4; // Sound should be embedded - if(int Result = DoButton_Editor(&m_Map.m_lSounds[i], aBuf, Selected, &Slot, - BUTTON_CONTEXT, "Select sound")) + float FontSize = 10.0f; + while(TextRender()->TextWidth(0, FontSize, aBuf, -1) > Slot.w) + FontSize--; + + if(int Result = DoButton_Ex(&m_Map.m_lSounds[i], aBuf, Selected, &Slot, + BUTTON_CONTEXT, "Select sound", 0, FontSize)) { m_SelectedSound = i;