(04facf9b6) Gray out the text in disabled buttons if the button has no visible sprite (the buttons in the main menu for example looked the same when disabled)

This commit is contained in:
Joonas Rikkonen
2019-04-03 16:24:34 +03:00
parent 64bec6d3b9
commit fd0e394827
3 changed files with 27 additions and 5 deletions
@@ -21,6 +21,8 @@ namespace Barotrauma
public bool CanBeSelected = true; public bool CanBeSelected = true;
private Color? defaultTextColor;
public override bool Enabled public override bool Enabled
{ {
get get
@@ -30,8 +32,13 @@ namespace Barotrauma
set set
{ {
if (value == enabled) return; if (value == enabled) { return; }
enabled = value; enabled = value;
if (color.A == 0)
{
if (defaultTextColor == null) { defaultTextColor = TextBlock.TextColor; }
TextBlock.TextColor = enabled ? defaultTextColor.Value : defaultTextColor.Value * 0.5f;
}
frame.Color = enabled ? color : Color.Gray * 0.7f; frame.Color = enabled ? color : Color.Gray * 0.7f;
} }
} }
@@ -682,6 +682,25 @@ namespace Barotrauma
} }
}; };
//spacing
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null);
new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft),
TextManager.Get("Cancel"), style: "GUIButtonLarge")
{
IgnoreLayoutGroups = true,
OnClicked = (x, y) =>
{
if (UnsavedSettings)
{
LoadPlayerConfig();
}
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
GUI.SettingsMenuOpen = false;
return true;
}
};
applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight), applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight),
TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge") TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge")
{ {
@@ -26,10 +26,6 @@ namespace Barotrauma.Items.Components
private float blinkTimer; private float blinkTimer;
private bool itemLoaded;
private float blinkTimer;
public PhysicsBody ParentBody; public PhysicsBody ParentBody;
[Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)] [Editable(MinValueFloat = 0.0f, MaxValueFloat = 2048.0f), Serialize(100.0f, true)]