From 8112f84c3303601f01cfc493c2447f6dc682cb38 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Fri, 8 Dec 2023 13:43:57 -0500 Subject: [PATCH] Mark the last item stored in storage for smart-equip (#22236) * mark the last item stored in grid inventory * shift --- .../Systems/Storage/Controls/ItemGridPiece.cs | 19 ++++++++++++++++++ .../Storage/Controls/StorageContainer.cs | 2 ++ .../Systems/Storage/StorageUIController.cs | 4 ++-- .../Interface/Default/Storage/marked.png | Bin 0 -> 134 bytes 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 Resources/Textures/Interface/Default/Storage/marked.png diff --git a/Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs b/Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs index ece668c945..a7298213e8 100644 --- a/Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs +++ b/Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs @@ -6,6 +6,7 @@ using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.UserInterface; using Robust.Client.UserInterface.CustomControls; +using YamlDotNet.Core; namespace Content.Client.UserInterface.Systems.Storage.Controls; @@ -18,6 +19,7 @@ public sealed class ItemGridPiece : Control public readonly EntityUid Entity; public ItemStorageLocation Location; + public bool Marked = false; public event Action? OnPiecePressed; public event Action? OnPieceUnpressed; @@ -41,6 +43,8 @@ public sealed class ItemGridPiece : Control private Texture? _bottomLeftTexture; private readonly string _bottomRightTexturePath = "Storage/piece_bottomRight"; private Texture? _bottomRightTexture; + private readonly string _markedTexturePath = "Storage/marked"; + private Texture? _markedTexture; #endregion public ItemGridPiece(Entity entity, ItemStorageLocation location, IEntityManager entityManager) @@ -85,6 +89,7 @@ public sealed class ItemGridPiece : Control _topRightTexture = Theme.ResolveTextureOrNull(_topRightTexturePath)?.Texture; _bottomLeftTexture = Theme.ResolveTextureOrNull(_bottomLeftTexturePath)?.Texture; _bottomRightTexture = Theme.ResolveTextureOrNull(_bottomRightTexturePath)?.Texture; + _markedTexture = Theme.ResolveTextureOrNull(_markedTexturePath)?.Texture; } protected override void Draw(DrawingHandleScreen handle) @@ -109,6 +114,9 @@ public sealed class ItemGridPiece : Control //yeah, this coloring is kinda hardcoded. deal with it. B) Color? colorModulate = hovering ? null : Color.FromHex("#a8a8a8"); + var marked = Marked; + Vector2i? maybeMarkedPos = null; + _texturesPositions.Clear(); for (var y = boundingGrid.Bottom; y <= boundingGrid.Top; y++) { @@ -129,6 +137,12 @@ public sealed class ItemGridPiece : Control { _texturesPositions.Add((nwTexture, Position + offset / UIScale)); handle.DrawTextureRect(nwTexture, new UIBox2(topLeft, topLeft + size), colorModulate); + + if (marked && nwTexture == _topLeftTexture) + { + maybeMarkedPos = topLeft; + marked = false; + } } if (GetTexture(adjustedShape, new Vector2i(x, y), Direction.SouthEast) is {} seTexture) { @@ -175,6 +189,11 @@ public sealed class ItemGridPiece : Control eyeRotation: iconRotation, overrideDirection: Direction.South); } + + if (maybeMarkedPos is {} markedPos && _markedTexture != null) + { + handle.DrawTextureRect(_markedTexture, new UIBox2(markedPos, markedPos + size)); + } } protected override bool HasPoint(Vector2 point) diff --git a/Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs b/Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs index bc35c29cf5..f40a20f2d2 100644 --- a/Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs +++ b/Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs @@ -249,6 +249,7 @@ public sealed class StorageContainer : BaseWindow var boundingGrid = storageComp.Grid.GetBoundingBox(); var size = _emptyTexture!.Size * 2; + var lastEntity = storageComp.Container.ContainedEntities.LastOrDefault(); //todo. at some point, we may want to only rebuild the pieces that have actually received new data. @@ -278,6 +279,7 @@ public sealed class StorageContainer : BaseWindow var gridPiece = new ItemGridPiece((itemEnt, itemEntComponent), item.Value, _entity) { MinSize = size, + Marked = itemEnt == lastEntity }; gridPiece.OnPiecePressed += OnPiecePressed; gridPiece.OnPieceUnpressed += OnPieceUnpressed; diff --git a/Content.Client/UserInterface/Systems/Storage/StorageUIController.cs b/Content.Client/UserInterface/Systems/Storage/StorageUIController.cs index a08dae1dd7..85631f1aa8 100644 --- a/Content.Client/UserInterface/Systems/Storage/StorageUIController.cs +++ b/Content.Client/UserInterface/Systems/Storage/StorageUIController.cs @@ -75,11 +75,11 @@ public sealed class StorageUIController : UIController, IOnSystemChangedXCAO7jL?92Zrx*`f*Hg#@1z_O>B=;eP7n8>vS`nXPWNk6={K~mi4 gq3&ZTww64G4@qVhC6{uo1DeI)>FVdQ&MBb@04bj>Bme*a literal 0 HcmV?d00001 -- 2.51.2