]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
feat(inventory): Add secondary smart-equip star (#25696)
authorexincore <me@exin.xyz>
Sat, 2 Mar 2024 23:57:42 +0000 (17:57 -0600)
committerGitHub <noreply@github.com>
Sat, 2 Mar 2024 23:57:42 +0000 (18:57 -0500)
* feat(inventory): Add secondary quick-remove star

* style: Fix end of file newline

* feat(inventory): Change secondary smart-equip star to silver star

* feat(inventory): Decrease secondary quick-equip star luminosity to better match the primary

Content.Client/UserInterface/Systems/Storage/Controls/ItemGridPiece.cs
Content.Client/UserInterface/Systems/Storage/Controls/StorageContainer.cs
Resources/Textures/Interface/Default/Storage/marked_first.png [moved from Resources/Textures/Interface/Default/Storage/marked.png with 100% similarity]
Resources/Textures/Interface/Default/Storage/marked_second.png [new file with mode: 0644]

index 8b51a3f219b2e90380cc5a7024ed41578c263912..f436cc8c39bbdc659f2e501e169fcd522ee59d5c 100644 (file)
@@ -18,7 +18,7 @@ public sealed class ItemGridPiece : Control
 
     public readonly EntityUid Entity;
     public ItemStorageLocation Location;
-    public bool Marked = false;
+    public ItemGridPieceMarks? Marked;
 
     public event Action<GUIBoundKeyEventArgs, ItemGridPiece>? OnPiecePressed;
     public event Action<GUIBoundKeyEventArgs, ItemGridPiece>? OnPieceUnpressed;
@@ -42,8 +42,10 @@ 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;
+    private readonly string _markedFirstTexturePath = "Storage/marked_first";
+    private Texture? _markedFirstTexture;
+    private readonly string _markedSecondTexturePath = "Storage/marked_second";
+    private Texture? _markedSecondTexture;
     #endregion
 
     public ItemGridPiece(Entity<ItemComponent> entity, ItemStorageLocation location,  IEntityManager entityManager)
@@ -88,7 +90,8 @@ 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;
+        _markedFirstTexture = Theme.ResolveTextureOrNull(_markedFirstTexturePath)?.Texture;
+        _markedSecondTexture = Theme.ResolveTextureOrNull(_markedSecondTexturePath)?.Texture;
     }
 
     protected override void Draw(DrawingHandleScreen handle)
@@ -113,7 +116,7 @@ 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;
+        var marked = Marked != null;
         Vector2i? maybeMarkedPos = null;
 
         _texturesPositions.Clear();
@@ -189,9 +192,19 @@ public sealed class ItemGridPiece : Control
                 overrideDirection: Direction.South);
         }
 
-        if (maybeMarkedPos is {} markedPos && _markedTexture != null)
+        if (maybeMarkedPos is {} markedPos)
         {
-            handle.DrawTextureRect(_markedTexture, new UIBox2(markedPos, markedPos + size));
+            var markedTexture = Marked switch
+            {
+                ItemGridPieceMarks.First => _markedFirstTexture,
+                ItemGridPieceMarks.Second => _markedSecondTexture,
+                _ => null,
+            };
+
+            if (markedTexture != null)
+            {
+                handle.DrawTextureRect(markedTexture, new UIBox2(markedPos, markedPos + size));
+            }
         }
     }
 
@@ -275,3 +288,9 @@ public sealed class ItemGridPiece : Control
         return actualSize * new Vector2i(8, 8);
     }
 }
+
+public enum ItemGridPieceMarks
+{
+    First,
+    Second,
+}
index 53a820edaaded2a7eb7620b2dc5e42fa6f2a13ec..bd952fe9577744bb6e51746e8cbb040605441349 100644 (file)
@@ -249,7 +249,7 @@ public sealed class StorageContainer : BaseWindow
 
         var boundingGrid = storageComp.Grid.GetBoundingBox();
         var size = _emptyTexture!.Size * 2;
-        var lastEntity = storageComp.Container.ContainedEntities.LastOrDefault();
+        var containedEntities = storageComp.Container.ContainedEntities.Reverse().ToArray();
 
         //todo. at some point, we may want to only rebuild the pieces that have actually received new data.
 
@@ -277,7 +277,12 @@ public sealed class StorageContainer : BaseWindow
                         var gridPiece = new ItemGridPiece((itemEnt, itemEntComponent), itemPos, _entity)
                         {
                             MinSize = size,
-                            Marked = itemEnt == lastEntity
+                            Marked = Array.IndexOf(containedEntities, itemEnt) switch
+                            {
+                                0 => ItemGridPieceMarks.First,
+                                1 => ItemGridPieceMarks.Second,
+                                _ => null,
+                            }
                         };
                         gridPiece.OnPiecePressed += OnPiecePressed;
                         gridPiece.OnPieceUnpressed += OnPieceUnpressed;
diff --git a/Resources/Textures/Interface/Default/Storage/marked_second.png b/Resources/Textures/Interface/Default/Storage/marked_second.png
new file mode 100644 (file)
index 0000000..26314b4
Binary files /dev/null and b/Resources/Textures/Interface/Default/Storage/marked_second.png differ