1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 05:37:24 +08:00

fix addition on node sample not working

This commit is contained in:
OliBomby 2024-07-14 22:50:15 +02:00
parent df7a42a00e
commit 9f02a1f1bf

View File

@ -176,8 +176,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
break; break;
} }
// If none of the selected objects have any addition samples, we should not apply the bank. // If none of the selected objects have any addition samples, we should not apply the addition bank.
if (SelectedItems.All(h => h.Samples.All(o => o.Name == HitSampleInfo.HIT_NORMAL))) if (SelectedItems.SelectMany(enumerateAllSamples).All(h => h.All(o => o.Name == HitSampleInfo.HIT_NORMAL)))
{ {
bindable.Value = TernaryState.False; bindable.Value = TernaryState.False;
break; break;
@ -260,16 +260,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
bindable.Value = GetStateFromSelection(samplesInSelection.SelectMany(s => s).Where(o => o.Name != HitSampleInfo.HIT_NORMAL), h => h.Bank == bankName); bindable.Value = GetStateFromSelection(samplesInSelection.SelectMany(s => s).Where(o => o.Name != HitSampleInfo.HIT_NORMAL), h => h.Bank == bankName);
} }
}
IEnumerable<IList<HitSampleInfo>> enumerateAllSamples(HitObject hitObject) private IEnumerable<IList<HitSampleInfo>> enumerateAllSamples(HitObject hitObject)
{
yield return hitObject.Samples;
if (hitObject is IHasRepeats withRepeats)
{ {
yield return hitObject.Samples; foreach (var node in withRepeats.NodeSamples)
yield return node;
if (hitObject is IHasRepeats withRepeats)
{
foreach (var node in withRepeats.NodeSamples)
yield return node;
}
} }
} }
@ -340,7 +340,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
EditorBeatmap.PerformOnSelection(h => EditorBeatmap.PerformOnSelection(h =>
{ {
if (h.Samples.Where(o => o.Name != HitSampleInfo.HIT_NORMAL).All(s => s.Bank == bankName)) if (enumerateAllSamples(h).SelectMany(o => o).Where(o => o.Name != HitSampleInfo.HIT_NORMAL).All(s => s.Bank == bankName))
return; return;
h.Samples = h.Samples.Select(s => s.Name != HitSampleInfo.HIT_NORMAL ? s.With(newBank: bankName) : s).ToList(); h.Samples = h.Samples.Select(s => s.Name != HitSampleInfo.HIT_NORMAL ? s.With(newBank: bankName) : s).ToList();