Skip to content

Commit

Permalink
fixes fixes fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MilonPL committed Nov 4, 2024
1 parent 26a557d commit 8e9dc43
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 32 deletions.
14 changes: 10 additions & 4 deletions Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Shared.Access.Systems;
using Content.Shared.Shipyard;
using Content.Shared.Whitelist;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Shared.Prototypes;

Expand Down Expand Up @@ -52,9 +51,16 @@ protected override void Dispose(bool disposing)
{
base.Dispose(disposing);

_menu?.Close();
if (disposing)
_menu?.Dispose();
if (!disposing)
return;

if (_menu == null)
return;

_menu.OnClose -= Close;
_menu.OnPurchased -= Purchase;
_menu.Close();
_menu = null;
}

private void Purchase(string id)
Expand Down
1 change: 0 additions & 1 deletion Content.Client/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<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="500 360"
MinSize="460 280"
Expand Down
8 changes: 3 additions & 5 deletions Content.Client/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
using Content.Shared.Shipyard.Prototypes;
using Content.Shared.Whitelist;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;

Expand All @@ -20,8 +18,8 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow

public event Action<string>? OnPurchased;

private readonly List<VesselPrototype> _vessels = new();
private readonly List<string> _categories = new();
private readonly List<VesselPrototype> _vessels = [];
private readonly List<string> _categories = [];

public Entity<ShipyardConsoleComponent> Console;
private string? _category;
Expand Down Expand Up @@ -80,7 +78,7 @@ private void PopulateProducts()
var search = SearchBar.Text.Trim().ToLowerInvariant();
foreach (var vessel in _vessels)
{
if (search.Length != 0 && !vessel.Name.ToLowerInvariant().Contains(search))
if (search.Length != 0 && !vessel.Name.Contains(search, StringComparison.InvariantCultureIgnoreCase))
continue;
if (_category != null && !vessel.Categories.Contains(_category))
continue;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/DeltaV/Shipyard/UI/VesselRow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
HorizontalExpand="True">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True">
<Button Name="Purchase" Text="{Loc 'purchase'}" StyleClasses="LabelSubText" />
<Button Name="Purchase" Text="{Loc 'shipyard-console-purchase'}" StyleClasses="LabelSubText" />
<Label Name="VesselName" HorizontalExpand="True" />
<PanelContainer>
<PanelContainer.PanelOverride>
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/DeltaV/Shipyard/UI/VesselRow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public VesselRow(VesselPrototype vessel, bool access)
VesselName.Text = vessel.Name;

var tooltip = new Tooltip();
tooltip.SetMessage(FormattedMessage.FromMarkup(vessel.Description));
tooltip.SetMessage(FormattedMessage.FromMarkupOrThrow(vessel.Description));
Purchase.TooltipSupplier = _ => tooltip;
Purchase.Disabled = !access;
Purchase.OnPressed += _ => OnPurchasePressed?.Invoke();
Expand Down
7 changes: 3 additions & 4 deletions Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
using Content.Shared.Shipyard;
using Content.Shared.Shipyard.Prototypes;
using Content.Shared.Whitelist;
using Robust.Server.GameObjects;
using Robust.Shared.Random;
using System.Diagnostics.CodeAnalysis;

namespace Content.Server.Shipyard;

Expand All @@ -28,7 +26,8 @@ public override void Initialize()
base.Initialize();

SubscribeLocalEvent<ShipyardConsoleComponent, BankBalanceUpdatedEvent>(OnBalanceUpdated);
Subs.BuiEvents<ShipyardConsoleComponent>(ShipyardConsoleUiKey.Key, subs =>
Subs.BuiEvents<ShipyardConsoleComponent>(ShipyardConsoleUiKey.Key,
subs =>
{
subs.Event<BoundUIOpenedEvent>(OnOpened);
});
Expand Down Expand Up @@ -63,7 +62,7 @@ protected override void TryPurchase(Entity<ShipyardConsoleComponent> ent, Entity

_cargo.UpdateBankAccount(bank, bank.Comp, -vessel.Price);

var message = Loc.GetString("shipyard-console-docking", ("vessel", vessel.Name.ToString()));
var message = Loc.GetString("shipyard-console-docking", ("vessel", vessel.Name));
_radio.SendRadioMessage(ent, message, ent.Comp.Channel, ent);
Audio.PlayPvs(ent.Comp.ConfirmSound, ent);
}
Expand Down
1 change: 0 additions & 1 deletion Content.Server/DeltaV/Shipyard/ShipyardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Shared.Tag;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using System.Diagnostics.CodeAnalysis;

namespace Content.Server.Shipyard;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public override void Initialize()
{
base.Initialize();

Subs.BuiEvents<ShipyardConsoleComponent>(ShipyardConsoleUiKey.Key, subs =>
Subs.BuiEvents<ShipyardConsoleComponent>(ShipyardConsoleUiKey.Key,
subs =>
{
subs.Event<ShipyardConsolePurchaseMessage>(OnPurchase);
});
Expand Down
18 changes: 4 additions & 14 deletions Content.Shared/DeltaV/Shipyard/ShipyardUi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,16 @@ public enum ShipyardConsoleUiKey : byte
}

[Serializable, NetSerializable]
public sealed class ShipyardConsoleState : BoundUserInterfaceState
public sealed class ShipyardConsoleState(int balance) : BoundUserInterfaceState
{
public readonly int Balance;

public ShipyardConsoleState(int balance)
{
Balance = balance;
}
public readonly int Balance = balance;
}

/// <summary>
/// Ask the server to purchase a vessel.
/// </summary>
[Serializable, NetSerializable]
public sealed class ShipyardConsolePurchaseMessage : BoundUserInterfaceMessage
public sealed class ShipyardConsolePurchaseMessage(string vessel) : BoundUserInterfaceMessage
{
public readonly ProtoId<VesselPrototype> Vessel;

public ShipyardConsolePurchaseMessage(string vessel)
{
Vessel = vessel;
}
public readonly ProtoId<VesselPrototype> Vessel = vessel;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ shipyard-console-menu-title = Shipyard Console
shipyard-console-error = Temporary embargo is in place, try later?
shipyard-console-docking = {$vessel} is en route to the station, eta 60 seconds.
shipyard-console-purchase = Purchase

0 comments on commit 8e9dc43

Please sign in to comment.