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