2021-01-08 10:29:08 -03:00
|
|
|
using Content.Shared.Roles;
|
|
|
|
|
using Robust.Client.AutoGenerated;
|
|
|
|
|
using Robust.Client.Console;
|
|
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
|
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Localization;
|
|
|
|
|
using Robust.Shared.Prototypes;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Administration.UI.SetOutfit
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
|
|
|
|
[GenerateTypedNameReferences]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed partial class SetOutfitMenu : DefaultWindow
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
2021-02-01 16:49:43 -08:00
|
|
|
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
2021-01-08 10:29:08 -03:00
|
|
|
|
|
|
|
|
public EntityUid? TargetEntityId { get; set; }
|
|
|
|
|
private StartingGearPrototype? _selectedOutfit;
|
|
|
|
|
|
|
|
|
|
public SetOutfitMenu()
|
|
|
|
|
{
|
2021-02-21 12:38:56 +01:00
|
|
|
MinSize = SetSize = (250, 320);
|
2021-01-08 10:29:08 -03:00
|
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
|
RobustXamlLoader.Load(this);
|
|
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
Title = Loc.GetString("set-outfit-menu-title");
|
2021-01-08 10:29:08 -03:00
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
ConfirmButton.Text = Loc.GetString("set-outfit-menu-confirm-button");
|
2021-01-08 10:29:08 -03:00
|
|
|
ConfirmButton.OnPressed += ConfirmButtonOnOnPressed;
|
|
|
|
|
SearchBar.OnTextChanged += SearchBarOnOnTextChanged;
|
|
|
|
|
OutfitList.OnItemSelected += OutfitListOnOnItemSelected;
|
|
|
|
|
OutfitList.OnItemDeselected += OutfitListOnOnItemDeselected;
|
|
|
|
|
PopulateList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConfirmButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
if (TargetEntityId == null || _selectedOutfit == null)
|
|
|
|
|
return;
|
|
|
|
|
var command = $"setoutfit {TargetEntityId} {_selectedOutfit.ID}";
|
2021-02-01 16:49:43 -08:00
|
|
|
_consoleHost.ExecuteCommand(command);
|
2021-01-08 10:29:08 -03:00
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OutfitListOnOnItemSelected(ItemList.ItemListSelectedEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
_selectedOutfit = (StartingGearPrototype) obj.ItemList[obj.ItemIndex].Metadata!;
|
|
|
|
|
ConfirmButton.Disabled = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OutfitListOnOnItemDeselected(ItemList.ItemListDeselectedEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
_selectedOutfit = null;
|
|
|
|
|
ConfirmButton.Disabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SearchBarOnOnTextChanged(LineEdit.LineEditEventArgs obj)
|
|
|
|
|
{
|
|
|
|
|
PopulateByFilter(SearchBar.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PopulateList()
|
|
|
|
|
{
|
|
|
|
|
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
|
|
|
|
|
{
|
|
|
|
|
OutfitList.Add(GetItem(gear, OutfitList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PopulateByFilter(string filter)
|
|
|
|
|
{
|
|
|
|
|
OutfitList.Clear();
|
|
|
|
|
foreach (var gear in _prototypeManager.EnumeratePrototypes<StartingGearPrototype>())
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(filter) &&
|
|
|
|
|
gear.ID.ToLowerInvariant().Contains(filter.Trim().ToLowerInvariant()))
|
|
|
|
|
{
|
|
|
|
|
OutfitList.Add(GetItem(gear, OutfitList));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static ItemList.Item GetItem(StartingGearPrototype gear, ItemList itemList)
|
|
|
|
|
{
|
|
|
|
|
return new(itemList)
|
|
|
|
|
{
|
|
|
|
|
Metadata = gear,
|
|
|
|
|
Text = gear.ID
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|