Mark the last item stored in storage for smart-equip (#22236)
* mark the last item stored in grid inventory * shift
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
BIN
Resources/Textures/Interface/Default/Storage/marked.png
Normal file
BIN
Resources/Textures/Interface/Default/Storage/marked.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 134 B |
Reference in New Issue
Block a user