1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-22 12:58:33 +01:00

made paragraphs and images use their callbacks when updating their area so that the first visible frame already has the right data

This commit is contained in:
Ellpeck 2019-12-19 14:04:50 +01:00
parent c704aa6160
commit ca258fe41a
2 changed files with 12 additions and 1 deletions

View file

@ -56,6 +56,12 @@ namespace MLEM.Ui.Elements {
return this.texture != null && this.scaleToImage ? this.texture.Size.ToVector2() : base.CalcActualSize(parentArea);
}
public override void ForceUpdateArea() {
if (this.GetTextureCallback != null)
this.Texture = this.GetTextureCallback(this);
base.ForceUpdateArea();
}
public override void Update(GameTime time) {
base.Update(time);
if (this.GetTextureCallback != null)

View file

@ -67,6 +67,12 @@ namespace MLEM.Ui.Elements {
return new Vector2(this.AutoAdjustWidth ? textDims.X + this.ScaledPadding.Width : size.X, textDims.Y + this.ScaledPadding.Height);
}
public override void ForceUpdateArea() {
if (this.GetTextCallback != null)
this.Text = this.GetTextCallback(this);
base.ForceUpdateArea();
}
public override void Update(GameTime time) {
base.Update(time);
if (this.GetTextCallback != null)
@ -103,5 +109,4 @@ namespace MLEM.Ui.Elements {
public delegate string TextCallback(Paragraph paragraph);
}
}