1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 16:34:05 +08:00
osu-lazer/osu.Game/Rulesets/Edit/Checks/Components/IssueTemplate.cs

75 lines
2.4 KiB
C#
Raw Normal View History

2021-04-07 20:35:33 +08:00
// 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 Humanizer;
using osu.Framework.Graphics;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Edit.Checks.Components
2021-04-07 20:35:33 +08:00
{
public class IssueTemplate
{
2021-04-12 14:28:13 +08:00
private static readonly Color4 problem_red = new Colour4(1.0f, 0.4f, 0.4f, 1.0f);
private static readonly Color4 warning_yellow = new Colour4(1.0f, 0.8f, 0.2f, 1.0f);
private static readonly Color4 negligible_green = new Colour4(0.33f, 0.8f, 0.5f, 1.0f);
private static readonly Color4 error_gray = new Colour4(0.5f, 0.5f, 0.5f, 1.0f);
/// <summary>
/// The check that this template originates from.
/// </summary>
2021-04-12 22:23:05 +08:00
public readonly ICheck Check;
2021-04-07 20:35:33 +08:00
/// <summary>
2021-04-12 14:27:12 +08:00
/// The type of the issue.
2021-04-07 20:35:33 +08:00
/// </summary>
public readonly IssueType Type;
/// <summary>
/// The unformatted message given when this issue is detected.
/// This gets populated later when an issue is constructed with this template.
/// E.g. "Inconsistent snapping (1/{0}) with [{1}] (1/{2})."
/// </summary>
public readonly string UnformattedMessage;
public IssueTemplate(ICheck check, IssueType type, string unformattedMessage)
2021-04-07 20:35:33 +08:00
{
Check = check;
2021-04-07 20:35:33 +08:00
Type = type;
UnformattedMessage = unformattedMessage;
}
/// <summary>
/// Returns the formatted message given the arguments used to format it.
/// </summary>
/// <param name="args">The arguments used to format the message.</param>
2021-04-12 14:37:41 +08:00
public string GetMessage(params object[] args) => UnformattedMessage.FormatWith(args);
2021-04-07 20:35:33 +08:00
/// <summary>
/// Returns the colour corresponding to the type of this issue.
/// </summary>
2021-04-12 14:30:33 +08:00
public Colour4 Colour
2021-04-07 20:35:33 +08:00
{
2021-04-12 14:30:33 +08:00
get
2021-04-07 20:35:33 +08:00
{
2021-04-12 14:30:33 +08:00
switch (Type)
{
case IssueType.Problem:
return problem_red;
case IssueType.Warning:
return warning_yellow;
case IssueType.Negligible:
return negligible_green;
case IssueType.Error:
return error_gray;
default:
return Color4.White;
}
}
2021-04-07 20:35:33 +08:00
}
}
}