Add a container display to dispenser UI (#25391)
* Implemented contents display for dispenser UI * Update Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml.cs Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> * Resolve the netent into a euid first --------- Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,8 @@
|
|||||||
StyleClasses="OpenLeft"/>
|
StyleClasses="OpenLeft"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<Control MinSize="0 10"/>
|
<Control MinSize="0 10"/>
|
||||||
|
<BoxContainer Orientation="Horizontal">
|
||||||
|
<SpriteView Name="View" Scale="4 4" MinSize="150 150"/>
|
||||||
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True" MinSize="0 160">
|
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True" MinSize="0 160">
|
||||||
<PanelContainer VerticalExpand="True"
|
<PanelContainer VerticalExpand="True"
|
||||||
SizeFlagsStretchRatio="6"
|
SizeFlagsStretchRatio="6"
|
||||||
@@ -47,4 +49,5 @@
|
|||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
</BoxContainer>
|
||||||
</DefaultWindow>
|
</DefaultWindow>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
using Content.Shared.Chemistry.Reagent;
|
using Content.Shared.Chemistry.Reagent;
|
||||||
@@ -19,6 +18,7 @@ namespace Content.Client.Chemistry.UI
|
|||||||
public sealed partial class ReagentDispenserWindow : DefaultWindow
|
public sealed partial class ReagentDispenserWindow : DefaultWindow
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
public event Action<BaseButton.ButtonEventArgs, DispenseReagentButton>? OnDispenseReagentButtonPressed;
|
public event Action<BaseButton.ButtonEventArgs, DispenseReagentButton>? OnDispenseReagentButtonPressed;
|
||||||
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseEntered;
|
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseEntered;
|
||||||
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseExited;
|
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseExited;
|
||||||
@@ -86,6 +86,9 @@ namespace Content.Client.Chemistry.UI
|
|||||||
UpdateContainerInfo(castState);
|
UpdateContainerInfo(castState);
|
||||||
UpdateReagentsList(castState.Inventory);
|
UpdateReagentsList(castState.Inventory);
|
||||||
|
|
||||||
|
_entityManager.TryGetEntity(castState.OutputContainerEntity, out var outputContainerEnt);
|
||||||
|
View.SetEntity(outputContainerEnt);
|
||||||
|
|
||||||
// Disable the Clear & Eject button if no beaker
|
// Disable the Clear & Eject button if no beaker
|
||||||
ClearButton.Disabled = castState.OutputContainer is null;
|
ClearButton.Disabled = castState.OutputContainer is null;
|
||||||
EjectButton.Disabled = castState.OutputContainer is null;
|
EjectButton.Disabled = castState.OutputContainer is null;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace Content.Server.Chemistry.EntitySystems
|
|||||||
|
|
||||||
var inventory = GetInventory(reagentDispenser);
|
var inventory = GetInventory(reagentDispenser);
|
||||||
|
|
||||||
var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, inventory, reagentDispenser.Comp.DispenseAmount);
|
var state = new ReagentDispenserBoundUserInterfaceState(outputContainerInfo, GetNetEntity(outputContainer), inventory, reagentDispenser.Comp.DispenseAmount);
|
||||||
_userInterfaceSystem.TrySetUiState(reagentDispenser, ReagentDispenserUiKey.Key, state);
|
_userInterfaceSystem.TrySetUiState(reagentDispenser, ReagentDispenserUiKey.Key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ namespace Content.Shared.Chemistry
|
|||||||
public sealed class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState
|
public sealed class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState
|
||||||
{
|
{
|
||||||
public readonly ContainerInfo? OutputContainer;
|
public readonly ContainerInfo? OutputContainer;
|
||||||
|
|
||||||
|
public readonly NetEntity? OutputContainerEntity;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of the reagents which this dispenser can dispense.
|
/// A list of the reagents which this dispenser can dispense.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -63,9 +65,10 @@ namespace Content.Shared.Chemistry
|
|||||||
|
|
||||||
public readonly ReagentDispenserDispenseAmount SelectedDispenseAmount;
|
public readonly ReagentDispenserDispenseAmount SelectedDispenseAmount;
|
||||||
|
|
||||||
public ReagentDispenserBoundUserInterfaceState(ContainerInfo? outputContainer, List<KeyValuePair<string, KeyValuePair<string, string>>> inventory, ReagentDispenserDispenseAmount selectedDispenseAmount)
|
public ReagentDispenserBoundUserInterfaceState(ContainerInfo? outputContainer, NetEntity? outputContainerEntity, List<KeyValuePair<string, KeyValuePair<string, string>>> inventory, ReagentDispenserDispenseAmount selectedDispenseAmount)
|
||||||
{
|
{
|
||||||
OutputContainer = outputContainer;
|
OutputContainer = outputContainer;
|
||||||
|
OutputContainerEntity = outputContainerEntity;
|
||||||
Inventory = inventory;
|
Inventory = inventory;
|
||||||
SelectedDispenseAmount = selectedDispenseAmount;
|
SelectedDispenseAmount = selectedDispenseAmount;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user