1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

Add ability for playlist items to be marked as invalid

This commit is contained in:
Dean Herbert 2021-11-16 17:01:24 +09:00
parent 49cdcffa30
commit aa188d5a52
2 changed files with 20 additions and 1 deletions

View File

@ -30,6 +30,11 @@ namespace osu.Game.Online.Rooms
[JsonProperty("expired")]
public bool Expired { get; set; }
[JsonIgnore]
public IBindable<bool> Valid => valid;
private readonly Bindable<bool> valid = new BindableBool(true);
[JsonIgnore]
public readonly Bindable<IBeatmapInfo> Beatmap = new Bindable<IBeatmapInfo>();
@ -69,6 +74,8 @@ namespace osu.Game.Online.Rooms
Ruleset.BindValueChanged(ruleset => RulesetID = ruleset.NewValue?.ID ?? 0);
}
public void MarkInvalid() => valid.Value = false;
public void MapObjects(RulesetStore rulesets)
{
Beatmap.Value ??= apiBeatmap;

View File

@ -45,6 +45,7 @@ namespace osu.Game.Screens.OnlinePlay
private ModDisplay modDisplay;
private readonly Bindable<IBeatmapInfo> beatmap = new Bindable<IBeatmapInfo>();
private readonly IBindable<bool> valid = new Bindable<bool>();
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly BindableList<Mod> requiredMods = new BindableList<Mod>();
@ -65,14 +66,18 @@ namespace osu.Game.Screens.OnlinePlay
this.allowSelection = allowSelection;
beatmap.BindTo(item.Beatmap);
valid.BindTo(item.Valid);
ruleset.BindTo(item.Ruleset);
requiredMods.BindTo(item.RequiredMods);
ShowDragHandle.Value = allowEdit;
}
[Resolved]
private OsuColour colours { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
if (!allowEdit)
HandleColour = HandleColour.Opacity(0);
@ -88,6 +93,7 @@ namespace osu.Game.Screens.OnlinePlay
beatmap.BindValueChanged(_ => Scheduler.AddOnce(refresh));
ruleset.BindValueChanged(_ => Scheduler.AddOnce(refresh));
valid.BindValueChanged(_ => Scheduler.AddOnce(refresh));
requiredMods.CollectionChanged += (_, __) => Scheduler.AddOnce(refresh);
refresh();
@ -97,6 +103,12 @@ namespace osu.Game.Screens.OnlinePlay
private void refresh()
{
if (!valid.Value)
{
maskingContainer.BorderThickness = 5;
maskingContainer.BorderColour = colours.Red;
}
difficultyIconContainer.Child = new DifficultyIcon(Item.Beatmap.Value, ruleset.Value, requiredMods, performBackgroundDifficultyLookup: false) { Size = new Vector2(32) };
panelBackground.Beatmap.Value = Item.Beatmap.Value;