Skip to content

Commit 9fbd847

Browse files
authored
Apply horizontal scaling to options menu value text (#685)
1 parent 34a23d4 commit 9fbd847

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

UnleashedRecomp/ui/options_menu.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,28 +1165,39 @@ static void DrawConfigOption(int32_t rowIndex, float yOffset, ConfigDef<T>* conf
11651165
size = Scale(20.0f);
11661166
textSize = g_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data());
11671167

1168-
min.x += ((max.x - min.x) - textSize.x) / 2.0f;
1169-
min.y += ((max.y - min.y) - textSize.y) / 2.0f;
1168+
auto textSquashRatio = 1.0f;
1169+
1170+
if (textSize.x > max.x - min.x)
1171+
textSquashRatio = (max.x - min.x) / textSize.x - 0.1f;
1172+
1173+
auto textX = min.x + ((max.x - min.x) - (textSize.x * textSquashRatio)) / 2.0f;
1174+
auto textY = min.y + ((max.y - min.y) - textSize.y) / 2.0f;
11701175

11711176
SetGradient
11721177
(
1173-
min,
1174-
{ min.x + textSize.x, min.y + textSize.y },
1178+
{ textX, textY },
1179+
{ textX + textSize.x, textY + textSize.y },
11751180
IM_COL32(192, 255, 0, 255),
11761181
IM_COL32(128, 170, 0, 255)
11771182
);
11781183

1184+
SetScale({ textSquashRatio, 1.0f });
1185+
SetOrigin({ textX, textY });
1186+
11791187
DrawTextWithOutline
11801188
(
11811189
g_newRodinFont,
11821190
size,
1183-
min,
1191+
{ textX, textY },
11841192
IM_COL32(255, 255, 255, 255 * alpha),
11851193
valueText.data(),
11861194
4,
11871195
IM_COL32(0, 0, 0, 255 * alpha)
11881196
);
11891197

1198+
SetScale({ 1.0f, 1.0f });
1199+
SetOrigin({ 0.0f, 0.0f });
1200+
11901201
ResetGradient();
11911202
}
11921203

0 commit comments

Comments
 (0)