2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-12-05 16:13:22 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2021-08-01 23:12:04 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-05 16:13:22 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
2021-10-04 14:40:00 +08:00
|
|
|
|
namespace osu.Game.Graphics
|
2018-12-05 16:13:22 +08:00
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
|
public partial class ErrorTextFlowContainer : OsuTextFlowContainer
|
2018-12-05 16:13:22 +08:00
|
|
|
|
{
|
2021-08-01 23:12:04 +08:00
|
|
|
|
private readonly List<ITextPart> errorTextParts = new List<ITextPart>();
|
2018-12-05 16:13:22 +08:00
|
|
|
|
|
|
|
|
|
public ErrorTextFlowContainer()
|
2019-02-20 18:32:30 +08:00
|
|
|
|
: base(cp => cp.Font = cp.Font.With(size: 12))
|
2018-12-05 16:13:22 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearErrors()
|
|
|
|
|
{
|
2021-08-01 23:12:04 +08:00
|
|
|
|
foreach (var textPart in errorTextParts)
|
|
|
|
|
RemovePart(textPart);
|
2018-12-05 16:13:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-06-23 23:59:36 +08:00
|
|
|
|
public void AddErrors(string[]? errors)
|
2018-12-05 16:13:22 +08:00
|
|
|
|
{
|
|
|
|
|
ClearErrors();
|
|
|
|
|
|
|
|
|
|
if (errors == null) return;
|
|
|
|
|
|
2021-10-27 12:04:41 +08:00
|
|
|
|
foreach (string error in errors)
|
2021-08-01 23:12:04 +08:00
|
|
|
|
errorTextParts.Add(AddParagraph(error, cp => cp.Colour = Color4.Red));
|
2018-12-05 16:13:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|