1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 15:32:57 +08:00
osu-lazer/osu.Game/Screens/Edit/Verify/IssueTable.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

135 lines
4.5 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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2021-09-16 17:28:35 +08:00
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
2021-04-07 20:38:43 +08:00
using osu.Game.Input.Bindings;
using osu.Game.Rulesets.Edit.Checks.Components;
namespace osu.Game.Screens.Edit.Verify
{
public class IssueTable : EditorTable
{
[Resolved]
private VerifyScreen verify { get; set; }
private Bindable<Issue> selectedIssue;
[Resolved]
private EditorClock clock { get; set; }
[Resolved]
private EditorBeatmap editorBeatmap { get; set; }
[Resolved]
private Editor editor { get; set; }
public IEnumerable<Issue> Issues
{
set
{
Content = null;
BackgroundFlow.Clear();
2021-04-10 19:09:16 +08:00
if (value == null)
return;
foreach (var issue in value)
{
BackgroundFlow.Add(new RowBackground(issue)
{
Action = () =>
{
selectedIssue.Value = issue;
if (issue.Time != null)
{
clock.Seek(issue.Time.Value);
2021-09-16 17:28:35 +08:00
editor.OnPressed(new KeyBindingPressEvent<GlobalAction>(GetContainingInputManager().CurrentState, GlobalAction.EditorComposeMode));
}
if (!issue.HitObjects.Any())
return;
editorBeatmap.SelectedHitObjects.Clear();
editorBeatmap.SelectedHitObjects.AddRange(issue.HitObjects);
},
});
}
Columns = createHeaders();
Content = value.Select((g, i) => createContent(i, g)).ToArray().ToRectangular();
}
}
protected override void LoadComplete()
{
base.LoadComplete();
selectedIssue = verify.SelectedIssue.GetBoundCopy();
selectedIssue.BindValueChanged(issue =>
{
foreach (var b in BackgroundFlow) b.Selected = b.Item == issue.NewValue;
}, true);
}
private TableColumn[] createHeaders()
{
var columns = new List<TableColumn>
{
2021-04-10 19:10:05 +08:00
new TableColumn(string.Empty, Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize)),
new TableColumn("Type", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 60)),
new TableColumn("Time", Anchor.CentreLeft, new Dimension(GridSizeMode.AutoSize, minSize: 60)),
2021-04-07 20:38:43 +08:00
new TableColumn("Message", Anchor.CentreLeft),
new TableColumn("Category", Anchor.CentreRight, new Dimension(GridSizeMode.AutoSize)),
};
return columns.ToArray();
}
private Drawable[] createContent(int index, Issue issue) => new Drawable[]
{
new OsuSpriteText
{
Text = $"#{index + 1}",
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Medium),
2021-04-10 19:10:05 +08:00
Margin = new MarginPadding { Right = 10 }
2021-04-07 20:38:43 +08:00
},
new OsuSpriteText
{
Text = issue.Template.Type.ToString(),
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
2021-04-10 19:10:05 +08:00
Margin = new MarginPadding { Right = 10 },
2021-04-12 14:30:33 +08:00
Colour = issue.Template.Colour
2021-04-07 20:38:43 +08:00
},
new OsuSpriteText
{
Text = issue.GetEditorTimestamp(),
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
2021-04-10 19:10:05 +08:00
Margin = new MarginPadding { Right = 10 },
},
new OsuSpriteText
{
2021-04-07 20:38:43 +08:00
Text = issue.ToString(),
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Medium)
},
2021-04-07 20:38:43 +08:00
new OsuSpriteText
{
2021-04-12 21:47:58 +08:00
Text = issue.Check.Metadata.Category.ToString(),
Font = OsuFont.GetFont(size: TEXT_SIZE, weight: FontWeight.Bold),
2021-04-07 20:38:43 +08:00
Margin = new MarginPadding(10)
}
};
}
}