mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 14:02:55 +08:00
Merge pull request #14400 from bdach/setting-warning-text-initial-state
Fix settings item warning text not showing initially
This commit is contained in:
commit
48e5199c58
@ -76,5 +76,23 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
AddStep("restore default", () => sliderBar.Current.SetDefault());
|
||||
AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWarningTextVisibility()
|
||||
{
|
||||
SettingsNumberBox numberBox = null;
|
||||
|
||||
AddStep("create settings item", () => Child = numberBox = new SettingsNumberBox());
|
||||
AddAssert("warning text not created", () => !numberBox.ChildrenOfType<SettingsNoticeText>().Any());
|
||||
|
||||
AddStep("set warning text", () => numberBox.WarningText = "this is a warning!");
|
||||
AddAssert("warning text created", () => numberBox.ChildrenOfType<SettingsNoticeText>().Single().Alpha == 1);
|
||||
|
||||
AddStep("unset warning text", () => numberBox.WarningText = default);
|
||||
AddAssert("warning text hidden", () => numberBox.ChildrenOfType<SettingsNoticeText>().Single().Alpha == 0);
|
||||
|
||||
AddStep("set warning text again", () => numberBox.WarningText = "another warning!");
|
||||
AddAssert("warning text shown again", () => numberBox.ChildrenOfType<SettingsNoticeText>().Single().Alpha == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace osu.Game.Overlays.Settings
|
||||
{
|
||||
set
|
||||
{
|
||||
bool hasValue = string.IsNullOrWhiteSpace(value.ToString());
|
||||
bool hasValue = !string.IsNullOrWhiteSpace(value.ToString());
|
||||
|
||||
if (warningText == null)
|
||||
{
|
||||
@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Settings
|
||||
FlowContent.Add(warningText = new SettingsNoticeText(colours) { Margin = new MarginPadding { Bottom = 5 } });
|
||||
}
|
||||
|
||||
warningText.Alpha = hasValue ? 0 : 1;
|
||||
warningText.Alpha = hasValue ? 1 : 0;
|
||||
warningText.Text = value.ToString(); // TODO: Remove ToString() call after TextFlowContainer supports localisation (see https://github.com/ppy/osu-framework/issues/4636).
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user