1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 07:43:00 +08:00

Add beat snap grid to osu!taiko editor

Addresses https://github.com/ppy/osu/discussions/25150.
This commit is contained in:
Dean Herbert 2023-10-17 16:54:59 +09:00
parent 1b9acdf55c
commit 2a89a25790
No known key found for this signature in database
4 changed files with 85 additions and 4 deletions

View File

@ -0,0 +1,19 @@
// 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.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Screens.Edit.Compose.Components;
namespace osu.Game.Rulesets.Taiko.Edit
{
public partial class TaikoBeatSnapGrid : BeatSnapGrid
{
protected override IEnumerable<Container> GetTargetContainers(HitObjectComposer composer) => new[]
{
((TaikoPlayfield)composer.Playfield).UnderlayElements
};
}
}

View File

@ -2,10 +2,14 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Compose.Components; using osu.Game.Screens.Edit.Compose.Components;
@ -16,6 +20,9 @@ namespace osu.Game.Rulesets.Taiko.Edit
{ {
protected override bool ApplyHorizontalCentering => false; protected override bool ApplyHorizontalCentering => false;
private TaikoBeatSnapGrid beatSnapGrid = null!;
private InputManager inputManager = null!;
public TaikoHitObjectComposer(TaikoRuleset ruleset) public TaikoHitObjectComposer(TaikoRuleset ruleset)
: base(ruleset) : base(ruleset)
{ {
@ -33,5 +40,41 @@ namespace osu.Game.Rulesets.Taiko.Edit
protected override ComposeBlueprintContainer CreateBlueprintContainer() protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new TaikoBlueprintContainer(this); => new TaikoBlueprintContainer(this);
[BackgroundDependencyLoader]
private void load()
{
AddInternal(beatSnapGrid = new TaikoBeatSnapGrid());
}
protected override void LoadComplete()
{
base.LoadComplete();
inputManager = GetContainingInputManager();
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
if (BlueprintContainer.CurrentTool is SelectTool)
{
if (EditorBeatmap.SelectedHitObjects.Any())
{
beatSnapGrid.SelectionTimeRange = (EditorBeatmap.SelectedHitObjects.Min(h => h.StartTime), EditorBeatmap.SelectedHitObjects.Max(h => h.GetEndTime()));
}
else
beatSnapGrid.SelectionTimeRange = null;
}
else
{
var result = FindSnappedPositionAndTime(inputManager.CurrentState.Mouse.Position);
if (result.Time is double time)
beatSnapGrid.SelectionTimeRange = (time, time);
else
beatSnapGrid.SelectionTimeRange = null;
}
}
} }
} }

View File

@ -40,6 +40,8 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </summary> /// </summary>
public Bindable<bool> ClassicHitTargetPosition = new BindableBool(); public Bindable<bool> ClassicHitTargetPosition = new BindableBool();
public Container UnderlayElements { get; private set; } = null!;
private Container<HitExplosion> hitExplosionContainer; private Container<HitExplosion> hitExplosionContainer;
private Container<KiaiHitExplosion> kiaiExplosionContainer; private Container<KiaiHitExplosion> kiaiExplosionContainer;
private JudgementContainer<DrawableTaikoJudgement> judgementContainer; private JudgementContainer<DrawableTaikoJudgement> judgementContainer;
@ -130,7 +132,14 @@ namespace osu.Game.Rulesets.Taiko.UI
{ {
Name = "Bar line content", Name = "Bar line content",
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = barLinePlayfield = new BarLinePlayfield(), Children = new Drawable[]
{
UnderlayElements = new Container
{
RelativeSizeAxes = Axes.Both,
},
barLinePlayfield = new BarLinePlayfield(),
}
}, },
hitObjectContent = new Container hitObjectContent = new Container
{ {

View File

@ -173,9 +173,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
public DrawableGridLine() public DrawableGridLine()
: base(new HitObject()) : base(new HitObject())
{ {
RelativeSizeAxes = Axes.X;
Height = 2;
AddInternal(new Box { RelativeSizeAxes = Axes.Both }); AddInternal(new Box { RelativeSizeAxes = Axes.Both });
} }
@ -191,6 +188,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
Origin = Anchor = direction.NewValue == ScrollingDirection.Up Origin = Anchor = direction.NewValue == ScrollingDirection.Up
? Anchor.TopLeft ? Anchor.TopLeft
: Anchor.BottomLeft; : Anchor.BottomLeft;
bool isHorizontal = direction.NewValue == ScrollingDirection.Left || direction.NewValue == ScrollingDirection.Right;
if (isHorizontal)
{
RelativeSizeAxes = Axes.Y;
Width = 2;
}
else
{
RelativeSizeAxes = Axes.X;
Height = 2;
}
} }
protected override void UpdateInitialTransforms() protected override void UpdateInitialTransforms()