mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
some exception handling
This commit is contained in:
parent
150d6f771a
commit
03923f91f6
3 changed files with 9 additions and 5 deletions
|
@ -305,10 +305,12 @@ namespace MLEM.Ui.Elements {
|
|||
|
||||
if (this.SetHeightBasedOnChildren && this.Children.Count > 0) {
|
||||
var lowest = this.GetLowestChild(e => !e.IsHidden);
|
||||
var newHeight = (lowest.UnscrolledArea.Bottom - pos.Y + this.ScaledChildPadding.Y) / this.Scale;
|
||||
if (newHeight != this.size.Y) {
|
||||
this.size.Y = newHeight;
|
||||
this.ForceUpdateArea();
|
||||
if (lowest != null) {
|
||||
var newHeight = (lowest.UnscrolledArea.Bottom - pos.Y + this.ScaledChildPadding.Y) / this.Scale;
|
||||
if (newHeight != this.size.Y) {
|
||||
this.size.Y = newHeight;
|
||||
this.ForceUpdateArea();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace MLEM.Ui.Elements {
|
|||
set {
|
||||
if (this.texture != value) {
|
||||
this.texture = value;
|
||||
this.IsHidden = this.texture == null;
|
||||
if (this.scaleToImage)
|
||||
this.SetAreaDirty();
|
||||
}
|
||||
|
@ -42,7 +43,7 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
|
||||
protected override Point CalcActualSize(Rectangle parentArea) {
|
||||
return this.scaleToImage ? this.texture.Size : base.CalcActualSize(parentArea);
|
||||
return this.texture != null && this.scaleToImage ? this.texture.Size : base.CalcActualSize(parentArea);
|
||||
}
|
||||
|
||||
public override void Draw(GameTime time, SpriteBatch batch, float alpha) {
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace MLEM.Ui.Elements {
|
|||
set {
|
||||
if (this.text != value) {
|
||||
this.text = value;
|
||||
this.IsHidden = string.IsNullOrWhiteSpace(this.text);
|
||||
this.SetAreaDirty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue