(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
@@ -20,6 +20,8 @@ namespace Barotrauma
public OnButtonDownHandler OnButtonDown;
public bool CanBeSelected = true;
private Color? defaultTextColor;
public override bool Enabled
{
@@ -30,8 +32,13 @@ namespace Barotrauma
set
{
if (value == enabled) return;
if (value == enabled) { return; }
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;
}
}
@@ -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),
TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge")
{