From 5d4f1293c7d2dde221e3114afdc9c349a1271bca Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 30 Mar 2024 12:10:50 +0100 Subject: [PATCH] fixed SetWidth/HeightBasedOnAspect behaving unexpectedly if an image has no texture --- MLEM.Ui/Elements/Image.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MLEM.Ui/Elements/Image.cs b/MLEM.Ui/Elements/Image.cs index 2c09d20..26411aa 100644 --- a/MLEM.Ui/Elements/Image.cs +++ b/MLEM.Ui/Elements/Image.cs @@ -144,6 +144,12 @@ namespace MLEM.Ui.Elements { ret.X = ret.Y * this.Texture.Width / this.Texture.Height + this.ScaledAutoSizeAddedAbsolute.X; if (this.SetHeightBasedOnAspect) ret.Y = ret.X * this.Texture.Height / this.Texture.Width + this.ScaledAutoSizeAddedAbsolute.Y; + } else { + // if we don't have a texture and we auto-set width or height, calculate as if we had a texture with a size of 0 + if (this.SetWidthBasedOnAspect) + ret.X = this.ScaledAutoSizeAddedAbsolute.X; + if (this.SetHeightBasedOnAspect) + ret.Y = this.ScaledAutoSizeAddedAbsolute.Y; } return ret; }