fish-station/Content.Client/_Sunrise/MentorHelp/MentorHelpStatisticsDialog.xaml.cs
Copilot aba00f7e8f
Implement Mentor Help System (MHelp) - Complete Ticket-based Help for Game Questions (#2915)
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>
2025-09-09 20:54:52 +03:00

72 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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);
}
}
}
}