1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 05:22:54 +08:00

Move schedule logic to buttons rather than section

It turns out there's some quite convoluted scheduling / order of
execution requirements of ModSelectOverlay and ModSection. Applying
scheduling causes a runaway condition ending in zero frames after many
mod button changes.

I wanted to avoid rewriting the whole component, so have just moved the
schedule to guard against the part where drawables are actually changed.
This commit is contained in:
Dean Herbert 2021-01-05 16:41:03 +09:00
parent 4d6c13f169
commit 5d8c153c1e
2 changed files with 37 additions and 33 deletions

View File

@ -64,6 +64,8 @@ namespace osu.Game.Overlays.Mods
if (newIndex >= 0 && !Mods[newIndex].HasImplementation)
return false;
Schedule(() =>
{
selectedIndex = newIndex;
Mod modAfter = SelectedMod ?? Mods[0];
@ -99,6 +101,8 @@ namespace osu.Game.Overlays.Mods
foregroundIcon.Selected.Value = Selected;
SelectionChanged?.Invoke(SelectedMod);
});
return true;
}

View File

@ -104,7 +104,7 @@ namespace osu.Game.Overlays.Mods
/// </summary>
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
/// <param name="immediate">Set to true to bypass animations and update selections immediately.</param>
public void DeselectTypes(IEnumerable<Type> modTypes, bool immediate = false) => Schedule(() =>
public void DeselectTypes(IEnumerable<Type> modTypes, bool immediate = false)
{
int delay = 0;
@ -124,13 +124,13 @@ namespace osu.Game.Overlays.Mods
}
}
}
});
}
/// <summary>
/// Select one or more mods in this section and deselects all other ones.
/// </summary>
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be selected.</param>
public void SelectTypes(IEnumerable<Type> modTypes) => Schedule(() =>
public void SelectTypes(IEnumerable<Type> modTypes)
{
foreach (var button in buttons)
{
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Mods
else
button.Deselect();
}
});
}
protected ModSection()
{