]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Mark the last item stored in storage for smart-equip (#22236)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 8 Dec 2023 18:43:57 +0000 (13:43 -0500)
committerGitHub <noreply@github.com>
Fri, 8 Dec 2023 18:43:57 +0000 (12:43 -0600)
* mark the last item stored in grid inventory

* shift

Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs
Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs
Content.Client/UserInterface/Systems/Storage/StorageUIController.cs
Resources/Textures/Interface/Default/Storage/marked.png [new file with mode: 0644]

index ece668c945426390a297c5df17bf0defec5bc904..a7298213e862e2b718791f85b3d74c442c1d1ad8 100644 (file)
@@ -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<GUIBoundKeyEventArgs, ItemGridPiece>? OnPiecePressed;
     public event Action<GUIBoundKeyEventArgs, ItemGridPiece>? 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<ItemComponent> 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)
index bc35c29cf509dca22954fa9ab3070298d5a57b75..f40a20f2d29bfd3a30d52c3e69e620a167c81fe9 100644 (file)
@@ -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;
index a08dae1dd7b7e742bfae1cc99c5a7989465db3e5..85631f1aa82fe6dbebe1186bd0e4f35ec3f9089c 100644 (file)
@@ -75,11 +75,11 @@ public sealed class StorageUIController : UIController, IOnSystemChanged<Storage
         if (_container == null)
             return;
 
-        _container.UpdateContainer(nullEnt);
-
         if (IsDragging)
             _menuDragHelper.EndDrag();
 
+        _container.UpdateContainer(nullEnt);
+
         if (nullEnt is not null)
         {
             // center it if we knock it off screen somehow.
diff --git a/Resources/Textures/Interface/Default/Storage/marked.png b/Resources/Textures/Interface/Default/Storage/marked.png
new file mode 100644 (file)
index 0000000..2739b7e
Binary files /dev/null and b/Resources/Textures/Interface/Default/Storage/marked.png differ