mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
# Description Port smartfridge functionality from [Delta-V](https://github.com/DeltaV-Station/Delta-v) and commits from [Frontier](https://github.com/new-frontiers-14/frontier-station-14) Pr and commits: https://github.com/DeltaV-Station/Delta-v/pull/320770a90320852d4abf62b7--- <details><summary><h1>Media</h1></summary> <p> https://github.com/user-attachments/assets/a67f78ca-327c-4e08-8e34-8be6a1a59eac </p> </details> --- # Changelog 🆑 sowelipililimute, Whatstone and Will-Oliver-Br - tweak: SmartFridge now really has functionality --------- Co-authored-by: pathetic meowmeow <uhhadd@gmail.com> Co-authored-by: Whatstone <whatston3@gmail.com>
43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Input;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared._DV.SmartFridge;
|
|
|
|
namespace Content.Client._DV.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.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));
|
|
}
|
|
}
|