mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:52:54 +08:00
Support HitType bindable changes
This commit is contained in:
parent
3487c1fd1b
commit
4e9631b546
@ -5,6 +5,8 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
@ -19,7 +21,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of keys which can result in hits for this HitObject.
|
/// A list of keys which can result in hits for this HitObject.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public TaikoAction[] HitActions { get; }
|
public TaikoAction[] HitActions { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The action that caused this <see cref="DrawableHit"/> to be hit.
|
/// The action that caused this <see cref="DrawableHit"/> to be hit.
|
||||||
@ -34,15 +36,35 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
|
|
||||||
private bool pressHandledThisFrame;
|
private bool pressHandledThisFrame;
|
||||||
|
|
||||||
|
private Bindable<HitType> type;
|
||||||
|
|
||||||
public DrawableHit(Hit hit)
|
public DrawableHit(Hit hit)
|
||||||
: base(hit)
|
: base(hit)
|
||||||
{
|
{
|
||||||
FillMode = FillMode.Fit;
|
FillMode = FillMode.Fit;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
type = HitObject.TypeBindable.GetBoundCopy();
|
||||||
|
type.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
updateType();
|
||||||
|
RecreatePieces();
|
||||||
|
});
|
||||||
|
|
||||||
|
updateType();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateType()
|
||||||
|
{
|
||||||
HitActions =
|
HitActions =
|
||||||
HitObject.Type == HitType.Centre
|
HitObject.Type == HitType.Centre
|
||||||
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
||||||
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
|
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
|
||||||
|
|
||||||
|
RecreatePieces();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
|
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
|
||||||
|
@ -8,6 +8,7 @@ using osuTK;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -115,10 +116,10 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
|
|
||||||
public new TObject HitObject;
|
public new TObject HitObject;
|
||||||
|
|
||||||
protected readonly Vector2 BaseSize;
|
protected Vector2 BaseSize;
|
||||||
protected readonly SkinnableDrawable MainPiece;
|
protected SkinnableDrawable MainPiece;
|
||||||
|
|
||||||
private readonly Container<DrawableStrongNestedHit> strongHitContainer;
|
private Container<DrawableStrongNestedHit> strongHitContainer;
|
||||||
|
|
||||||
protected DrawableTaikoHitObject(TObject hitObject)
|
protected DrawableTaikoHitObject(TObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
@ -129,11 +130,21 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
|||||||
Origin = Anchor.Custom;
|
Origin = Anchor.Custom;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
AddInternal(strongHitContainer = new Container<DrawableStrongNestedHit>());
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
RecreatePieces();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void RecreatePieces()
|
||||||
|
{
|
||||||
Size = BaseSize = new Vector2(HitObject.IsStrong ? TaikoHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE);
|
Size = BaseSize = new Vector2(HitObject.IsStrong ? TaikoHitObject.DEFAULT_STRONG_SIZE : TaikoHitObject.DEFAULT_SIZE);
|
||||||
|
|
||||||
|
Content.Clear();
|
||||||
Content.Add(MainPiece = CreateMainPiece());
|
Content.Add(MainPiece = CreateMainPiece());
|
||||||
|
|
||||||
AddInternal(strongHitContainer = new Container<DrawableStrongNestedHit>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
protected override void AddNestedHitObject(DrawableHitObject hitObject)
|
||||||
|
Loading…
Reference in New Issue
Block a user