mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 21:12:55 +08:00
Add placeholder when no colours are visible
Will be removed once combo colours are mutable.
This commit is contained in:
parent
0cd1aa8c1c
commit
577755ee19
@ -20,13 +20,14 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
createColourPalette(hasDescription);
|
createColourPalette(hasDescription);
|
||||||
|
|
||||||
AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4);
|
AddRepeatStep("add random colour", () => component.Colours.Add(randomColour()), 4);
|
||||||
|
|
||||||
|
AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo");
|
||||||
|
|
||||||
AddRepeatStep("remove random colour", () =>
|
AddRepeatStep("remove random colour", () =>
|
||||||
{
|
{
|
||||||
if (component.Colours.Count > 0)
|
if (component.Colours.Count > 0)
|
||||||
component.Colours.RemoveAt(RNG.Next(component.Colours.Count));
|
component.Colours.RemoveAt(RNG.Next(component.Colours.Count));
|
||||||
}, 5);
|
}, 8);
|
||||||
|
|
||||||
AddStep("set custom prefix", () => component.ColourNamePrefix = "Combo");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createColourPalette(bool hasDescription = false)
|
private void createColourPalette(bool hasDescription = false)
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
// 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.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
@ -32,6 +34,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
}
|
}
|
||||||
|
|
||||||
private FillFlowContainer<ColourDisplay> palette;
|
private FillFlowContainer<ColourDisplay> palette;
|
||||||
|
private Container placeholder;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -39,12 +42,27 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
InternalChild = palette = new FillFlowContainer<ColourDisplay>
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
palette = new FillFlowContainer<ColourDisplay>
|
||||||
AutoSizeAxes = Axes.Y,
|
{
|
||||||
Spacing = new Vector2(10),
|
RelativeSizeAxes = Axes.X,
|
||||||
Direction = FillDirection.Full
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Spacing = new Vector2(10),
|
||||||
|
Direction = FillDirection.Full
|
||||||
|
},
|
||||||
|
placeholder = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Child = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Text = "(none)",
|
||||||
|
Font = OsuFont.Default.With(weight: FontWeight.Bold)
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,12 +71,26 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
Colours.BindCollectionChanged((_, __) => updatePalette(), true);
|
Colours.BindCollectionChanged((_, __) => updatePalette(), true);
|
||||||
|
FinishTransforms(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private const int fade_duration = 200;
|
||||||
|
|
||||||
private void updatePalette()
|
private void updatePalette()
|
||||||
{
|
{
|
||||||
palette.Clear();
|
palette.Clear();
|
||||||
|
|
||||||
|
if (Colours.Any())
|
||||||
|
{
|
||||||
|
palette.FadeIn(fade_duration, Easing.OutQuint);
|
||||||
|
placeholder.FadeOut(fade_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
palette.FadeOut(fade_duration, Easing.OutQuint);
|
||||||
|
placeholder.FadeIn(fade_duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var item in Colours)
|
foreach (var item in Colours)
|
||||||
{
|
{
|
||||||
palette.Add(new ColourDisplay
|
palette.Add(new ColourDisplay
|
||||||
|
Loading…
Reference in New Issue
Block a user