Skip to content

Commit 9b91126

Browse files
committed
Fixed an issue in fa403c8 where buttons would become invisible when selected
1 parent fa403c8 commit 9b91126

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

MLEM.Ui/Elements/Button.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class Button : Element {
2020
/// <summary>
2121
/// The color that the button draws its texture with
2222
/// </summary>
23-
public StyleProp<Color> NormalColor = Color.White;
23+
public StyleProp<Color> NormalColor;
2424
/// <summary>
2525
/// The texture that the button uses while being moused over.
2626
/// If this is null, it uses its default <see cref="Texture"/>.
@@ -141,18 +141,18 @@ public Button(Anchor anchor, Vector2 size, Paragraph.TextCallback textCallback =
141141
/// <inheritdoc />
142142
public override void Draw(GameTime time, SpriteBatch batch, float alpha, SpriteBatchContext context) {
143143
var tex = this.Texture;
144-
var color = this.NormalColor;
144+
var color = this.NormalColor.OrDefault(Color.White);
145145
if (this.IsDisabled) {
146146
tex = this.DisabledTexture.OrDefault(tex);
147-
color = this.DisabledColor;
147+
color = this.DisabledColor.OrDefault(color);
148148
} else if (this.IsMouseOver) {
149149
tex = this.HoveredTexture.OrDefault(tex);
150-
color = this.HoveredColor;
150+
color = this.HoveredColor.OrDefault(color);
151151
} else if (this.IsSelected && this.Controls.IsAutoNavMode) {
152152
tex = this.SelectedTexture.OrDefault(tex);
153-
color = this.SelectedColor;
153+
color = this.SelectedColor.OrDefault(color);
154154
}
155-
batch.Draw(tex, this.DisplayArea, color.Value * alpha, this.Scale);
155+
batch.Draw(tex, this.DisplayArea, color * alpha, this.Scale);
156156
base.Draw(time, batch, alpha, context);
157157
}
158158

0 commit comments

Comments
 (0)