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;
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)
_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)
//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();
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));
+ }
}
}
return actualSize * new Vector2i(8, 8);
}
}
+
+public enum ItemGridPieceMarks
+{
+ First,
+ Second,
+}
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.
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;