Files
wwdpublic/Content.Client/_DV/SmartFridge/SmartFridgeBoundUserInterface.cs
Will-Oliver-Br c00f942bb1 Port SmartFridge Functionality (#2479)
# 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/3207

70a9032085

2d4abf62b7

---

<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>
2025-07-12 12:42:31 +10:00

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));
}
}