mirror of https://github.com/ppy/osu
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:
parent
4d6c13f169
commit
5d8c153c1e
|
@ -64,41 +64,45 @@ private bool changeSelectedIndex(int newIndex)
|
|||
if (newIndex >= 0 && !Mods[newIndex].HasImplementation)
|
||||
return false;
|
||||
|
||||
selectedIndex = newIndex;
|
||||
Mod modAfter = SelectedMod ?? Mods[0];
|
||||
|
||||
if (beforeSelected != Selected)
|
||||
Schedule(() =>
|
||||
{
|
||||
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic);
|
||||
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic);
|
||||
}
|
||||
selectedIndex = newIndex;
|
||||
Mod modAfter = SelectedMod ?? Mods[0];
|
||||
|
||||
if (modBefore != modAfter)
|
||||
{
|
||||
const float rotate_angle = 16;
|
||||
|
||||
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
backgroundIcon.Mod = modAfter;
|
||||
|
||||
using (BeginDelayedSequence(mod_switch_duration, true))
|
||||
if (beforeSelected != Selected)
|
||||
{
|
||||
foregroundIcon
|
||||
.RotateTo(-rotate_angle * direction)
|
||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
backgroundIcon
|
||||
.RotateTo(rotate_angle * direction)
|
||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
Schedule(() => displayMod(modAfter));
|
||||
iconsContainer.RotateTo(Selected ? 5f : 0f, 300, Easing.OutElastic);
|
||||
iconsContainer.ScaleTo(Selected ? 1.1f : 1f, 300, Easing.OutElastic);
|
||||
}
|
||||
}
|
||||
|
||||
foregroundIcon.Selected.Value = Selected;
|
||||
if (modBefore != modAfter)
|
||||
{
|
||||
const float rotate_angle = 16;
|
||||
|
||||
foregroundIcon.RotateTo(rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||
backgroundIcon.RotateTo(-rotate_angle * direction, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
backgroundIcon.Mod = modAfter;
|
||||
|
||||
using (BeginDelayedSequence(mod_switch_duration, true))
|
||||
{
|
||||
foregroundIcon
|
||||
.RotateTo(-rotate_angle * direction)
|
||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
backgroundIcon
|
||||
.RotateTo(rotate_angle * direction)
|
||||
.RotateTo(0f, mod_switch_duration, mod_switch_easing);
|
||||
|
||||
Schedule(() => displayMod(modAfter));
|
||||
}
|
||||
}
|
||||
|
||||
foregroundIcon.Selected.Value = Selected;
|
||||
|
||||
SelectionChanged?.Invoke(SelectedMod);
|
||||
});
|
||||
|
||||
SelectionChanged?.Invoke(SelectedMod);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ protected override bool OnKeyDown(KeyDownEvent e)
|
|||
/// </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 @@ public void DeselectTypes(IEnumerable<Type> modTypes, bool immediate = false) =>
|
|||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <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 @@ public void SelectTypes(IEnumerable<Type> modTypes) => Schedule(() =>
|
|||
else
|
||||
button.Deselect();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected ModSection()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue