1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 11:27:23 +08:00
osu-lazer/osu.Game/Screens/Edit/Verify/VerifyScreen.cs

131 lines
4.2 KiB
C#
Raw Normal View History

// 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.
2021-04-07 20:38:43 +08:00
using System.Linq;
using osu.Framework.Allocation;
2021-04-07 20:38:43 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2021-04-07 20:38:43 +08:00
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
2021-04-07 20:38:43 +08:00
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osuTK;
namespace osu.Game.Screens.Edit.Verify
{
2021-04-07 20:38:43 +08:00
public class VerifyScreen : EditorScreen
{
2021-04-07 20:38:43 +08:00
private Ruleset ruleset;
private static Checker checker; // TODO: Should not be static, but apparently needs to be?
public VerifyScreen()
: base(EditorScreenMode.Verify)
{
}
2021-04-07 20:38:43 +08:00
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
2021-04-07 20:38:43 +08:00
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
ruleset = parent.Get<IBindable<WorkingBeatmap>>().Value.BeatmapInfo.Ruleset?.CreateInstance();
checker = ruleset?.CreateChecker();
return dependencies;
}
[BackgroundDependencyLoader]
private void load()
{
Child = new Container
{
2021-04-07 20:38:43 +08:00
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(20),
Child = new GridContainer
{
2021-04-07 20:38:43 +08:00
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 200),
},
Content = new[]
{
new Drawable[]
{
new IssueList(),
new IssueSettings(),
},
}
}
};
}
2021-04-07 20:38:43 +08:00
public class IssueList : CompositeDrawable
{
private IssueTable table;
[Resolved]
private EditorClock clock { get; set; }
[Resolved]
protected EditorBeatmap Beatmap { get; private set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.Both;
InternalChildren = new Drawable[]
{
new Box
{
Colour = colours.Gray0,
RelativeSizeAxes = Axes.Both,
},
new OsuScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = table = new IssueTable(),
2021-04-07 20:38:43 +08:00
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding(20),
Children = new Drawable[]
{
new TriangleButton
{
Text = "Refresh",
Action = refresh,
Size = new Vector2(120, 40),
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
},
}
},
};
}
2021-04-07 20:38:43 +08:00
protected override void LoadComplete()
{
base.LoadComplete();
refresh();
}
private void refresh()
{
table.Issues = checker.Run(Beatmap)
.OrderByDescending(issue => issue.Template.Type)
.ThenByDescending(issue => issue.Template.Origin.Metadata().Category);
}
}
}
}