Reverse direction of binding to allow for better abstract class definitions

This commit is contained in:
Dean Herbert
2021-05-12 16:53:49 +09:00
parent 17e3764576
commit d2e0e8ad94
14 changed files with 42 additions and 51 deletions

View File

@ -8,12 +8,10 @@ using osu.Game.Overlays.Settings;
namespace osu.Game.Screens.Edit.Verify
{
internal class InterpretationSection : Section
internal class InterpretationSection : EditorRoundedScreenSettingsSection
{
public InterpretationSection(IssueList issueList)
: base(issueList)
{
}
[Resolved]
private VerifyScreen verify { get; set; }
protected override string Header => "Interpretation";
@ -26,7 +24,8 @@ namespace osu.Game.Screens.Edit.Verify
Origin = Anchor.CentreLeft,
TooltipText = "Affects checks that depend on difficulty level"
};
dropdown.Current.BindTo(IssueList.InterpretedDifficulty);
dropdown.Current.BindTo(verify.InterpretedDifficulty);
Flow.Add(dropdown);
}

View File

@ -18,6 +18,7 @@ using osuTK;
namespace osu.Game.Screens.Edit.Verify
{
[Cached]
public class IssueList : CompositeDrawable
{
private IssueTable table;
@ -32,7 +33,7 @@ namespace osu.Game.Screens.Edit.Verify
private EditorBeatmap beatmap { get; set; }
[Resolved]
private Bindable<Issue> selectedIssue { get; set; }
private VerifyScreen verify { get; set; }
public Dictionary<IssueType, Bindable<bool>> ShowType { get; set; }
@ -55,7 +56,7 @@ namespace osu.Game.Screens.Edit.Verify
generalVerifier = new BeatmapVerifier();
rulesetVerifier = beatmap.BeatmapInfo.Ruleset?.CreateInstance()?.CreateBeatmapVerifier();
InterpretedDifficulty = new Bindable<DifficultyRating>(beatmap.BeatmapInfo.DifficultyRating);
InterpretedDifficulty = verify.InterpretedDifficulty.GetBoundCopy();
RelativeSizeAxes = Axes.Both;

View File

@ -6,19 +6,12 @@ using osu.Framework.Graphics;
namespace osu.Game.Screens.Edit.Verify
{
public class IssueSettings : RoundedContentEditorScreenSettings
public class IssueSettings : EditorRoundedScreenSettings
{
private readonly IssueList issueList;
public IssueSettings(IssueList issueList)
{
this.issueList = issueList;
}
protected override IReadOnlyList<Drawable> CreateSections() => new Drawable[]
{
new InterpretationSection(issueList),
new VisibilitySection(issueList)
new InterpretationSection(),
new VisibilitySection()
};
}
}

View File

@ -18,7 +18,9 @@ namespace osu.Game.Screens.Edit.Verify
public class IssueTable : EditorTable
{
[Resolved]
private Bindable<Issue> selectedIssue { get; set; }
private VerifyScreen verify { get; set; }
private Bindable<Issue> selectedIssue;
[Resolved]
private EditorClock clock { get; set; }
@ -71,6 +73,7 @@ namespace osu.Game.Screens.Edit.Verify
{
base.LoadComplete();
selectedIssue = verify.SelectedIssue.GetBoundCopy();
selectedIssue.BindValueChanged(issue =>
{
foreach (var b in BackgroundFlow) b.Selected = b.Item == issue.NewValue;

View File

@ -1,67 +0,0 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Screens.Edit.Verify
{
public abstract class Section : CompositeDrawable
{
private const int header_height = 50;
protected readonly IssueList IssueList;
protected FillFlowContainer Flow;
protected abstract string Header { get; }
protected Section(IssueList issueList)
{
IssueList = issueList;
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colours)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
InternalChildren = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.X,
Height = header_height,
Padding = new MarginPadding { Horizontal = 20 },
Child = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = Header,
Font = new FontUsage(size: 25, weight: "bold")
}
},
new Container
{
Y = header_height,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Child = Flow = new FillFlowContainer
{
Padding = new MarginPadding { Horizontal = 20 },
Spacing = new Vector2(10),
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
}
}
};
}
}
}

View File

@ -5,14 +5,19 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Screens.Edit.Verify
{
public class VerifyScreen : RoundedContentEditorScreen
[Cached]
public class VerifyScreen : EditorRoundedScreen
{
[Cached]
private Bindable<Issue> selectedIssue = new Bindable<Issue>();
public readonly Bindable<Issue> SelectedIssue = new Bindable<Issue>();
public readonly Bindable<DifficultyRating> InterpretedDifficulty = new Bindable<DifficultyRating>();
public IssueList IssueList { get; private set; }
public VerifyScreen()
: base(EditorScreenMode.Verify)
@ -22,8 +27,7 @@ namespace osu.Game.Screens.Edit.Verify
[BackgroundDependencyLoader]
private void load()
{
IssueList issueList;
IssueList = new IssueList();
Child = new Container
{
RelativeSizeAxes = Axes.Both,
@ -39,8 +43,8 @@ namespace osu.Game.Screens.Edit.Verify
{
new Drawable[]
{
issueList = new IssueList(),
new IssueSettings(issueList),
IssueList,
new IssueSettings(),
},
}
}

View File

@ -9,19 +9,17 @@ using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Screens.Edit.Verify
{
internal class VisibilitySection : Section
internal class VisibilitySection : EditorRoundedScreenSettingsSection
{
public VisibilitySection(IssueList issueList)
: base(issueList)
{
}
[Resolved]
private VerifyScreen verify { get; set; }
protected override string Header => "Visibility";
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colours)
{
foreach (IssueType issueType in IssueList.ShowType.Keys)
foreach (IssueType issueType in verify.IssueList.ShowType.Keys)
{
var checkbox = new SettingsCheckbox
{
@ -30,8 +28,8 @@ namespace osu.Game.Screens.Edit.Verify
LabelText = issueType.ToString()
};
checkbox.Current.BindTo(IssueList.ShowType[issueType]);
checkbox.Current.BindValueChanged(_ => IssueList.Refresh());
checkbox.Current.BindTo(verify.IssueList.ShowType[issueType]);
checkbox.Current.BindValueChanged(_ => verify.IssueList.Refresh());
Flow.Add(checkbox);
}
}