mirror of
https://github.com/ppy/osu.git
synced 2024-11-13 15:27:30 +08:00
Merge pull request #28387 from bdach/taiko-selection-handler-is-slow
Fix performance overhead from ternary state bindable callbacks when selection is changing
This commit is contained in:
commit
9f6ff48833
@ -53,6 +53,9 @@ namespace osu.Game.Rulesets.Taiko.Edit
|
||||
|
||||
public void SetStrongState(bool state)
|
||||
{
|
||||
if (SelectedItems.OfType<Hit>().All(h => h.IsStrong == state))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
if (!(h is Hit taikoHit)) return;
|
||||
@ -67,6 +70,9 @@ namespace osu.Game.Rulesets.Taiko.Edit
|
||||
|
||||
public void SetRimState(bool state)
|
||||
{
|
||||
if (SelectedItems.OfType<Hit>().All(h => h.Type == (state ? HitType.Rim : HitType.Centre)))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
if (h is Hit taikoHit)
|
||||
|
@ -198,6 +198,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <param name="bankName">The name of the sample bank.</param>
|
||||
public void AddSampleBank(string bankName)
|
||||
{
|
||||
if (SelectedItems.All(h => h.Samples.All(s => s.Bank == bankName)))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
if (h.Samples.All(s => s.Bank == bankName))
|
||||
@ -214,6 +217,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <param name="sampleName">The name of the hit sample.</param>
|
||||
public void AddHitSample(string sampleName)
|
||||
{
|
||||
if (SelectedItems.All(h => h.Samples.Any(s => s.Name == sampleName)))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
// Make sure there isn't already an existing sample
|
||||
@ -231,6 +237,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <param name="sampleName">The name of the hit sample.</param>
|
||||
public void RemoveHitSample(string sampleName)
|
||||
{
|
||||
if (SelectedItems.All(h => h.Samples.All(s => s.Name != sampleName)))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
h.SamplesBindable.RemoveAll(s => s.Name == sampleName);
|
||||
@ -245,6 +254,9 @@ 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)
|
||||
{
|
||||
if (SelectedItems.OfType<IHasComboInformation>().All(h => h.NewCombo == state))
|
||||
return;
|
||||
|
||||
EditorBeatmap.PerformOnSelection(h =>
|
||||
{
|
||||
var comboInfo = h as IHasComboInformation;
|
||||
|
@ -198,6 +198,11 @@ namespace osu.Game.Screens.Edit
|
||||
/// Perform the provided action on every selected hitobject.
|
||||
/// Changes will be grouped as one history action.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Note that this incurs a full state save, and as such requires the entire beatmap to be encoded, etc.
|
||||
/// Very frequent use of this method (e.g. once a frame) is most discouraged.
|
||||
/// If there is need to do so, use local precondition checks to eliminate changes that are known to be no-ops.
|
||||
/// </remarks>
|
||||
/// <param name="action">The action to perform.</param>
|
||||
public void PerformOnSelection(Action<HitObject> action)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user