1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 13:27:23 +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)
{
foreach (var issueType in verify.ShowIssueType.Keys)
{
if (!verify.ShowIssueType[issueType].Value)
issues = issues.Where(issue => issue.Template.Type != issueType);
}
return issues;
return issues.Where(issue => !verify.HiddenIssueTypes.Contains(issue.Template.Type));
}
}
}

View File

@ -1,7 +1,6 @@
// 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.
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -18,12 +17,7 @@ namespace osu.Game.Screens.Edit.Verify
public readonly Bindable<DifficultyRating> InterpretedDifficulty = new Bindable<DifficultyRating>();
public readonly Dictionary<IssueType, Bindable<bool>> ShowIssueType = new Dictionary<IssueType, Bindable<bool>>
{
{ IssueType.Warning, new Bindable<bool>(true) },
{ IssueType.Error, new Bindable<bool>(true) },
{ IssueType.Negligible, new Bindable<bool>(false) }
};
public readonly BindableList<IssueType> HiddenIssueTypes = new BindableList<IssueType> { IssueType.Negligible };
public IssueList IssueList { get; private set; }

View File

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