mirror of https://github.com/ppy/osu
Move first tick tracking logic inside `TickPiece`
This commit is contained in:
parent
cb6b9898c1
commit
1975385cc7
|
@ -5,6 +5,7 @@
|
|||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
@ -16,6 +17,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||
{
|
||||
public class DrawableDrumRollTick : DrawableTaikoStrongableHitObject<DrumRollTick, DrumRollTick.StrongNestedHit>
|
||||
{
|
||||
public BindableBool IsFirstTick = new BindableBool();
|
||||
|
||||
/// <summary>
|
||||
/// The hit type corresponding to the <see cref="TaikoAction"/> that the user pressed to hit this <see cref="DrawableDrumRollTick"/>.
|
||||
/// </summary>
|
||||
|
@ -32,14 +35,17 @@ public DrawableDrumRollTick([CanBeNull] DrumRollTick tick)
|
|||
FillMode = FillMode.Fit;
|
||||
}
|
||||
|
||||
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick),
|
||||
_ => new TickPiece
|
||||
{
|
||||
Filled = HitObject.FirstTick
|
||||
});
|
||||
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.DrumRollTick), _ => new TickPiece());
|
||||
|
||||
public override double MaximumJudgementOffset => HitObject.HitWindow;
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
base.OnApply();
|
||||
|
||||
IsFirstTick.Value = HitObject.FirstTick;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!userTriggered)
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
|
@ -22,20 +26,10 @@ public class TickPiece : CompositeDrawable
|
|||
/// </summary>
|
||||
private const float tick_size = 0.35f;
|
||||
|
||||
private bool filled;
|
||||
|
||||
public bool Filled
|
||||
{
|
||||
get => filled;
|
||||
set
|
||||
{
|
||||
filled = value;
|
||||
fillBox.Alpha = filled ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Box fillBox;
|
||||
|
||||
private Bindable<bool> isFirstTick = null!;
|
||||
|
||||
public TickPiece()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
|
@ -62,5 +56,19 @@ public TickPiece()
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private DrawableHitObject drawableHitObject { get; set; } = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (drawableHitObject is DrawableDrumRollTick drumRollTick)
|
||||
{
|
||||
isFirstTick = drumRollTick.IsFirstTick.GetBoundCopy();
|
||||
isFirstTick.BindValueChanged(first => fillBox.Alpha = first.NewValue ? 1 : 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue