This simplifies the code and makes the experience of examining contents easier without the reagent dispenser UI, as well as adding the possibility for dispensers to have items of heterogeneous sizes in them, which would allow configuring reagent dispensers to accept smaller containers such as beakers or vials in order to allow for more types of smaller quantities of reagents, or other flexibilities brought by using a standard storage component.
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using Content.Shared.Chemistry;
|
|
using Content.Shared.Storage;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.XAML;
|
|
|
|
namespace Content.Client.Chemistry.UI;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class ReagentCardControl : Control
|
|
{
|
|
public ItemStorageLocation StorageLocation { get; }
|
|
public Action<ItemStorageLocation>? OnPressed;
|
|
public Action<ItemStorageLocation>? OnEjectButtonPressed;
|
|
|
|
public ReagentCardControl(ReagentInventoryItem item)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
|
|
StorageLocation = item.StorageLocation;
|
|
ColorPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = item.ReagentColor };
|
|
ReagentNameLabel.Text = item.ReagentLabel;
|
|
FillLabel.Text = Loc.GetString("reagent-dispenser-window-quantity-label-text", ("quantity", item.Quantity));;
|
|
EjectButtonIcon.Text = Loc.GetString("reagent-dispenser-window-eject-container-button");
|
|
|
|
if (item.Quantity == 0.0)
|
|
MainButton.Disabled = true;
|
|
|
|
MainButton.OnPressed += args => OnPressed?.Invoke(StorageLocation);
|
|
EjectButton.OnPressed += args => OnEjectButtonPressed?.Invoke(StorageLocation);
|
|
}
|
|
}
|