Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to show stack visuals on closed containers #29309

Merged
merged 13 commits into from
Jul 21, 2024
Merged
2 changes: 1 addition & 1 deletion Content.Client/Storage/Systems/ItemCounterSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private void OnAppearanceChange(EntityUid uid, ItemCounterComponent comp, ref Ap

if (!_appearanceSystem.TryGetData<bool>(uid, StackVisuals.Hide, out var hidden, args.Component))
hidden = false;

if (comp.IsComposite)
ProcessCompositeSprite(uid, actual, maxCount, comp.LayerStates, hidden, sprite: args.Sprite);
else
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Storage/Components/ItemCounterComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Whitelist;

namespace Content.Shared.Storage.Components
Expand Down
6 changes: 5 additions & 1 deletion Content.Shared/Storage/EntitySystems/SharedStorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,11 @@ public void UpdateAppearance(Entity<StorageComponent?, AppearanceComponent?> ent
_appearance.SetData(uid, StorageVisuals.Capacity, capacity, appearance);
_appearance.SetData(uid, StorageVisuals.Open, isOpen, appearance);
_appearance.SetData(uid, SharedBagOpenVisuals.BagState, isOpen ? SharedBagState.Open : SharedBagState.Closed, appearance);
_appearance.SetData(uid, StackVisuals.Hide, !isOpen, appearance);
CroilBird marked this conversation as resolved.
Show resolved Hide resolved

// set the StackVisuals.Hide property to true when the container is closed. This is done
// on containers that only show their contents when they are open (e.g. donut boxes)
ShadowCommander marked this conversation as resolved.
Show resolved Hide resolved
if (storage.HideClosedStackVisuals)
_appearance.SetData(uid, StackVisuals.Hide, !isOpen, appearance);
}

/// <summary>
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Storage/StorageComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ public sealed partial class StorageComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public StorageDefaultOrientation? DefaultStorageOrientation;

/// <summary>
/// If true, sets StackVisuals.Hide to true when the container is closed
/// Used in cases where there are sprites that are shown when the container is open but not
/// when it is closed
/// </summary>
[DataField]
public bool HideClosedStackVisuals = true;

[Serializable, NetSerializable]
public enum StorageUiKey : byte
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
whitelist:
tags:
- Cola
hideClosedStackVisuals: false
- type: StorageFill
contents:
- id: DrinkColaCan
Expand Down
Loading