Cargo Pallet Sale Console (#14422)
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using Content.Client.Cargo.UI;
|
||||
using Content.Shared.Cargo.BUI;
|
||||
using Content.Shared.Cargo.Events;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Cargo.BUI;
|
||||
|
||||
public sealed class CargoPalletConsoleBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private CargoPalletMenu? _menu;
|
||||
|
||||
public CargoPalletConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
_menu = new CargoPalletMenu();
|
||||
_menu.AppraiseRequested += OnAppraisal;
|
||||
_menu.SellRequested += OnSell;
|
||||
_menu.OnClose += Close;
|
||||
|
||||
_menu.OpenCentered();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
if (disposing)
|
||||
{
|
||||
_menu?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppraisal()
|
||||
{
|
||||
SendMessage(new CargoPalletAppraiseMessage());
|
||||
}
|
||||
|
||||
private void OnSell()
|
||||
{
|
||||
SendMessage(new CargoPalletSellMessage());
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (state is not CargoPalletConsoleInterfaceState palletState)
|
||||
return;
|
||||
|
||||
_menu?.SetEnabled(palletState.Enabled);
|
||||
_menu?.SetAppraisal(palletState.Appraisal);
|
||||
_menu?.SetCount(palletState.Count);
|
||||
}
|
||||
}
|
||||
25
Content.Client/Cargo/UI/CargoPalletMenu.xaml
Normal file
25
Content.Client/Cargo/UI/CargoPalletMenu.xaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<controls:FancyWindow xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
SetSize="300 150"
|
||||
MinSize="300 150">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'cargo-pallet-menu-appraisal-label'}"
|
||||
StyleClasses="LabelKeyText" />
|
||||
<Label Name="AppraisalLabel"
|
||||
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />
|
||||
</BoxContainer>
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc 'cargo-pallet-menu-count-label'}"
|
||||
StyleClasses="LabelKeyText" />
|
||||
<Label Name="CountLabel"
|
||||
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />
|
||||
</BoxContainer>
|
||||
<Button Name="AppraiseButton"
|
||||
Text="{Loc 'cargo-pallet-appraise-button'}"/>
|
||||
<Button Name="SellButton"
|
||||
Text="{Loc 'cargo-pallet-sell-button'}"/>
|
||||
<TextureButton VerticalExpand="True" />
|
||||
</BoxContainer>
|
||||
</controls:FancyWindow>
|
||||
47
Content.Client/Cargo/UI/CargoPalletMenu.xaml.cs
Normal file
47
Content.Client/Cargo/UI/CargoPalletMenu.xaml.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.Cargo;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
|
||||
namespace Content.Client.Cargo.UI;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class CargoPalletMenu : FancyWindow
|
||||
{
|
||||
public Action? SellRequested;
|
||||
public Action? AppraiseRequested;
|
||||
|
||||
public CargoPalletMenu()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
SellButton.OnPressed += OnSellPressed;
|
||||
AppraiseButton.OnPressed += OnAppraisePressed;
|
||||
Title = Loc.GetString("cargo-pallet-console-menu-title");
|
||||
}
|
||||
|
||||
public void SetAppraisal(int amount)
|
||||
{
|
||||
AppraisalLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", amount.ToString()));
|
||||
}
|
||||
|
||||
public void SetCount(int count)
|
||||
{
|
||||
CountLabel.Text = count.ToString();
|
||||
}
|
||||
public void SetEnabled(bool enabled)
|
||||
{
|
||||
AppraiseButton.Disabled = !enabled;
|
||||
SellButton.Disabled = !enabled;
|
||||
}
|
||||
|
||||
private void OnSellPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
SellRequested?.Invoke();
|
||||
}
|
||||
|
||||
private void OnAppraisePressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
AppraiseRequested?.Invoke();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user