Simplify TooltipText for EditorRadioButton

This commit is contained in:
Nguyên Minh Hồ 2024-03-30 16:04:22 +07:00
parent 8d6358a138
commit 5d497ba4a8
4 changed files with 18 additions and 13 deletions

View File

@ -68,7 +68,13 @@ namespace osu.Game.Rulesets.Osu.Edit
}
}
};
selectionCentreButton.TooltipTextWhenDisabled = "We can't rotate a circle around itself! Can we?";
selectionCentreButton.Selected.DisabledChanged += (isDisabled) =>
{
if (isDisabled)
selectionCentreButton.TooltipText = "We can't rotate a circle around itself! Can we?";
else
selectionCentreButton.TooltipText = string.Empty;
};
}
protected override void LoadComplete()

View File

@ -214,7 +214,13 @@ namespace osu.Game.Rulesets.Edit
foreach (var item in toolboxCollection.Items)
{
item.TooltipTextWhenDisabled = "Add at least one timing point first!";
item.Selected.DisabledChanged += (isDisabled) =>
{
if (isDisabled)
item.TooltipText = "Add at least one timing point first!";
else
item.TooltipText = string.Empty;
};
}
TernaryStates = CreateTernaryButtons().ToArray();

View File

@ -94,6 +94,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
X = 40f
};
public LocalisableString TooltipText => Enabled.Value ? Button.TooltipTextWhenEnabled : Button.TooltipTextWhenDisabled;
public LocalisableString TooltipText => Button.TooltipText;
}
}

View File

@ -16,16 +16,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// </summary>
public readonly BindableBool Selected;
/// <summary>
/// Tooltip text that will be shown on hover if button is enabled.
/// </summary>
public LocalisableString TooltipTextWhenEnabled { get; set; } = string.Empty;
/// <summary>
/// Tooltip text that will be shown on hover if button is disabled.
/// </summary>
public LocalisableString TooltipTextWhenDisabled { get; set; } = string.Empty;
/// <summary>
/// The item related to this button.
/// </summary>
@ -62,5 +52,8 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// Deselects this <see cref="RadioButton"/>.
/// </summary>
public void Deselect() => Selected.Value = false;
// Tooltip text that will be shown when hovered over
public LocalisableString TooltipText { get; set; } = string.Empty;
}
}