Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Client/Cargo/UI/CargoPalletMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public CargoPalletMenu()

public void SetAppraisal(int amount)
{
AppraisalLabel.Text = BankSystemExtensions.ToSpesoString(amount); // Frontier: custom speso formatting
AppraisalLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", amount.ToString()));
}

public void SetCount(int count)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Client.Cargo.UI;
using Content.Client._NF.Cargo.UI;
using Content.Shared._NF.Cargo.BUI;
using Content.Shared.Cargo.Events;
using Robust.Client.UserInterface;
Expand All @@ -9,7 +9,7 @@ namespace Content.Client._NF.Cargo.BUI;
public sealed class CargoPalletConsoleNFBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private CargoPalletMenu? _menu;
private NFCargoPalletMenu? _menu;

public CargoPalletConsoleNFBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
Expand All @@ -21,7 +21,7 @@ protected override void Open()

if (_menu == null)
{
_menu = this.CreateWindow<CargoPalletMenu>();
_menu = this.CreateWindow<NFCargoPalletMenu>();
_menu.AppraiseRequested += OnAppraisal;
_menu.SellRequested += OnSell;
}
Expand All @@ -44,8 +44,7 @@ protected override void UpdateState(BoundUserInterfaceState state)
if (state is not NFCargoPalletConsoleInterfaceState palletState)
return;

_menu?.UpdateValues(palletState.Appraisal, palletState.Count, palletState.MarketModifier, palletState.MarketOffer - palletState.Appraisal, palletState.MarketOffer);
_menu?.SetEnabled(palletState.Enabled);
_menu?.SetAppraisal(palletState.Appraisal);
_menu?.SetCount(palletState.Count);
}
}
37 changes: 37 additions & 0 deletions Content.Client/_NF/Cargo/UI/NFCargoPalletMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!-- Significantly adapted from Content.Client/Cargo/UI/CargoPalletMenu.xaml -->
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
MinSize="300 150"
MaxWidth="300"
Title="{Loc 'cargo-pallet-console-menu-title'}">
<BoxContainer Orientation="Vertical" Margin="5">
<RichTextLabel Name="ModifierRateLabel" HorizontalExpand="True"/>
<controls:TableContainer Columns="2" Name="AppraisalContainer">
<Label Text="{Loc 'cargo-pallet-menu-appraisal-label'}"
StyleClasses="LabelKeyText" />
<Label Name="AppraisalLabel"
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />

<Label Name="ModifierLabel"
Text="{Loc 'cargo-pallet-menu-modifier-label-positive'}"
StyleClasses="LabelKeyText" />
<Label Name="ModifierValueLabel"
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />

<Label Text="{Loc 'cargo-pallet-menu-total-label'}"
StyleClasses="LabelKeyText" />
<Label Name="TotalLabel"
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />

<Label Text="{Loc 'cargo-pallet-menu-count-label'}"
StyleClasses="LabelKeyText" />
<Label Name="CountLabel"
Text="{Loc 'cargo-pallet-menu-no-goods-text'}" />
</controls:TableContainer>
<Button Name="AppraiseButton"
Text="{Loc 'cargo-pallet-appraise-button'}"/>
<Button Name="SellButton"
Text="{Loc 'cargo-pallet-sell-button'}"/>
<TextureButton VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
77 changes: 77 additions & 0 deletions Content.Client/_NF/Cargo/UI/NFCargoPalletMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._NF.Bank;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._NF.Cargo.UI;

[GenerateTypedNameReferences]
public sealed partial class NFCargoPalletMenu : FancyWindow
{
public Action? SellRequested;
public Action? AppraiseRequested;

public NFCargoPalletMenu()
{
RobustXamlLoader.Load(this);
SellButton.OnPressed += OnSellPressed;
AppraiseButton.OnPressed += OnAppraisePressed;
}

public void UpdateValues(
int amount,
int count,
float modifier,
int modifierSpesos,
int total)
{
AppraisalLabel.Text = BankSystemExtensions.ToSpesoString(amount);
CountLabel.Text = count.ToString();

var modifierPercentage = (modifier - 1.0) * 100;
if (modifier > 1.0)
{
ModifierLabel.Text = Loc.GetString("cargo-pallet-menu-modifier-label-positive");
ModifierRateLabel.Text = Loc.GetString(
"cargo-pallet-menu-modifier-rate-label-positive",
("modifier", modifierPercentage));
ModifierRateLabel.Visible = true;
}
else if (modifier < 1.0)
{
ModifierLabel.Text = Loc.GetString("cargo-pallet-menu-modifier-label-negative");
ModifierRateLabel.Text = Loc.GetString(
"cargo-pallet-menu-modifier-rate-label-negative",
("modifier", -modifierPercentage));
ModifierRateLabel.Visible = true;
}
else
{
ModifierLabel.Text = Loc.GetString("cargo-pallet-menu-modifier-label-neutral");
ModifierRateLabel.Visible = false;
}

ModifierValueLabel.Text = BankSystemExtensions.ToSpesoString(modifierSpesos);
TotalLabel.Text = BankSystemExtensions.ToSpesoString(total);
// Re-layout the table in case the displayed values need a different amount of space than before (items added or
// removed)
AppraisalContainer.InvalidateMeasure();
}

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();
}
}
20 changes: 12 additions & 8 deletions Content.Server/_NF/Cargo/Systems/NFCargoSystem.Pallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Content.Shared.Mobs;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using System.Numerics;
using Content.Shared.Coordinates;
using Robust.Shared.Random;

Expand Down Expand Up @@ -41,20 +40,25 @@ private void UpdatePalletConsoleInterface(Entity<NFCargoPalletConsoleComponent>
if (Transform(ent).GridUid is not EntityUid gridUid)
{
_ui.SetUiState(ent.Owner, CargoPalletConsoleUiKey.Sale,
new NFCargoPalletConsoleInterfaceState(0, 0, false));
new NFCargoPalletConsoleInterfaceState());
return;
}

// Modify prices based on modifier.
GetPalletGoods(ent, gridUid, out var toSell, out var amount, out var noModAmount, out Dictionary<string, double> additionalCurrency);
var modifier = 1.0f;
if (TryComp<MarketModifierComponent>(ent, out var priceMod))
{
amount *= priceMod.Mod;
modifier = priceMod.Mod;
}
amount += noModAmount;

_ui.SetUiState(ent.Owner, CargoPalletConsoleUiKey.Sale,
new NFCargoPalletConsoleInterfaceState((int)amount, toSell.Count, true));
new NFCargoPalletConsoleInterfaceState(
(int)(amount + noModAmount),
toSell.Count,
modifier,
(int)(amount * modifier + noModAmount),
true));
}

private void OnPalletUIOpen(Entity<NFCargoPalletConsoleComponent> ent, ref BoundUIOpenedEvent args)
Expand Down Expand Up @@ -197,7 +201,7 @@ private void GetPalletGoods(Entity<NFCargoPalletConsoleComponent> consoleUid, En
noMultiplierAmount += price;
else
amount += price;

// Check for any additional currency payouts
if (TryComp(ent, out AdditionalPalletCurrencyComponent? currencyComponent))
{
Expand Down Expand Up @@ -250,7 +254,7 @@ private void OnPalletSale(Entity<NFCargoPalletConsoleComponent> ent, ref CargoPa
if (xform.GridUid is not EntityUid gridUid)
{
_ui.SetUiState(ent.Owner, CargoPalletConsoleUiKey.Sale,
new NFCargoPalletConsoleInterfaceState(0, 0, false));
new NFCargoPalletConsoleInterfaceState());
return;
}

Expand All @@ -268,7 +272,7 @@ private void OnPalletSale(Entity<NFCargoPalletConsoleComponent> ent, ref CargoPa
var stackUid = _stack.Spawn((int)price, stackPrototype, args.Actor.ToCoordinates());
if (!_hands.TryPickupAnyHand(args.Actor, stackUid))
_transform.SetLocalRotation(stackUid, Angle.Zero); // Orient these to grid north instead of map north

// Iterate through additional currency payouts, putting them in hand if possible
foreach (var (currencyId, currencyAmount) in additionalCurrency)
{
Expand Down
15 changes: 15 additions & 0 deletions Content.Shared/_NF/Cargo/BUI/NFCargoPalletConsoleInterfaceState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ namespace Content.Shared._NF.Cargo.BUI;
public sealed class NFCargoPalletConsoleInterfaceState(
int appraisal,
int count,
float marketModifier,
int marketOffer,
bool enabled) : BoundUserInterfaceState
{
public NFCargoPalletConsoleInterfaceState() : this(0, 0, 1.0f, 0, false) { }

/// <summary>
/// The estimated apraised value of all the entities on top of pallets on the same grid as the console.
/// </summary>
Expand All @@ -18,6 +22,17 @@ public sealed class NFCargoPalletConsoleInterfaceState(
/// </summary>
public int Count = count;

/// <summary>
/// The market modifier on the cargo console.
/// </summary>
public float MarketModifier = marketModifier;

/// <summary>
/// The sale price the market offers. This may be different from <code>Appraisal * MarketModifier</code> because
/// some entities are exempt from market modifiers.
/// </summary>
public int MarketOffer = marketOffer;

/// <summary>
/// True if the buttons should be enabled.
/// </summary>
Expand Down
11 changes: 11 additions & 0 deletions Resources/Locale/en-US/cargo/cargo-pallet-console-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,14 @@ cargo-pallet-menu-appraisal-label = Estimated Value:{" "}
cargo-pallet-menu-count-label = Number of sale items:{" "}
cargo-pallet-appraise-button = Appraise
cargo-pallet-sell-button = Sell

# Frontier
cargo-pallet-menu-modifier-rate-label-positive = Nanotrasen will subsidize trade in the sector with a bonus of [color=green]{$modifier}%[/color] for most items sold here.
cargo-pallet-menu-modifier-rate-label-negative = Nanotrasen will charge a handling fee of [color=red]{$modifier}%[/color] on most items sold here.

cargo-pallet-menu-modifier-label-positive = Bonus:{" "}
cargo-pallet-menu-modifier-label-neutral = {cargo-pallet-menu-modifier-label-negative}
cargo-pallet-menu-modifier-label-negative = Fee:{" "}

cargo-pallet-menu-total-label = Total:{" "}
# End Frontier
Loading