acdream/tests/AcDream.App.Tests/UI/Layout/CharacterLayoutImportProbe.cs
Erik 844cf092a1 feat(render): Campaign V slice V11 commit 1 - delete ImGui, Studio, and the DevTools frontend
The ImGui developer-tools stack (AcDream.UI.ImGui), UI Studio
(src/AcDream.App/Studio), and the DevToolsFramePresenter/
SettingsDevToolsCompositionPhase ImGui composition machinery are removed.
Vulkan never composed a DevTools frontend (DevToolsEnabled already forced
false whenever the backend was Vulkan); this commit makes that permanent by
deleting the only implementation rather than leaving a dead branch behind.

What moved: Studio/SampleData.cs is a live production dependency
(InteractionRetainedUiComposition's character-sheet fallback, plus three
UI.Layout test files) - git mv'd to src/AcDream.App/UI/Layout/SampleData.cs,
namespace AcDream.App.UI.Layout, and trimmed to the SampleCharacter API that
is actually still called (BuildObjectTable/AddItem/AddEquipped/the item-guid
and icon constants had zero callers left once the Studio fixture provider
that used them was deleted).

What survives as backend-neutral seams, per the tests that still exercise
them: IDevToolsFrameLifecycle (moved into RenderFramePreparationController.cs,
now always bound to null), IFramebufferDevToolsTarget/FramebufferDevToolsBinding
in FramebufferResizeController.cs (its concrete DevToolsFramebufferTarget
adapter is deleted), and IDevToolsGameplayCommands in
GameplayInputCommandController.cs (DevToolsGameplayCommands becomes a
documented no-op instead of forwarding to the deleted presenter). A follow-up
re-homes Settings/Debug onto the retained UI through IPanelRenderer; until
then keybind remapping falls back to editing keybinds.json.

DevToolsEnabled is now `private const bool DevToolsEnabled = false`.
RuntimeOptions.DevTools is unchanged and still reaches VulkanGraphicsContext
for the optional debug-utils extensions; Program.cs now logs one line when
ACDREAM_DEVTOOLS=1 explaining that the ImGui UI is gone and the flag is
Vulkan-only now.

Removed: AcDream.UI.ImGui (project + ImGui.NET/Silk.NET.OpenGL.Extensions.ImGui
package refs), src/AcDream.App/Studio (minus SampleData.cs),
DevToolsFramePresenter.cs and everything only it constructed
(ISettingsDevToolsCompositionFactory, RetailSettingsDevToolsCompositionFactory,
DevToolsCompositionOwner, IGameWindowSettingsDevToolsPublication,
SettingsDevToolsOptionalDependencies, the "developer tools" shutdown-ledger
stage and its DevTools-typed fields on IngressShutdownRoots/
RenderShutdownRoots), the ui-studio Program.cs verb, and the cimgui native
manifest entries in GraphicalHostPlatformServices. GameWindow.cs's DevTools
composition branch, its _vitalsVm/_debugVm/_devToolsComposition/
_devToolsFramePresenter/_devToolsCommandBus fields, and every settingsDevTools
.DevTools?.* access across FrameRootComposition.cs/SessionPlayerComposition.cs
are gone with it.

Build green; complete Release solution suite 8,830 / 5 skips (App Tests
4,097/3 skips run standalone - one #250-family zero-allocation test flakes
under the full parallel `dotnet test AcDream.slnx` run, a pre-existing,
documented class unrelated to this change).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 23:56:04 +02:00

108 lines
3.5 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AcDream.App.UI;
using AcDream.App.UI.Layout;
using DatReaderWriter;
using DatReaderWriter.Options;
using Xunit;
namespace AcDream.App.Tests.UI.Layout;
public sealed class CharacterLayoutImportProbe
{
private const uint CharacterLayout = 0x2100002Eu;
private static string? DatDir()
{
var d = Environment.GetEnvironmentVariable("ACDREAM_DAT_DIR")
?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Documents", "Asheron's Call");
return Directory.Exists(d) ? d : null;
}
[Fact]
public void Selected_attribute_shows_raise_buttons_on_visible_footer_state()
{
var datDir = DatDir();
if (datDir is null) return;
using var dats = new DatCollection(datDir, DatAccessType.Read);
var layout = LayoutImporter.Import(dats, CharacterLayout, _ => (1u, 30, 26), null);
Assert.NotNull(layout);
CharacterStatController.Bind(layout!, SampleData.SampleCharacter, spriteResolve: _ => (1u, 30, 26));
var rows = new List<UiClickablePanel>();
CollectRows(layout!.Root, rows);
Assert.True(rows.Count >= 9, $"expected at least 9 attribute rows, found {rows.Count}");
rows[4].OnClick!();
var buttons = new List<UiButton>();
CollectButtons(layout.Root, buttons);
Assert.Contains(buttons, b =>
b.ElementId == CharacterStatController.RaiseOneId
&& b.ActiveState == "Normal"
&& IsEffectivelyVisible(b));
Assert.Contains(buttons, b =>
b.ElementId == CharacterStatController.RaiseTenId
&& b.ActiveState == "Normal"
&& IsEffectivelyVisible(b));
}
[Fact]
public void Close_button_resolves_and_invokes_controller_close_callback()
{
var datDir = DatDir();
if (datDir is null) return;
using var dats = new DatCollection(datDir, DatAccessType.Read);
var layout = LayoutImporter.Import(dats, CharacterLayout, _ => (1u, 30, 26), null);
Assert.NotNull(layout);
var close = layout!.FindElement(WindowChromeController.CharacterCloseButtonId);
Assert.NotNull(close);
Assert.True(close is UiButton or UiDatElement,
$"character close button resolved to {close?.GetType().Name ?? "null"}");
int closes = 0;
CharacterStatController.Bind(layout, SampleData.SampleCharacter, onClose: () => closes++);
close!.OnEvent(new UiEvent(0u, close, UiEventType.Click));
Assert.Equal(1, closes);
}
private static void CollectRows(UiElement node, List<UiClickablePanel> result)
{
if (node is UiClickablePanel row && row.Height is >= 20f and <= 22f && row.OnClick is not null)
result.Add(row);
foreach (var child in node.Children)
CollectRows(child, result);
}
private static void CollectButtons(UiElement node, List<UiButton> result)
{
if (node is UiButton button
&& (button.ElementId == CharacterStatController.RaiseOneId
|| button.ElementId == CharacterStatController.RaiseTenId))
{
result.Add(button);
}
foreach (var child in node.Children)
CollectButtons(child, result);
}
private static bool IsEffectivelyVisible(UiElement element)
{
for (UiElement? e = element; e is not null; e = e.Parent)
{
if (!e.Visible) return false;
}
return true;
}
}