Implement SmartFridge functionality (#38648)
* Add SmartFridge * my nit so pick * my access so expanded and my whitelist so both * list -> hashset
This commit is contained in:
committed by
GitHub
parent
99b431cafd
commit
d2ddbcbcda
43
Content.Client/SmartFridge/SmartFridgeBoundUserInterface.cs
Normal file
43
Content.Client/SmartFridge/SmartFridgeBoundUserInterface.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user