Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: VigersRay <60344369+VigersRay@users.noreply.github.com> Co-authored-by: Vigers Ray <vigersray@gmail.com>
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using Content.Shared._Sunrise.MentorHelp;
|
||
using Robust.Client.AutoGenerated;
|
||
using Robust.Client.UserInterface.Controls;
|
||
using Robust.Client.UserInterface.CustomControls;
|
||
using Robust.Client.UserInterface.XAML;
|
||
|
||
namespace Content.Client._Sunrise.MentorHelp
|
||
{
|
||
[GenerateTypedNameReferences]
|
||
public sealed partial class MentorHelpStatisticsDialog : DefaultWindow
|
||
{
|
||
private MentorHelpSystem? _mentorHelpSystem;
|
||
|
||
public MentorHelpStatisticsDialog()
|
||
{
|
||
RobustXamlLoader.Load(this);
|
||
IoCManager.InjectDependencies(this);
|
||
|
||
CloseButton.OnPressed += _ => Close();
|
||
}
|
||
|
||
public void Initialize(MentorHelpSystem mentorHelpSystem)
|
||
{
|
||
if (_mentorHelpSystem != null)
|
||
return;
|
||
|
||
_mentorHelpSystem = mentorHelpSystem;
|
||
_mentorHelpSystem.OnStatisticsReceived += OnStatisticsReceived;
|
||
|
||
_mentorHelpSystem.RequestStatistics();
|
||
}
|
||
|
||
public void Uninitialize()
|
||
{
|
||
if (_mentorHelpSystem != null)
|
||
{
|
||
_mentorHelpSystem.OnStatisticsReceived -= OnStatisticsReceived;
|
||
_mentorHelpSystem = null;
|
||
}
|
||
}
|
||
|
||
|
||
private void OnStatisticsReceived(object? sender, MentorHelpStatisticsMessage message)
|
||
{
|
||
UpdateStatistics(message.Statistics);
|
||
}
|
||
|
||
private void UpdateStatistics(List<MentorHelpStatisticsData> statistics)
|
||
{
|
||
StatisticsContainer.RemoveAllChildren();
|
||
|
||
if (statistics.Count == 0)
|
||
{
|
||
var noDataLabel = new Label
|
||
{
|
||
Text = "Нет данных о статистике менторов", // а не локализирую, бугагагага
|
||
HorizontalAlignment = HAlignment.Center,
|
||
StyleClasses = { "LabelSubText" }
|
||
};
|
||
StatisticsContainer.AddChild(noDataLabel);
|
||
return;
|
||
}
|
||
|
||
foreach (var stat in statistics)
|
||
{
|
||
var entry = new StatisticsEntryControl();
|
||
entry.UpdateData(stat);
|
||
StatisticsContainer.AddChild(entry);
|
||
}
|
||
}
|
||
}
|
||
}
|