From 9fbd847d50561709f34fe1718f49ede7d65cc0e5 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 3 Mar 2025 00:47:07 +0000 Subject: [PATCH] Apply horizontal scaling to options menu value text (#685) --- UnleashedRecomp/ui/options_menu.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/UnleashedRecomp/ui/options_menu.cpp b/UnleashedRecomp/ui/options_menu.cpp index 87134dd..a9955d2 100644 --- a/UnleashedRecomp/ui/options_menu.cpp +++ b/UnleashedRecomp/ui/options_menu.cpp @@ -1165,28 +1165,39 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef* conf size = Scale(20.0f); textSize = g_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data()); - min.x += ((max.x - min.x) - textSize.x) / 2.0f; - min.y += ((max.y - min.y) - textSize.y) / 2.0f; + auto textSquashRatio = 1.0f; + + if (textSize.x > max.x - min.x) + textSquashRatio = (max.x - min.x) / textSize.x - 0.1f; + + auto textX = min.x + ((max.x - min.x) - (textSize.x * textSquashRatio)) / 2.0f; + auto textY = min.y + ((max.y - min.y) - textSize.y) / 2.0f; SetGradient ( - min, - { min.x + textSize.x, min.y + textSize.y }, + { textX, textY }, + { textX + textSize.x, textY + textSize.y }, IM_COL32(192, 255, 0, 255), IM_COL32(128, 170, 0, 255) ); + SetScale({ textSquashRatio, 1.0f }); + SetOrigin({ textX, textY }); + DrawTextWithOutline ( g_newRodinFont, size, - min, + { textX, textY }, IM_COL32(255, 255, 255, 255 * alpha), valueText.data(), 4, IM_COL32(0, 0, 0, 255 * alpha) ); + SetScale({ 1.0f, 1.0f }); + SetOrigin({ 0.0f, 0.0f }); + ResetGradient(); }