Skip to content

Commit

Permalink
Shuttles generators shipyard tab (#2271)
Browse files Browse the repository at this point in the history
* Code

* Shuttles

* Update decadedove.yml

* SM->Supermatter, NFSD classes, orders

* Remove Stealth FTL entry

* VesselPrototype: comment rewrites

---------

Co-authored-by: Whatstone <whatston3@gmail.com>
  • Loading branch information
dvir001 and whatston3 authored Oct 19, 2024
1 parent b3635ef commit bd89429
Show file tree
Hide file tree
Showing 90 changed files with 299 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private void Populate(List<string> availablePrototypes, List<string> unavailable
_menu.PopulateProducts(availablePrototypes, unavailablePrototypes, freeListings, validId);
_menu.PopulateCategories(availablePrototypes, unavailablePrototypes);
_menu.PopulateClasses(availablePrototypes, unavailablePrototypes);
_menu.PopulateEngines(availablePrototypes, unavailablePrototypes);
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand Down
7 changes: 5 additions & 2 deletions Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<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="600 500"
MinSize="600 300">
SetSize="640 500"
MinSize="640 300">
<BoxContainer Orientation="Vertical" Margin="5 0 5 0">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
Expand Down Expand Up @@ -32,6 +32,9 @@
<OptionButton Name="Classes"
Prefix="{Loc 'shipyard-console-menu-class-label'}"
HorizontalExpand="True" />
<OptionButton Name="Engines"
Prefix="{Loc 'shipyard-console-menu-engine-label'}"
HorizontalExpand="True" />
</BoxContainer>
<ScrollContainer HorizontalExpand="True"
VerticalExpand="True"
Expand Down
61 changes: 61 additions & 0 deletions Content.Client/Shipyard/UI/ShipyardConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow
private readonly ShipyardConsoleBoundUserInterface _menu;
private readonly List<VesselSize> _categoryStrings = new();
private readonly List<VesselClass> _classStrings = new();
private readonly List<VesselEngine> _engineStrings = new();
private VesselSize? _category;
private VesselClass? _class;
private VesselEngine? _engine;

private List<string> _lastAvailableProtos = new();
private List<string> _lastUnavailableProtos = new();
Expand All @@ -39,6 +41,7 @@ public ShipyardConsoleMenu(ShipyardConsoleBoundUserInterface owner)
SearchBar.OnTextChanged += OnSearchBarTextChanged;
Categories.OnItemSelected += OnCategoryItemSelected;
Classes.OnItemSelected += OnClassItemSelected;
Engines.OnItemSelected += OnEngineItemSelected;
SellShipButton.OnPressed += (args) => { OnSellShip?.Invoke(args); };
}

Expand All @@ -55,6 +58,12 @@ private void OnClassItemSelected(OptionButton.ItemSelectedEventArgs args)
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
}

private void OnEngineItemSelected(OptionButton.ItemSelectedEventArgs args)
{
SetEngineText(args.Id);
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
}

private void OnSearchBarTextChanged(LineEdit.LineEditEventArgs args)
{
PopulateProducts(_lastAvailableProtos, _lastUnavailableProtos, _freeListings, _validId);
Expand All @@ -70,6 +79,11 @@ private void SetClassText(int id)
_class = id == 0 ? null : _classStrings[id];
Classes.SelectId(id);
}
private void SetEngineText(int id)
{
_engine = id == 0 ? null : _engineStrings[id];
Engines.SelectId(id);
}
/// <summary>
/// Populates the list of products that will actually be shown, using the current filters.
/// </summary>
Expand Down Expand Up @@ -115,6 +129,8 @@ private void AddVesselsToControls(IEnumerable<VesselPrototype?> vessels, string
continue;
if (_class != null && !prototype!.Classes.Contains(_class.Value))
continue;
if (_engine != null && !prototype!.Engines.Contains(_engine.Value))
continue;
if (search.Length > 0 && !prototype!.Name.ToLowerInvariant().Contains(search))
continue;

Expand Down Expand Up @@ -176,6 +192,9 @@ private void AddCategoriesFromPrototypes(IEnumerable<string> prototypes)
}
}

/// <summary>
/// Populates the list classes that will actually be shown, using the current filters.
/// </summary>
public void PopulateClasses(List<string> availablePrototypes, List<string> unavailablePrototypes)
{
_classStrings.Clear();
Expand Down Expand Up @@ -215,6 +234,48 @@ private void AddClassesFromPrototypes(IEnumerable<string> prototypes)
}
}

/// <summary>
/// Populates the list engines that will actually be shown, using the current filters.
/// </summary>
public void PopulateEngines(List<string> availablePrototypes, List<string> unavailablePrototypes)
{
_engineStrings.Clear();
Engines.Clear();

AddEnginesFromPrototypes(availablePrototypes);
AddEnginesFromPrototypes(unavailablePrototypes);

_engineStrings.Sort();

// Add "All" category at the top of the list
_engineStrings.Insert(0, VesselEngine.All);

foreach (var str in _engineStrings)
{
Engines.AddItem(Loc.GetString($"shipyard-console-engine-{str}"));
}
}

/// <summary>
/// Adds all ship engine power type from a list of vessel prototypes to the current control's list if they are missing.
/// </summary>
private void AddEnginesFromPrototypes(IEnumerable<string> prototypes)
{
foreach (var protoId in prototypes)
{
if (!_protoManager.TryIndex<VesselPrototype>(protoId, out var prototype))
continue;

foreach (var cl in prototype.Engines)
{
if (!_engineStrings.Contains(cl) && cl != VesselEngine.All)
{
_engineStrings.Add(cl);
}
}
}
}

public void UpdateState(ShipyardConsoleInterfaceState state)
{
BalanceLabel.Text = BankSystemExtensions.ToSpesoString(state.Balance);
Expand Down
41 changes: 32 additions & 9 deletions Content.Shared/Shipyard/Prototypes/VesselPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,29 @@ public sealed class VesselPrototype : IPrototype
public int Price;

/// <summary>
/// The category of the product. (e.g. Small, Medium, Large, Emergency, Special etc.)
/// The size of the vessel. (e.g. Small, Medium, Large etc.)
/// </summary>
[DataField("category", required: true)]
public VesselSize Category = VesselSize.Small;

/// <summary>
/// The group of the product. (e.g. Civilian, Syndicate, Contraband etc.)
/// The shipyard listing that the vessel should be in. (e.g. Civilian, Syndicate, Contraband etc.)
/// </summary>
[DataField("group", required: true)]
public ShipyardConsoleUiKey Group = ShipyardConsoleUiKey.Shipyard;

/// <summary>
/// The group of the product. (e.g. Civilian, Syndicate, Contraband etc.)
/// The purpose of the vessel. (e.g. Service, Cargo, Engineering etc.)
/// </summary>
[DataField("class")]
public List<VesselClass> Classes = new();

/// <summary>
/// The engine type that powers the vessel. (e.g. AME, Plasma, Solar etc.)
/// </summary>
[DataField("engine")]
public List<VesselEngine> Engines = new();

/// <summary>
/// The access required to buy the product. (e.g. Command, Mail, Bailiff, etc.)
/// </summary>
Expand Down Expand Up @@ -96,6 +102,13 @@ public enum VesselSize : byte
public enum VesselClass : byte
{
All, // Should not be used by ships, intended as a placeholder value to represent everything
// NFSD-specific categories
Capital,
Detainment,
Detective,
Fighter,
Patrol,
Pursuit,
// Capabilities
Expedition,
Scrapyard,
Expand All @@ -114,11 +127,21 @@ public enum VesselClass : byte
// Antag ships
Syndicate,
Pirate,
// NFSD-specific categories
Detainment,
Detective,
Fighter,
Stealth,
Capital,
}

public enum VesselEngine : byte
{
All, // Should not be used by ships, intended as a placeholder value to represent everything
AME,
TEG,
Supermatter,
Tesla,
Singularity,
Solar,
RTG,
APU,
Welding,
Plasma,
Uranium,
Bananium,
}
22 changes: 20 additions & 2 deletions Resources/Locale/en-US/_NF/shipyard/shipyard-console-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ shipyard-console-dangerous-materials = Dangerous materials detected onboard.
shipyard-console-menu-size-label = Size:{" "}
shipyard-console-menu-class-label = Class:{" "}
shipyard-console-menu-engine-label = Engine:{" "}
shipyard-console-purchase-available = Purchase
shipyard-console-guidebook = Manual
Expand All @@ -53,10 +54,27 @@ shipyard-console-class-Atmospherics = Atmospherics
shipyard-console-class-Medical = Medical
shipyard-console-class-Civilian = Civilian
shipyard-console-class-Kitchen = Kitchen
# Antag
shipyard-console-class-Syndicate = Syndicate
shipyard-console-class-Pirate = Pirate
# NFSD
shipyard-console-class-Capital = Capital
shipyard-console-class-Detainment = Detainment
shipyard-console-class-Detective = Detective
shipyard-console-class-Fighter = Fighter
shipyard-console-class-Stealth = Stealth
shipyard-console-class-Capital = Capital
shipyard-console-class-Patrol = Patrol
shipyard-console-class-Pursuit = Pursuit
shipyard-console-engine-All = All
shipyard-console-engine-AME = AME
shipyard-console-engine-TEG = TEG
shipyard-console-engine-Supermatter = Supermatter
shipyard-console-engine-Tesla = Tesla
shipyard-console-engine-Singularity = Singularity
shipyard-console-engine-Solar = Solar
shipyard-console-engine-RTG = RTG
shipyard-console-engine-APU = APU
shipyard-console-engine-Welding = Welding Fuel
shipyard-console-engine-Plasma = Plasma
shipyard-console-engine-Uranium = Uranium
shipyard-console-engine-Bananium = Bananium
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/BlackMarket/barnacle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
guidebookPage: Null
class:
- Pirate
engine:
- Plasma

- type: gameMap
id: Barnacle
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/BlackMarket/bocakillo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
guidebookPage: Null
class:
- Pirate
engine:
- Plasma

- type: gameMap
id: Bocakillo
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/BlackMarket/falcon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
guidebookPage: Null
class:
- Pirate
engine:
- Plasma

- type: gameMap
id: Falcon
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/BlackMarket/menace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
guidebookPage: Null
class:
- Pirate
engine:
- Plasma

- type: gameMap
id: Menace
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/BlackMarket/schooner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
guidebookPage: Null
class:
- Pirate
engine:
- Uranium

- type: gameMap
id: Schooner
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/ambition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class:
- Expedition
- Atmospherics
engine:
- AME

- type: gameMap
id: Ambition
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/anchor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class:
- Expedition
- Civilian
engine:
- AME

- type: gameMap
id: Anchor
Expand Down
4 changes: 3 additions & 1 deletion Resources/Prototypes/_NF/Shipyard/Expedition/brigand.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
guidebookPage: ShipyardBrigand
class:
- Expedition

engine:
- AME

- type: gameMap
id: Brigand
mapName: 'Brigand'
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/decadedove.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
guidebookPage: Null
class:
- Expedition
engine:
- AME

- type: gameMap
id: DecadeDove
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/dragonfly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
guidebookPage: Null
class:
- Expedition
engine:
- AME

- type: gameMap
id: Dragonfly
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/gasbender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
class:
- Expedition
- Atmospherics
engine:
- AME

- type: gameMap
id: Gasbender
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/gourd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- Expedition
- Science
- Civilian
engine:
- AME

- type: gameMap
id: Gourd
Expand Down
4 changes: 3 additions & 1 deletion Resources/Prototypes/_NF/Shipyard/Expedition/pathfinder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
guidebookPage: ShipyardPathfinder
class:
- Expedition

engine:
- AME

- type: gameMap
id: Pathfinder
mapName: 'KC Pathfinder'
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Expedition/sprinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
guidebookPage: Null
class:
- Expedition
engine:
- AME

- type: gameMap
id: Sprinter
Expand Down
2 changes: 2 additions & 0 deletions Resources/Prototypes/_NF/Shipyard/Nfsd/broadhead.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
guidebookPage: Null
class:
- Detective
engine:
- Uranium

- type: gameMap
id: Broadhead
Expand Down
Loading

0 comments on commit bd89429

Please sign in to comment.