feat(render): Campaign V slice V4a - port TextRenderer/BitmapFont/DebugLineRenderer/TextureCache onto IGpuDevice
TextRenderer, BitmapFont, DebugLineRenderer, and TextureCache's UI-texture
upload path (GetOrUploadRenderSurface/UploadRgba8) now issue every draw and
resource creation through the pinned IGpuDevice/IGpuFrame/IGpuPassEncoder
RHI contract instead of raw GL. This is the RHI's first real production
consumer - V0-V3 only established the contract, GL backend skeleton, and a
shader-dialect migration with no live GL exercise. TextRenderer owns one
IGpuPipeline (ui_text shader, straight-alpha blend, depth disabled) and
allocates a per-bucket ring each Flush; BitmapFont's atlas texture is
created and uploaded via device.CreateTexture/.Upload; DebugLineRenderer
mirrors the same one-pipeline-per-Flush shape for its line-list draws.
World-path TextureCache methods (GetOrUpload, the raw-GL layer-array
upload) are untouched - still legacy GL, still out of scope.
Frame lifecycle: GpuDeviceFrameLifetime (RenderFrameOrchestrator.cs) wraps
IGpuDevice.BeginFrame()/IGpuFrame.End() inside the existing
IRenderFrameLifetime bracket HostInputCameraCompositionPhase already opens
per callback, additively - no frame-graph restructuring. Ported renderers
reach the frame via ICurrentGpuFrameSource, a plain interface (not a
delegate field) so WorldSceneDiagnosticsController keeps passing its
existing "no stored window/delegate" architectural-conformance test.
Two real bugs surfaced by actually exercising the RHI against a live GL
context (nothing here was previously reachable before this slice):
- GlGpuDevice.BeginFrame() now resets the render-state cache every frame.
The cache assumes it is the sole writer of GL program/blend/depth/cull
state, which was true while it had zero real consumers, but every
still-legacy renderer (WbDrawDispatcher, terrain, particles, EnvCells)
mutates that same GL state directly and never informs the cache. Once a
legacy renderer ran between two RHI binds, the cache's belief about the
current GL program went stale, so a later BindPipeline(text shader)
skipped re-issuing glUseProgram and the following push-constant upload
threw GL_INVALID_OPERATION against whatever program was actually bound.
Reset() at the frame boundary is the same defensive move BeginPass
already makes after a forced clear (see its comment); it costs one
redundant state application on the frame's first bind.
- GL_MULTISAMPLE has no representation in the pinned contract. Added a
GL-backend-internal Multisample field to GlRenderStateSnapshot/Changes,
computed from GpuPipelineDescription.SampleCount at BindPipeline time -
mirrors how Vulkan bakes MSAA into the pipeline instead of a separate
toggle.
Collateral, scoped to keep the port real rather than a stub:
- GpuTextureSlot (Unassigned = uint.MaxValue, NOT 0) now flows through
every consumer of TextureCache.GetOrUploadRenderSurface/UploadRgba8 and
TextRenderer.DrawSprite - the entire retained UI layer, since a pervasive
Func<uint,(uint,int,int)> sprite-resolve delegate threads through nearly
every UI element/controller. Every prior `== 0` / `!= 0` "no texture"
check became `.IsAssigned` / `!.IsAssigned`; slot 0 is a real assigned
slot (the device's default white texture), so the old sentinel would
have produced live visual regressions if left in place.
- GpuTextureSlot/IGpuDevice/IGpuFrame are internal, so ~270 previously
public AcDream.App types that touched them (directly or transitively)
are now internal too - safe, since AcDream.App is an exe with no
external project references; only the two test projects consume it, via
InternalsVisibleTo. A handful of unrelated types the sweep caught
(ElementInfo/ImportedLayout's property-bag hierarchy, several enums used
as public [Theory] parameters, CursorFeedbackSnapshot's DragAcceptState)
were reverted back to public where making them internal would have
either cascaded into unrelated files or broken xUnit's public-member
discovery.
- ExternalViewportTextureBridge (new) registers the still-raw-GL FBO
color textures PrivateEntityViewportRenderer/PaperdollViewportRenderer
produce (V4g's scope) into the device's texture table for
UiViewport.TextureHandle, via a temporary
GlGpuDevice.RegisterExternalColorTexture escape hatch (internal, not
part of IGpuDevice) deleted when V4g ports those viewports.
- TextRenderGlStateScope.cs and its test deleted: the pipeline description
now bakes what it used to restore by hand.
- ResourceCleanupGroupTests/GlTextureOwnershipTests: the two source-text
conformance tests keyed to TextRenderer's old multi-resource
construction shape (Shader + per-flight FrameBufferSet array + white
texture + tracked VAO/VBO, all via ResourceCleanupGroup) no longer apply
- that shape is gone, replaced by one IGpuPipeline created through
IGpuDevice. The construction-order test is deleted; the checked-commit
texture-creation check now targets GlGpuTexture (which already used
the same GlResourceCommand.CreateName primitive before this slice).
Gates:
- dotnet build -c Release: 0 warnings, 0 errors (AcDream.App has
TreatWarningsAsErrors).
- dotnet test tests/AcDream.App.Tests -c Release: 3,840 passed / 3
skipped (was 3,843/3 entering this slice - net 3 fewer tests:
TextRendererFailureSafetyTests.cs deleted (2, tested the now-deleted
TextRenderGlStateScope) plus the one retired ResourceCleanupGroupTests
method). Full solution: 8,908 passed / 5 skipped across all nine test
projects.
- Offline pixel gate (tools/run-offline-pixel-gate.ps1, parent ec414d60
vs this commit): differing fraction 0.318% (1,791/563,200 compared
pixels), above the 0.001 threshold. Investigated pixel-by-pixel rather
than waved through: a diff heatmap plus 4x crops at the differing
clusters show zero differences anywhere in the retained UI, terrain,
scenery, or static meshes - every differing pixel sits on continuously-
animated ambient content (flying-insect sprites over the swamp, foliage
sparkle/dew glints) whose exact phase depends on elapsed wall-clock
time, the same category the gate's own sky-masking rationale already
documents and the campaign doc's coverage table explicitly excludes
("Not covered - particles"). Confirming evidence: two same-commit
captures at HEAD compare clean against each other (0.0025%), and two
same-commit captures at the parent compare clean against each other
(0.0044%) - only base-vs-head is consistently elevated, which is what
frame-pacing drift from genuinely new per-frame RHI work (BeginFrame,
ring resets, the render-state reset above) would produce against a
fixed wall-clock capture deadline, not a rendering defect. Recommend a
quick user visual check of this capture pair alongside the automated
result, matching how V2c's particle work was already handled in this
campaign (flagged for user visual confirmation rather than blocked on
an automated gate that cannot cover animated content).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
ec414d60cd
commit
ceec3bc440
334 changed files with 3660 additions and 3840 deletions
|
|
@ -1,27 +1,27 @@
|
|||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
|
||||
namespace AcDream.App.Studio;
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpLayout — load a panel from the retail UI layout dump
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpLayout — load a panel from the retail UI layout dump
|
||||
//
|
||||
// The dump stores every node's rect in ABSOLUTE screen coordinates (the
|
||||
// panel's design position in the retail UI, not relative to its parent).
|
||||
// Evidence: for the "inventory" panel, the root node is at x=500,y=138 and
|
||||
// its direct children are also at x=500,y=161 — the child y=161 is only
|
||||
// its direct children are also at x=500,y=161 — the child y=161 is only
|
||||
// 23 pixels below the parent y=138, which makes sense as a child offset
|
||||
// (the header row), not as the raw rect. If the rects were parent-relative,
|
||||
// (500,161) would place the child way off the window.
|
||||
//
|
||||
// DumpLayout converts absolute → parent-relative by computing:
|
||||
// DumpLayout converts absolute → parent-relative by computing:
|
||||
// child.Left = child.Rect.X - parent.Rect.X
|
||||
// child.Top = child.Rect.Y - parent.Rect.Y
|
||||
//
|
||||
// The root node (ParentTraversalIndex == null) is placed at (0,0) so the
|
||||
// whole tree sits at the UiHost origin rather than at the panel's retail
|
||||
// screen position.
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Builds a static <see cref="UiElement"/> tree from the retail UI layout dump
|
||||
|
|
@ -30,11 +30,11 @@ namespace AcDream.App.Studio;
|
|||
/// node's <see cref="UiElement.EventId"/> set to the dump's element_id and
|
||||
/// <see cref="UiElement.Name"/> set to the widget_kind string.
|
||||
///
|
||||
/// <para>This source is STATIC — no controllers, no FixtureProvider, no live
|
||||
/// <para>This source is STATIC — no controllers, no FixtureProvider, no live
|
||||
/// game data. It is a build reference for the UI Studio showing any of the 26
|
||||
/// retail windows without needing the production panel wired up.</para>
|
||||
/// </summary>
|
||||
public static class DumpLayout
|
||||
internal static class DumpLayout
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse the dump at <paramref name="dumpPath"/>, find the panel whose slug
|
||||
|
|
@ -42,7 +42,7 @@ public static class DumpLayout
|
|||
///
|
||||
/// <para>
|
||||
/// <paramref name="resolve"/> maps a RenderSurface id (0x06xxxxxx) to a
|
||||
/// (GL texture handle, native width, native height) triple — pass
|
||||
/// (GL texture handle, native width, native height) triple — pass
|
||||
/// <c>RenderStack.ResolveChrome</c> from the studio, or a stub returning
|
||||
/// (1,1,1) for tests.
|
||||
/// </para>
|
||||
|
|
@ -52,10 +52,10 @@ public static class DumpLayout
|
|||
public static UiElement? Load(
|
||||
string dumpPath,
|
||||
string slug,
|
||||
Func<uint, (uint, int, int)> resolve,
|
||||
Func<uint, (GpuTextureSlot, int, int)> resolve,
|
||||
out string? error)
|
||||
{
|
||||
// ── 1. Parse the dump JSON ────────────────────────────────────────
|
||||
// ── 1. Parse the dump JSON ────────────────────────────────────────
|
||||
var dump = UiDumpModel.Parse(dumpPath);
|
||||
if (dump is null)
|
||||
{
|
||||
|
|
@ -63,7 +63,7 @@ public static class DumpLayout
|
|||
return null;
|
||||
}
|
||||
|
||||
// ── 2. Find the requested panel ───────────────────────────────────
|
||||
// ── 2. Find the requested panel ───────────────────────────────────
|
||||
var panel = dump.Panels.FirstOrDefault(
|
||||
p => string.Equals(p.Slug, slug, StringComparison.OrdinalIgnoreCase));
|
||||
if (panel is null)
|
||||
|
|
@ -79,12 +79,12 @@ public static class DumpLayout
|
|||
return null;
|
||||
}
|
||||
|
||||
// ── 3. Build a traversal-index → node lookup ──────────────────────
|
||||
// ── 3. Build a traversal-index → node lookup ──────────────────────
|
||||
var byIndex = new Dictionary<int, DumpNode>(panel.Nodes.Count);
|
||||
foreach (var n in panel.Nodes)
|
||||
byIndex[n.TraversalIndex] = n;
|
||||
|
||||
// ── 4. Create UiElement objects for every node ────────────────────
|
||||
// ── 4. Create UiElement objects for every node ────────────────────
|
||||
var elements = new Dictionary<int, UiElement>(panel.Nodes.Count);
|
||||
foreach (var node in panel.Nodes)
|
||||
{
|
||||
|
|
@ -92,7 +92,7 @@ public static class DumpLayout
|
|||
elements[node.TraversalIndex] = el;
|
||||
}
|
||||
|
||||
// ── 5. Wire parent–child relationships + set parent-relative coords ─
|
||||
// ── 5. Wire parent–child relationships + set parent-relative coords ─
|
||||
UiElement? root = null;
|
||||
foreach (var node in panel.Nodes)
|
||||
{
|
||||
|
|
@ -100,7 +100,7 @@ public static class DumpLayout
|
|||
|
||||
if (node.ParentTraversalIndex is null)
|
||||
{
|
||||
// Root node — place at (0,0) so the tree sits at the UiHost origin.
|
||||
// Root node — place at (0,0) so the tree sits at the UiHost origin.
|
||||
// The panel's absolute rect offset is discarded here (it was the
|
||||
// retail design position inside the retail screen, which we don't need).
|
||||
el.Left = 0f;
|
||||
|
|
@ -109,7 +109,7 @@ public static class DumpLayout
|
|||
}
|
||||
else
|
||||
{
|
||||
// Non-root: convert absolute → parent-relative by subtracting parent rect.
|
||||
// Non-root: convert absolute → parent-relative by subtracting parent rect.
|
||||
// child.Left = child.Rect.X - parent.Rect.X
|
||||
// child.Top = child.Rect.Y - parent.Rect.Y
|
||||
// This preserves the visual layout inside each group without placing the
|
||||
|
|
@ -137,11 +137,11 @@ public static class DumpLayout
|
|||
return root;
|
||||
}
|
||||
|
||||
// ── Private helpers ───────────────────────────────────────────────────────
|
||||
// ── Private helpers ───────────────────────────────────────────────────────
|
||||
|
||||
private static UiElement BuildElement(
|
||||
DumpNode node,
|
||||
Func<uint, (uint, int, int)> resolve)
|
||||
Func<uint, (GpuTextureSlot, int, int)> resolve)
|
||||
{
|
||||
uint imageId = UiDumpModel.PickImageId(node);
|
||||
var kind = node.WidgetKind ?? "Group";
|
||||
|
|
@ -149,7 +149,7 @@ public static class DumpLayout
|
|||
UiElement el;
|
||||
if (imageId != 0 && !string.Equals(kind, "Group", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Sprite/Button/Scrollbar/Slider — create a sprite-drawing element.
|
||||
// Sprite/Button/Scrollbar/Slider — create a sprite-drawing element.
|
||||
el = new DumpSpriteElement(imageId, resolve)
|
||||
{
|
||||
Name = kind,
|
||||
|
|
@ -159,7 +159,7 @@ public static class DumpLayout
|
|||
}
|
||||
else
|
||||
{
|
||||
// Group (or sprite without an image) — plain container, no own draw.
|
||||
// Group (or sprite without an image) — plain container, no own draw.
|
||||
el = new DumpGroupElement()
|
||||
{
|
||||
Name = kind,
|
||||
|
|
@ -168,7 +168,7 @@ public static class DumpLayout
|
|||
};
|
||||
}
|
||||
|
||||
// EventId is set from the dump's element_id (cast to uint — the decimal
|
||||
// EventId is set from the dump's element_id (cast to uint — the decimal
|
||||
// values in the JSON represent the same dat handle used at runtime).
|
||||
el.EventId = (uint)node.ElementId;
|
||||
el.Left = node.Rect.X; // overwritten by caller per root/child logic
|
||||
|
|
@ -180,27 +180,27 @@ public static class DumpLayout
|
|||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpSpriteElement — minimal element that draws a single sprite
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpSpriteElement — minimal element that draws a single sprite
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Draws a single sprite at its native size tiled to fill <see cref="UiElement.Width"/>
|
||||
/// × <see cref="UiElement.Height"/>. Used for Sprite/Button/Scrollbar/Slider nodes from
|
||||
/// × <see cref="UiElement.Height"/>. Used for Sprite/Button/Scrollbar/Slider nodes from
|
||||
/// the retail UI dump.
|
||||
///
|
||||
/// <para>We do NOT reuse <see cref="AcDream.App.UI.Layout.UiDatElement"/> here because
|
||||
/// that class requires an <c>ElementInfo</c> with a populated <c>StateMedia</c>
|
||||
/// dictionary — the dat-import plumbing — which is not needed for a static dump
|
||||
/// dictionary — the dat-import plumbing — which is not needed for a static dump
|
||||
/// preview. A minimal subclass keeps the code simpler and the dependency surface
|
||||
/// smaller.</para>
|
||||
/// </summary>
|
||||
internal sealed class DumpSpriteElement : UiElement
|
||||
{
|
||||
private readonly uint _imageId;
|
||||
private readonly Func<uint, (uint tex, int w, int h)> _resolve;
|
||||
private readonly Func<uint, (GpuTextureSlot tex, int w, int h)> _resolve;
|
||||
|
||||
public DumpSpriteElement(uint imageId, Func<uint, (uint tex, int w, int h)> resolve)
|
||||
public DumpSpriteElement(uint imageId, Func<uint, (GpuTextureSlot tex, int w, int h)> resolve)
|
||||
{
|
||||
_imageId = imageId;
|
||||
_resolve = resolve;
|
||||
|
|
@ -211,25 +211,25 @@ internal sealed class DumpSpriteElement : UiElement
|
|||
if (_imageId == 0) return;
|
||||
|
||||
var (tex, tw, th) = _resolve(_imageId);
|
||||
if (tex == 0 || tw == 0 || th == 0) return;
|
||||
if (!tex.IsAssigned || tw == 0 || th == 0) return;
|
||||
|
||||
// Tile at native resolution (same as UiDatElement.OnDraw — UV-repeat on both
|
||||
// Tile at native resolution (same as UiDatElement.OnDraw — UV-repeat on both
|
||||
// axes via GL_REPEAT, Width/tw and Height/th tile the texture).
|
||||
ctx.DrawSprite(tex, 0, 0, Width, Height,
|
||||
0, 0, Width / tw, Height / th, Vector4.One);
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpGroupElement — pure container (Group nodes from the dump)
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// DumpGroupElement — pure container (Group nodes from the dump)
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Container element for dump Group nodes — no own draw, just hosts children.
|
||||
/// Container element for dump Group nodes — no own draw, just hosts children.
|
||||
/// Extending UiElement directly (no OnDraw override) gives transparent groups,
|
||||
/// which matches Group nodes in the retail layout that have no background sprite.
|
||||
/// </summary>
|
||||
internal sealed class DumpGroupElement : UiElement
|
||||
{
|
||||
// No OnDraw — completely transparent container.
|
||||
// No OnDraw — completely transparent container.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Combat;
|
||||
|
|
@ -15,7 +15,7 @@ namespace AcDream.App.Studio;
|
|||
/// controller Bind methods against <see cref="SampleData"/>.
|
||||
///
|
||||
/// <para>
|
||||
/// The studio is intentionally thin — there is no live game session, no
|
||||
/// The studio is intentionally thin — there is no live game session, no
|
||||
/// server connection, and no network. FixtureProvider bridges that gap by
|
||||
/// feeding static fixtures (vitals percentages, a fake inventory, empty
|
||||
/// shortcut lists) so the bound widgets show plausible state instead of
|
||||
|
|
@ -23,7 +23,7 @@ namespace AcDream.App.Studio;
|
|||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>IconIds approach:</b> raw-resolve stub — resolve the base <c>iconId</c>
|
||||
/// <b>IconIds approach:</b> raw-resolve stub — resolve the base <c>iconId</c>
|
||||
/// via <see cref="RenderStack.ResolveChrome"/> and return the GL handle
|
||||
/// directly. This is intentionally simpler than GameWindow's full
|
||||
/// <see cref="IconComposer"/> (5-layer composite). The raw icon is enough
|
||||
|
|
@ -31,7 +31,7 @@ namespace AcDream.App.Studio;
|
|||
/// compositor is the live-game concern, not the layout preview concern.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static class FixtureProvider
|
||||
internal static class FixtureProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Populate <paramref name="layout"/> with sample data appropriate for
|
||||
|
|
@ -131,7 +131,7 @@ public static class FixtureProvider
|
|||
{
|
||||
// Resolve the per-list empty-slot art from the dat cell template, matching the
|
||||
// exact lookup GameWindow.OnLoad performs (UIElement_ItemList::InternalCreateItem
|
||||
// 0x004e3570 → attr 0x1000000e → catalog 0x21000037 → ItemSlot_Empty).
|
||||
// 0x004e3570 → attr 0x1000000e → catalog 0x21000037 → ItemSlot_Empty).
|
||||
uint contentsEmpty = ItemListCellTemplate.ResolveEmptySprite(dats, 0x21000021u, 0x100001C6u);
|
||||
uint sideBagEmpty = ItemListCellTemplate.ResolveEmptySprite(dats, 0x21000022u, 0x100001CAu);
|
||||
uint mainPackEmpty = ItemListCellTemplate.ResolveEmptySprite(dats, 0x21000022u, 0x100001C9u);
|
||||
|
|
@ -177,10 +177,10 @@ public static class FixtureProvider
|
|||
return new RetainedPanelControllerGroup(inventory, paperdoll);
|
||||
}
|
||||
|
||||
case 0x2100002Eu: // gmStatManagementUI — Attributes/Skills/Titles window (LayoutDesc 0x2100002E)
|
||||
case 0x2100002Eu: // gmStatManagementUI — Attributes/Skills/Titles window (LayoutDesc 0x2100002E)
|
||||
// Bind the REAL importer-mounted header + list elements (name/heritage/PK/level/
|
||||
// total-XP/XP-meter + the 9-row attribute list + footer State-A). NOT the text-report
|
||||
// sub-panel (that is gmCharacterInfoUI 0x2100001A → CharacterController).
|
||||
// sub-panel (that is gmCharacterInfoUI 0x2100001A → CharacterController).
|
||||
// LargeDatFont (0x40000001, MaxCharHeight=18) is used for the attribute row text;
|
||||
// fallback to VitalsDatFont (0x40000000, 16px) if unavailable.
|
||||
CharacterStatController.Bind(
|
||||
|
|
@ -192,12 +192,12 @@ public static class FixtureProvider
|
|||
return null;
|
||||
|
||||
default:
|
||||
// Unknown layout — no-op; the panel renders structurally.
|
||||
// Unknown layout — no-op; the panel renders structurally.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Build the <c>iconIds</c> delegate for toolbar / inventory controllers.
|
||||
|
|
@ -206,15 +206,15 @@ public static class FixtureProvider
|
|||
/// Raw-resolve stub: resolve the base <paramref name="iconId"/> (arg 2)
|
||||
/// via <see cref="RenderStack.ResolveChrome"/> and return its GL handle.
|
||||
/// The remaining args (type, underlayId, overlayId, effects) are ignored
|
||||
/// for the studio — a single-layer icon is sufficient for layout preview.
|
||||
/// for the studio — a single-layer icon is sufficient for layout preview.
|
||||
/// </para>
|
||||
///
|
||||
/// <para>This is what the task spec calls "v1 raw-resolve stub".</para>
|
||||
/// </summary>
|
||||
private static Func<ItemType, uint, uint, uint, uint, uint> MakeIconIds(RenderStack stack)
|
||||
private static Func<ItemType, uint, uint, uint, uint, GpuTextureSlot> MakeIconIds(RenderStack stack)
|
||||
=> (_, iconId, _, _, _) =>
|
||||
{
|
||||
if (iconId == 0u) return 0u;
|
||||
if (iconId == 0u) return GpuTextureSlot.Unassigned;
|
||||
var (handle, _, _) = stack.ResolveChrome(iconId);
|
||||
return handle;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using AcDream.App.UI;
|
||||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using DatReaderWriter;
|
||||
using AcDream.Content;
|
||||
|
|
@ -6,21 +6,21 @@ using AcDream.Content;
|
|||
namespace AcDream.App.Studio;
|
||||
|
||||
/// <summary>Which kind of source the studio is currently previewing.</summary>
|
||||
public enum LayoutSourceKind { DatLayout, Markup }
|
||||
internal enum LayoutSourceKind { DatLayout, Markup }
|
||||
|
||||
/// <summary>
|
||||
/// Wraps the two ways the UI Studio can load a panel to preview:
|
||||
/// a LayoutDesc dat id, or a KSML markup file path (Task 6 — unsupported now).
|
||||
/// a LayoutDesc dat id, or a KSML markup file path (Task 6 — unsupported now).
|
||||
///
|
||||
/// <para>Call <see cref="Load"/> with the current <see cref="StudioOptions"/> to
|
||||
/// import the layout and get the root <see cref="UiElement"/>. The result is also
|
||||
/// cached in <see cref="CurrentLayout"/> so <see cref="Reload"/> can re-run the same
|
||||
/// source without re-reading the options.</para>
|
||||
/// </summary>
|
||||
public sealed class LayoutSource
|
||||
internal sealed class LayoutSource
|
||||
{
|
||||
private readonly IDatReaderWriter _dats;
|
||||
private readonly Func<uint, (uint, int, int)> _resolve;
|
||||
private readonly Func<uint, (GpuTextureSlot, int, int)> _resolve;
|
||||
private readonly UiDatFont? _datFont;
|
||||
private readonly Func<uint, UiDatFont?>? _fontResolve;
|
||||
|
||||
|
|
@ -33,17 +33,17 @@ public sealed class LayoutSource
|
|||
/// <summary>
|
||||
/// Create a LayoutSource.
|
||||
/// </summary>
|
||||
/// <param name="fontResolve">Optional per-element font resolver: FontDid →
|
||||
/// <param name="fontResolve">Optional per-element font resolver: FontDid →
|
||||
/// <see cref="UiDatFont"/> (null when the font isn't in the dats). When supplied,
|
||||
/// elements with a non-zero FontDid receive their own dat font at build time
|
||||
/// instead of the shared <paramref name="datFont"/> global. Controllers that
|
||||
/// explicitly set <see cref="UiText.DatFont"/> after
|
||||
/// <see cref="ImportedLayout.FindElement"/> still override the build-time value.
|
||||
/// Pass null (default) for the original single-font behavior — the live
|
||||
/// Pass null (default) for the original single-font behavior — the live
|
||||
/// <see cref="GameWindow"/> path passes null so it is provably unchanged.</param>
|
||||
public LayoutSource(
|
||||
IDatReaderWriter dats,
|
||||
Func<uint, (uint, int, int)> resolve,
|
||||
Func<uint, (GpuTextureSlot, int, int)> resolve,
|
||||
UiDatFont? datFont,
|
||||
Func<uint, UiDatFont?>? fontResolve = null)
|
||||
{
|
||||
|
|
@ -107,7 +107,7 @@ public sealed class LayoutSource
|
|||
return LoadDat(LayoutId.Value);
|
||||
}
|
||||
|
||||
// ── Private ──────────────────────────────────────────────────────────────────
|
||||
// ── Private ──────────────────────────────────────────────────────────────────
|
||||
|
||||
private UiElement? LoadDat(uint layoutId)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using AcDream.App.Rendering.Wb;
|
||||
using AcDream.App.UI;
|
||||
|
|
@ -19,11 +19,11 @@ namespace AcDream.App.Studio;
|
|||
/// displaying the texture in ImGui (pass uv0=(0,1), uv1=(1,0) to ImGui.Image)
|
||||
/// so the image appears right-side-up in ImGui's top-left coordinate system.</para>
|
||||
/// </summary>
|
||||
public sealed unsafe class PanelFbo : IDisposable
|
||||
internal sealed unsafe class PanelFbo : IDisposable
|
||||
{
|
||||
private readonly GL _gl;
|
||||
|
||||
// Off-screen target — lazily (re)created when the requested size changes.
|
||||
// Off-screen target — lazily (re)created when the requested size changes.
|
||||
private uint _fbo;
|
||||
private uint _colorTex;
|
||||
private uint _depthRbo;
|
||||
|
|
@ -37,7 +37,7 @@ public sealed unsafe class PanelFbo : IDisposable
|
|||
|
||||
/// <summary>
|
||||
/// Render <paramref name="host"/> (a full <see cref="UiHost"/> draw pass) into a
|
||||
/// private FBO at <paramref name="width"/> × <paramref name="height"/> pixels.
|
||||
/// private FBO at <paramref name="width"/> × <paramref name="height"/> pixels.
|
||||
/// Returns the GL color texture handle (0 on failure). The texture is valid until
|
||||
/// the next call to <see cref="Render"/> with a different size, or until <see cref="Dispose"/>.
|
||||
/// </summary>
|
||||
|
|
@ -50,7 +50,7 @@ public sealed unsafe class PanelFbo : IDisposable
|
|||
|
||||
// Seal the entire pass: GLStateScope saves + restores every GL state the
|
||||
// UI draw touches (viewport, blend, FBO binding, etc.) so ImGui's own state
|
||||
// — set up by BeginFrame and expected intact by Render — is untouched.
|
||||
// — set up by BeginFrame and expected intact by Render — is untouched.
|
||||
using var scope = new GLStateScope(_gl);
|
||||
|
||||
_gl.BindFramebuffer(FramebufferTarget.Framebuffer, _fbo);
|
||||
|
|
@ -95,7 +95,7 @@ public sealed unsafe class PanelFbo : IDisposable
|
|||
return buf;
|
||||
}
|
||||
|
||||
// ── FBO lifecycle (mirrors PaperdollViewportRenderer.EnsureFramebuffer) ──────
|
||||
// ── FBO lifecycle (mirrors PaperdollViewportRenderer.EnsureFramebuffer) ──────
|
||||
|
||||
private void EnsureFramebuffer(int width, int height)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using AcDream.App.UI.Layout;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Items;
|
||||
|
||||
namespace AcDream.App.Studio;
|
||||
|
|
@ -25,18 +25,18 @@ namespace AcDream.App.Studio;
|
|||
/// Equipped chest armor : 0x060011CFu
|
||||
/// Equipped melee weapon : 0x060011CBu
|
||||
///
|
||||
/// These are the icon *base* RenderSurface ids — the same ids GameWindow passes
|
||||
/// These are the icon *base* RenderSurface ids — the same ids GameWindow passes
|
||||
/// as `iconId` into the iconIds lambda. FixtureProvider resolves them via
|
||||
/// <see cref="Rendering.RenderStack.ResolveChrome"/> and returns the raw GL handle.
|
||||
/// </summary>
|
||||
public static class SampleData
|
||||
internal static class SampleData
|
||||
{
|
||||
// ── Guids ────────────────────────────────────────────────────────────────
|
||||
// ── Guids ────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Fake server guid for the studio's synthetic player.</summary>
|
||||
public const uint PlayerGuid = 0x50000001u;
|
||||
|
||||
// Items in main pack (slots 0–5).
|
||||
// Items in main pack (slots 0–5).
|
||||
private const uint SwordGuid = 0x50000010u;
|
||||
private const uint ChestGuid = 0x50000011u;
|
||||
private const uint GlovesGuid = 0x50000012u;
|
||||
|
|
@ -53,7 +53,7 @@ public static class SampleData
|
|||
private const uint ChestEqGuid = 0x50000031u;
|
||||
private const uint WeaponEqGuid = 0x50000032u;
|
||||
|
||||
// ── Icon ids (0x06xxxxxx RenderSurface dat ids) ───────────────────────────
|
||||
// ── Icon ids (0x06xxxxxx RenderSurface dat ids) ───────────────────────────
|
||||
|
||||
// These are the same underlay/fallback icon ids the IconComposer tests pin.
|
||||
private const uint IconWeapon = 0x060011CBu; // weapon underlay
|
||||
|
|
@ -62,7 +62,7 @@ public static class SampleData
|
|||
private const uint IconJewelry = 0x060011D5u; // jewelry underlay
|
||||
private const uint IconMisc = 0x060011D4u; // misc / fallback underlay
|
||||
|
||||
// ── Public API ──────────────────────────────────────────────────────────
|
||||
// ── Public API ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Build a fresh <see cref="ClientObjectTable"/> populated with the
|
||||
|
|
@ -74,7 +74,7 @@ public static class SampleData
|
|||
{
|
||||
var t = new ClientObjectTable();
|
||||
|
||||
// ── Player object ─────────────────────────────────────────────────
|
||||
// ── Player object ─────────────────────────────────────────────────
|
||||
t.AddOrUpdate(new ClientObject
|
||||
{
|
||||
ObjectId = PlayerGuid,
|
||||
|
|
@ -89,7 +89,7 @@ public static class SampleData
|
|||
AetheriaUnlocks.PropertyId,
|
||||
(int)AetheriaUnlockState.All);
|
||||
|
||||
// ── Loose items in main pack (slots 0–5) ──────────────────────────
|
||||
// ── Loose items in main pack (slots 0–5) ──────────────────────────
|
||||
|
||||
AddItem(t, SwordGuid, ItemType.MeleeWeapon, IconWeapon, "Iron Sword", PlayerGuid, 0, burden: 60);
|
||||
AddItem(t, ChestGuid, ItemType.Armor, IconArmor, "Leather Breastplate", PlayerGuid, 1, burden: 200);
|
||||
|
|
@ -98,14 +98,14 @@ public static class SampleData
|
|||
AddItem(t, HealKitGuid, ItemType.Misc, IconMisc, "Healing Kit", PlayerGuid, 4, burden: 30);
|
||||
AddItem(t, CompGuid, ItemType.SpellComponents, IconMisc, "Spell Comps", PlayerGuid, 5, burden: 25, stackSize: 50, stackMax: 100);
|
||||
|
||||
// ── Side bags (Container items in main pack, slots 6 & 7) ─────────
|
||||
// ── Side bags (Container items in main pack, slots 6 & 7) ─────────
|
||||
|
||||
AddItem(t, Bag1Guid, ItemType.Container, IconMisc, "Small Pack 1",
|
||||
containerId: PlayerGuid, slot: 6, burden: 20, itemsCapacity: 24);
|
||||
AddItem(t, Bag2Guid, ItemType.Container, IconMisc, "Small Pack 2",
|
||||
containerId: PlayerGuid, slot: 7, burden: 20, itemsCapacity: 24);
|
||||
|
||||
// ── Equipped items (ContainerId = PlayerGuid, CurrentlyEquippedLocation set) ──
|
||||
// ── Equipped items (ContainerId = PlayerGuid, CurrentlyEquippedLocation set) ──
|
||||
|
||||
AddEquipped(t, HelmGuid, ItemType.Armor, IconClothing, "Tin Helm", EquipMask.HeadWear);
|
||||
AddEquipped(t, ChestEqGuid, ItemType.Armor, IconArmor, "Chain Coat", EquipMask.ChestArmor);
|
||||
|
|
@ -114,13 +114,13 @@ public static class SampleData
|
|||
return t;
|
||||
}
|
||||
|
||||
// ── Sample vital constants (used by FixtureProvider) ────────────────────
|
||||
// ── Sample vital constants (used by FixtureProvider) ────────────────────
|
||||
|
||||
public const float HealthPct = 0.8f;
|
||||
public const float StaminaPct = 0.6f;
|
||||
public const float ManaPct = 0.9f;
|
||||
|
||||
// ── Sample character sheet (used by CharacterController in the Studio) ───
|
||||
// ── Sample character sheet (used by CharacterController in the Studio) ───
|
||||
|
||||
/// <summary>
|
||||
/// Returns a representative <see cref="CharacterSheet"/> for the studio's
|
||||
|
|
@ -145,12 +145,12 @@ public static class SampleData
|
|||
XpToNextLevel = 42_000_000,
|
||||
XpFraction = 0.63f,
|
||||
|
||||
// Vitals: retail screenshot spec (Pass 1 acceptance criteria §Goal).
|
||||
// Vitals: retail screenshot spec (Pass 1 acceptance criteria §Goal).
|
||||
HealthCurrent = 5, HealthMax = 5,
|
||||
StaminaCurrent = 10, StaminaMax = 10,
|
||||
ManaCurrent = 10, ManaMax = 10,
|
||||
|
||||
// Attributes: Strength + Quickness = 200; all others = 10 (retail screenshot spec §Goal).
|
||||
// Attributes: Strength + Quickness = 200; all others = 10 (retail screenshot spec §Goal).
|
||||
Strength = 200,
|
||||
Endurance = 10,
|
||||
Quickness = 200,
|
||||
|
|
@ -171,9 +171,9 @@ public static class SampleData
|
|||
|
||||
// Raise costs in retail display order (Strength, Endurance, Coordination, Quickness,
|
||||
// Focus, Self, Health, Stamina, Mana).
|
||||
// Str@200 = maxed → 0 (disabled). Quickness@200 = maxed → 0. Others @10 → affordable.
|
||||
// Focus@10 → 110 matches the authoritative retail screenshot (spec §4).
|
||||
// Formula bracket at value=10: ExperienceToAttributeLevel(11) − ExperienceToAttributeLevel(10).
|
||||
// Str@200 = maxed → 0 (disabled). Quickness@200 = maxed → 0. Others @10 → affordable.
|
||||
// Focus@10 → 110 matches the authoritative retail screenshot (spec §4).
|
||||
// Formula bracket at value=10: ExperienceToAttributeLevel(11) − ExperienceToAttributeLevel(10).
|
||||
AttributeRaiseCosts = new long[] { 0L, 95L, 100L, 0L, 110L, 105L, 90L, 88L, 112L },
|
||||
AttributeRaise10Costs = new long[] { 0L, 950L, 1_000L, 0L, 1_100L, 1_050L, 900L, 880L, 1_120L },
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ public static class SampleData
|
|||
BurdenMax = 4500,
|
||||
};
|
||||
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────
|
||||
// ── Helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
private static void AddItem(
|
||||
ClientObjectTable t,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using AcDream.App.UI;
|
||||
using ImGuiNET;
|
||||
|
||||
|
|
@ -8,7 +8,7 @@ namespace AcDream.App.Studio;
|
|||
/// All canvas mouse events gathered by <see cref="StudioInspector.DrawCanvas"/> in one frame.
|
||||
/// All coordinates are already mapped to panel-local pixels (origin top-left, same as UiRoot).
|
||||
/// </summary>
|
||||
public readonly struct CanvasInputEvent
|
||||
internal readonly struct CanvasInputEvent
|
||||
{
|
||||
/// <summary>Mouse is currently hovering the canvas image. When false all other fields are 0 / false.</summary>
|
||||
public readonly bool IsHovered;
|
||||
|
|
@ -37,13 +37,13 @@ public readonly struct CanvasInputEvent
|
|||
/// <summary>
|
||||
/// Four-pane ImGui IDE for the acdream UI Studio:
|
||||
/// <list type="bullet">
|
||||
/// <item><b>Toolbar</b> — panel picker (slug combo) across the top.</item>
|
||||
/// <item><b>Canvas</b> — shows the panel FBO texture; in Interact mode mouse events
|
||||
/// <item><b>Toolbar</b> — panel picker (slug combo) across the top.</item>
|
||||
/// <item><b>Canvas</b> — shows the panel FBO texture; in Interact mode mouse events
|
||||
/// are forwarded to the panel UiHost (buttons/tabs respond); in Inspect mode a
|
||||
/// left-click hit-tests and selects the element under the cursor.</item>
|
||||
/// <item><b>Tree</b> — recursive ImGui tree of the element hierarchy; clicking a node
|
||||
/// <item><b>Tree</b> — recursive ImGui tree of the element hierarchy; clicking a node
|
||||
/// sets <see cref="Selected"/>.</item>
|
||||
/// <item><b>Properties</b> — shows the <see cref="Selected"/> element's geometry,
|
||||
/// <item><b>Properties</b> — shows the <see cref="Selected"/> element's geometry,
|
||||
/// anchors, and z-order.</item>
|
||||
/// </list>
|
||||
///
|
||||
|
|
@ -52,20 +52,20 @@ public readonly struct CanvasInputEvent
|
|||
/// sub-window. After <c>ImGui.Image</c> we call <c>ImGui.GetItemRectMin()</c> to get the
|
||||
/// screen-space top-left of the drawn image (accounting for the sub-window's title bar,
|
||||
/// padding, and any scrolling). Subtracting that from the raw mouse screen position gives
|
||||
/// panel-local pixels directly — no additional scale factor is needed because the image is
|
||||
/// panel-local pixels directly — no additional scale factor is needed because the image is
|
||||
/// drawn 1:1.</para>
|
||||
///
|
||||
/// <para><b>V-flip — no extra Y inversion needed:</b>
|
||||
/// <para><b>V-flip — no extra Y inversion needed:</b>
|
||||
/// The FBO origin is bottom-left (GL convention), so we pass uv0=(0,1), uv1=(1,0) to
|
||||
/// <c>ImGui.Image</c> to flip V. After this flip, displayed row 0 (top of the image on
|
||||
/// screen) corresponds to panel Y=0 (the top of the UI panel), matching UiRoot's
|
||||
/// top-left origin. Therefore the panel-local Y computed above maps directly into UiRoot
|
||||
/// without further inversion — do NOT flip Y again.</para>
|
||||
/// without further inversion — do NOT flip Y again.</para>
|
||||
///
|
||||
/// <para>Layout: the four panes call <c>SetNextWindowPos</c> + <c>SetNextWindowSize</c>
|
||||
/// with <c>ImGuiCond.FirstUseEver</c> so they start docked but can be freely dragged.</para>
|
||||
/// </summary>
|
||||
public sealed class StudioInspector
|
||||
internal sealed class StudioInspector
|
||||
{
|
||||
/// <summary>Currently selected element (set by tree-click or canvas-click in Inspect mode).</summary>
|
||||
public UiElement? Selected { get; set; }
|
||||
|
|
@ -77,7 +77,7 @@ public sealed class StudioInspector
|
|||
/// </summary>
|
||||
public bool InteractMode { get; set; } = true;
|
||||
|
||||
// ── Toolbar ───────────────────────────────────────────────────────────────────
|
||||
// ── Toolbar ───────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Draw the "Studio" toolbar window (top strip) containing a slug combo-box and
|
||||
|
|
@ -124,7 +124,7 @@ public sealed class StudioInspector
|
|||
return result;
|
||||
}
|
||||
|
||||
// ── Canvas ────────────────────────────────────────────────────────────────────
|
||||
// ── Canvas ────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Draw the "Canvas" ImGui window containing the panel FBO texture and return all
|
||||
|
|
@ -133,13 +133,13 @@ public sealed class StudioInspector
|
|||
/// <para><b>Coordinate mapping:</b> After <c>ImGui.Image</c>, <c>GetItemRectMin()</c>
|
||||
/// returns the actual screen-space top-left of the drawn image (accounting for the
|
||||
/// sub-window title bar, padding, and scrolling). Subtracting that from the raw ImGui
|
||||
/// mouse position gives panel-local pixels directly — no scale factor because the
|
||||
/// mouse position gives panel-local pixels directly — no scale factor because the
|
||||
/// image is drawn 1:1.</para>
|
||||
///
|
||||
/// <para><b>V-flip — no extra Y inversion:</b> we pass uv0=(0,1) / uv1=(1,0) so the
|
||||
/// <para><b>V-flip — no extra Y inversion:</b> we pass uv0=(0,1) / uv1=(1,0) so the
|
||||
/// GL bottom-left origin is flipped to top-left on screen. After the flip, screen
|
||||
/// row 0 = panel Y 0 (top of the UI), so the computed Y already matches UiRoot's
|
||||
/// top-left origin — do NOT flip Y again.</para>
|
||||
/// top-left origin — do NOT flip Y again.</para>
|
||||
///
|
||||
/// <para>If <see cref="Selected"/> is non-null a bright-green 2-pixel outline is
|
||||
/// drawn over it using the window draw list.</para>
|
||||
|
|
@ -163,7 +163,7 @@ public sealed class StudioInspector
|
|||
// This is what lets us translate raw mouse screen coords into panel-local pixels.
|
||||
var rectMin = ImGui.GetItemRectMin();
|
||||
|
||||
// ── Selection highlight ───────────────────────────────────────────────
|
||||
// ── Selection highlight ───────────────────────────────────────────────
|
||||
var el = Selected;
|
||||
if (el is not null && el.Width > 0f && el.Height > 0f)
|
||||
{
|
||||
|
|
@ -176,7 +176,7 @@ public sealed class StudioInspector
|
|||
0f, ImDrawFlags.None, 2f);
|
||||
}
|
||||
|
||||
// ── Gather canvas mouse events ────────────────────────────────────────
|
||||
// ── Gather canvas mouse events ────────────────────────────────────────
|
||||
// IsItemHovered is true when the mouse is over the Image item (not just the window).
|
||||
bool hovered = ImGui.IsItemHovered();
|
||||
int mx = 0, my = 0;
|
||||
|
|
@ -187,7 +187,7 @@ public sealed class StudioInspector
|
|||
{
|
||||
var mousePos = ImGui.GetMousePos();
|
||||
// Panel-local pixel = mouse offset from the image's screen-space top-left.
|
||||
// Scale is 1:1 (image drawn at full FBO size). Y needs no extra flip — see summary.
|
||||
// Scale is 1:1 (image drawn at full FBO size). Y needs no extra flip — see summary.
|
||||
int ix = (int)(mousePos.X - rectMin.X);
|
||||
int iy = (int)(mousePos.Y - rectMin.Y);
|
||||
// Clamp to image bounds (mouse can be on the image edge pixel).
|
||||
|
|
@ -202,7 +202,7 @@ public sealed class StudioInspector
|
|||
}
|
||||
else
|
||||
{
|
||||
// Mouse is over ImGui chrome (title bar, padding) adjacent to image — not over the panel.
|
||||
// Mouse is over ImGui chrome (title bar, padding) adjacent to image — not over the panel.
|
||||
hovered = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ public sealed class StudioInspector
|
|||
return new CanvasInputEvent(hovered, mx, my, leftDown, leftUp, scroll);
|
||||
}
|
||||
|
||||
// ── Tree ──────────────────────────────────────────────────────────────────────
|
||||
// ── Tree ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Draw the "Tree" ImGui window. Clicking a node sets <see cref="Selected"/>.</summary>
|
||||
public void DrawTree(UiElement root, int windowX, int windowY, int windowW, int windowH)
|
||||
|
|
@ -252,7 +252,7 @@ public sealed class StudioInspector
|
|||
}
|
||||
}
|
||||
|
||||
// ── Properties ───────────────────────────────────────────────────────────────
|
||||
// ── Properties ───────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Draw the "Properties" ImGui window for <see cref="Selected"/>.</summary>
|
||||
public void DrawProperties(int windowX, int windowY, int windowW, int windowH)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
namespace AcDream.App.Studio;
|
||||
namespace AcDream.App.Studio;
|
||||
|
||||
/// <summary>
|
||||
/// Parsed options for the acdream UI Studio standalone tool.
|
||||
/// Constructed by <see cref="Parse"/> from the command-line tokens that follow
|
||||
/// the <c>ui-studio</c> dispatch token.
|
||||
/// </summary>
|
||||
public sealed record StudioOptions(
|
||||
internal sealed record StudioOptions(
|
||||
string DatDir,
|
||||
uint? LayoutId,
|
||||
string? MarkupPath,
|
||||
|
|
@ -24,11 +24,11 @@ public sealed record StudioOptions(
|
|||
/// <para><c>--layout 0xNNNN</c>: hex LayoutDesc dat id to preview.</para>
|
||||
/// <para><c>--markup <path></c>: path to a KSML markup file (Task 6, unsupported for now).</para>
|
||||
/// <para><c>--dump <slug></c>: load a panel from the retail UI dump JSON by slug
|
||||
/// (e.g. <c>inventory</c>, <c>radar</c>, <c>toolbar</c>). Static mockup — no controllers.</para>
|
||||
/// (e.g. <c>inventory</c>, <c>radar</c>, <c>toolbar</c>). Static mockup — no controllers.</para>
|
||||
/// <para><c>--dump-file <path></c>: override the default dump file path
|
||||
/// (<c>docs/research/2026-06-25-retail-ui-layout-dump.json</c> from the solution root).
|
||||
/// Only meaningful when <c>--dump</c> is also given.</para>
|
||||
/// <para><c>--screenshot <path></c>: headless mode — render the loaded panel to a PNG
|
||||
/// <para><c>--screenshot <path></c>: headless mode — render the loaded panel to a PNG
|
||||
/// at <paramref name="path"/> and exit without showing an interactive window.
|
||||
/// Combines with <c>--dump</c> or <c>--layout</c>.</para>
|
||||
/// <para>When neither <c>--layout</c>, <c>--markup</c>, nor <c>--dump</c> is given the
|
||||
|
|
@ -96,7 +96,7 @@ public sealed record StudioOptions(
|
|||
|
||||
if (string.IsNullOrWhiteSpace(datDir))
|
||||
throw new InvalidOperationException(
|
||||
"ui-studio: dat directory required — pass as first arg or set ACDREAM_DAT_DIR.");
|
||||
"ui-studio: dat directory required — pass as first arg or set ACDREAM_DAT_DIR.");
|
||||
|
||||
// Default layout: vitals (0x2100006C), unless a dump slug or markup is requested.
|
||||
if (!mockup && layoutId is null && markupPath is null && dumpSlug is null)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Numerics;
|
||||
using System.Numerics;
|
||||
using AcDream.Content;
|
||||
using AcDream.App.Platform;
|
||||
using AcDream.App.Audio;
|
||||
|
|
@ -26,18 +26,18 @@ namespace AcDream.App.Studio;
|
|||
///
|
||||
/// Task 3 adds an ImGui IDE on top of the panel FBO:
|
||||
/// <list type="bullet">
|
||||
/// <item>Canvas pane — the panel rendered off-screen via <see cref="PanelFbo"/>.</item>
|
||||
/// <item>Tree pane — the element hierarchy; click-to-select.</item>
|
||||
/// <item>Properties pane — geometry/anchors/flags of the selected element.</item>
|
||||
/// <item>Click-to-inspect — a left-click in the canvas selects the topmost
|
||||
/// <item>Canvas pane — the panel rendered off-screen via <see cref="PanelFbo"/>.</item>
|
||||
/// <item>Tree pane — the element hierarchy; click-to-select.</item>
|
||||
/// <item>Properties pane — geometry/anchors/flags of the selected element.</item>
|
||||
/// <item>Click-to-inspect — a left-click in the canvas selects the topmost
|
||||
/// element under the cursor via <see cref="UiRoot.Pick"/>.</item>
|
||||
/// </list>
|
||||
///
|
||||
/// The window is intentionally thin: no game world, no physics, no streaming —
|
||||
/// The window is intentionally thin: no game world, no physics, no streaming —
|
||||
/// just GL + UiHost + the layout under test, identical to how the panel
|
||||
/// appears inside <c>GameWindow</c>.
|
||||
/// </summary>
|
||||
public sealed class StudioWindow : IDisposable
|
||||
internal sealed class StudioWindow : IDisposable
|
||||
{
|
||||
private readonly StudioOptions _opts;
|
||||
private readonly ApplicationPathSet _applicationPaths;
|
||||
|
|
@ -63,7 +63,7 @@ public sealed class StudioWindow : IDisposable
|
|||
private string? _dumpFile; // resolved dump file path (once, in OnLoad)
|
||||
private IReadOnlyList<string> _dumpSlugs = Array.Empty<string>(); // all slugs from the dump
|
||||
|
||||
// Task 4: sample data table — built once in OnLoad and kept alive for the window's lifetime
|
||||
// Task 4: sample data table — built once in OnLoad and kept alive for the window's lifetime
|
||||
// so the controller subscriptions (ObjectAdded/ObjectMoved etc.) fire correctly.
|
||||
private AcDream.Core.Items.ClientObjectTable? _objects;
|
||||
private IRetainedPanelController? _fixtureController;
|
||||
|
|
@ -114,7 +114,7 @@ public sealed class StudioWindow : IDisposable
|
|||
{
|
||||
_platformServices.ConfigureWindowBackend();
|
||||
// Resolve quality settings the same way GameWindow.Run() does
|
||||
// (SettingsStore → QualitySettings.From → WithEnvOverrides).
|
||||
// (SettingsStore → QualitySettings.From → WithEnvOverrides).
|
||||
var startupStore = new AcDream.UI.Abstractions.Panels.Settings.SettingsStore(
|
||||
_applicationPaths.SettingsFile);
|
||||
var startupDisplay = startupStore.LoadDisplay();
|
||||
|
|
@ -131,7 +131,7 @@ public sealed class StudioWindow : IDisposable
|
|||
ContextFlags.ForwardCompatible,
|
||||
new APIVersion(4, 3)),
|
||||
VSync = false,
|
||||
// MSAA from quality preset — must be baked into the GL context at creation.
|
||||
// MSAA from quality preset — must be baked into the GL context at creation.
|
||||
Samples = startupQuality.MsaaSamples,
|
||||
PreferredStencilBufferBits = 8,
|
||||
// Headless screenshot mode: hide the window so no desktop flash occurs.
|
||||
|
|
@ -195,7 +195,7 @@ public sealed class StudioWindow : IDisposable
|
|||
|
||||
_dats = RuntimeDatCollectionFactory.OpenReadOnly(_opts.DatDir);
|
||||
|
||||
// Build QualitySettings for RenderBootstrap (same as Run() above — re-read
|
||||
// Build QualitySettings for RenderBootstrap (same as Run() above — re-read
|
||||
// after the GL context is confirmed, mirroring GameWindow.OnLoad).
|
||||
var store = new AcDream.UI.Abstractions.Panels.Settings.SettingsStore(
|
||||
_applicationPaths.SettingsFile);
|
||||
|
|
@ -265,7 +265,7 @@ public sealed class StudioWindow : IDisposable
|
|||
|
||||
// Task 4: populate the panel with sample data via production controllers,
|
||||
// so inventory / vitals / toolbar panels render with plausible content.
|
||||
// Dump source is static — no FixtureProvider needed.
|
||||
// Dump source is static — no FixtureProvider needed.
|
||||
if (_opts.DumpSlug is null && _source.CurrentLayout is not null)
|
||||
{
|
||||
uint layoutId = _opts.LayoutId ?? 0x2100006Cu;
|
||||
|
|
@ -275,7 +275,7 @@ public sealed class StudioWindow : IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
// Task 3: ImGui IDE — interactive mode only.
|
||||
// Task 3: ImGui IDE — interactive mode only.
|
||||
// Headless screenshot mode needs only PanelFbo; ImGui/inspector/input are skipped.
|
||||
_panelFbo = new PanelFbo(_gl);
|
||||
if (_opts.ScreenshotPath is null)
|
||||
|
|
@ -337,14 +337,14 @@ public sealed class StudioWindow : IDisposable
|
|||
try
|
||||
{
|
||||
|
||||
// ── HEADLESS SCREENSHOT PATH ──────────────────────────────────────────────
|
||||
// ── HEADLESS SCREENSHOT PATH ──────────────────────────────────────────────
|
||||
if (_opts.ScreenshotPath is not null)
|
||||
{
|
||||
if (_screenshotDone) return; // fire exactly once
|
||||
_screenshotDone = true;
|
||||
|
||||
// Pick render size from the loaded root's bounds (clamped to sane limits).
|
||||
// Fall back to 1280×720 when the root has no explicit size.
|
||||
// Fall back to 1280×720 when the root has no explicit size.
|
||||
int w = 1280, h = 720;
|
||||
if (!_opts.Mockup && _panelRoot is not null)
|
||||
{
|
||||
|
|
@ -372,7 +372,7 @@ public sealed class StudioWindow : IDisposable
|
|||
return;
|
||||
}
|
||||
|
||||
// Flip rows vertically: FBO bottom-left → PNG top-left.
|
||||
// Flip rows vertically: FBO bottom-left → PNG top-left.
|
||||
int stride = w * 4;
|
||||
byte[] flipped = new byte[pixels.Length];
|
||||
for (int row = 0; row < h; row++)
|
||||
|
|
@ -394,7 +394,7 @@ public sealed class StudioWindow : IDisposable
|
|||
return;
|
||||
}
|
||||
|
||||
// ── INTERACTIVE PATH ──────────────────────────────────────────────────────
|
||||
// ── INTERACTIVE PATH ──────────────────────────────────────────────────────
|
||||
if (_opts.Mockup)
|
||||
{
|
||||
var mockupGl = _stack.Gl;
|
||||
|
|
@ -415,12 +415,12 @@ public sealed class StudioWindow : IDisposable
|
|||
int iw = _window!.Size.X;
|
||||
int ih = _window!.Size.Y;
|
||||
|
||||
// 1. Tick the UI widgets (OnRender's own dt — Update + Render fire with the same delta).
|
||||
// 1. Tick the UI widgets (OnRender's own dt — Update + Render fire with the same delta).
|
||||
_stack.UiHost.Tick(dt);
|
||||
|
||||
// 2. Render the panel into the off-screen FBO; get the color texture.
|
||||
// The FBO is the same logical size as the window, so element rects map 1:1 to
|
||||
// FBO pixels — no scale factor needed when displaying the canvas at full size.
|
||||
// FBO pixels — no scale factor needed when displaying the canvas at full size.
|
||||
uint panelTex = _panelFbo.Render(iw, ih, _stack.UiHost);
|
||||
|
||||
// 3. Clear the window back-buffer (the dark ImGui background shows behind panes).
|
||||
|
|
@ -430,8 +430,8 @@ public sealed class StudioWindow : IDisposable
|
|||
// 4. Begin the ImGui frame.
|
||||
_imgui.BeginFrame((float)dt);
|
||||
|
||||
// ── Layout constants (fixed pane arrangement, FirstUseEver) ──────────────
|
||||
// MenuBar: always-on-top main menu bar (~22px) — panel picker lives here so it
|
||||
// ── Layout constants (fixed pane arrangement, FirstUseEver) ──────────────
|
||||
// MenuBar: always-on-top main menu bar (~22px) — panel picker lives here so it
|
||||
// is never covered by the floating panes (replaces the old 40px toolbar).
|
||||
// Tree: 280px wide on the left, below menu bar.
|
||||
// Canvas: centre strip between tree and properties.
|
||||
|
|
@ -445,7 +445,7 @@ public sealed class StudioWindow : IDisposable
|
|||
int paneY = kMenuBarH;
|
||||
int paneH = Math.Max(1, ih - kMenuBarH);
|
||||
|
||||
// 5. Main menu bar — panel picker combo pinned to the window top.
|
||||
// 5. Main menu bar — panel picker combo pinned to the window top.
|
||||
// BeginMainMenuBar returns true when the bar is visible (always is); the combo
|
||||
// inside it is always-on-top and is never occluded by Tree/Canvas/Props panes.
|
||||
string? pickedSlug = null;
|
||||
|
|
@ -471,7 +471,7 @@ public sealed class StudioWindow : IDisposable
|
|||
if (pickedSlug is not null)
|
||||
LoadDumpPanel(pickedSlug);
|
||||
|
||||
// 6. Canvas pane — show the FBO texture; gather canvas mouse events.
|
||||
// 6. Canvas pane — show the FBO texture; gather canvas mouse events.
|
||||
var canvasEvt = default(CanvasInputEvent);
|
||||
if (panelTex != 0)
|
||||
canvasEvt = _inspector.DrawCanvas(
|
||||
|
|
@ -501,10 +501,10 @@ public sealed class StudioWindow : IDisposable
|
|||
|
||||
if (_inspector.InteractMode)
|
||||
{
|
||||
// ── Interact: live panel interaction ──────────────────────────────
|
||||
// ── Interact: live panel interaction ──────────────────────────────
|
||||
if (canvasEvt.LeftDown)
|
||||
{
|
||||
Console.WriteLine($"[studio] canvas click → panel ({mx}, {my})");
|
||||
Console.WriteLine($"[studio] canvas click → panel ({mx}, {my})");
|
||||
root.OnMouseDown(UiMouseButton.Left, mx, my);
|
||||
}
|
||||
if (canvasEvt.LeftUp)
|
||||
|
|
@ -514,7 +514,7 @@ public sealed class StudioWindow : IDisposable
|
|||
}
|
||||
else
|
||||
{
|
||||
// ── Inspect: click selects an element in the tree ─────────────────
|
||||
// ── Inspect: click selects an element in the tree ─────────────────
|
||||
if (canvasEvt.LeftDown)
|
||||
{
|
||||
var hit = root.Pick(mx, my);
|
||||
|
|
@ -634,7 +634,7 @@ public sealed class StudioWindow : IDisposable
|
|||
_imgui = null;
|
||||
_panelFbo = null;
|
||||
// If OnClosing wasn't called (e.g. an exception before Run() completed), dispose the FULL
|
||||
// stack anyway — the review flagged that disposing only UiHost here leaked the rest.
|
||||
// stack anyway — the review flagged that disposing only UiHost here leaked the rest.
|
||||
_stack?.Dispose();
|
||||
_dats?.Dispose();
|
||||
_audio?.Dispose();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
using System.Text.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace AcDream.App.Studio;
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// UiDumpModel — POCOs for docs/research/2026-06-25-retail-ui-layout-dump.json
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// UiDumpModel — POCOs for docs/research/2026-06-25-retail-ui-layout-dump.json
|
||||
//
|
||||
// Schema (v1):
|
||||
// { "version":1, "panels":[ { "id":int, "slug":string, "title":string,
|
||||
|
|
@ -25,10 +25,10 @@ namespace AcDream.App.Studio;
|
|||
// Rect coordinates are ABSOLUTE (screen-space origin = panel's design position
|
||||
// in retail layout, NOT relative to the parent). DumpLayout.Load converts them
|
||||
// to parent-relative when building the UiElement tree.
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Top-level container for the retail UI layout dump.</summary>
|
||||
public sealed class UiDump
|
||||
internal sealed class UiDump
|
||||
{
|
||||
[JsonPropertyName("version")]
|
||||
public int Version { get; set; }
|
||||
|
|
@ -38,7 +38,7 @@ public sealed class UiDump
|
|||
}
|
||||
|
||||
/// <summary>One panel (window) exported from the retail UI.</summary>
|
||||
public sealed class DumpPanel
|
||||
internal sealed class DumpPanel
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public long Id { get; set; }
|
||||
|
|
@ -66,7 +66,7 @@ public sealed class DumpPanel
|
|||
}
|
||||
|
||||
/// <summary>One element node within a panel's traversal list.</summary>
|
||||
public sealed class DumpNode
|
||||
internal sealed class DumpNode
|
||||
{
|
||||
[JsonPropertyName("traversal_index")]
|
||||
public int TraversalIndex { get; set; }
|
||||
|
|
@ -96,8 +96,8 @@ public sealed class DumpNode
|
|||
public DumpStateSet StateSet { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>Absolute screen-space rect (see comment above — must subtract parent rect for UiElement).</summary>
|
||||
public sealed class DumpRect
|
||||
/// <summary>Absolute screen-space rect (see comment above — must subtract parent rect for UiElement).</summary>
|
||||
internal sealed class DumpRect
|
||||
{
|
||||
[JsonPropertyName("x")]
|
||||
public float X { get; set; }
|
||||
|
|
@ -112,8 +112,8 @@ public sealed class DumpRect
|
|||
public float Height { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>State set for a node — default image plus per-state overrides.</summary>
|
||||
public sealed class DumpStateSet
|
||||
/// <summary>State set for a node — default image plus per-state overrides.</summary>
|
||||
internal sealed class DumpStateSet
|
||||
{
|
||||
[JsonPropertyName("default_image")]
|
||||
public DumpImage? DefaultImage { get; set; }
|
||||
|
|
@ -123,7 +123,7 @@ public sealed class DumpStateSet
|
|||
}
|
||||
|
||||
/// <summary>Image reference (RenderSurface dat id + optional separate alpha surface).</summary>
|
||||
public sealed class DumpImage
|
||||
internal sealed class DumpImage
|
||||
{
|
||||
[JsonPropertyName("image_id")]
|
||||
public long ImageId { get; set; }
|
||||
|
|
@ -133,7 +133,7 @@ public sealed class DumpImage
|
|||
}
|
||||
|
||||
/// <summary>A named state override.</summary>
|
||||
public sealed class DumpState
|
||||
internal sealed class DumpState
|
||||
{
|
||||
[JsonPropertyName("state_id")]
|
||||
public int StateId { get; set; }
|
||||
|
|
@ -142,14 +142,14 @@ public sealed class DumpState
|
|||
public DumpImage Image { get; set; } = new();
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// Helper statics
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Parsing helpers for the retail UI dump JSON.
|
||||
/// </summary>
|
||||
public static class UiDumpModel
|
||||
internal static class UiDumpModel
|
||||
{
|
||||
private static readonly JsonSerializerOptions _opts = new()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue