1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 02:07:34 +08:00

Show a message when attempting to customisse a screen which doesn't support it

This commit is contained in:
Dean Herbert 2021-05-11 18:37:41 +09:00
parent 6d587dc392
commit f55407f871
3 changed files with 81 additions and 47 deletions

View File

@ -87,9 +87,9 @@ namespace osu.Game.Screens
private static Color4 getColourFor(object type)
{
int hash = type.GetHashCode();
byte r = (byte)Math.Clamp(((hash & 0xFF0000) >> 16) * 0.8f, 20, 255);
byte g = (byte)Math.Clamp(((hash & 0x00FF00) >> 8) * 0.8f, 20, 255);
byte b = (byte)Math.Clamp((hash & 0x0000FF) * 0.8f, 20, 255);
byte r = (byte)Math.Clamp(((hash & 0xFF0000) >> 16) * 2, 128, 255);
byte g = (byte)Math.Clamp(((hash & 0x00FF00) >> 8) * 2, 128, 255);
byte b = (byte)Math.Clamp((hash & 0x0000FF) * 2, 128, 255);
return new Color4(r, g, b, 255);
}
@ -109,10 +109,10 @@ namespace osu.Game.Screens
private readonly Container boxContainer;
public UnderConstructionMessage(string name)
public UnderConstructionMessage(string name, string description = "is not yet ready for use!")
{
RelativeSizeAxes = Axes.Both;
Size = new Vector2(0.3f);
AutoSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
@ -124,7 +124,7 @@ namespace osu.Game.Screens
{
CornerRadius = 20,
Masking = true,
RelativeSizeAxes = Axes.Both,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]
@ -133,15 +133,15 @@ namespace osu.Game.Screens
{
RelativeSizeAxes = Axes.Both,
Colour = colour,
Alpha = 0.2f,
Blending = BlendingParameters.Additive,
Colour = colour.Darken(0.8f),
Alpha = 0.8f,
},
TextContainer = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Padding = new MarginPadding(20),
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
@ -157,14 +157,14 @@ namespace osu.Game.Screens
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = name,
Colour = colour.Lighten(0.8f),
Colour = colour,
Font = OsuFont.GetFont(size: 36),
},
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Text = "is not yet ready for use!",
Text = description,
Font = OsuFont.GetFont(size: 20),
},
new OsuSpriteText

View File

@ -7,8 +7,10 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Screens.Play.HUD;
@ -36,7 +38,17 @@ namespace osu.Game.Skinning.Editor
base.LoadComplete();
// track each target container on the current screen.
foreach (var targetContainer in target.ChildrenOfType<SkinnableElementTargetContainer>())
var targetContainers = target.ChildrenOfType<SkinnableElementTargetContainer>().ToArray();
if (targetContainers.Length == 0)
{
var targetScreen = target.ChildrenOfType<Screen>().LastOrDefault()?.GetType().Name ?? "this screen";
AddInternal(new ScreenWhiteBox.UnderConstructionMessage(targetScreen, "doesn't support skin customisation just yet."));
return;
}
foreach (var targetContainer in targetContainers)
{
var bindableList = new BindableList<ISkinnableComponent> { BindTarget = targetContainer.Components };
bindableList.BindCollectionChanged(componentsChanged, true);

View File

@ -62,46 +62,68 @@ namespace osu.Game.Skinning.Editor
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X
},
new SkinBlueprintContainer(targetScreen),
new SkinComponentToolbox(600)
new GridContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RequestPlacement = placeComponent
},
new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Spacing = new Vector2(5),
Padding = new MarginPadding
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
Top = 10,
Left = 10,
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
Margin = new MarginPadding
Content = new[]
{
Right = 10,
Bottom = 10,
},
Children = new Drawable[]
{
new TriangleButton
new Drawable[]
{
Text = "Save Changes",
Width = 140,
Action = save,
},
new DangerousTriangleButton
{
Text = "Revert to default",
Width = 140,
Action = revert,
},
new SkinComponentToolbox(600)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RequestPlacement = placeComponent
},
new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new SkinBlueprintContainer(targetScreen),
new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Spacing = new Vector2(5),
Padding = new MarginPadding
{
Top = 10,
Left = 10,
},
Margin = new MarginPadding
{
Right = 10,
Bottom = 10,
},
Children = new Drawable[]
{
new TriangleButton
{
Text = "Save Changes",
Width = 140,
Action = save,
},
new DangerousTriangleButton
{
Text = "Revert to default",
Width = 140,
Action = revert,
},
}
},
}
},
}
}
},
}
}
};
}