mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Centralise cases of performing actions on the current selection
By moving this to a central location, we can avoid invoking the EditorChangeHandler when there is no selection made. This helps alleviate the issue pointed out in https://github.com/ppy/osu/issues/11901, but not fix it completely.
This commit is contained in:
@ -495,8 +495,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
// Apply the start time at the newly snapped-to position
|
||||
double offset = result.Time.Value - movementBlueprints.First().HitObject.StartTime;
|
||||
|
||||
foreach (HitObject obj in Beatmap.SelectedHitObjects)
|
||||
obj.StartTime += offset;
|
||||
Beatmap.PerformOnSelection(obj => obj.StartTime += offset);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -320,18 +320,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <param name="sampleName">The name of the hit sample.</param>
|
||||
public void AddHitSample(string sampleName)
|
||||
{
|
||||
EditorBeatmap.BeginChange();
|
||||
|
||||
foreach (var h in EditorBeatmap.SelectedHitObjects)
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
// Make sure there isn't already an existing sample
|
||||
if (h.Samples.Any(s => s.Name == sampleName))
|
||||
continue;
|
||||
return;
|
||||
|
||||
h.Samples.Add(new HitSampleInfo(sampleName));
|
||||
}
|
||||
|
||||
EditorBeatmap.EndChange();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -341,19 +337,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <exception cref="InvalidOperationException">Throws if any selected object doesn't implement <see cref="IHasComboInformation"/></exception>
|
||||
public void SetNewCombo(bool state)
|
||||
{
|
||||
EditorBeatmap.BeginChange();
|
||||
|
||||
foreach (var h in EditorBeatmap.SelectedHitObjects)
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
var comboInfo = h as IHasComboInformation;
|
||||
|
||||
if (comboInfo == null || comboInfo.NewCombo == state) continue;
|
||||
if (comboInfo == null || comboInfo.NewCombo == state) return;
|
||||
|
||||
comboInfo.NewCombo = state;
|
||||
EditorBeatmap.Update(h);
|
||||
}
|
||||
|
||||
EditorBeatmap.EndChange();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -362,12 +354,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <param name="sampleName">The name of the hit sample.</param>
|
||||
public void RemoveHitSample(string sampleName)
|
||||
{
|
||||
EditorBeatmap.BeginChange();
|
||||
|
||||
foreach (var h in EditorBeatmap.SelectedHitObjects)
|
||||
h.SamplesBindable.RemoveAll(s => s.Name == sampleName);
|
||||
|
||||
EditorBeatmap.EndChange();
|
||||
EditorBeatmap.PerformOnSelection(h => h.SamplesBindable.RemoveAll(s => s.Name == sampleName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user