1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-07 19:22:58 +08:00

Split ShowIssueTypes dict into hidden and configurable lists

This way `VerifyScreen` is decoupled from which options `VisibilitySection` provides.

Bindings are a bit less neat, though.
This commit is contained in:
Naxess 2021-05-13 04:50:32 +02:00
parent dd8423c4c4
commit fbb76ba598
3 changed files with 22 additions and 17 deletions

View File

@ -102,13 +102,7 @@ namespace osu.Game.Screens.Edit.Verify
private IEnumerable<Issue> filter(IEnumerable<Issue> issues) private IEnumerable<Issue> filter(IEnumerable<Issue> issues)
{ {
foreach (var issueType in verify.ShowIssueType.Keys) return issues.Where(issue => !verify.HiddenIssueTypes.Contains(issue.Template.Type));
{
if (!verify.ShowIssueType[issueType].Value)
issues = issues.Where(issue => issue.Template.Type != issueType);
}
return issues;
} }
} }
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -18,12 +17,7 @@ namespace osu.Game.Screens.Edit.Verify
public readonly Bindable<DifficultyRating> InterpretedDifficulty = new Bindable<DifficultyRating>(); public readonly Bindable<DifficultyRating> InterpretedDifficulty = new Bindable<DifficultyRating>();
public readonly Dictionary<IssueType, Bindable<bool>> ShowIssueType = new Dictionary<IssueType, Bindable<bool>> public readonly BindableList<IssueType> HiddenIssueTypes = new BindableList<IssueType> { IssueType.Negligible };
{
{ IssueType.Warning, new Bindable<bool>(true) },
{ IssueType.Error, new Bindable<bool>(true) },
{ IssueType.Negligible, new Bindable<bool>(false) }
};
public IssueList IssueList { get; private set; } public IssueList IssueList { get; private set; }

View File

@ -14,12 +14,19 @@ namespace osu.Game.Screens.Edit.Verify
[Resolved] [Resolved]
private VerifyScreen verify { get; set; } private VerifyScreen verify { get; set; }
private readonly IssueType[] configurableIssueTypes =
{
IssueType.Warning,
IssueType.Error,
IssueType.Negligible
};
protected override string Header => "Visibility"; protected override string Header => "Visibility";
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colours) private void load(OverlayColourProvider colours)
{ {
foreach (IssueType issueType in verify.ShowIssueType.Keys) foreach (IssueType issueType in configurableIssueTypes)
{ {
var checkbox = new SettingsCheckbox var checkbox = new SettingsCheckbox
{ {
@ -28,8 +35,18 @@ namespace osu.Game.Screens.Edit.Verify
LabelText = issueType.ToString() LabelText = issueType.ToString()
}; };
checkbox.Current.BindTo(verify.ShowIssueType[issueType]); checkbox.Current.Default = !verify.HiddenIssueTypes.Contains(issueType);
checkbox.Current.BindValueChanged(_ => verify.IssueList.Refresh()); checkbox.Current.SetDefault();
checkbox.Current.BindValueChanged(state =>
{
if (!state.NewValue)
verify.HiddenIssueTypes.Add(issueType);
else
verify.HiddenIssueTypes.Remove(issueType);
verify.IssueList.Refresh();
});
Flow.Add(checkbox); Flow.Add(checkbox);
} }
} }