Move text display layout to Toast.

This commit is contained in:
Lucas A
2019-07-12 08:50:53 +02:00
parent 2c62891c48
commit 09d679de8d
3 changed files with 42 additions and 38 deletions

View File

@ -90,6 +90,10 @@ namespace osu.Game.Tests.Visual.UserInterface
private class EmptyToast : Toast private class EmptyToast : Toast
{ {
public EmptyToast()
: base("", "", "")
{
}
} }
private class TestOnScreenDisplay : OnScreenDisplay private class TestOnScreenDisplay : OnScreenDisplay

View File

@ -4,6 +4,9 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Overlays.OSD namespace osu.Game.Overlays.OSD
@ -13,7 +16,7 @@ namespace osu.Game.Overlays.OSD
private readonly Container content; private readonly Container content;
protected override Container<Drawable> Content => content; protected override Container<Drawable> Content => content;
protected Toast() protected Toast(string description, string value, string keybinding)
{ {
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
@ -35,7 +38,35 @@ namespace osu.Game.Overlays.OSD
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
} },
new OsuSpriteText
{
Padding = new MarginPadding(10),
Name = "Description",
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Black),
Spacing = new Vector2(1, 0),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = description.ToUpperInvariant()
},
new OsuSpriteText
{
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
Padding = new MarginPadding { Left = 10, Right = 10 },
Name = "Value",
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Text = value
},
new OsuSpriteText
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Name = "Shortcut",
Margin = new MarginPadding { Bottom = 15 },
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = string.IsNullOrEmpty(keybinding) ? "NO KEY BOUND" : keybinding.ToUpperInvariant()
},
}; };
} }
} }

View File

@ -9,9 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -20,55 +18,29 @@ namespace osu.Game.Overlays.OSD
public class TrackedSettingToast : Toast public class TrackedSettingToast : Toast
{ {
public TrackedSettingToast(SettingDescription description) public TrackedSettingToast(SettingDescription description)
: base(description.Name, description.Value, description.Shortcut)
{ {
SpriteText textLine2;
FillFlowContainer<OptionLight> optionLights; FillFlowContainer<OptionLight> optionLights;
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText
{
Padding = new MarginPadding(10),
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Black),
Spacing = new Vector2(1, 0),
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = description.Name.ToUpperInvariant()
},
textLine2 = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
Padding = new MarginPadding { Left = 10, Right = 10 },
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Text = description.Value
},
new FillFlowContainer new FillFlowContainer
{ {
Anchor = Anchor.BottomCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Margin = new MarginPadding { Top = 70 },
Children = new Drawable[] Children = new Drawable[]
{ {
optionLights = new FillFlowContainer<OptionLight> optionLights = new FillFlowContainer<OptionLight>
{ {
Padding = new MarginPadding { Top = 20, Bottom = 5 }, Padding = new MarginPadding { Bottom = 5 },
Spacing = new Vector2(5, 0), Spacing = new Vector2(5, 0),
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both AutoSizeAxes = Axes.Both
}, },
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Bottom = 15 },
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Alpha = 0.3f,
Text = string.IsNullOrEmpty(description.Shortcut) ? "NO KEY BOUND" : description.Shortcut.ToUpperInvariant()
},
} }
} }
}; };
@ -90,9 +62,6 @@ namespace osu.Game.Overlays.OSD
break; break;
} }
textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre;
textLine2.Y = optionCount > 0 ? 0 : 5;
for (int i = 0; i < optionCount; i++) for (int i = 0; i < optionCount; i++)
{ {
optionLights.Add(new OptionLight optionLights.Add(new OptionLight