mirror of
https://github.com/ppy/osu
synced 2025-03-19 01:24:34 +00:00
Merge pull request #7647 from peppy/select-tool
Move select tool to an actual tool implementation
This commit is contained in:
commit
e0c3fa0cc1
@ -137,12 +137,12 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
toolboxCollection.Items =
|
toolboxCollection.Items = CompositionTools
|
||||||
CompositionTools.Select(t => new RadioButton(t.Name, () => selectTool(t)))
|
.Prepend(new SelectTool())
|
||||||
.Prepend(new RadioButton("Select", () => selectTool(null)))
|
.Select(t => new RadioButton(t.Name, () => toolSelected(t)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
toolboxCollection.Items[0].Select();
|
toolboxCollection.Items.First().Select();
|
||||||
|
|
||||||
blueprintContainer.SelectionChanged += selectionChanged;
|
blueprintContainer.SelectionChanged += selectionChanged;
|
||||||
}
|
}
|
||||||
@ -187,11 +187,11 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
showGridFor(hitObjects);
|
showGridFor(hitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectTool(HitObjectCompositionTool tool)
|
private void toolSelected(HitObjectCompositionTool tool)
|
||||||
{
|
{
|
||||||
blueprintContainer.CurrentTool = tool;
|
blueprintContainer.CurrentTool = tool;
|
||||||
|
|
||||||
if (tool == null)
|
if (tool is SelectTool)
|
||||||
distanceSnapGridContainer.Hide();
|
distanceSnapGridContainer.Hide();
|
||||||
else
|
else
|
||||||
showGridFor(Enumerable.Empty<HitObject>());
|
showGridFor(Enumerable.Empty<HitObject>());
|
||||||
|
@ -13,5 +13,7 @@ namespace osu.Game.Rulesets.Edit.Tools
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract PlacementBlueprint CreatePlacementBlueprint();
|
public abstract PlacementBlueprint CreatePlacementBlueprint();
|
||||||
|
|
||||||
|
public override string ToString() => Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
osu.Game/Rulesets/Edit/Tools/SelectTool.cs
Normal file
15
osu.Game/Rulesets/Edit/Tools/SelectTool.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Edit.Tools
|
||||||
|
{
|
||||||
|
public class SelectTool : HitObjectCompositionTool
|
||||||
|
{
|
||||||
|
public SelectTool()
|
||||||
|
: base("Select")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override PlacementBlueprint CreatePlacementBlueprint() => null;
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,6 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
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.Graphics.UserInterface;
|
||||||
@ -37,8 +36,8 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
|||||||
{
|
{
|
||||||
this.button = button;
|
this.button = button;
|
||||||
|
|
||||||
Text = button.Text;
|
Text = button.Item.ToString();
|
||||||
Action = button.Action;
|
Action = button.Select;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
@ -100,19 +99,6 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
|||||||
bubble.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
|
bubble.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
if (button.Selected.Value)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (!Enabled.Value)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
button.Selected.Value = true;
|
|
||||||
|
|
||||||
return base.OnClick(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override SpriteText CreateText() => new OsuSpriteText
|
protected override SpriteText CreateText() => new OsuSpriteText
|
||||||
{
|
{
|
||||||
Depth = -1,
|
Depth = -1,
|
||||||
|
@ -15,33 +15,37 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
|
|||||||
public readonly BindableBool Selected;
|
public readonly BindableBool Selected;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The text that should be displayed in this button.
|
/// The item related to this button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Text;
|
public object Item;
|
||||||
|
|
||||||
/// <summary>
|
private readonly Action action;
|
||||||
/// The <see cref="Action"/> that should be invoked when this button is selected.
|
|
||||||
/// </summary>
|
|
||||||
public Action Action;
|
|
||||||
|
|
||||||
public RadioButton(string text, Action action)
|
public RadioButton(object item, Action action)
|
||||||
{
|
{
|
||||||
Text = text;
|
Item = item;
|
||||||
Action = action;
|
this.action = action;
|
||||||
Selected = new BindableBool();
|
Selected = new BindableBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RadioButton(string text)
|
public RadioButton(string item)
|
||||||
: this(text, null)
|
: this(item, null)
|
||||||
{
|
{
|
||||||
Text = text;
|
Item = item;
|
||||||
Action = null;
|
action = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Selects this <see cref="RadioButton"/>.
|
/// Selects this <see cref="RadioButton"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Select() => Selected.Value = true;
|
public void Select()
|
||||||
|
{
|
||||||
|
if (!Selected.Value)
|
||||||
|
{
|
||||||
|
Selected.Value = true;
|
||||||
|
action?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deselects this <see cref="RadioButton"/>.
|
/// Deselects this <see cref="RadioButton"/>.
|
||||||
|
Loading…
Reference in New Issue
Block a user