Delta-v/Content.Client/_CD/Admin/UI/ModifyCharacterRecords.xaml.cs

49 lines
1.3 KiB
C#

using Content.Shared._CD.Records;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client._CD.Admin.UI;
[GenerateTypedNameReferences]
public sealed partial class ModifyCharacterRecords : DefaultWindow
{
public ModifyCharacterRecords()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
foreach (var v in Enum.GetValues<CharacterRecordType>())
{
EntityEntryType.AddItem(v.ToString());
}
EntityEntryType.OnItemSelected += args =>
{
EntityEntryType.SelectId(args.Id);
UpdateCommands();
};
EntityEdit.OnTextChanged += _ => UpdateCommands();
EntityEntryIndex.OnTextChanged += _ => UpdateCommands();
}
private void UpdateCommands()
{
if (!int.TryParse(EntityEdit.Text, out var uid))
{
return;
}
if (!int.TryParse(EntityEntryIndex.Text, out var idx))
{
return;
}
var ty = (CharacterRecordType)EntityEntryType.SelectedId;
PurgeCommand.Command = $"purgecharacterrecords {uid}";
DelCommand.Command = $"delrecordentry {uid} {ty.ToString()} {idx}";
}
}