Skip to content

Commit

Permalink
Merge branch 'new-frontiers-14:master' into SW-KnuckleVerse
Browse files Browse the repository at this point in the history
  • Loading branch information
Batuh1n authored Feb 26, 2024
2 parents 46f3380 + 26eabc9 commit a27e822
Show file tree
Hide file tree
Showing 155 changed files with 19,534 additions and 6,866 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Content.Client._NF.Contraband.UI;
using Content.Shared._NF.Contraband.BUI;
using Content.Shared._NF.Contraband.Events;
using Robust.Shared.Utility;

namespace Content.Client._NF.Contraband.BUI;

public sealed class ContrabandPalletConsoleBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private ContrabandPalletMenu? _menu;

public ContrabandPalletConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();
var disclaimer = new FormattedMessage();
disclaimer.AddText(Loc.GetString($"contraband-pallet-disclaimer"));
_menu = new ContrabandPalletMenu();
_menu.AppraiseRequested += OnAppraisal;
_menu.SellRequested += OnSell;
_menu.OnClose += Close;
_menu.Disclaimer.SetMessage(disclaimer);
_menu.OpenCentered();
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_menu?.Dispose();
}
}

private void OnAppraisal()
{
SendMessage(new ContrabandPalletAppraiseMessage());
}

private void OnSell()
{
SendMessage(new ContrabandPalletSellMessage());
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (state is not ContrabandPalletConsoleInterfaceState palletState)
return;

_menu?.SetEnabled(palletState.Enabled);
_menu?.SetAppraisal(palletState.Appraisal);
_menu?.SetCount(palletState.Count);
}
}
28 changes: 28 additions & 0 deletions Content.Client/_NF/Contraband/UI/ContrabandPalletMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<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 196"
MinSize="300 196">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" SetHeight="24">
<Label Text="{Loc 'contraband-pallet-menu-appraisal-label'}"
StyleClasses="LabelKeyText" />
<Label Name="AppraisalLabel"
Text="{Loc 'contraband-pallet-menu-no-goods-text'}" />
</BoxContainer>
<BoxContainer Orientation="Horizontal" SetHeight="24">
<Label Text="{Loc 'contraband-pallet-menu-count-label'}"
StyleClasses="LabelKeyText" />
<Label Name="CountLabel"
Text="{Loc 'contraband-pallet-menu-no-goods-text'}" />
</BoxContainer>
<BoxContainer Orientation = "Horizontal" VerticalExpand = "False" SetHeight="58">
<RichTextLabel Name="Disclaimer" Access="Public" StyleClasses="LabelSubText"/>
</BoxContainer>
<Button Name="AppraiseButton"
Text="{Loc 'contraband-pallet-appraise-button'}"/>
<Button Name="SellButton"
Text="{Loc 'contraband-pallet-sell-button'}"/>
<TextureButton VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
47 changes: 47 additions & 0 deletions Content.Client/_NF/Contraband/UI/ContrabandPalletMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Client.UserInterface.Controls;
using Content.Shared._NF.Contraband.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._NF.Contraband.UI;

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

public ContrabandPalletMenu()
{
RobustXamlLoader.Load(this);
SellButton.OnPressed += OnSellPressed;
AppraiseButton.OnPressed += OnAppraisePressed;
Title = Loc.GetString("contraband-pallet-console-menu-title");
}

public void SetAppraisal(int amount)
{
AppraisalLabel.Text = Loc.GetString("contraband-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();
}
}
7 changes: 5 additions & 2 deletions Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,12 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com
// Log order approval
_adminLogger.Add(LogType.Action, LogImpact.Low,
$"{ToPrettyString(player):user} approved order [orderId:{order.OrderId}, quantity:{order.OrderQuantity}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bankAccount.Balance}");
if (TryComp<StationBankAccountComponent>(_station.GetOwningStation(uid), out var stationBank))

var stationQuery = EntityQuery<StationBankAccountComponent>();

foreach (var stationBankComp in stationQuery)
{
DeductFunds(stationBank, (int) -(Math.Floor(cost * 0.65f)));
DeductFunds(stationBankComp, (int) -(Math.Floor(cost * 0.45f)));
}
_bankSystem.TryBankWithdraw(player, cost);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Construction.Components
{
/// <summary>
/// Used for construction graphs in building tabletop computers.
/// </summary>
[RegisterComponent]
public sealed partial class ComputerTabletopBoardComponent : Component
{
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Prototype { get; private set; }
}
}
8 changes: 8 additions & 0 deletions Content.Server/Construction/NodeEntities/BoardNodeEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ public sealed partial class BoardNodeEntity : IGraphNodeEntity

var board = container.ContainedEntities[0];

// Frontier - adds tabletop variants
if (args.EntityManager.TryGetComponent(container.Owner, out ConstructionComponent? constructionComponent)
&& constructionComponent.Graph == "GraphComputerTabletop"
&& args.EntityManager.TryGetComponent(board, out ComputerTabletopBoardComponent? tabletopComputer))
{
return tabletopComputer.Prototype;
}

// There should not be a case where both of these components exist on the same entity...
if (args.EntityManager.TryGetComponent(board, out MachineBoardComponent? machine))
return machine.Prototype;
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Database/ServerBanDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public string FormatBanMessage(IConfigurationManager cfg, ILocalizationManager l
{loc.GetString("ban-banned-2", ("reason", Reason))}
{expires}
{loc.GetString("ban-banned-3")}
{loc.GetString("ban-banned-4")}
""";
}
}
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Power/Pow3r/BatteryRampPegSolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,9 @@ private void UpdateNetwork(Network network, PowerState state, float frameTime)

battery.SupplyRampTarget = battery.MaxEffectiveSupply * relativeTargetBatteryOutput - battery.CurrentReceiving * battery.Efficiency;

DebugTools.Assert(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency <= battery.LoadingNetworkDemand
|| MathHelper.CloseToPercent(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency, battery.LoadingNetworkDemand, 0.001));
// #Frontier - This is causing server crashes on debug builds, disabling it for now. Happens when big new group of demanding machines turn on causing a surge.
//DebugTools.Assert(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency <= battery.LoadingNetworkDemand
// || MathHelper.CloseToPercent(battery.SupplyRampTarget + battery.CurrentReceiving * battery.Efficiency, battery.LoadingNetworkDemand, 0.001));
}
}

Expand Down
7 changes: 5 additions & 2 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,13 @@ public void AuthorizedVend(EntityUid uid, EntityUid sender, InventoryType type,
{
if (TryEjectVendorItem(uid, type, itemId, component.CanShoot, bank.Balance, component))
{
if (TryComp<StationBankAccountComponent>(_station.GetOwningStation(uid), out var stationBank))
var stationQuery = EntityQuery<StationBankAccountComponent>();

foreach (var stationBankComp in stationQuery)
{
_cargo.DeductFunds(stationBank, (int) -(Math.Floor(totalPrice * 0.65f)));
_cargo.DeductFunds(stationBankComp, (int) -(Math.Floor(totalPrice * 0.45f)));
}

UpdateVendingMachineInterfaceState(uid, component, bank.Balance);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server._NF.Contraband.Components;

/// <summary>
/// Any entities intersecting when a shuttle is recalled will be sold.
/// </summary>
[RegisterComponent]
public sealed partial class ContrabandPalletComponent : Component {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Content.Server._NF.Contraband.Systems;
using Content.Shared.Stacks;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server._NF.Contraband.Components;

[RegisterComponent]
[Access(typeof(ContrabandSystem))]
public sealed partial class ContrabandPalletConsoleComponent : Component
{
[ViewVariables(VVAccess.ReadWrite), DataField("cashType", customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
public string RewardType = "FrontierUplinkCoin";
}
Loading

0 comments on commit a27e822

Please sign in to comment.