Adds pills type selection and pills canister (#5539)
* Added pill type selection Ui textures missing for now * bugfixes * Pill type selection * ui changes * Added pills canister * Change requests
This commit is contained in:
@@ -38,13 +38,19 @@ namespace Content.Client.Chemistry.UI
|
||||
_window.OnClose += Close;
|
||||
|
||||
//Setup static button actions.
|
||||
_window.EjectButton.OnPressed += _ => PrepareData(UiAction.Eject, null, null, null);
|
||||
_window.BufferTransferButton.OnPressed += _ => PrepareData(UiAction.Transfer, null, null, null);
|
||||
_window.BufferDiscardButton.OnPressed += _ => PrepareData(UiAction.Discard, null, null, null);
|
||||
_window.CreatePillButton.OnPressed += _ => PrepareData(UiAction.CreatePills, null, _window.PillAmount.Value, null);
|
||||
_window.CreateBottleButton.OnPressed += _ => PrepareData(UiAction.CreateBottles, null, null, _window.BottleAmount.Value);
|
||||
_window.EjectButton.OnPressed += _ => PrepareData(UiAction.Eject, null, null, null, null);
|
||||
_window.BufferTransferButton.OnPressed += _ => PrepareData(UiAction.Transfer, null, null, null, null);
|
||||
_window.BufferDiscardButton.OnPressed += _ => PrepareData(UiAction.Discard, null, null, null, null);
|
||||
_window.CreatePillButton.OnPressed += _ => PrepareData(UiAction.CreatePills, null, null, _window.PillAmount.Value, null);
|
||||
_window.CreateBottleButton.OnPressed += _ => PrepareData(UiAction.CreateBottles, null, null, null, _window.BottleAmount.Value);
|
||||
|
||||
_window.OnChemButtonPressed += (args, button) => PrepareData(UiAction.ChemButton, button, null, null);
|
||||
for(uint i = 0; i < _window.PillTypeButtons.Length; i++)
|
||||
{
|
||||
uint type = i;
|
||||
_window.PillTypeButtons[i].OnPressed += _ => PrepareData(UiAction.SetPillType, null, type + 1, null, null);
|
||||
}
|
||||
|
||||
_window.OnChemButtonPressed += (args, button) => PrepareData(UiAction.ChemButton, button, null, null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -63,15 +69,15 @@ namespace Content.Client.Chemistry.UI
|
||||
_window?.UpdateState(castState); //Update window state
|
||||
}
|
||||
|
||||
private void PrepareData(UiAction action, ChemButton? button, int? pillAmount, int? bottleAmount)
|
||||
private void PrepareData(UiAction action, ChemButton? button, uint? pillType, int? pillAmount, int? bottleAmount)
|
||||
{
|
||||
if (button != null)
|
||||
{
|
||||
SendMessage(new UiActionMessage(action, button.Amount, button.Id, button.isBuffer, null, null));
|
||||
SendMessage(new UiActionMessage(action, button.Amount, button.Id, button.IsBuffer, null, null, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(new UiActionMessage(action, null, null, null, pillAmount, bottleAmount));
|
||||
SendMessage(new UiActionMessage(action, null, null, null, pillType, pillAmount, bottleAmount));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
MinSize="400 525"
|
||||
@@ -72,6 +72,15 @@
|
||||
<!-- Packaging Info -->
|
||||
<BoxContainer Orientation="Vertical"
|
||||
HorizontalExpand="True">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<!-- Pills Type Buttons -->
|
||||
<Label Text="{Loc 'chem-master-window-pill-type-label'}"/>
|
||||
<Control HorizontalExpand="True"
|
||||
MinSize="50 0"></Control>
|
||||
<GridContainer Name="Grid" Columns="10">
|
||||
<!-- Pills type buttons are generated in the code -->
|
||||
</GridContainer>
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'chem-master-window-pills-label'}" />
|
||||
<Control HorizontalExpand="True"
|
||||
|
||||
@@ -6,14 +6,17 @@ using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.Chemistry.Components.SharedChemMasterComponent;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
|
||||
@@ -27,6 +30,9 @@ namespace Content.Client.Chemistry.UI
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
public event Action<BaseButton.ButtonEventArgs, ChemButton>? OnChemButtonPressed;
|
||||
public readonly Button[] PillTypeButtons;
|
||||
|
||||
private const string PillsRsiPath = "/Textures/Objects/Specific/Chemistry/pills.rsi";
|
||||
|
||||
private static bool IsSpinValid(int n)
|
||||
{
|
||||
@@ -42,6 +48,47 @@ namespace Content.Client.Chemistry.UI
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
//Pill type selection buttons, in total there are 20 pills.
|
||||
//Pill rsi file should have states named as pill1, pill2, and so on.
|
||||
var resourcePath = new ResourcePath(PillsRsiPath);
|
||||
var pillTypeGroup = new ButtonGroup();
|
||||
PillTypeButtons = new Button[20];
|
||||
for (uint i = 0; i < PillTypeButtons.Length; i++)
|
||||
{
|
||||
//For every button decide which stylebase to have
|
||||
//Every row has 10 buttons
|
||||
String styleBase = StyleBase.ButtonOpenBoth;
|
||||
uint modulo = i % 10;
|
||||
if (i > 0 && modulo == 0)
|
||||
styleBase = StyleBase.ButtonOpenRight;
|
||||
else if (i > 0 && modulo == 9)
|
||||
styleBase = StyleBase.ButtonOpenLeft;
|
||||
else if (i == 0)
|
||||
styleBase = StyleBase.ButtonOpenRight;
|
||||
|
||||
//Generate buttons
|
||||
PillTypeButtons[i] = new Button
|
||||
{
|
||||
Access = AccessLevel.Public,
|
||||
StyleClasses = { styleBase },
|
||||
MaxSize = (42, 28),
|
||||
Group = pillTypeGroup
|
||||
};
|
||||
|
||||
|
||||
//Generate buttons textures
|
||||
var specifier = new SpriteSpecifier.Rsi(resourcePath, "pill" + (i + 1));
|
||||
TextureRect pillTypeTexture = new TextureRect
|
||||
{
|
||||
Texture = specifier.Frame0(),
|
||||
TextureScale = (1.75f, 1.75f),
|
||||
Stretch = TextureRect.StretchMode.KeepCentered,
|
||||
};
|
||||
|
||||
PillTypeButtons[i].AddChild(pillTypeTexture);
|
||||
Grid.AddChild(PillTypeButtons[i]);
|
||||
}
|
||||
|
||||
PillAmount.IsValid = IsSpinValid;
|
||||
BottleAmount.IsValid = IsSpinValid;
|
||||
PillAmount.InitDefaultButtons();
|
||||
@@ -70,6 +117,8 @@ namespace Content.Client.Chemistry.UI
|
||||
ButtonHelpers.SetButtonDisabledRecursive(Contents, !castState.HasPower);
|
||||
EjectButton.Disabled = !castState.HasBeaker;
|
||||
}
|
||||
|
||||
PillTypeButtons[castState.SelectedPillType - 1].Pressed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -206,15 +255,15 @@ namespace Content.Client.Chemistry.UI
|
||||
public class ChemButton : Button
|
||||
{
|
||||
public FixedPoint2 Amount { get; set; }
|
||||
public bool isBuffer = true;
|
||||
public bool IsBuffer = true;
|
||||
public string Id { get; set; }
|
||||
public ChemButton(string _text, FixedPoint2 _amount, string _id, bool _isBuffer, string _styleClass)
|
||||
public ChemButton(string text, FixedPoint2 amount, string id, bool isBuffer, string styleClass)
|
||||
{
|
||||
AddStyleClass(_styleClass);
|
||||
Text = _text;
|
||||
Amount = _amount;
|
||||
Id = _id;
|
||||
isBuffer = _isBuffer;
|
||||
AddStyleClass(styleClass);
|
||||
Text = text;
|
||||
Amount = amount;
|
||||
Id = id;
|
||||
IsBuffer = isBuffer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user