2019-01-24 08:43:03 +00: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.
|
2018-12-05 08:13:22 +00:00
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2021-08-01 15:12:04 +00:00
|
|
|
using osu.Framework.Graphics.Containers;
|
2018-12-05 08:13:22 +00:00
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2021-10-04 06:40:00 +00:00
|
|
|
namespace osu.Game.Graphics
|
2018-12-05 08:13:22 +00:00
|
|
|
{
|
|
|
|
public class ErrorTextFlowContainer : OsuTextFlowContainer
|
|
|
|
{
|
2021-08-01 15:12:04 +00:00
|
|
|
private readonly List<ITextPart> errorTextParts = new List<ITextPart>();
|
2018-12-05 08:13:22 +00:00
|
|
|
|
|
|
|
public ErrorTextFlowContainer()
|
2019-02-20 10:32:30 +00:00
|
|
|
: base(cp => cp.Font = cp.Font.With(size: 12))
|
2018-12-05 08:13:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ClearErrors()
|
|
|
|
{
|
2021-08-01 15:12:04 +00:00
|
|
|
foreach (var textPart in errorTextParts)
|
|
|
|
RemovePart(textPart);
|
2018-12-05 08:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void AddErrors(string[] errors)
|
|
|
|
{
|
|
|
|
ClearErrors();
|
|
|
|
|
|
|
|
if (errors == null) return;
|
|
|
|
|
2021-10-27 04:04:41 +00:00
|
|
|
foreach (string error in errors)
|
2021-08-01 15:12:04 +00:00
|
|
|
errorTextParts.Add(AddParagraph(error, cp => cp.Colour = Color4.Red));
|
2018-12-05 08:13:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|