mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 16:32:54 +08:00
Apply review suggestions
This commit is contained in:
parent
9c15024014
commit
6533f114d4
@ -24,6 +24,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Add(osd);
|
Add(osd);
|
||||||
|
|
||||||
AddStep("Display empty osd toast", () => osd.Display(new EmptyToast()));
|
AddStep("Display empty osd toast", () => osd.Display(new EmptyToast()));
|
||||||
|
AddAssert("Toast width is 240", () => osd.Child.Width == 240);
|
||||||
|
|
||||||
|
AddStep("Display toast with lengthy text", () => osd.Display(new LengthyToast()));
|
||||||
|
AddAssert("Toast width is greater than 240", () => osd.Child.Width > 240);
|
||||||
|
|
||||||
AddRepeatStep("Change toggle (no bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingNoKeybind), 2);
|
AddRepeatStep("Change toggle (no bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingNoKeybind), 2);
|
||||||
AddRepeatStep("Change toggle (with bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingWithKeybind), 2);
|
AddRepeatStep("Change toggle (with bind)", () => config.ToggleSetting(TestConfigSetting.ToggleSettingWithKeybind), 2);
|
||||||
AddRepeatStep("Change enum (no bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingNoKeybind), 3);
|
AddRepeatStep("Change enum (no bind)", () => config.IncrementEnumSetting(TestConfigSetting.EnumSettingNoKeybind), 3);
|
||||||
@ -96,6 +101,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class LengthyToast : Toast
|
||||||
|
{
|
||||||
|
public LengthyToast()
|
||||||
|
: base("Toast with a very very very long text", "A very very very very very very long text also", "A very very very very very long shortcut")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class TestOnScreenDisplay : OnScreenDisplay
|
private class TestOnScreenDisplay : OnScreenDisplay
|
||||||
{
|
{
|
||||||
protected override void DisplayTemporarily(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110);
|
protected override void DisplayTemporarily(Drawable toDisplay) => toDisplay.FadeIn().ResizeHeightTo(110);
|
||||||
|
@ -13,22 +13,30 @@ namespace osu.Game.Overlays.OSD
|
|||||||
{
|
{
|
||||||
public abstract class Toast : Container
|
public abstract class Toast : Container
|
||||||
{
|
{
|
||||||
|
private const int toast_minimum_width = 240;
|
||||||
|
|
||||||
private readonly Container content;
|
private readonly Container content;
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
protected readonly OsuSpriteText ValueText;
|
protected readonly OsuSpriteText ValueText;
|
||||||
|
|
||||||
protected Toast(string description, string value, string keybinding)
|
protected Toast(string description, string value, string shortcut)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre;
|
Anchor = Anchor.Centre;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
Width = 240;
|
|
||||||
|
|
||||||
// A toast's height is decided (and transformed) by the containing OnScreenDisplay.
|
// A toast's height is decided (and transformed) by the containing OnScreenDisplay.
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
|
new Container //this container exists just to set a minimum width for the toast
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Width = toast_minimum_width
|
||||||
|
},
|
||||||
new Box
|
new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -68,7 +76,7 @@ namespace osu.Game.Overlays.OSD
|
|||||||
Alpha = 0.3f,
|
Alpha = 0.3f,
|
||||||
Margin = new MarginPadding { Bottom = 15 },
|
Margin = new MarginPadding { Bottom = 15 },
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||||
Text = string.IsNullOrEmpty(keybinding) ? "NO KEY BOUND" : keybinding.ToUpperInvariant()
|
Text = string.IsNullOrEmpty(shortcut) ? "NO KEY BOUND" : shortcut.ToUpperInvariant()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user