feat(ui): unify retained window mounts
This commit is contained in:
parent
6e9e10367f
commit
a8e9503d2e
20 changed files with 823 additions and 366 deletions
|
|
@ -23,15 +23,15 @@ internal static class MockupDesktop
|
|||
var windows = new List<MockupWindow>();
|
||||
|
||||
if (MountVitals(dats, stack, objects) is { } vitals)
|
||||
RegisterWindow(stack, windows, WindowNames.Vitals, "Vitals", vitals, zOrder: 10);
|
||||
RecordWindow(windows, "Vitals", vitals, zOrder: 10);
|
||||
if (MountToolbar(dats, stack, objects) is { } toolbar)
|
||||
RegisterWindow(stack, windows, WindowNames.Toolbar, "Toolbar", toolbar, zOrder: 20);
|
||||
RecordWindow(windows, "Toolbar", toolbar, zOrder: 20);
|
||||
if (MountCharacter(dats, stack, objects) is { } character)
|
||||
RegisterWindow(stack, windows, WindowNames.Character, "Character", character, zOrder: 30);
|
||||
RecordWindow(windows, "Character", character, zOrder: 30);
|
||||
if (MountInventory(dats, stack, objects) is { } inventory)
|
||||
RegisterWindow(stack, windows, WindowNames.Inventory, "Inventory", inventory, zOrder: 40);
|
||||
RecordWindow(windows, "Inventory", inventory, zOrder: 40);
|
||||
if (MountChat(dats, stack) is { } chat)
|
||||
RegisterWindow(stack, windows, WindowNames.Chat, "Chat", chat, zOrder: 50);
|
||||
RecordWindow(windows, "Chat", chat, zOrder: 50);
|
||||
|
||||
MountControls(stack, windows);
|
||||
}
|
||||
|
|
@ -40,27 +40,31 @@ internal static class MockupDesktop
|
|||
=> LayoutImporter.Import(dats, layoutId, stack.ResolveChrome, stack.VitalsDatFont,
|
||||
fontResolve: stack.ResolveDatFont);
|
||||
|
||||
private static UiElement? MountVitals(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
private static RetailWindowHandle? MountVitals(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
{
|
||||
var layout = Import(dats, 0x2100006Cu, stack);
|
||||
if (layout is null) return null;
|
||||
|
||||
FixtureProvider.Populate(0x2100006Cu, layout, stack, objects, dats);
|
||||
|
||||
var root = layout.Root;
|
||||
root.Left = 12f;
|
||||
root.Top = 18f;
|
||||
root.ClickThrough = false;
|
||||
root.Anchors = AnchorEdges.None;
|
||||
root.Draggable = true;
|
||||
root.Resizable = true;
|
||||
root.ResizeX = true;
|
||||
root.ResizeY = false;
|
||||
root.MinWidth = 40f;
|
||||
return root;
|
||||
return RetailWindowFrame.Mount(
|
||||
stack.UiHost.Root,
|
||||
layout.Root,
|
||||
stack.ResolveChrome,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.Vitals,
|
||||
Chrome = RetailWindowChrome.Imported,
|
||||
Left = 12f,
|
||||
Top = 18f,
|
||||
ResizeX = true,
|
||||
ResizeY = false,
|
||||
MinWidth = 40f,
|
||||
ContentClickThrough = false,
|
||||
});
|
||||
}
|
||||
|
||||
private static UiElement? MountToolbar(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
private static RetailWindowHandle? MountToolbar(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
{
|
||||
var layout = Import(dats, 0x21000016u, stack);
|
||||
if (layout is null) return null;
|
||||
|
|
@ -71,27 +75,29 @@ internal static class MockupDesktop
|
|||
var toolbarRoot = layout.Root;
|
||||
float contentW = toolbarRoot.Width > 0f ? toolbarRoot.Width : 300f;
|
||||
float contentH = toolbarRoot.Height;
|
||||
var frame = new UiCollapsibleFrame(stack.ResolveChrome)
|
||||
{
|
||||
Left = 12f,
|
||||
Top = 220f,
|
||||
Width = contentW + 2 * border,
|
||||
Height = contentH + 2 * border,
|
||||
Opacity = 1f,
|
||||
};
|
||||
|
||||
toolbarRoot.Left = border;
|
||||
toolbarRoot.Top = border;
|
||||
toolbarRoot.Width = contentW;
|
||||
toolbarRoot.Height = contentH;
|
||||
toolbarRoot.Anchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Right;
|
||||
toolbarRoot.ClickThrough = true;
|
||||
toolbarRoot.Draggable = false;
|
||||
toolbarRoot.Resizable = false;
|
||||
frame.AddChild(toolbarRoot);
|
||||
RetailWindowHandle handle = RetailWindowFrame.Mount(
|
||||
stack.UiHost.Root,
|
||||
toolbarRoot,
|
||||
stack.ResolveChrome,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.Toolbar,
|
||||
Chrome = RetailWindowChrome.CollapsibleNineSlice,
|
||||
Left = 12f,
|
||||
Top = 220f,
|
||||
ContentWidth = contentW,
|
||||
ContentHeight = contentH,
|
||||
Resizable = false,
|
||||
ResizeX = false,
|
||||
ResizeY = true,
|
||||
ResizableEdges = ResizeEdges.Bottom,
|
||||
ContentAnchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Right,
|
||||
ContentClickThrough = true,
|
||||
});
|
||||
var frame = (UiCollapsibleFrame)handle.OuterFrame;
|
||||
|
||||
ConfigureToolbarCollapse(layout, frame, contentH, border);
|
||||
return frame;
|
||||
return handle;
|
||||
}
|
||||
|
||||
private static void ConfigureToolbarCollapse(ImportedLayout layout, UiCollapsibleFrame frame, float contentH, int border)
|
||||
|
|
@ -126,60 +132,60 @@ internal static class MockupDesktop
|
|||
frame.MaxHeight = expandedH;
|
||||
}
|
||||
|
||||
private static UiElement? MountCharacter(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
private static RetailWindowHandle? MountCharacter(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
{
|
||||
var layout = Import(dats, 0x2100002Eu, stack);
|
||||
if (layout is null) return null;
|
||||
|
||||
FixtureProvider.Populate(0x2100002Eu, layout, stack, objects, dats);
|
||||
|
||||
var root = layout.Root;
|
||||
root.Left = 540f;
|
||||
root.Top = 18f;
|
||||
root.Anchors = AnchorEdges.None;
|
||||
root.ClickThrough = false;
|
||||
root.Draggable = true;
|
||||
root.Resizable = true;
|
||||
root.MinWidth = root.Width;
|
||||
root.MinHeight = root.Height;
|
||||
return root;
|
||||
return RetailWindowFrame.Mount(
|
||||
stack.UiHost.Root,
|
||||
layout.Root,
|
||||
stack.ResolveChrome,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.Character,
|
||||
Chrome = RetailWindowChrome.NineSlice,
|
||||
Left = 540f,
|
||||
Top = 18f,
|
||||
MaxHeight = 760f,
|
||||
ResizeX = false,
|
||||
ResizeY = true,
|
||||
ResizableEdges = ResizeEdges.Bottom,
|
||||
ContentAnchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Bottom,
|
||||
ContentClickThrough = false,
|
||||
});
|
||||
}
|
||||
|
||||
private static UiElement? MountInventory(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
private static RetailWindowHandle? MountInventory(DatCollection dats, RenderStack stack, AcDream.Core.Items.ClientObjectTable objects)
|
||||
{
|
||||
var layout = Import(dats, 0x21000023u, stack);
|
||||
if (layout is null) return null;
|
||||
|
||||
FixtureProvider.Populate(0x21000023u, layout, stack, objects, dats);
|
||||
|
||||
const int border = RetailChromeSprites.Border;
|
||||
var inventoryRoot = layout.Root;
|
||||
float contentW = inventoryRoot.Width;
|
||||
float contentH = inventoryRoot.Height;
|
||||
var frame = new UiNineSlicePanel(stack.ResolveChrome)
|
||||
{
|
||||
Left = 900f,
|
||||
Top = 18f,
|
||||
Width = contentW + 2 * border,
|
||||
Height = contentH + 2 * border,
|
||||
Opacity = 1f,
|
||||
Visible = true,
|
||||
Anchors = AnchorEdges.None,
|
||||
Draggable = true,
|
||||
Resizable = true,
|
||||
ResizeX = false,
|
||||
ResizableEdges = ResizeEdges.Bottom,
|
||||
MinHeight = contentH + 2 * border,
|
||||
MaxHeight = 560f,
|
||||
};
|
||||
|
||||
inventoryRoot.Left = border;
|
||||
inventoryRoot.Top = border;
|
||||
inventoryRoot.Width = contentW;
|
||||
inventoryRoot.Height = contentH;
|
||||
inventoryRoot.Anchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Bottom;
|
||||
inventoryRoot.Draggable = false;
|
||||
frame.AddChild(inventoryRoot);
|
||||
RetailWindowHandle handle = RetailWindowFrame.Mount(
|
||||
stack.UiHost.Root,
|
||||
inventoryRoot,
|
||||
stack.ResolveChrome,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.Inventory,
|
||||
Chrome = RetailWindowChrome.NineSlice,
|
||||
Left = 900f,
|
||||
Top = 18f,
|
||||
ContentWidth = contentW,
|
||||
ContentHeight = contentH,
|
||||
ResizeX = false,
|
||||
ResizeY = true,
|
||||
ResizableEdges = ResizeEdges.Bottom,
|
||||
MaxHeight = 560f,
|
||||
ContentAnchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Bottom,
|
||||
});
|
||||
|
||||
StretchV(layout, 0x100001D0u);
|
||||
StretchV(layout, 0x100001CFu);
|
||||
|
|
@ -188,7 +194,7 @@ internal static class MockupDesktop
|
|||
PinTopLeft(layout, 0x100001CDu);
|
||||
PinTopLeft(layout, 0x100001CEu);
|
||||
|
||||
return frame;
|
||||
return handle;
|
||||
}
|
||||
|
||||
private static void StretchV(ImportedLayout layout, uint id)
|
||||
|
|
@ -203,7 +209,7 @@ internal static class MockupDesktop
|
|||
element.Anchors = AnchorEdges.Left | AnchorEdges.Top;
|
||||
}
|
||||
|
||||
private static UiElement? MountChat(DatCollection dats, RenderStack stack)
|
||||
private static RetailWindowHandle? MountChat(DatCollection dats, RenderStack stack)
|
||||
{
|
||||
var rootInfo = LayoutImporter.ImportInfos(dats, ChatWindowController.LayoutId);
|
||||
if (rootInfo is null) return null;
|
||||
|
|
@ -229,42 +235,42 @@ internal static class MockupDesktop
|
|||
stack.ResolveChrome);
|
||||
if (controller is null) return null;
|
||||
|
||||
const int border = RetailChromeSprites.Border;
|
||||
var chatRoot = controller.Root;
|
||||
float contentW = 490f;
|
||||
float contentH = chatRoot.Height;
|
||||
var frame = new UiNineSlicePanel(stack.ResolveChrome)
|
||||
{
|
||||
Left = 12f,
|
||||
Top = 390f,
|
||||
Width = contentW + 2 * border,
|
||||
Height = contentH + 2 * border,
|
||||
MinWidth = 200f,
|
||||
MinHeight = 90f,
|
||||
Opacity = 0.75f,
|
||||
};
|
||||
|
||||
chatRoot.Left = border;
|
||||
chatRoot.Top = border;
|
||||
chatRoot.Width = contentW;
|
||||
chatRoot.Height = contentH;
|
||||
chatRoot.Anchors = AnchorEdges.Left | AnchorEdges.Top | AnchorEdges.Right | AnchorEdges.Bottom;
|
||||
chatRoot.Draggable = false;
|
||||
chatRoot.Resizable = false;
|
||||
frame.AddChild(chatRoot);
|
||||
RetailWindowHandle handle = RetailWindowFrame.Mount(
|
||||
stack.UiHost.Root,
|
||||
chatRoot,
|
||||
stack.ResolveChrome,
|
||||
new RetailWindowFrame.Options
|
||||
{
|
||||
WindowName = WindowNames.Chat,
|
||||
Chrome = RetailWindowChrome.NineSlice,
|
||||
Left = 12f,
|
||||
Top = 390f,
|
||||
ContentWidth = 490f,
|
||||
ContentHeight = chatRoot.Height,
|
||||
RebaseContentLayout = true,
|
||||
DatConstraintSource = controller.DatWindowInfo,
|
||||
MinWidth = 200f,
|
||||
ResizeX = true,
|
||||
ResizeY = true,
|
||||
Opacity = 0.75f,
|
||||
});
|
||||
controller.AttachWindow(handle);
|
||||
|
||||
stack.UiHost.Root.DefaultTextInput = controller.Input;
|
||||
return frame;
|
||||
return handle;
|
||||
}
|
||||
|
||||
private static void RegisterWindow(RenderStack stack, List<MockupWindow> windows,
|
||||
string name, string title, UiElement element, int zOrder)
|
||||
private static void RecordWindow(
|
||||
List<MockupWindow> windows,
|
||||
string title,
|
||||
RetailWindowHandle handle,
|
||||
int zOrder)
|
||||
{
|
||||
UiElement element = handle.OuterFrame;
|
||||
element.ZOrder = zOrder;
|
||||
stack.UiHost.Root.AddChild(element);
|
||||
stack.UiHost.RegisterWindow(name, element);
|
||||
windows.Add(new MockupWindow(
|
||||
name,
|
||||
handle.Name,
|
||||
title,
|
||||
element,
|
||||
new MockupRect(element.Left, element.Top, element.Width, element.Height),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue