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>
150 lines
5.4 KiB
C#
150 lines
5.4 KiB
C#
using AcDream.App.UI;
|
|
using AcDream.App.UI.Layout;
|
|
|
|
namespace AcDream.App.Tests.UI.Layout;
|
|
|
|
public sealed class CharacterControllerTests
|
|
{
|
|
[Fact]
|
|
public void AuthoredPanel_BindsTextScrollbarAndClose()
|
|
{
|
|
ImportedLayout layout = FixtureLoader.LoadCharacterInformation();
|
|
int closes = 0;
|
|
|
|
CharacterController.Bind(
|
|
layout, SampleData.SampleCharacter, close: () => closes++);
|
|
|
|
UiText text = Assert.IsType<UiText>(
|
|
layout.FindElement(CharacterController.MainTextId));
|
|
UiScrollbar scrollbar = Assert.IsType<UiScrollbar>(
|
|
layout.FindElement(CharacterController.ScrollbarId));
|
|
Assert.Same(text.Scroll, scrollbar.Model);
|
|
Assert.False(text.PreserveEndOnLayout);
|
|
Assert.Contains("You were born on", VisibleText(text));
|
|
|
|
UiButton close = Assert.IsType<UiButton>(
|
|
layout.FindElement(CharacterController.CloseId));
|
|
close.OnEvent(new UiEvent(0, close, UiEventType.Click));
|
|
Assert.Equal(1, closes);
|
|
}
|
|
|
|
[Fact]
|
|
public void Report_UsesRetailContentInsteadOfInventedCharacterSheetSummary()
|
|
{
|
|
string report = Report(SampleData.SampleCharacter());
|
|
|
|
Assert.DoesNotContain("Studio Player", report);
|
|
Assert.DoesNotContain("Level 126", report);
|
|
Assert.DoesNotContain("Health:", report);
|
|
Assert.DoesNotContain("Augmentations", report);
|
|
Assert.DoesNotContain("Encumbrance", report);
|
|
|
|
Assert.Contains("You have died 42 times.", report);
|
|
Assert.Contains("Natural Resistances:", report);
|
|
Assert.Contains("Drain Resistances:", report);
|
|
Assert.Contains("Regeneration Bonus:", report);
|
|
Assert.Contains("Innate Strength: 200", report);
|
|
Assert.Contains("Innate Coordination: 10", report);
|
|
Assert.Contains("Chess Rank: 12", report);
|
|
Assert.Contains("Fishing Skill: 4", report);
|
|
Assert.Contains("Your melee mastery is Swords.", report);
|
|
Assert.Contains("You are not overburdened at this time.", report);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(200, "None")]
|
|
[InlineData(201, "Poor")]
|
|
[InlineData(260, "Poor")]
|
|
[InlineData(261, "Mediocre")]
|
|
[InlineData(321, "Hardy")]
|
|
[InlineData(381, "Resilient")]
|
|
[InlineData(441, "Indomitable")]
|
|
public void ResistanceGrade_UsesRetailInclusiveBoundaries(
|
|
int value, string expected)
|
|
=> Assert.Equal(expected, CharacterController.ResistanceGrade(
|
|
value, 200, 260, 320, 380, 440));
|
|
|
|
[Theory]
|
|
[InlineData(0, "")]
|
|
[InlineData(1, "1 second")]
|
|
[InlineData(61, "1 minute 1 second")]
|
|
[InlineData(3_196_800, "1 month 1 week")]
|
|
[InlineData(31_536_000, "1 year")]
|
|
public void Duration_UsesRetailUnitDecomposition(int seconds, string expected)
|
|
=> Assert.Equal(expected, CharacterController.FormatRetailDuration(seconds));
|
|
|
|
[Fact]
|
|
public void DeathCount_UsesRetailSpecialCases()
|
|
{
|
|
Assert.Contains("never died", Report(new CharacterSheet { Deaths = 0 }));
|
|
Assert.Contains("only once", Report(new CharacterSheet { Deaths = 1 }));
|
|
Assert.Contains("died twice", Report(new CharacterSheet { Deaths = 2 }));
|
|
Assert.Contains("died 3 times", Report(new CharacterSheet { Deaths = 3 }));
|
|
}
|
|
|
|
[Fact]
|
|
public void EmptyLayout_GetsFallbackMainText()
|
|
{
|
|
ImportedLayout layout = FakeLayout();
|
|
CharacterController.Bind(layout, SampleData.SampleCharacter);
|
|
Assert.Contains(layout.Root.Children.OfType<UiText>(),
|
|
text => text.EventId == CharacterController.MainTextId);
|
|
}
|
|
|
|
[Fact]
|
|
public void Stable_draws_reuse_report_until_source_or_layout_changes()
|
|
{
|
|
ImportedLayout layout = FixtureLoader.LoadCharacterInformation();
|
|
int builds = 0;
|
|
int deaths = 1;
|
|
Action? changed = null;
|
|
using CharacterInformationUiController controller =
|
|
CharacterController.Bind(
|
|
layout,
|
|
() =>
|
|
{
|
|
builds++;
|
|
return new CharacterSheet { Deaths = deaths };
|
|
},
|
|
subscribeChanged: handler =>
|
|
{
|
|
changed = handler;
|
|
return new TestSubscription();
|
|
});
|
|
UiText text = Assert.IsType<UiText>(
|
|
layout.FindElement(CharacterController.MainTextId));
|
|
|
|
IReadOnlyList<UiText.Line> first = text.LinesProvider();
|
|
IReadOnlyList<UiText.Line> second = text.LinesProvider();
|
|
Assert.Same(first, second);
|
|
Assert.Equal(1, builds);
|
|
|
|
deaths = 2;
|
|
changed!();
|
|
IReadOnlyList<UiText.Line> changedLines = text.LinesProvider();
|
|
Assert.NotSame(first, changedLines);
|
|
Assert.Equal(2, builds);
|
|
|
|
text.Width -= 24f;
|
|
IReadOnlyList<UiText.Line> resized = text.LinesProvider();
|
|
Assert.NotSame(changedLines, resized);
|
|
Assert.Equal(2, builds);
|
|
}
|
|
|
|
private static string Report(CharacterSheet sheet)
|
|
=> CharacterController.BuildReport(sheet, CharacterInfoStrings.English);
|
|
|
|
private static string VisibleText(UiText text)
|
|
=> string.Join('\n', text.LinesProvider().Select(line => line.Text));
|
|
|
|
private static ImportedLayout FakeLayout()
|
|
=> new(new UiPanel { Width = 300f, Height = 362f },
|
|
new Dictionary<uint, UiElement>());
|
|
|
|
private sealed class TestSubscription : IDisposable
|
|
{
|
|
public void Dispose()
|
|
{
|
|
}
|
|
}
|
|
}
|