1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 03:02:54 +08:00

Add slider placement binding description in tooltip

This commit is contained in:
Bartłomiej Dach 2024-06-18 08:16:22 +02:00
parent 683d5310b1
commit 310265c43f
No known key found for this signature in database
5 changed files with 37 additions and 7 deletions

View File

@ -15,6 +15,13 @@ namespace osu.Game.Rulesets.Osu.Edit
public SliderCompositionTool()
: base(nameof(Slider))
{
TooltipText = """
Left click for new point.
Left click twice or S key for new segment.
Tab, Shift-Tab, or Alt-1~4 to change current segment type.
Right click to finish.
Click and drag for drawing mode.
""";
}
public override Drawable CreateIcon() => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Sliders);

View File

@ -215,14 +215,14 @@ namespace osu.Game.Rulesets.Edit
toolboxCollection.Items = CompositionTools
.Prepend(new SelectTool())
.Select(t => new RadioButton(t.Name, () => toolSelected(t), t.CreateIcon))
.Select(t => new HitObjectCompositionToolButton(t, () => toolSelected(t)))
.ToList();
foreach (var item in toolboxCollection.Items)
{
item.Selected.DisabledChanged += isDisabled =>
{
item.TooltipText = isDisabled ? "Add at least one timing point first!" : string.Empty;
item.TooltipText = isDisabled ? "Add at least one timing point first!" : ((HitObjectCompositionToolButton)item).TooltipText;
};
}

View File

@ -0,0 +1,22 @@
// 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 System;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Screens.Edit.Components.RadioButtons;
namespace osu.Game.Rulesets.Edit
{
public class HitObjectCompositionToolButton : RadioButton
{
public HitObjectCompositionTool Tool { get; }
public HitObjectCompositionToolButton(HitObjectCompositionTool tool, Action? action)
: base(tool.Name, action, tool.CreateIcon)
{
Tool = tool;
TooltipText = tool.TooltipText;
}
}
}

View File

@ -1,9 +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.
#nullable disable
using osu.Framework.Graphics;
using osu.Framework.Localisation;
namespace osu.Game.Rulesets.Edit.Tools
{
@ -11,6 +10,8 @@ namespace osu.Game.Rulesets.Edit.Tools
{
public readonly string Name;
public LocalisableString TooltipText { get; init; } = default;
protected HitObjectCompositionTool(string name)
{
Name = name;
@ -18,7 +19,7 @@ namespace osu.Game.Rulesets.Edit.Tools
public abstract PlacementBlueprint CreatePlacementBlueprint();
public virtual Drawable CreateIcon() => null;
public virtual Drawable? CreateIcon() => null;
public override string ToString() => Name;
}

View File

@ -24,11 +24,11 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// <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;
public readonly Func<Drawable?>? CreateIcon;
private readonly Action? action;
public RadioButton(string label, Action? action, Func<Drawable>? createIcon = null)
public RadioButton(string label, Action? action, Func<Drawable?>? createIcon = null)
{
Label = label;
CreateIcon = createIcon;