fish-station/Content.Client/_Sunrise/MentorHelp/TicketEntryControl.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

83 lines
2.8 KiB
C#

using Content.Shared._Sunrise.MentorHelp;
using Content.Shared.Database;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Input;
namespace Content.Client._Sunrise.MentorHelp
{
[GenerateTypedNameReferences]
public sealed partial class TicketEntryControl : Control
{
private static readonly Color NormalColor = Color.FromHex("#202023");
private static readonly Color HoverColor = Color.FromHex("#2F2F33");
private MentorHelpTicketData? _ticketData;
public event Action<MentorHelpTicketData>? OnTicketSelected;
public TicketEntryControl()
{
RobustXamlLoader.Load(this);
TooltipDelay = 0.5f;
BackgroundColorPanel.PanelOverride = new StyleBoxFlat
{
BackgroundColor = NormalColor
};
BackgroundColorPanel.OnMouseEntered += args =>
{
var panel = (StyleBoxFlat)BackgroundColorPanel.PanelOverride!;
panel.BackgroundColor = HoverColor;
};
BackgroundColorPanel.OnMouseExited += args =>
{
var panel = (StyleBoxFlat)BackgroundColorPanel.PanelOverride!;
panel.BackgroundColor = NormalColor;
};
BackgroundColorPanel.OnKeyBindDown += args =>
{
if (args.Function != EngineKeyFunctions.Use)
return;
if (_ticketData != null)
OnTicketSelected?.Invoke(_ticketData);
};
}
public void UpdateData(MentorHelpTicketData ticketData)
{
_ticketData = ticketData;
IdLabel.Text = $"#{ticketData.Id}";
PlayerLabel.Text = ticketData.PlayerName;
var statusText = GetStatusText(ticketData.Status);
StatusLabel.Text = statusText;
AssignedLabel.Text = ticketData.AssignedToName ?? Loc.GetString("mentor-help-unassigned");
var subjectText = ticketData.Subject;
if (ticketData.HasUnreadMessages)
subjectText = "* " + subjectText;
SubjectLabel.Text = subjectText;
}
private string GetStatusText(MentorHelpTicketStatus status)
{
return status switch
{
MentorHelpTicketStatus.Open => Loc.GetString("mentor-help-status-open"),
MentorHelpTicketStatus.Assigned => Loc.GetString("mentor-help-status-assigned"),
MentorHelpTicketStatus.AwaitingResponse => Loc.GetString("mentor-help-status-awaiting"),
MentorHelpTicketStatus.Closed => Loc.GetString("mentor-help-status-closed"),
_ => Loc.GetString("mentor-help-status-unknown")
};
}
}
}