From 404562ea6e91f57aaa74f2af785ea52389068fef Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 17 Jul 2026 01:45:32 +0100 Subject: [PATCH] Render spatial inventory footprints --- .../Runtime/EveUiToolkitSurfaceLowerer.cs | 16 ++++++++++++++-- .../Editor/EveUiToolkitSurfaceLowererTests.cs | 7 ++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/org.gamecult.eve.unity-uitoolkit/Runtime/EveUiToolkitSurfaceLowerer.cs b/packages/org.gamecult.eve.unity-uitoolkit/Runtime/EveUiToolkitSurfaceLowerer.cs index cf7690a..9cdc677 100644 --- a/packages/org.gamecult.eve.unity-uitoolkit/Runtime/EveUiToolkitSurfaceLowerer.cs +++ b/packages/org.gamecult.eve.unity-uitoolkit/Runtime/EveUiToolkitSurfaceLowerer.cs @@ -335,11 +335,23 @@ namespace GameCult.Eve.UnityUIToolkit return; var cellSize = Math.Max(1f, ParseNumber(parent.GetProp("cellSize"), 72f)); var gap = Math.Max(0f, ParseNumber(parent.GetProp("cellGap"), 4f)); + var widthCells = Math.Max(1, ParseInt(child.GetProp("shapeWidth"), 1)); + var heightCells = Math.Max(1, ParseInt(child.GetProp("shapeHeight"), 1)); + var rotation = child.GetProp("rotation"); + if (string.Equals(rotation, "Clockwise", StringComparison.OrdinalIgnoreCase) || + string.Equals(rotation, "CounterClockwise", StringComparison.OrdinalIgnoreCase) || + string.Equals(rotation, "Right", StringComparison.OrdinalIgnoreCase) || + string.Equals(rotation, "Left", StringComparison.OrdinalIgnoreCase) || + string.Equals(rotation, "Rotate90", StringComparison.OrdinalIgnoreCase) || + string.Equals(rotation, "Rotate270", StringComparison.OrdinalIgnoreCase)) + { + (widthCells, heightCells) = (heightCells, widthCells); + } element.style.position = Position.Absolute; element.style.left = Math.Max(0, ParseInt(child.GetProp("x"), 0)) * (cellSize + gap); element.style.top = Math.Max(0, ParseInt(child.GetProp("y"), 0)) * (cellSize + gap); - element.style.width = cellSize; - element.style.height = cellSize; + element.style.width = widthCells * cellSize + Math.Max(0, widthCells - 1) * gap; + element.style.height = heightCells * cellSize + Math.Max(0, heightCells - 1) * gap; } private static VisualElement? InventoryGridAncestor(VisualElement? element) diff --git a/packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/EveUiToolkitSurfaceLowererTests.cs b/packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/EveUiToolkitSurfaceLowererTests.cs index 7752398..e6db232 100644 --- a/packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/EveUiToolkitSurfaceLowererTests.cs +++ b/packages/org.gamecult.eve.unity-uitoolkit/Tests/Editor/EveUiToolkitSurfaceLowererTests.cs @@ -182,7 +182,10 @@ namespace GameCult.Eve.UnityUIToolkit.Tests ["label"] = "Iron Ore", ["sourceKind"] = "cargo", ["x"] = "1", - ["y"] = "2" + ["y"] = "2", + ["shapeWidth"] = "2", + ["shapeHeight"] = "3", + ["rotation"] = "Clockwise" }); var grid = new EveSurfaceComponent( "cargo", @@ -206,6 +209,8 @@ namespace GameCult.Eve.UnityUIToolkit.Tests Assert.That(loweredItem.text, Is.EqualTo("Iron Ore")); Assert.That(loweredItem.style.left.value.value, Is.EqualTo(34f)); Assert.That(loweredItem.style.top.value.value, Is.EqualTo(68f)); + Assert.That(loweredItem.style.width.value.value, Is.EqualTo(100f)); + Assert.That(loweredItem.style.height.value.value, Is.EqualTo(66f)); } private static EveSurfaceDocument Document(EveSurfaceComponent root, string surfaceId = "test-surface")