Return a virtual scale with the correct ratio if scale variable is set

This prevents the widget from being stretched out on widescreen, currently only the compass uses scalecvar
This commit is contained in:
smallmodel 2024-11-18 21:13:34 +01:00
parent 05d304dfc3
commit 59d03ff6f0
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -3141,14 +3141,20 @@ void UIWidget::SetScaleCvar
void UIWidget::SetVirtualScale(vec2_t out)
{
out[0] = uid.vidWidth / 640.0;
out[1] = uid.vidHeight / 480.0;
if (m_scaleCvar)
{
out[0] *= m_scaleCvar->value;
out[1] *= m_scaleCvar->value;
const float vidRatio = (float)uid.vidWidth / (float)uid.vidHeight;
const float minHeight = 480;
const float minWidth = minHeight * vidRatio;
out[0] = uid.vidWidth / minWidth * m_scaleCvar->value;
out[1] = uid.vidHeight / minHeight * m_scaleCvar->value;
}
else
{
out[0] = uid.vidWidth / 640.0;
out[1] = uid.vidHeight / 480.0;
}
}
void UIWidget::SetDontLocalize(Event* ev)