1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

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

@ -10,7 +10,7 @@ using osu.Game.Overlays;
namespace osu.Game.Screens.Edit
{
public class RoundedContentEditorScreen : EditorScreen
public class EditorRoundedScreen : EditorScreen
{
public const int HORIZONTAL_PADDING = 100;
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Edit
protected override Container<Drawable> Content => roundedContent;
public RoundedContentEditorScreen(EditorScreenMode mode)
public EditorRoundedScreen(EditorScreenMode mode)
: base(mode)
{
ColourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);

View File

@ -11,7 +11,7 @@ using osu.Game.Overlays;
namespace osu.Game.Screens.Edit
{
public abstract class RoundedContentEditorScreenSettings : CompositeDrawable
public abstract class EditorRoundedScreenSettings : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colours)

View File

@ -9,22 +9,15 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Screens.Edit.Verify
namespace osu.Game.Screens.Edit
{
public abstract class Section : CompositeDrawable
public abstract class EditorRoundedScreenSettingsSection : 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)
{

View File

@ -7,7 +7,7 @@ using osu.Game.Graphics.Containers;
namespace osu.Game.Screens.Edit.Setup
{
public class SetupScreen : RoundedContentEditorScreen
public class SetupScreen : EditorRoundedScreen
{
[Cached]
private SectionsContainer<SetupSection> sections = new SectionsContainer<SetupSection>();

View File

@ -93,7 +93,7 @@ namespace osu.Game.Screens.Edit.Setup
public SetupScreenTabControl()
{
TabContainer.Margin = new MarginPadding { Horizontal = RoundedContentEditorScreen.HORIZONTAL_PADDING };
TabContainer.Margin = new MarginPadding { Horizontal = EditorRoundedScreen.HORIZONTAL_PADDING };
AddInternal(background = new Box
{

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Edit.Setup
Padding = new MarginPadding
{
Vertical = 10,
Horizontal = RoundedContentEditorScreen.HORIZONTAL_PADDING
Horizontal = EditorRoundedScreen.HORIZONTAL_PADDING
};
InternalChild = new FillFlowContainer

View File

@ -6,7 +6,7 @@ using osu.Framework.Graphics;
namespace osu.Game.Screens.Edit.Timing
{
public class ControlPointSettings : RoundedContentEditorScreenSettings
public class ControlPointSettings : EditorRoundedScreenSettings
{
protected override IReadOnlyList<Drawable> CreateSections() => new Drawable[]
{

View File

@ -15,7 +15,7 @@ using osuTK;
namespace osu.Game.Screens.Edit.Timing
{
public class TimingScreen : RoundedContentEditorScreen
public class TimingScreen : EditorRoundedScreen
{
[Cached]
private Bindable<ControlPointGroup> selectedGroup = new Bindable<ControlPointGroup>();

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

@ -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);
}
}