mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Make mania use the new nested hitobject structure
This commit is contained in:
parent
1a0dfcdd46
commit
8a284bacba
@ -2,13 +2,12 @@
|
|||||||
// 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.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
using osu.Game.Rulesets.Mania.Objects.Drawables.Pieces;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
@ -22,8 +21,12 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
{
|
{
|
||||||
public override bool DisplayResult => false;
|
public override bool DisplayResult => false;
|
||||||
|
|
||||||
public readonly DrawableNote Head;
|
private readonly Container<DrawableHeadNote> headContainer;
|
||||||
public readonly DrawableNote Tail;
|
private readonly Container<DrawableTailNote> tailContainer;
|
||||||
|
private readonly Container<DrawableHoldNoteTick> tickContainer;
|
||||||
|
|
||||||
|
public DrawableNote Head { get; private set; }
|
||||||
|
public DrawableNote Tail { get; private set; }
|
||||||
|
|
||||||
private readonly BodyPiece bodyPiece;
|
private readonly BodyPiece bodyPiece;
|
||||||
|
|
||||||
@ -40,50 +43,81 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
|||||||
public DrawableHoldNote(HoldNote hitObject)
|
public DrawableHoldNote(HoldNote hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
Container<DrawableHoldNoteTick> tickContainer;
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
AddRangeInternal(new Drawable[]
|
AddRangeInternal(new Drawable[]
|
||||||
{
|
{
|
||||||
bodyPiece = new BodyPiece
|
bodyPiece = new BodyPiece { RelativeSizeAxes = Axes.X },
|
||||||
{
|
tickContainer = new Container<DrawableHoldNoteTick> { RelativeSizeAxes = Axes.Both },
|
||||||
RelativeSizeAxes = Axes.X,
|
headContainer = new Container<DrawableHeadNote> { RelativeSizeAxes = Axes.Both },
|
||||||
},
|
tailContainer = new Container<DrawableTailNote> { RelativeSizeAxes = Axes.Both },
|
||||||
tickContainer = new Container<DrawableHoldNoteTick>
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
ChildrenEnumerable = HitObject.NestedHitObjects.OfType<HoldNoteTick>().Select(tick => new DrawableHoldNoteTick(tick)
|
|
||||||
{
|
|
||||||
HoldStartTime = () => holdStartTime
|
|
||||||
})
|
|
||||||
},
|
|
||||||
Head = new DrawableHeadNote(this)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre
|
|
||||||
},
|
|
||||||
Tail = new DrawableTailNote(this)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.TopCentre
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var tick in tickContainer)
|
|
||||||
AddNested(tick);
|
|
||||||
|
|
||||||
AddNested(Head);
|
|
||||||
AddNested(Tail);
|
|
||||||
|
|
||||||
AccentColour.BindValueChanged(colour =>
|
AccentColour.BindValueChanged(colour =>
|
||||||
{
|
{
|
||||||
bodyPiece.AccentColour = colour.NewValue;
|
bodyPiece.AccentColour = colour.NewValue;
|
||||||
Head.AccentColour.Value = colour.NewValue;
|
|
||||||
Tail.AccentColour.Value = colour.NewValue;
|
|
||||||
tickContainer.ForEach(t => t.AccentColour.Value = colour.NewValue);
|
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void AddNested(DrawableHitObject h)
|
||||||
|
{
|
||||||
|
base.AddNested(h);
|
||||||
|
|
||||||
|
switch (h)
|
||||||
|
{
|
||||||
|
case DrawableHeadNote head:
|
||||||
|
headContainer.Child = head;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableTailNote tail:
|
||||||
|
tailContainer.Child = tail;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DrawableHoldNoteTick tick:
|
||||||
|
tickContainer.Add(tick);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ClearNested()
|
||||||
|
{
|
||||||
|
base.ClearNested();
|
||||||
|
headContainer.Clear();
|
||||||
|
tailContainer.Clear();
|
||||||
|
tickContainer.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override DrawableHitObject CreateNested(HitObject hitObject)
|
||||||
|
{
|
||||||
|
switch (hitObject)
|
||||||
|
{
|
||||||
|
case TailNote _:
|
||||||
|
return Tail = new DrawableTailNote(this)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
|
||||||
|
case Note _:
|
||||||
|
return Head = new DrawableHeadNote(this)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
|
||||||
|
case HoldNoteTick tick:
|
||||||
|
return new DrawableHoldNoteTick(tick)
|
||||||
|
{
|
||||||
|
HoldStartTime = () => holdStartTime,
|
||||||
|
AccentColour = { BindTarget = AccentColour }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.CreateNested(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
protected override void OnDirectionChanged(ValueChangedEvent<ScrollingDirection> e)
|
||||||
{
|
{
|
||||||
base.OnDirectionChanged(e);
|
base.OnDirectionChanged(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user