Skip to content

Commit

Permalink
upstream fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MetalSage committed Dec 22, 2024
1 parent 065c63f commit ec6e06b
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 207 deletions.
10 changes: 3 additions & 7 deletions Content.Client/Chemistry/UI/ChemMasterBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ protected override void Open()
new ItemSlotButtonPressedEvent(SharedChemMaster.InputSlotName));
_window.OutputEjectButton.OnPressed += _ => SendMessage(
new ItemSlotButtonPressedEvent(SharedChemMaster.OutputSlotName));
_window.BufferStorageButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Storage));
_window.BufferOutputButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Output));
_window.BufferTransferButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Transfer));
_window.BufferDiscardButton.OnPressed += _ => SendMessage(
new ChemMasterSetModeMessage(ChemMasterMode.Discard));
_window.OutputBufferDiscardButton.OnPressed += _ => SendMessage(
new ChemMasterDiscardBufferMessage(SharedChemMaster.OutputBufferSolutionName));
_window.CreatePillButton.OnPressed += _ => SendMessage(
new ChemMasterCreatePillsMessage(
(uint) _window.PillDosage.Value, (uint) _window.PillNumber.Value, _window.LabelLine));
Expand All @@ -57,7 +53,7 @@ protected override void Open()
_window.PillTypeButtons[i].OnPressed += _ => SendMessage(new ChemMasterSetPillTypeMessage(pillType));
}

_window.OnReagentButtonPressed += (args, button) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, button.Amount, button.IsBuffer, button.Origin));
_window.OnReagentButtonPressed += (args, button) => SendMessage(new ChemMasterReagentAmountButtonMessage(button.Id, button.Amount, button.IsBuffer));
}

/// <summary>
Expand Down
36 changes: 6 additions & 30 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'chem-master-window-buffer-text'}" />
<Control HorizontalExpand="True" />
<Button MinSize="80 0" Name="BufferStorageButton" Access="Public" Text="{Loc 'chem-master-window-storage-button'}" ToggleMode="True" StyleClasses="OpenRight" />
<Button MinSize="80 0" Name="BufferOutputButton" Access="Public" Text="{Loc 'chem-master-window-output-button'}" ToggleMode="True" StyleClasses="ButtonSquare" />
<Button MinSize="80 0" Name="BufferTransferButton" Access="Public" Text="{Loc 'chem-master-window-transfer-button'}" ToggleMode="True" StyleClasses="OpenRight" />
<Button MinSize="80 0" Name="BufferDiscardButton" Access="Public" Text="{Loc 'chem-master-window-discard-button'}" ToggleMode="True" StyleClasses="OpenLeft" />
</BoxContainer>

Expand All @@ -46,7 +45,7 @@

<ScrollContainer HorizontalExpand="True" MinSize="0 200">
<!-- Buffer reagent list -->
<BoxContainer Name="StorageBufferInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<BoxContainer Name="BufferInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-buffer-empty-text'}" />
</BoxContainer>
</ScrollContainer>
Expand All @@ -61,51 +60,28 @@
<Button MinSize="80 0" Name="OutputEjectButton" Access="Public" Text="{Loc 'chem-master-window-eject-button'}" />
</BoxContainer>

<PanelContainer VerticalExpand="True" MinSize="0 100">
<PanelContainer VerticalExpand="True" MinSize="0 200">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 100">
<ScrollContainer HorizontalExpand="True" MinSize="0 200">
<!-- Initially empty, when server sends state data this will have container contents and fill volume.-->
<BoxContainer Name="OutputContainerInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-no-container-loaded-text'}" />
</BoxContainer>
</ScrollContainer>
</PanelContainer>

<!-- Padding -->
<Control MinSize="0 10" />

<!-- Output Buffer Reagent List -->
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'chem-master-window-output-buffer-text'}" />
<Control HorizontalExpand="True" />
<Button MinSize="80 0" Name="OutputBufferDiscardButton" Access="Public" Text="{Loc 'chem-master-window-discard-button'}" ToggleMode="False" StyleClasses="OpenRight" />
</BoxContainer>

<PanelContainer VerticalExpand="True" MinSize="0 100">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>

<ScrollContainer HorizontalExpand="True" MinSize="0 100">
<!-- Initially empty, when server sends state data this will have container contents and fill volume.-->
<BoxContainer Name="OutputBufferInfo" Orientation="Vertical" Margin="4" HorizontalExpand="True">
<Label Text="{Loc 'chem-master-window-buffer-empty-text'}" />
</BoxContainer>
</ScrollContainer>
</PanelContainer>

<!-- Padding -->
<Control MinSize="0 10" />

<!-- Packaging -->
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'chem-master-window-packaging-text'}" />
<Control HorizontalExpand="True"/>
<!-- <Label Text="{Loc 'chem-master-window-buffer-label'}" />
<Label Name="BufferOutputVolume" StyleClasses="LabelSecondaryColor" /> -->
<Label Text="{Loc 'chem-master-window-buffer-label'}" />
<Label Name="BufferCurrentVolume" StyleClasses="LabelSecondaryColor" />
</BoxContainer>

<!-- Wrap the packaging info-->
Expand Down
39 changes: 23 additions & 16 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ChemMasterWindow()
Tabs.SetTabTitle(1, Loc.GetString("chem-master-window-output-tab"));
}

private ReagentButton MakeReagentButton(string text, ChemMasterReagentAmount amount, ReagentId id, bool isBuffer, string origin, string styleClass)
private ReagentButton MakeReagentButton(string text, ChemMasterReagentAmount amount, ReagentId id, bool isBuffer, string styleClass)
{
var reagentTransferButton = new ReagentButton(text, amount, id, isBuffer, styleClass);
reagentTransferButton.OnPressed += args
Expand Down Expand Up @@ -140,11 +140,9 @@ public void UpdateState(BoundUserInterfaceState state)

// Ensure the Panel Info is updated, including UI elements for Buffer Volume, Output Container and so on
UpdatePanelInfo(castState);

var output = castState.OutputContainerInfo;

//BufferOutputVolume.Text = $" {castState.BufferOutputVolume?.Int() ?? 0}u";


BufferCurrentVolume.Text = $" {castState.BufferCurrentVolume?.Int() ?? 0}u";

InputEjectButton.Disabled = castState.InputContainerInfo is null;
OutputEjectButton.Disabled = castState.OutputContainerInfo is null;
CreateBottleButton.Disabled = castState.OutputContainerInfo?.Reagents == null;
Expand Down Expand Up @@ -193,29 +191,40 @@ private void UpdateDosageFields(ChemMasterBoundUserInterfaceState castState)
/// <param name="state">State data sent by the server.</param>
private string GenerateLabel(ChemMasterBoundUserInterfaceState state)
{
if (state.BufferOutputVolume == 0)
if (state.BufferCurrentVolume == 0)
return "";

var reagent = state.BufferOutputReagents.OrderBy(r => r.Quantity).Last().Reagent;
var reagent = state.BufferReagents.OrderBy(r => r.Quantity).First().Reagent;
_prototypeManager.TryIndex(reagent.Prototype, out ReagentPrototype? proto);
return proto?.LocalizedName ?? "";
}

private void UpdateBufferInfo(BoxContainer bufferInfo, IReadOnlyList<ReagentQuantity> bufferReagents, FixedPoint2? bufferVolume, bool isStorageBuffer, string bufferName)
/// <summary>
/// Update the container, buffer, and packaging panels.
/// </summary>
/// <param name="state">State data for the dispenser.</param>
private void UpdatePanelInfo(ChemMasterBoundUserInterfaceState state)
{
bufferInfo.Children.Clear();
BufferTransferButton.Pressed = state.Mode == ChemMasterMode.Transfer;
BufferDiscardButton.Pressed = state.Mode == ChemMasterMode.Discard;

BuildContainerUI(InputContainerInfo, state.InputContainerInfo, true);
BuildContainerUI(OutputContainerInfo, state.OutputContainerInfo, false);

if (!bufferReagents.Any())
BufferInfo.Children.Clear();

if (!state.BufferReagents.Any())
{
bufferInfo.Children.Add(new Label { Text = Loc.GetString("chem-master-window-buffer-empty-text") });
BufferInfo.Children.Add(new Label { Text = Loc.GetString("chem-master-window-buffer-empty-text") });

return;
}

var bufferHBox = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal
};
bufferInfo.AddChild(bufferHBox);
BufferInfo.AddChild(bufferHBox);

var bufferLabel = new Label { Text = $"{Loc.GetString("chem-master-window-buffer-label")} " };
bufferHBox.AddChild(bufferLabel);
Expand Down Expand Up @@ -361,15 +370,13 @@ public sealed class ReagentButton : Button
{
public ChemMasterReagentAmount Amount { get; set; }
public bool IsBuffer = true;
public string Origin { get; set; }
public ReagentId Id { get; set; }
public ReagentButton(string text, ChemMasterReagentAmount amount, ReagentId id, bool isBuffer, string origin, string styleClass)
public ReagentButton(string text, ChemMasterReagentAmount amount, ReagentId id, bool isBuffer, string styleClass)
{
AddStyleClass(styleClass);
Text = text;
Amount = amount;
Id = id;
Origin = origin;
IsBuffer = isBuffer;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Chemistry/Components/ChemMasterComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed partial class ChemMasterComponent : Component
public uint PillType = 0;

[DataField("mode"), ViewVariables(VVAccess.ReadWrite)]
public ChemMasterMode Mode = ChemMasterMode.Storage;
public ChemMasterMode Mode = ChemMasterMode.Transfer;

[DataField("pillDosageLimit", required: true), ViewVariables(VVAccess.ReadWrite)]
public uint PillDosageLimit;
Expand Down
Loading

0 comments on commit ec6e06b

Please sign in to comment.