1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 03:25:11 +08:00

Fix taiko sample selection not updating when changing strong/rim type

This commit is contained in:
Dean Herbert 2020-09-23 17:57:57 +09:00
parent 7efaa37447
commit 8f3eb9a422
2 changed files with 53 additions and 7 deletions

View File

@ -42,6 +42,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
: base(hit)
{
FillMode = FillMode.Fit;
updateActionsFromType();
}
[BackgroundDependencyLoader]
@ -50,21 +52,39 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
type = HitObject.TypeBindable.GetBoundCopy();
type.BindValueChanged(_ =>
{
updateType();
updateActionsFromType();
// will overwrite samples, should only be called on change.
updateSamplesFromTypeChange();
RecreatePieces();
});
updateType();
}
private void updateType()
private void updateSamplesFromTypeChange()
{
var rimSamples = HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_CLAP || s.Name == HitSampleInfo.HIT_WHISTLE).ToArray();
bool isRimType = HitObject.Type == HitType.Rim;
if (isRimType != rimSamples.Any())
{
if (isRimType)
HitObject.Samples.Add(new HitSampleInfo { Name = HitSampleInfo.HIT_CLAP });
else
{
foreach (var sample in rimSamples)
HitObject.Samples.Remove(sample);
}
}
}
private void updateActionsFromType()
{
HitActions =
HitObject.Type == HitType.Centre
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
RecreatePieces();
}
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre

View File

@ -141,7 +141,31 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private void load()
{
isStrong = HitObject.IsStrongBindable.GetBoundCopy();
isStrong.BindValueChanged(_ => RecreatePieces(), true);
isStrong.BindValueChanged(_ =>
{
// will overwrite samples, should only be called on change.
updateSamplesFromStrong();
RecreatePieces();
});
RecreatePieces();
}
private void updateSamplesFromStrong()
{
var strongSamples = HitObject.Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToArray();
if (isStrong.Value != strongSamples.Any())
{
if (isStrong.Value)
HitObject.Samples.Add(new HitSampleInfo { Name = HitSampleInfo.HIT_FINISH });
else
{
foreach (var sample in strongSamples)
HitObject.Samples.Remove(sample);
}
}
}
protected virtual void RecreatePieces()
@ -150,6 +174,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
MainPiece?.Expire();
Content.Add(MainPiece = CreateMainPiece());
LoadSamples();
}
protected override void AddNestedHitObject(DrawableHitObject hitObject)