Remove GalacticMarket component (#7914)
This commit is contained in:
@@ -19,9 +19,6 @@ namespace Content.Client.Cargo
|
||||
[ViewVariables]
|
||||
private CargoConsoleOrderMenu? _orderMenu;
|
||||
|
||||
[ViewVariables]
|
||||
public GalacticMarketComponent? Market { get; private set; }
|
||||
|
||||
[ViewVariables]
|
||||
public CargoOrderDatabaseComponent? Orders { get; private set; }
|
||||
|
||||
@@ -51,10 +48,8 @@ namespace Content.Client.Cargo
|
||||
base.Open();
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entMan.TryGetComponent(Owner.Owner, out GalacticMarketComponent? market) ||
|
||||
!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return;
|
||||
if (!entMan.TryGetComponent(Owner.Owner, out CargoOrderDatabaseComponent? orders)) return;
|
||||
|
||||
Market = market;
|
||||
Orders = orders;
|
||||
|
||||
_menu = new CargoConsoleMenu(this);
|
||||
@@ -64,8 +59,6 @@ namespace Content.Client.Cargo
|
||||
|
||||
_menu.Populate();
|
||||
|
||||
Market.OnDatabaseUpdated += _menu.PopulateProducts;
|
||||
Market.OnDatabaseUpdated += _menu.PopulateCategories;
|
||||
Orders.OnDatabaseUpdated += _menu.PopulateOrders;
|
||||
|
||||
_menu.CallShuttleButton.OnPressed += (_) =>
|
||||
@@ -121,12 +114,6 @@ namespace Content.Client.Cargo
|
||||
|
||||
if (!disposing) return;
|
||||
|
||||
if (Market != null && _menu != null)
|
||||
{
|
||||
Market.OnDatabaseUpdated -= _menu.PopulateProducts;
|
||||
Market.OnDatabaseUpdated -= _menu.PopulateCategories;
|
||||
}
|
||||
|
||||
if (Orders != null && _menu != null)
|
||||
{
|
||||
Orders.OnDatabaseUpdated -= _menu.PopulateOrders;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
using System;
|
||||
using Content.Shared.Cargo;
|
||||
using Content.Shared.Cargo.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client.Cargo.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class GalacticMarketComponent : SharedGalacticMarketComponent
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Event called when the database is updated.
|
||||
/// </summary>
|
||||
public event Action? OnDatabaseUpdated;
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
if (curState is not GalacticMarketState state)
|
||||
return;
|
||||
_productIds.Clear();
|
||||
foreach (var productId in state.Products)
|
||||
{
|
||||
if (!_prototypeManager.TryIndex(productId, out CargoProductPrototype? product))
|
||||
continue;
|
||||
_products.Add(product);
|
||||
}
|
||||
|
||||
OnDatabaseUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -21,6 +22,9 @@ namespace Content.Client.Cargo.UI
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class CargoConsoleMenu : DefaultWindow
|
||||
{
|
||||
[Dependency]
|
||||
private IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public CargoConsoleBoundUserInterface Owner { get; private set; }
|
||||
|
||||
public event Action<ButtonEventArgs>? OnItemSelected;
|
||||
@@ -66,6 +70,8 @@ namespace Content.Client.Cargo.UI
|
||||
Categories.SelectId(id);
|
||||
}
|
||||
|
||||
public IEnumerable<CargoProductPrototype> ProductPrototypes => _prototypeManager.EnumeratePrototypes<CargoProductPrototype>();
|
||||
|
||||
/// <summary>
|
||||
/// Populates the list of products that will actually be shown, using the current filters.
|
||||
/// </summary>
|
||||
@@ -73,13 +79,8 @@ namespace Content.Client.Cargo.UI
|
||||
{
|
||||
Products.RemoveAllChildren();
|
||||
|
||||
if (Owner.Market == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var search = SearchBar.Text.Trim().ToLowerInvariant();
|
||||
foreach (var prototype in Owner.Market.Products)
|
||||
foreach (var prototype in ProductPrototypes)
|
||||
{
|
||||
// if no search or category
|
||||
// else if search
|
||||
@@ -112,14 +113,9 @@ namespace Content.Client.Cargo.UI
|
||||
_categoryStrings.Clear();
|
||||
Categories.Clear();
|
||||
|
||||
if (Owner.Market == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_categoryStrings.Add(Loc.GetString("cargo-console-menu-populate-categories-all-text"));
|
||||
|
||||
foreach (var prototype in Owner.Market.Products)
|
||||
foreach (var prototype in ProductPrototypes)
|
||||
{
|
||||
if (!_categoryStrings.Contains(prototype.Category))
|
||||
{
|
||||
@@ -141,26 +137,26 @@ namespace Content.Client.Cargo.UI
|
||||
Orders.RemoveAllChildren();
|
||||
Requests.RemoveAllChildren();
|
||||
|
||||
if (Owner.Orders == null || Owner.Market == null)
|
||||
if (Owner.Orders == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var order in Owner.Orders.Orders)
|
||||
{
|
||||
var productName = Owner.Market.GetProduct(order.ProductId)?.Name;
|
||||
|
||||
if (productName == null)
|
||||
if (!_prototypeManager.TryIndex<CargoProductPrototype>(order.ProductId, out CargoProductPrototype? product))
|
||||
{
|
||||
DebugTools.Assert(false);
|
||||
Logger.ErrorS("cargo", $"Unable to find product name for {order.ProductId}");
|
||||
continue;
|
||||
}
|
||||
|
||||
var productName = product.Name;
|
||||
|
||||
var row = new CargoOrderRow
|
||||
{
|
||||
Order = order,
|
||||
Icon = { Texture = Owner.Market.GetProduct(order.ProductId)?.Icon.Frame0() },
|
||||
Icon = { Texture = product.Icon.Frame0() },
|
||||
ProductName =
|
||||
{
|
||||
Text = Loc.GetString(
|
||||
|
||||
Reference in New Issue
Block a user