Files
HellionChat/HellionChat/SelfTests/MainWindowFlagsStep.cs
T
JonKazama-Hellion b397591ba4 feat(window): restore the title-bar, hide-button, and 24-hour-clock toggles
Re-wires four 1.5.6 settings that survived the v1.6.0 rewrite as dormant config
fields but lost their UI + consumers:
- ShowTitleBar / ShowPopOutTitleBar: gate ImGuiWindowFlags.NoTitleBar on the main
  window (ResolveFlags) and pop-out windows (new PreDraw). Inverted logic matches
  1.5.6 (flag set only when the toggle is off).
- ShowHideButton: gate the input-bar hide button on the toggle.
- Use24HourClock: add the toggle (MessageList already consumes the field).
New 'Window style' section in WindowTab; Use24HourClock in ChatTab display modes.
MainWindowFlagsStep extended with the NoTitleBar fresh-base contract.
2026-06-15 20:19:59 +02:00

97 lines
3.4 KiB
C#

using Dalamud.Bindings.ImGui;
using Dalamud.Plugin.SelfTest;
using HellionChat.Ui.Windows;
namespace HellionChat.SelfTests;
// B1-2 window flags. Drives the REAL MainWindow.PreDraw and asserts it wired
// Window.Flags to ResolveFlags(CanMove, CanResize), then pins the pure
// fresh-base contract: false/false adds NoMove|NoResize, true/true clears them
// (the masterplan's "flags must rebuild from a fresh base, else NoMove sticks
// after toggling back" risk). NoScrollbar|NoScrollWithMouse always present.
// Non-test caller of ResolveFlags: MainWindow.PreDraw.
internal sealed class MainWindowFlagsStep : ISelfTestStep
{
private readonly Plugin plugin;
public MainWindowFlagsStep(Plugin plugin)
{
this.plugin = plugin;
}
public string Name => "Hellion Chat - MainWindow flags";
public SelfTestStepResult RunStep()
{
var window = this.plugin.MainWindow;
if (window is null)
{
ImGui.Text("Plugin.MainWindow is null");
return SelfTestStepResult.Fail;
}
// Wiring proof: drive the real PreDraw and confirm Flags == the helper's
// value for the live config. No state mutation needed.
var savedFlags = window.Flags;
window.PreDraw();
var expected = MainWindow.ResolveFlags(
Plugin.Config.CanMove,
Plugin.Config.CanResize,
Plugin.Config.ShowTitleBar
);
if (window.Flags != expected)
{
ImGui.Text($"PreDraw set Flags {window.Flags}, expected ResolveFlags = {expected}");
window.Flags = savedFlags;
return SelfTestStepResult.Fail;
}
// Fresh-base contract: locked window carries NoMove|NoResize ...
var locked = MainWindow.ResolveFlags(false, false, true);
if (
!locked.HasFlag(ImGuiWindowFlags.NoMove)
|| !locked.HasFlag(ImGuiWindowFlags.NoResize)
|| !locked.HasFlag(ImGuiWindowFlags.NoScrollbar)
)
{
ImGui.Text(
$"ResolveFlags(false,false,true) = {locked}, missing NoMove/NoResize/NoScrollbar"
);
window.Flags = savedFlags;
return SelfTestStepResult.Fail;
}
// ... and re-enabling both CLEARS NoMove|NoResize (no accumulation).
var free = MainWindow.ResolveFlags(true, true, true);
if (free.HasFlag(ImGuiWindowFlags.NoMove) || free.HasFlag(ImGuiWindowFlags.NoResize))
{
ImGui.Text(
$"ResolveFlags(true,true,true) = {free}, NoMove/NoResize stuck after re-enable"
);
window.Flags = savedFlags;
return SelfTestStepResult.Fail;
}
// P7 title-bar contract: ShowTitleBar=false adds NoTitleBar from the
// fresh base, true clears it (same no-accumulation guarantee).
var barHidden = MainWindow.ResolveFlags(true, true, false);
var barShown = MainWindow.ResolveFlags(true, true, true);
if (
!barHidden.HasFlag(ImGuiWindowFlags.NoTitleBar)
|| barShown.HasFlag(ImGuiWindowFlags.NoTitleBar)
)
{
ImGui.Text(
$"NoTitleBar wiring wrong: hidden={barHidden} (want NoTitleBar), shown={barShown} (want none)"
);
window.Flags = savedFlags;
return SelfTestStepResult.Fail;
}
window.Flags = savedFlags;
return SelfTestStepResult.Pass;
}
public void CleanUp() { }
}