// Copyright (c) ppy Pty Ltd . 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.Screens.Edit.Verify.Components { public class IssueTemplate { /// /// The type, or severity, of an issue. This decides its priority. /// public enum IssueType { /// A must-fix in the vast majority of cases. Problem = 3, /// A possible mistake. Often requires critical thinking. Warning = 2, // TODO: Try/catch all checks run and return error templates if exceptions occur. /// An error occurred and a complete check could not be made. Error = 1, // TODO: Negligible issues should be hidden by default. /// A possible mistake so minor/unlikely that it can often be safely ignored. Negligible = 0, } /// /// The check that this template originates from. /// public Check Origin; /// /// The type of the issue. E.g. , /// , or . /// public readonly IssueType Type; /// /// 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})." /// public readonly string UnformattedMessage; public IssueTemplate(IssueType type, string unformattedMessage) { Type = type; UnformattedMessage = unformattedMessage; } /// /// Returns the formatted message given the arguments used to format it. /// /// The arguments used to format the message. /// public string Message(params object[] args) => UnformattedMessage.FormatWith(args); public static readonly Color4 PROBLEM_RED = new Colour4(1.0f, 0.4f, 0.4f, 1.0f); public static readonly Color4 WARNING_YELLOW = new Colour4(1.0f, 0.8f, 0.2f, 1.0f); public static readonly Color4 NEGLIGIBLE_GREEN = new Colour4(0.33f, 0.8f, 0.5f, 1.0f); public static readonly Color4 ERROR_GRAY = new Colour4(0.5f, 0.5f, 0.5f, 1.0f); /// /// Returns the colour corresponding to the type of this issue. /// /// public Colour4 TypeColour() { return Type switch { IssueType.Problem => PROBLEM_RED, IssueType.Warning => WARNING_YELLOW, IssueType.Negligible => NEGLIGIBLE_GREEN, IssueType.Error => ERROR_GRAY, _ => Color4.White }; } } }