Revert "Add limited-reagent dispensers (#23907)"
This reverts commit 9394a26245.
This commit is contained in:
@@ -57,23 +57,13 @@ namespace Content.Client.Chemistry.UI
|
||||
_window.OnDispenseReagentButtonMouseEntered += (args, button) =>
|
||||
{
|
||||
if (_lastState is not null)
|
||||
_window.UpdateContainerInfo(_lastState);
|
||||
_window.UpdateContainerInfo(_lastState, button.ReagentId);
|
||||
};
|
||||
_window.OnDispenseReagentButtonMouseExited += (args, button) =>
|
||||
{
|
||||
if (_lastState is not null)
|
||||
_window.UpdateContainerInfo(_lastState);
|
||||
};
|
||||
|
||||
_window.OnEjectJugButtonPressed += (args, button) => SendMessage(new ItemSlotButtonPressedEvent(button.ReagentId));
|
||||
_window.OnEjectJugButtonMouseEntered += (args, button) => {
|
||||
if (_lastState is not null)
|
||||
_window.UpdateContainerInfo(_lastState);
|
||||
};
|
||||
_window.OnEjectJugButtonMouseExited += (args, button) => {
|
||||
if (_lastState is not null)
|
||||
_window.UpdateContainerInfo(_lastState);
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
<DefaultWindow xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
Title="{Loc 'reagent-dispenser-bound-user-interface-title'}"
|
||||
MinSize="680 450">
|
||||
SetSize="620 450"
|
||||
MinSize="620 450">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'reagent-dispenser-window-amount-to-dispense-label'}"/>
|
||||
@@ -17,8 +18,10 @@
|
||||
<Button Name="DispenseButton100" Access="Public" Text="100" StyleClasses="OpenLeft"/>
|
||||
</BoxContainer>
|
||||
<Control MinSize="0 10"/>
|
||||
<GridContainer Name="ChemicalList" HorizontalExpand="True" VerticalExpand="True" Access="Public" Columns="6">
|
||||
</GridContainer>
|
||||
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" MinSize="0 170">
|
||||
<GridContainer Name="ChemicalList" Access="Public" Columns="4">
|
||||
</GridContainer>
|
||||
</ScrollContainer>
|
||||
<Control MinSize="0 10"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'reagent-dispenser-window-container-label'}"/>
|
||||
|
||||
@@ -23,10 +23,6 @@ namespace Content.Client.Chemistry.UI
|
||||
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseEntered;
|
||||
public event Action<GUIMouseHoverEventArgs, DispenseReagentButton>? OnDispenseReagentButtonMouseExited;
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs, EjectJugButton>? OnEjectJugButtonPressed;
|
||||
public event Action<GUIMouseHoverEventArgs, EjectJugButton>? OnEjectJugButtonMouseEntered;
|
||||
public event Action<GUIMouseHoverEventArgs, EjectJugButton>? OnEjectJugButtonMouseExited;
|
||||
|
||||
/// <summary>
|
||||
/// Create and initialize the dispenser UI client-side. Creates the basic layout,
|
||||
/// actual data isn't filled in until the server sends data about the dispenser.
|
||||
@@ -52,25 +48,25 @@ namespace Content.Client.Chemistry.UI
|
||||
/// Update the button grid of reagents which can be dispensed.
|
||||
/// </summary>
|
||||
/// <param name="inventory">Reagents which can be dispensed by this dispenser</param>
|
||||
public void UpdateReagentsList(List<KeyValuePair<string, KeyValuePair<string,string>>> inventory)
|
||||
public void UpdateReagentsList(List<ReagentId> inventory)
|
||||
{
|
||||
if (ChemicalList == null)
|
||||
return;
|
||||
|
||||
ChemicalList.Children.Clear();
|
||||
|
||||
foreach (KeyValuePair<string, KeyValuePair<string, string>> entry in inventory)
|
||||
foreach (var entry in inventory
|
||||
.OrderBy(r => {_prototypeManager.TryIndex(r.Prototype, out ReagentPrototype? p); return p?.LocalizedName;}))
|
||||
{
|
||||
var button = new DispenseReagentButton(entry.Key, entry.Value.Key, entry.Value.Value);
|
||||
var localizedName = _prototypeManager.TryIndex(entry.Prototype, out ReagentPrototype? p)
|
||||
? p.LocalizedName
|
||||
: Loc.GetString("reagent-dispenser-window-reagent-name-not-found-text");
|
||||
|
||||
var button = new DispenseReagentButton(entry, localizedName);
|
||||
button.OnPressed += args => OnDispenseReagentButtonPressed?.Invoke(args, button);
|
||||
button.OnMouseEntered += args => OnDispenseReagentButtonMouseEntered?.Invoke(args, button);
|
||||
button.OnMouseExited += args => OnDispenseReagentButtonMouseExited?.Invoke(args, button);
|
||||
ChemicalList.AddChild(button);
|
||||
var ejectButton = new EjectJugButton(entry.Key);
|
||||
ejectButton.OnPressed += args => OnEjectJugButtonPressed?.Invoke(args, ejectButton);
|
||||
ejectButton.OnMouseEntered += args => OnEjectJugButtonMouseEntered?.Invoke(args, ejectButton);
|
||||
ejectButton.OnMouseExited += args => OnEjectJugButtonMouseExited?.Invoke(args, ejectButton);
|
||||
ChemicalList.AddChild(ejectButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +121,9 @@ namespace Content.Client.Chemistry.UI
|
||||
/// <para>Also highlights a reagent if it's dispense button is being mouse hovered.</para>
|
||||
/// </summary>
|
||||
/// <param name="state">State data for the dispenser.</param>
|
||||
/// <param name="highlightedReagentId">Prototype ID of the reagent whose dispense button is currently being mouse hovered,
|
||||
/// or null if no button is being hovered.</param>
|
||||
public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state)
|
||||
public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state, ReagentId? highlightedReagentId = null)
|
||||
{
|
||||
ContainerInfo.Children.Clear();
|
||||
|
||||
@@ -164,6 +161,12 @@ namespace Content.Client.Chemistry.UI
|
||||
StyleClasses = {StyleNano.StyleClassLabelSecondaryColor},
|
||||
};
|
||||
|
||||
// Check if the reagent is being moused over. If so, color it green.
|
||||
if (reagent == highlightedReagentId) {
|
||||
nameLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
|
||||
quantityLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
|
||||
}
|
||||
|
||||
ContainerInfo.Children.Add(new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal,
|
||||
@@ -177,27 +180,13 @@ namespace Content.Client.Chemistry.UI
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DispenseReagentButton : Button
|
||||
{
|
||||
public string ReagentId { get; }
|
||||
public sealed class DispenseReagentButton : Button {
|
||||
public ReagentId ReagentId { get; }
|
||||
|
||||
public DispenseReagentButton(string reagentId, string text, string amount)
|
||||
public DispenseReagentButton(ReagentId reagentId, string text)
|
||||
{
|
||||
AddStyleClass("OpenRight");
|
||||
ReagentId = reagentId;
|
||||
Text = text + " " + amount;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class EjectJugButton : Button
|
||||
{
|
||||
public string ReagentId { get; }
|
||||
|
||||
public EjectJugButton(string reagentId)
|
||||
{
|
||||
AddStyleClass("OpenLeft");
|
||||
ReagentId = reagentId;
|
||||
Text = "⏏";
|
||||
Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user