Disallow selection of invalid items

This commit is contained in:
Dean Herbert 2021-11-17 11:28:43 +09:00
parent 6dd684588a
commit 8e9b55ef6d

View File

@ -90,7 +90,24 @@ namespace osu.Game.Screens.OnlinePlay
{
base.LoadComplete();
SelectedItem.BindValueChanged(selected => maskingContainer.BorderThickness = selected.NewValue == Model ? 5 : 0, true);
SelectedItem.BindValueChanged(selected =>
{
bool isCurrent = selected.NewValue == Model;
if (!valid.Value)
{
// Don't allow selection when not valid.
if (isCurrent)
{
SelectedItem.Value = selected.OldValue;
}
// Don't update border when not valid (the border is displaying this fact).
return;
}
maskingContainer.BorderThickness = isCurrent ? 5 : 0;
}, true);
beatmap.BindValueChanged(_ => Scheduler.AddOnce(refresh));
ruleset.BindValueChanged(_ => Scheduler.AddOnce(refresh));