Skip to content

Commit

Permalink
Merge pull request ppy#28746 from bdach/fix-ternary-state-breakage
Browse files Browse the repository at this point in the history
Fix incorrect ternary state computation for bank toggles
  • Loading branch information
smoogipoo authored Jul 5, 2024
2 parents f8a2b07 + 4c59ec1 commit 0bb6c25
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,25 @@ public void TestHotkeysAffectNodeSamples()
hitObjectNodeHasSamples(2, 1, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_WHISTLE);
}

[Test]
public void TestSelectingObjectDoesNotMutateSamples()
{
clickSamplePiece(0);
toggleAdditionViaPopover(1);
setAdditionBankViaPopover(HitSampleInfo.BANK_SOFT);
dismissPopover();

hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH);
hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL);
hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT);

AddStep("select first object", () => EditorBeatmap.SelectedHitObjects.Add(EditorBeatmap.HitObjects[0]));

hitObjectHasSamples(0, HitSampleInfo.HIT_NORMAL, HitSampleInfo.HIT_FINISH);
hitObjectHasSampleNormalBank(0, HitSampleInfo.BANK_NORMAL);
hitObjectHasSampleAdditionBank(0, HitSampleInfo.BANK_SOFT);
}

private void clickSamplePiece(int objectIndex) => AddStep($"click {objectIndex.ToOrdinalWords()} sample piece", () =>
{
var samplePiece = this.ChildrenOfType<SamplePointPiece>().Single(piece => piece.HitObject == EditorBeatmap.HitObjects.ElementAt(objectIndex));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected virtual void UpdateTernaryStates()

foreach ((string bankName, var bindable) in SelectionBankStates)
{
bindable.Value = GetStateFromSelection(samplesInSelection, h => h.Any(s => s.Bank == bankName));
bindable.Value = GetStateFromSelection(samplesInSelection.SelectMany(s => s), h => h.Bank == bankName);
}

IEnumerable<IList<HitSampleInfo>> enumerateAllSamples(HitObject hitObject)
Expand Down

0 comments on commit 0bb6c25

Please sign in to comment.