feat(ui): persist retained window layouts

This commit is contained in:
Erik 2026-07-10 23:17:29 +02:00
parent a8e9503d2e
commit 921c388e2c
22 changed files with 705 additions and 141 deletions

View file

@ -24,6 +24,10 @@ public sealed class InventoryController : IItemListDragHandler
public const uint ContentsCaptionId = 0x100001C5u; // "Contents of Backpack"
public const uint TitleTextId = 0x100001D3u; // "Inventory of <name>"
public const uint ContentsScrollbarId = 0x100001C7u; // gm3DItemsUI gutter scrollbar (right of the grid)
private const uint BackdropId = 0x100001D0u;
private const uint ContentsWindowId = 0x100001CFu;
private const uint PaperdollWindowId = 0x100001CDu;
private const uint BackpackWindowId = 0x100001CEu;
// 3D-items grid: 192x96 → 6 cols x 3 rows of the 32x32 UIItem cell (template 0x21000037).
private const int ContentsColumns = 6;
@ -92,6 +96,8 @@ public sealed class InventoryController : IItemListDragHandler
_containerList = layout.FindElement(ContainerListId) as UiItemList;
_topContainer = layout.FindElement(TopContainerId) as UiItemList;
ConfigureResizeLayout(layout);
if (_contentsGrid is not null)
{
_contentsGrid.Columns = ContentsColumns;
@ -153,6 +159,24 @@ public sealed class InventoryController : IItemListDragHandler
Populate();
}
internal static void ConfigureResizeLayout(ImportedLayout layout)
{
static void Set(ImportedLayout imported, uint id, AnchorEdges anchors)
{
if (imported.FindElement(id) is not { } element) return;
element.Anchors = anchors;
element.CaptureCurrentAnchorBaseline();
}
AnchorEdges stretch = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Bottom;
Set(layout, BackdropId, stretch);
Set(layout, ContentsWindowId, stretch);
Set(layout, ContentsGridId, stretch);
Set(layout, ContentsScrollbarId, stretch);
Set(layout, PaperdollWindowId, AnchorEdges.Left | AnchorEdges.Top);
Set(layout, BackpackWindowId, AnchorEdges.Left | AnchorEdges.Top);
}
public static InventoryController Bind(
ImportedLayout layout,
ClientObjectTable objects,