* Add SmartFridge * my nit so pick * my access so expanded and my whitelist so both * list -> hashset
44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared.SmartFridge;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Input;
|
|
|
|
namespace Content.Client.SmartFridge;
|
|
|
|
public sealed class SmartFridgeBoundUserInterface : BoundUserInterface
|
|
{
|
|
private SmartFridgeMenu? _menu;
|
|
|
|
public SmartFridgeBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_menu = this.CreateWindow<SmartFridgeMenu>();
|
|
_menu.OnItemSelected += OnItemSelected;
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
if (_menu is not {} menu || !EntMan.TryGetComponent(Owner, out SmartFridgeComponent? fridge))
|
|
return;
|
|
|
|
menu.SetFlavorText(Loc.GetString(fridge.FlavorText));
|
|
menu.Populate((Owner, fridge));
|
|
}
|
|
|
|
private void OnItemSelected(GUIBoundKeyEventArgs args, ListData data)
|
|
{
|
|
if (args.Function != EngineKeyFunctions.UIClick)
|
|
return;
|
|
|
|
if (data is not SmartFridgeListData entry)
|
|
return;
|
|
SendPredictedMessage(new SmartFridgeDispenseItemMessage(entry.Entry));
|
|
}
|
|
}
|