using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
+using YamlDotNet.Core;
namespace Content.Client.UserInterface.Systems.Storage.Controls;
public readonly EntityUid Entity;
public ItemStorageLocation Location;
+ public bool Marked = false;
public event Action<GUIBoundKeyEventArgs, ItemGridPiece>? OnPiecePressed;
public event Action<GUIBoundKeyEventArgs, ItemGridPiece>? OnPieceUnpressed;
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)
_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)
//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++)
{
{
_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)
{
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)
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.
var gridPiece = new ItemGridPiece((itemEnt, itemEntComponent), item.Value, _entity)
{
MinSize = size,
+ Marked = itemEnt == lastEntity
};
gridPiece.OnPiecePressed += OnPiecePressed;
gridPiece.OnPieceUnpressed += OnPieceUnpressed;