1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Fix auto selection scenario regressing due to scheduling too much

This commit is contained in:
Dean Herbert 2021-01-08 14:17:14 +09:00
parent 22981a667c
commit c208800150

View File

@ -52,9 +52,10 @@ namespace osu.Game.Overlays.Mods
if (newIndex == selectedIndex) return false; if (newIndex == selectedIndex) return false;
int direction = newIndex < selectedIndex ? -1 : 1; int direction = newIndex < selectedIndex ? -1 : 1;
bool beforeSelected = Selected; bool beforeSelected = Selected;
Mod modBefore = SelectedMod ?? Mods[0]; Mod previousSelection = SelectedMod ?? Mods[0];
if (newIndex >= Mods.Length) if (newIndex >= Mods.Length)
newIndex = -1; newIndex = -1;
@ -64,25 +65,26 @@ namespace osu.Game.Overlays.Mods
if (newIndex >= 0 && !Mods[newIndex].HasImplementation) if (newIndex >= 0 && !Mods[newIndex].HasImplementation)
return false; return false;
selectedIndex = newIndex;
Mod newSelection = SelectedMod ?? Mods[0];
Schedule(() => Schedule(() =>
{ {
selectedIndex = newIndex;
Mod modAfter = SelectedMod ?? Mods[0];
if (beforeSelected != Selected) if (beforeSelected != Selected)
{ {
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic); iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic);
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic); iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic);
} }
if (modBefore != modAfter) if (previousSelection != newSelection)
{ {
const float rotate_angle = 16; const float rotate_angle = 16;
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing); foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing); backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
backgroundIcon.Mod = modAfter; backgroundIcon.Mod = newSelection;
using (BeginDelayedSequence(mod_switch_duration, true)) using (BeginDelayedSequence(mod_switch_duration, true))
{ {
@ -94,15 +96,15 @@ namespace osu.Game.Overlays.Mods
.RotateTo(rotate_angle * direction) .RotateTo(rotate_angle * direction)
.RotateTo(0f, mod_switch_duration, mod_switch_easing); .RotateTo(0f, mod_switch_duration, mod_switch_easing);
Schedule(() => displayMod(modAfter)); Schedule(() => displayMod(newSelection));
} }
} }
foregroundIcon.Selected.Value = Selected; foregroundIcon.Selected.Value = Selected;
SelectionChanged?.Invoke(SelectedMod);
}); });
SelectionChanged?.Invoke(newSelection);
return true; return true;
} }