1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

Update to support non-control-point sample changes

This commit is contained in:
Dean Herbert 2023-05-24 14:20:38 +09:00
parent e68ba6366c
commit a9ba16a2be
2 changed files with 6 additions and 21 deletions

View File

@ -199,12 +199,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void bankChanged(string bankName, TernaryState state)
{
if (currentPlacement == null) return;
if (CurrentPlacement == null) return;
switch (state)
{
case TernaryState.True:
currentPlacement.HitObject.SampleControlPoint.SampleBank = bankName;
CurrentPlacement.HitObject.Samples = CurrentPlacement.HitObject.Samples.Select(s => s.With(newBank: bankName)).ToList();
break;
}
}

View File

@ -81,7 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
// Never remove a sample bank.
// These are basically radio buttons, not toggles.
if (SelectedItems.All(h => h.SampleControlPoint.SampleBank == bankName))
if (SelectedItems.All(h => h.Samples.All(s => s.Bank == bankName)))
bindable.Value = TernaryState.True;
}
@ -167,7 +167,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
foreach ((string bankName, var bindable) in SelectionBankStates)
{
bindable.Value = GetStateFromSelection(SelectedItems, h => h.SampleControlPoint.SampleBank == bankName);
bindable.Value = GetStateFromSelection(SelectedItems, h => h.Samples.All(s => s.Bank == bankName));
}
}
@ -183,25 +183,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
EditorBeatmap.PerformOnSelection(h =>
{
if (h.SampleControlPoint.SampleBank == bankName)
if (h.Samples.All(s => s.Bank == bankName))
return;
h.SampleControlPoint.SampleBank = bankName;
EditorBeatmap.Update(h);
});
}
/// <summary>
/// Removes a sample bank from all selected <see cref="HitObject"/>s.
/// </summary>
/// <param name="bankName">The name of the sample bank.</param>
public void RemoveSampleBank(string bankName)
{
EditorBeatmap.PerformOnSelection(h =>
{
if (h.SampleControlPoint.SampleBank == bankName)
h.SampleControlPoint.SampleBankBindable.SetDefault();
h.Samples = h.Samples.Select(s => s.With(newBank: bankName)).ToList();
EditorBeatmap.Update(h);
});
}