mirror of
https://github.com/ppy/osu
synced 2024-12-23 15:22:37 +00:00
Add icons for editor toolbox tools
This commit is contained in:
parent
b79e9791c3
commit
c9f5005efd
@ -1,6 +1,8 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles;
|
||||
@ -15,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Circles);
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => new HitCirclePlacementBlueprint();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders;
|
||||
@ -15,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders);
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => new SliderPlacementBlueprint();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Edit.Tools;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Spinners;
|
||||
@ -15,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Spinners);
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => new SpinnerPlacementBlueprint();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Screens.Edit.Components.RadioButtons;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
@ -22,7 +23,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
new RadioButton("Item 1", () => { }),
|
||||
new RadioButton("Item 2", () => { }),
|
||||
new RadioButton("Item 3", () => { }),
|
||||
new RadioButton("Item 3", () => { }, () => new SpriteIcon { Icon = FontAwesome.Regular.Angry }),
|
||||
new RadioButton("Item 4", () => { }),
|
||||
new RadioButton("Item 5", () => { })
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
toolboxCollection.Items = CompositionTools
|
||||
.Prepend(new SelectTool())
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t)))
|
||||
.Select(t => new RadioButton(t.Name, () => toolSelected(t), t.CreateIcon))
|
||||
.ToList();
|
||||
|
||||
setSelectTool();
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
public abstract class HitObjectCompositionTool
|
||||
@ -14,6 +16,8 @@ namespace osu.Game.Rulesets.Edit.Tools
|
||||
|
||||
public abstract PlacementBlueprint CreatePlacementBlueprint();
|
||||
|
||||
public virtual Drawable CreateIcon() => null;
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
// 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.Sprites;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
public class SelectTool : HitObjectCompositionTool
|
||||
@ -10,6 +13,8 @@ namespace osu.Game.Rulesets.Edit.Tools
|
||||
{
|
||||
}
|
||||
|
||||
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.Solid.MousePointer };
|
||||
|
||||
public override PlacementBlueprint CreatePlacementBlueprint() => null;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -29,7 +28,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
private Color4 selectedBackgroundColour;
|
||||
private Color4 selectedBubbleColour;
|
||||
|
||||
private readonly Drawable bubble;
|
||||
private Drawable icon;
|
||||
private readonly RadioButton button;
|
||||
|
||||
public DrawableRadioButton(RadioButton button)
|
||||
@ -40,19 +39,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
Action = button.Select;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
bubble = new CircularContainer
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
Scale = new Vector2(0.5f),
|
||||
X = 10,
|
||||
Masking = true,
|
||||
Blending = BlendingParameters.Additive,
|
||||
Child = new Box { RelativeSizeAxes = Axes.Both }
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -73,7 +59,14 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
Colour = Color4.Black.Opacity(0.5f)
|
||||
};
|
||||
|
||||
Add(bubble);
|
||||
Add(icon = (button.CreateIcon?.Invoke() ?? new Circle()).With(b =>
|
||||
{
|
||||
b.Blending = BlendingParameters.Additive;
|
||||
b.Anchor = Anchor.CentreLeft;
|
||||
b.Origin = Anchor.CentreLeft;
|
||||
b.Size = new Vector2(20);
|
||||
b.X = 10;
|
||||
}));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -96,7 +89,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
return;
|
||||
|
||||
BackgroundColour = button.Selected.Value ? selectedBackgroundColour : defaultBackgroundColour;
|
||||
bubble.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
|
||||
icon.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
|
||||
}
|
||||
|
||||
protected override SpriteText CreateText() => new OsuSpriteText
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
{
|
||||
@ -19,11 +20,17 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
||||
/// </summary>
|
||||
public object Item;
|
||||
|
||||
/// <summary>
|
||||
/// A function which creates a drawable icon to represent this item. If null, a sane default should be used.
|
||||
/// </summary>
|
||||
public readonly Func<Drawable> CreateIcon;
|
||||
|
||||
private readonly Action action;
|
||||
|
||||
public RadioButton(object item, Action action)
|
||||
public RadioButton(object item, Action action, Func<Drawable> createIcon = null)
|
||||
{
|
||||
Item = item;
|
||||
CreateIcon = createIcon;
|
||||
this.action = action;
|
||||
Selected = new BindableBool();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user