mirror of
https://github.com/ppy/osu.git
synced 2024-12-16 09:05:59 +08:00
Match button appearance to that of the beatmap editor
This commit is contained in:
parent
a1e64f4e3c
commit
e663629bc6
@ -5,12 +5,14 @@ using System;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
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.Effects;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
using osu.Game.Screens.Play.HUD;
|
using osu.Game.Screens.Play.HUD;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -22,6 +24,8 @@ namespace osu.Game.Skinning.Editor
|
|||||||
{
|
{
|
||||||
public Action<Type> RequestPlacement;
|
public Action<Type> RequestPlacement;
|
||||||
|
|
||||||
|
private const float component_display_scale = 0.8f;
|
||||||
|
|
||||||
public SkinComponentToolbox(float height)
|
public SkinComponentToolbox(float height)
|
||||||
: base("Components", height)
|
: base("Components", height)
|
||||||
{
|
{
|
||||||
@ -56,7 +60,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ToolboxComponent attemptAddComponent(Type type)
|
private static ToolboxComponentButton attemptAddComponent(Type type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -64,7 +68,7 @@ namespace osu.Game.Skinning.Editor
|
|||||||
|
|
||||||
Debug.Assert(instance != null);
|
Debug.Assert(instance != null);
|
||||||
|
|
||||||
return new ToolboxComponent(instance);
|
return new ToolboxComponentButton(instance);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -72,59 +76,60 @@ namespace osu.Game.Skinning.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ToolboxComponent : CompositeDrawable
|
private class ToolboxComponentButton : OsuButton
|
||||||
{
|
{
|
||||||
private readonly Drawable component;
|
private readonly Drawable component;
|
||||||
private readonly Box box;
|
|
||||||
|
|
||||||
public Action<Type> RequestPlacement;
|
public Action<Type> RequestPlacement;
|
||||||
|
|
||||||
public ToolboxComponent(Drawable component)
|
private Container innerContainer;
|
||||||
|
|
||||||
|
public ToolboxComponentButton(Drawable component)
|
||||||
{
|
{
|
||||||
this.component = component;
|
this.component = component;
|
||||||
Container innerContainer;
|
|
||||||
|
Enabled.Value = true;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
Height = 70;
|
||||||
|
}
|
||||||
|
|
||||||
InternalChild = new FillFlowContainer
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
BackgroundColour = colours.Gray3;
|
||||||
|
Content.EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
Type = EdgeEffectType.Shadow,
|
||||||
AutoSizeAxes = Axes.Y,
|
Radius = 2,
|
||||||
Children = new Drawable[]
|
Offset = new Vector2(0, 1),
|
||||||
{
|
Colour = Color4.Black.Opacity(0.5f)
|
||||||
new OsuSpriteText { Text = component.GetType().Name },
|
|
||||||
innerContainer = new Container
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
AutoSizeAxes = Axes.Y,
|
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 10,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
box = new Box
|
|
||||||
{
|
|
||||||
Colour = Color4.Black,
|
|
||||||
Alpha = 0.5f,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
},
|
|
||||||
component
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// adjust provided component to fit / display in a known state.
|
AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = component.GetType().Name,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
},
|
||||||
|
innerContainer = new Container
|
||||||
|
{
|
||||||
|
Y = 10,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Scale = new Vector2(component_display_scale),
|
||||||
|
Masking = true,
|
||||||
|
Child = component
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// adjust provided component to fit / display in a known state.
|
||||||
component.Anchor = Anchor.Centre;
|
component.Anchor = Anchor.Centre;
|
||||||
component.Origin = Anchor.Centre;
|
component.Origin = Anchor.Centre;
|
||||||
|
|
||||||
if (component.RelativeSizeAxes != Axes.None)
|
|
||||||
{
|
|
||||||
innerContainer.AutoSizeAxes = Axes.None;
|
|
||||||
innerContainer.Height = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (component)
|
switch (component)
|
||||||
{
|
{
|
||||||
case IScoreCounter score:
|
case IScoreCounter score:
|
||||||
@ -137,26 +142,22 @@ namespace osu.Game.Skinning.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
protected override void LoadComplete()
|
||||||
private OsuColour colours { get; set; }
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
if (component.RelativeSizeAxes != Axes.None)
|
||||||
|
{
|
||||||
|
innerContainer.AutoSizeAxes = Axes.None;
|
||||||
|
innerContainer.Height = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
RequestPlacement?.Invoke(component.GetType());
|
RequestPlacement?.Invoke(component.GetType());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
|
||||||
{
|
|
||||||
box.FadeColour(colours.Yellow, 100);
|
|
||||||
return base.OnHover(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
|
||||||
{
|
|
||||||
box.FadeColour(Color4.Black, 100);
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user