Predict StorageComponent (#19682)

This commit is contained in:
metalgearsloth
2023-09-11 21:20:46 +10:00
committed by GitHub
parent 99b77bc2d3
commit d5bd1c6f86
68 changed files with 1124 additions and 1121 deletions

View File

@@ -8,7 +8,9 @@ using Content.Client.UserInterface.Controls;
using Content.Shared.IdentityManagement;
using Content.Shared.Item;
using Content.Shared.Stacks;
using Content.Shared.Storage;
using Robust.Client.UserInterface;
using Robust.Shared.Containers;
using static Robust.Client.UserInterface.Controls.BoxContainer;
using static Content.Shared.Storage.SharedStorageComponent;
using Direction = Robust.Shared.Maths.Direction;
@@ -18,9 +20,9 @@ namespace Content.Client.Storage.UI
/// <summary>
/// GUI class for client storage component
/// </summary>
public sealed class StorageWindow : DefaultWindow
public sealed class StorageWindow : FancyWindow
{
private IEntityManager _entityManager;
private readonly IEntityManager _entityManager;
private readonly Label _information;
public readonly ContainerButton StorageContainerButton;
@@ -41,7 +43,7 @@ namespace Content.Client.Storage.UI
MouseFilter = MouseFilterMode.Pass,
};
Contents.AddChild(StorageContainerButton);
ContentsContainer.AddChild(StorageContainerButton);
var innerContainerButton = new PanelContainer
{
@@ -54,6 +56,7 @@ namespace Content.Client.Storage.UI
{
Orientation = LayoutOrientation.Vertical,
MouseFilter = MouseFilterMode.Ignore,
Margin = new Thickness(5),
};
StorageContainerButton.AddChild(vBox);
@@ -87,20 +90,27 @@ namespace Content.Client.Storage.UI
/// <summary>
/// Loops through stored entities creating buttons for each, updates information labels
/// </summary>
public void BuildEntityList(StorageBoundUserInterfaceState state)
public void BuildEntityList(EntityUid entity, StorageComponent component)
{
var list = state.StoredEntities.ConvertAll(nent => new EntityListData(_entityManager.GetEntity(nent)));
var storedCount = component.Container.ContainedEntities.Count;
var list = new List<EntityListData>(storedCount);
foreach (var uid in component.Container.ContainedEntities)
{
list.Add(new EntityListData(uid));
}
EntityList.PopulateList(list);
//Sets information about entire storage container current capacity
if (state.StorageCapacityMax != 0)
// Sets information about entire storage container current capacity
if (component.StorageCapacityMax != 0)
{
_information.Text = Loc.GetString("comp-storage-window-volume", ("itemCount", state.StoredEntities.Count),
("usedVolume", state.StorageSizeUsed), ("maxVolume", state.StorageCapacityMax));
_information.Text = Loc.GetString("comp-storage-window-volume", ("itemCount", storedCount),
("usedVolume", component.StorageUsed), ("maxVolume", component.StorageCapacityMax));
}
else
{
_information.Text = Loc.GetString("comp-storage-window-volume-unlimited", ("itemCount", state.StoredEntities.Count));
_information.Text = Loc.GetString("comp-storage-window-volume-unlimited", ("itemCount", storedCount));
}
}