Convert ChemDispenser Window to XAML UI (#5040)
* Appease the Github diff * Complete the rest of the UI * Change access to public
This commit is contained in:
49
Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml
Normal file
49
Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml
Normal file
@@ -0,0 +1,49 @@
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
Title="{Loc 'reagent-dispenser-bound-user-interface-title'}"
|
||||
SetSize="590 450"
|
||||
MinSize="590 450">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'reagent-dispenser-window-amount-to-dispense-label'}"/>
|
||||
<Control MinSize="20 0"></Control>
|
||||
<Button Name="DispenseButton1" Access="Public" Text="1" StyleClasses="OpenRight"/>
|
||||
<Button Name="DispenseButton5" Access="Public" Text="5" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton10" Access="Public" Text="10" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton15" Access="Public" Text="15" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton20" Access="Public" Text="20" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton25" Access="Public" Text="25" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton30" Access="Public" Text="25" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton50" Access="Public" Text="50" StyleClasses="OpenBoth"/>
|
||||
<Button Name="DispenseButton100" Access="Public" Text="100" StyleClasses="OpenLeft"/>
|
||||
</BoxContainer>
|
||||
<Control MinSize="0 10"/>
|
||||
<GridContainer Name="ChemicalList" Access="Public" Columns="5">
|
||||
</GridContainer>
|
||||
<Control MinSize="0 10"/>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'reagent-dispenser-window-container-label'}"/>
|
||||
<Button Name="ClearButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'reagent-dispenser-window-clear-button'}"
|
||||
StyleClasses="OpenRight"/>
|
||||
<Button Name="EjectButton"
|
||||
Access="Public"
|
||||
Text="{Loc 'reagent-dispenser-window-eject-button'}"
|
||||
StyleClasses="OpenLeft"/>
|
||||
</BoxContainer>
|
||||
<Control MinSize="0 10"/>
|
||||
<PanelContainer VerticalExpand="True"
|
||||
SizeFlagsStretchRatio="6"
|
||||
MinSize="0 150">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#1b1b1e" />
|
||||
</PanelContainer.PanelOverride>
|
||||
<BoxContainer Name="ContainerInfo"
|
||||
Orientation="Vertical"
|
||||
HorizontalExpand="True">
|
||||
<Label Text="{Loc 'reagent-dispenser-window-no-container-loaded-text'}"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</SS14Window>
|
||||
@@ -3,14 +3,13 @@ using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Shared.Chemistry.Dispenser;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.Chemistry.Dispenser.SharedReagentDispenserComponent;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
@@ -20,133 +19,30 @@ namespace Content.Client.Chemistry.UI
|
||||
/// <summary>
|
||||
/// Client-side UI used to control a <see cref="SharedReagentDispenserComponent"/>
|
||||
/// </summary>
|
||||
public class ReagentDispenserWindow : SS14Window
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class ReagentDispenserWindow : SS14Window
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
/// <summary>Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.</summary>
|
||||
private readonly BoxContainer ContainerInfo;
|
||||
|
||||
/// <summary>Sets the dispense amount to 1 when pressed.</summary>
|
||||
public Button DispenseButton1 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 5 when pressed.</summary>
|
||||
public Button DispenseButton5 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 10 when pressed.</summary>
|
||||
public Button DispenseButton10 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 15 when pressed.</summary>
|
||||
public Button DispenseButton15 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 20 when pressed.</summary>
|
||||
public Button DispenseButton20 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 25 when pressed.</summary>
|
||||
public Button DispenseButton25 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 30 when pressed.</summary>
|
||||
public Button DispenseButton30 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 50 when pressed.</summary>
|
||||
public Button DispenseButton50 { get; }
|
||||
|
||||
/// <summary>Sets the dispense amount to 100 when pressed.</summary>
|
||||
public Button DispenseButton100 { get; }
|
||||
|
||||
/// <summary>Ejects the reagent container from the dispenser.</summary>
|
||||
public Button ClearButton { get; }
|
||||
|
||||
/// <summary>Removes all reagents from the reagent container.</summary>
|
||||
public Button EjectButton { get; }
|
||||
|
||||
/// <summary>A grid of buttons for each reagent which can be dispensed.</summary>
|
||||
public GridContainer ChemicalList { get; }
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public ReagentDispenserWindow()
|
||||
{
|
||||
SetSize = MinSize = (590, 400);
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
var dispenseAmountGroup = new ButtonGroup();
|
||||
|
||||
Contents.AddChild(new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
Children =
|
||||
{
|
||||
//First, our dispense amount buttons
|
||||
new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal,
|
||||
Children =
|
||||
{
|
||||
new Label {Text = Loc.GetString("reagent-dispenser-window-amount-to-dispense-label")},
|
||||
//Padding
|
||||
new Control {MinSize = (20, 0)},
|
||||
(DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenRight }}),
|
||||
(DispenseButton5 = new Button {Text = "5", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton10 = new Button {Text = "10", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton15 = new Button {Text = "15", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton20 = new Button {Text = "20", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton25 = new Button {Text = "25", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton30 = new Button {Text = "30", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton50 = new Button {Text = "50", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenBoth }}),
|
||||
(DispenseButton100 = new Button {Text = "100", Group = dispenseAmountGroup, StyleClasses = { StyleBase.ButtonOpenLeft }}),
|
||||
}
|
||||
},
|
||||
//Padding
|
||||
new Control {MinSize = (0.0f, 10.0f)},
|
||||
//Grid of which reagents can be dispensed.
|
||||
(ChemicalList = new GridContainer
|
||||
{
|
||||
Columns = 5
|
||||
}),
|
||||
//Padding
|
||||
new Control {MinSize = (0.0f, 10.0f)},
|
||||
new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal,
|
||||
Children =
|
||||
{
|
||||
new Label {Text = Loc.GetString("reagent-dispenser-window-container-label") + " "},
|
||||
(ClearButton = new Button {Text = Loc.GetString("reagent-dispenser-window-clear-button"), StyleClasses = {StyleBase.ButtonOpenRight}}),
|
||||
(EjectButton = new Button {Text = Loc.GetString("reagent-dispenser-window-eject-button"), StyleClasses = {StyleBase.ButtonOpenLeft}})
|
||||
}
|
||||
},
|
||||
//Wrap the container info in a PanelContainer so we can color it's background differently.
|
||||
new PanelContainer
|
||||
{
|
||||
VerticalExpand = true,
|
||||
SizeFlagsStretchRatio = 6,
|
||||
MinSize = (0, 150),
|
||||
PanelOverride = new StyleBoxFlat
|
||||
{
|
||||
BackgroundColor = new Color(27, 27, 30)
|
||||
},
|
||||
Children =
|
||||
{
|
||||
//Currently empty, when server sends state data this will have container contents and fill volume.
|
||||
(ContainerInfo = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
HorizontalExpand = true,
|
||||
Children =
|
||||
{
|
||||
new Label
|
||||
{
|
||||
Text = Loc.GetString("reagent-dispenser-window-no-container-loaded-text")
|
||||
}
|
||||
}
|
||||
}),
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
DispenseButton1.Group = dispenseAmountGroup;
|
||||
DispenseButton5.Group = dispenseAmountGroup;
|
||||
DispenseButton10.Group = dispenseAmountGroup;
|
||||
DispenseButton15.Group = dispenseAmountGroup;
|
||||
DispenseButton20.Group = dispenseAmountGroup;
|
||||
DispenseButton25.Group = dispenseAmountGroup;
|
||||
DispenseButton30.Group = dispenseAmountGroup;
|
||||
DispenseButton50.Group = dispenseAmountGroup;
|
||||
DispenseButton10.Group = dispenseAmountGroup;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
Reference in New Issue
Block a user