mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 03:17:45 +08:00
Merge changes of branch refactor-osd into music-controller-hotkeys
This commit is contained in:
commit
2ab30281fb
@ -6,8 +6,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Configuration.Tracking;
|
using osu.Framework.Configuration.Tracking;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
using osu.Game.Overlays.OSD;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
@ -23,8 +23,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
osd.BeginTracking(this, config);
|
osd.BeginTracking(this, config);
|
||||||
Add(osd);
|
Add(osd);
|
||||||
|
|
||||||
AddStep("Display empty osd toast", () => osd.Display(new Overlays.OSD.OsdToast()));
|
AddStep("Display empty osd toast", () => osd.Display(new EmptyToast()));
|
||||||
AddStep("Display osd toast with icon and message", () => osd.Display(new Overlays.OSD.OsdIconToast("Hey there !", FontAwesome.Solid.HandSpock)));
|
|
||||||
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);
|
||||||
@ -89,6 +88,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Setting4
|
Setting4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class EmptyToast : Toast
|
||||||
|
{
|
||||||
|
public EmptyToast()
|
||||||
|
: base("", "", "")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.OSD
|
|
||||||
{
|
|
||||||
public class OsdToast : Container
|
|
||||||
{
|
|
||||||
private readonly Container content;
|
|
||||||
protected override Container<Drawable> Content => content;
|
|
||||||
|
|
||||||
public OsdToast()
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre;
|
|
||||||
Origin = Anchor.Centre;
|
|
||||||
Width = 240;
|
|
||||||
RelativeSizeAxes = Axes.Y;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4.Black,
|
|
||||||
Alpha = 0.7f
|
|
||||||
},
|
|
||||||
content = new Container
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
75
osu.Game/Overlays/OSD/Toast.cs
Normal file
75
osu.Game/Overlays/OSD/Toast.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.OSD
|
||||||
|
{
|
||||||
|
public abstract class Toast : Container
|
||||||
|
{
|
||||||
|
private readonly Container content;
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
protected readonly OsuSpriteText ValueText;
|
||||||
|
|
||||||
|
protected Toast(string description, string value, string keybinding)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Width = 240;
|
||||||
|
|
||||||
|
// A toast's height is decided (and transformed) by the containing OnScreenDisplay.
|
||||||
|
RelativeSizeAxes = Axes.Y;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Black,
|
||||||
|
Alpha = 0.7f
|
||||||
|
},
|
||||||
|
content = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
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()
|
||||||
|
},
|
||||||
|
ValueText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
|
||||||
|
Padding = new MarginPadding { Left = 10, Right = 10 },
|
||||||
|
Name = "Value",
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
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()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Configuration.Tracking;
|
using osu.Framework.Configuration.Tracking;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -8,67 +9,38 @@ 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;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace osu.Game.Overlays.OSD
|
namespace osu.Game.Overlays.OSD
|
||||||
{
|
{
|
||||||
public class OsdTrackedSettingToast : OsdToast
|
public class TrackedSettingToast : Toast
|
||||||
{
|
{
|
||||||
public OsdTrackedSettingToast(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,8 +62,7 @@ namespace osu.Game.Overlays.OSD
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
textLine2.Origin = optionCount > 0 ? Anchor.BottomCentre : Anchor.Centre;
|
ValueText.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++)
|
||||||
{
|
{
|
@ -97,16 +97,16 @@ namespace osu.Game.Overlays
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays the given <see cref="OsdToast"/> as parameter on the OSD
|
/// Displays the given <see cref="Toast"/> as parameter on the OSD
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="toast"></param>
|
/// <param name="toast"></param>
|
||||||
public void Display(OsdToast toast)
|
public void Display(Toast toast)
|
||||||
{
|
{
|
||||||
box.Child = toast;
|
box.Child = toast;
|
||||||
DisplayTemporarily(box);
|
DisplayTemporarily(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayTrackedSettingChange(SettingDescription description) => Schedule(() => Display(new OsdTrackedSettingToast(description)));
|
private void displayTrackedSettingChange(SettingDescription description) => Schedule(() => Display(new TrackedSettingToast(description)));
|
||||||
|
|
||||||
private TransformSequence<Drawable> fadeIn;
|
private TransformSequence<Drawable> fadeIn;
|
||||||
private ScheduledDelegate fadeOut;
|
private ScheduledDelegate fadeOut;
|
||||||
|
Loading…
Reference in New Issue
Block a user