feat(chat): Campaign CH slice CH6c — window opacity + transparency setting
Retail's ChatInterface::SetOpacity (0x004F3120) fades the WHOLE composited
window surface with one alpha; UiRenderContext.ApplyAlpha already gated
DrawSprite/DrawRect/DrawFill (since 1da697ec, pre-CH6) but DrawStringDat and
DrawString still passed applyAlpha:false, so text stayed sharp over a
translucent window. Both now route through the same chokepoint.
RetailWindowOpacityController (new) subscribes to a new
RetailWindowManager.WindowRegistered event and drives every registered
window's live Opacity from keyboard-focus state, applied to EVERY window
(chat, floaties, vitals, toolbar, ...) rather than retail's ChatInterface-only
scope — register row AP-190, retiring the stale AP-40 "fixed 0.75, no focus
transition" row in the same commit.
Verified retail's shipped opacity defaults from the decomp (constructor
literals, no cdb needed): the base ChatInterface ctor sets
DefaultOpacity=0.5/ActiveOpacity=1.0, kept unmodified by the four floating
windows; gmMainChatUI's own ctor overrides the main window to 1.0/1.0
(always fully opaque). acdream ships one shared global default (0.5/1.0)
rather than replicating the per-class override — also AP-190. The linking
invariant (raising default above active drags active UP; lowering active
below default drags default DOWN — never a clamp) is ported verbatim as
ChatOpacityLink in AcDream.UI.Abstractions, shared by the live controller
and the new Settings -> Chat tab's two linked opacity sliders.
Persistence: ChatSettings.DefaultOpacity/ActiveOpacity round-trip through
SettingsStore; Save pushes both through IRuntimeSettingsTargets.SetChatOpacity
into the live controller, no restart required.
Rider (CH6a/b re-review): strengthened the grip-media regression guard past
a bare SpriteFile != 0 check — ChatLayoutConformanceTests now drives each
live grip through a real UiRenderContext/TextRenderer (backed by the
in-memory RecordingGpuDevice test double) and asserts the draw call chain
actually queued sprite geometry, via a new TextRenderer.DebugSpriteSegments
test-only accessor.
Full Release suite 12,459 passed / 4 skipped / 0 failed (baseline
12,420/4/0). No subagents, no client launches (session hard constraints);
pending the next connected user gate for visual confirmation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
ccab53d9a1
commit
a819687cf0
23 changed files with 1174 additions and 38 deletions
|
|
@ -0,0 +1,87 @@
|
|||
using AcDream.UI.Abstractions.Panels.Settings;
|
||||
|
||||
namespace AcDream.UI.Abstractions.Tests.Panels.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// Campaign CH slice CH6c: pins <see cref="ChatOpacityLink"/>'s port of retail's
|
||||
/// linked default/active opacity invariant (<c>ChatInterface::SetDefaultOpacity
|
||||
/// @0x004F3BC0</c> / <c>SetActiveOpacity @0x004F3C40</c>) — active >= default,
|
||||
/// ALWAYS, enforced by dragging the OTHER value rather than clamping the one
|
||||
/// being set.
|
||||
/// </summary>
|
||||
public sealed class ChatOpacityLinkTests
|
||||
{
|
||||
[Fact]
|
||||
public void SetDefault_BelowCurrentActive_LeavesActiveUnchanged()
|
||||
{
|
||||
// The ordinary case: lowering the background opacity while it's already
|
||||
// below the active value doesn't need to touch active at all.
|
||||
var (def, active) = ChatOpacityLink.SetDefault(currentActive: 1.0f, newDefault: 0.3f);
|
||||
Assert.Equal(0.3f, def);
|
||||
Assert.Equal(1.0f, active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDefault_AboveCurrentActive_DragsActiveUp_DoesNotClampDefault()
|
||||
{
|
||||
// The decomp-verified answer to "does raising default above active drag
|
||||
// active up, or clamp default?": ChatInterface::SetDefaultOpacity always
|
||||
// WRITES this->m_fDefaultOpacity = arg2 first, THEN calls SetActiveOpacity
|
||||
// when active < default. Default is never clamped down.
|
||||
var (def, active) = ChatOpacityLink.SetDefault(currentActive: 0.4f, newDefault: 0.9f);
|
||||
Assert.Equal(0.9f, def);
|
||||
Assert.Equal(0.9f, active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetActive_AboveCurrentDefault_LeavesDefaultUnchanged()
|
||||
{
|
||||
var (def, active) = ChatOpacityLink.SetActive(currentDefault: 0.2f, newActive: 0.9f);
|
||||
Assert.Equal(0.2f, def);
|
||||
Assert.Equal(0.9f, active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetActive_BelowCurrentDefault_DragsDefaultDown()
|
||||
{
|
||||
// Symmetric case: ChatInterface::SetActiveOpacity writes m_fActiveOpacity
|
||||
// first, then calls SetDefaultOpacity when default > active.
|
||||
var (def, active) = ChatOpacityLink.SetActive(currentDefault: 0.7f, newActive: 0.3f);
|
||||
Assert.Equal(0.3f, def);
|
||||
Assert.Equal(0.3f, active);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(-1f, 0f)]
|
||||
[InlineData(2f, 1f)]
|
||||
public void SetDefault_ClampsInputToUnitRange(float rawInput, float expectedDefault)
|
||||
{
|
||||
var (def, _) = ChatOpacityLink.SetDefault(currentActive: 1f, newDefault: rawInput);
|
||||
Assert.Equal(expectedDefault, def);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(-1f, 0f)]
|
||||
[InlineData(2f, 1f)]
|
||||
public void SetActive_ClampsInputToUnitRange(float rawInput, float expectedActive)
|
||||
{
|
||||
var (_, active) = ChatOpacityLink.SetActive(currentDefault: 0f, newActive: rawInput);
|
||||
Assert.Equal(expectedActive, active);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDefault_ThenSetActive_NeverProducesActiveBelowDefault()
|
||||
{
|
||||
// A short sequence exercising the invariant through several moves, the
|
||||
// way a user dragging both sliders back and forth would.
|
||||
(float def, float active) = (0.5f, 1.0f);
|
||||
(def, active) = ChatOpacityLink.SetDefault(active, 0.9f);
|
||||
Assert.True(active >= def);
|
||||
(def, active) = ChatOpacityLink.SetActive(def, 0.1f);
|
||||
Assert.True(active >= def);
|
||||
(def, active) = ChatOpacityLink.SetDefault(active, 0.6f);
|
||||
Assert.True(active >= def);
|
||||
Assert.Equal(0.6f, def);
|
||||
Assert.Equal(0.6f, active);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,14 @@ public sealed class ChatSettingsTests
|
|||
Assert.True(d.ShowTimestamps);
|
||||
Assert.True(d.FilterProfanity);
|
||||
Assert.Equal(12f, d.FontSize);
|
||||
|
||||
// Campaign CH slice CH6c: retail's base ChatInterface constructor
|
||||
// (0x004F4550) sets DefaultOpacity=0.5/ActiveOpacity=1.0 — the value
|
||||
// every gmFloatyChatUI (the four floating windows) keeps unmodified.
|
||||
// acdream ships that pair as ONE shared global default (register row
|
||||
// AP-190), rather than gmMainChatUI's own 1.0/1.0 override.
|
||||
Assert.Equal(0.5f, d.DefaultOpacity);
|
||||
Assert.Equal(1.0f, d.ActiveOpacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -474,6 +474,70 @@ public sealed class SettingsPanelTests
|
|||
Assert.Equal(1f, (float)masterCall.Args[3]!);
|
||||
}
|
||||
|
||||
// -- Campaign CH slice CH6c: chat tab opacity sliders -----------------
|
||||
|
||||
[Fact]
|
||||
public void Chat_tab_when_active_renders_two_linked_opacity_sliders()
|
||||
{
|
||||
var (panel, vm, _, _) = Build();
|
||||
var r = new FakePanelRenderer { ActiveTabLabel = "Chat" };
|
||||
|
||||
panel.Render(new PanelContext(0.016f, new NullBus()), r);
|
||||
|
||||
var sliders = r.Calls.Where(c => c.Method == "SliderFloat")
|
||||
.Select(c => (string)c.Args[0]!).ToList();
|
||||
Assert.Contains("Background opacity (unfocused)", sliders);
|
||||
Assert.Contains("Active opacity (typing / focused)", sliders);
|
||||
|
||||
var bgCall = r.Calls.First(
|
||||
c => c.Method == "SliderFloat" && (string)c.Args[0]! == "Background opacity (unfocused)");
|
||||
Assert.Equal(vm.ChatDraft.DefaultOpacity, (float)bgCall.Args[1]!);
|
||||
Assert.Equal(0f, (float)bgCall.Args[2]!);
|
||||
Assert.Equal(1f, (float)bgCall.Args[3]!);
|
||||
|
||||
var activeCall = r.Calls.First(
|
||||
c => c.Method == "SliderFloat" && (string)c.Args[0]! == "Active opacity (typing / focused)");
|
||||
Assert.Equal(vm.ChatDraft.ActiveOpacity, (float)activeCall.Args[1]!);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Chat_tab_opacity_sliders_do_not_render_when_a_different_tab_is_active()
|
||||
{
|
||||
var (panel, _, _, _) = Build();
|
||||
var r = new FakePanelRenderer { ActiveTabLabel = "Display" };
|
||||
|
||||
panel.Render(new PanelContext(0.016f, new NullBus()), r);
|
||||
|
||||
var sliders = r.Calls.Where(c => c.Method == "SliderFloat")
|
||||
.Select(c => (string)c.Args[0]!).ToList();
|
||||
Assert.DoesNotContain("Background opacity (unfocused)", sliders);
|
||||
Assert.DoesNotContain("Active opacity (typing / focused)", sliders);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Chat_tab_dragging_active_opacity_below_background_drags_background_down_in_draft()
|
||||
{
|
||||
// FakePanelRenderer applies ONE injected value to every SliderFloat call
|
||||
// in the same Render pass and each branch's `_vm.SetChat` starts from the
|
||||
// ORIGINAL pre-render draft — so with SliderFloatNextReturn set, the
|
||||
// LAST-rendered opacity slider ("Active", rendered after "Background")
|
||||
// determines the final draft. That exercises ChatOpacityLink.SetActive's
|
||||
// drag-background-down path end-to-end through the real panel code,
|
||||
// starting from ChatSettings.Default (DefaultOpacity=0.5, ActiveOpacity=1.0).
|
||||
var (panel, vm, _, _) = Build();
|
||||
var r = new FakePanelRenderer
|
||||
{
|
||||
ActiveTabLabel = "Chat",
|
||||
SliderFloatNextReturn = true,
|
||||
SliderFloatNextValue = 0.2f,
|
||||
};
|
||||
|
||||
panel.Render(new PanelContext(0.016f, new NullBus()), r);
|
||||
|
||||
Assert.Equal(0.2f, vm.ChatDraft.DefaultOpacity);
|
||||
Assert.Equal(0.2f, vm.ChatDraft.ActiveOpacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Save_Cancel_buttons_render_outside_the_tab_bar()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -330,6 +330,35 @@ public sealed class SettingsStoreTests : System.IDisposable
|
|||
Assert.Equal(original.ChatWindow4Filter, loaded.ChatWindow4Filter);
|
||||
}
|
||||
|
||||
// -- Campaign CH slice CH6c: window opacity round-trip -----------------
|
||||
|
||||
[Fact]
|
||||
public void LoadChat_returns_retail_ChatInterface_opacity_defaults_when_file_is_missing()
|
||||
{
|
||||
var store = new SettingsStore(_tempPath);
|
||||
ChatSettings loaded = store.LoadChat();
|
||||
|
||||
Assert.Equal(0.5f, loaded.DefaultOpacity);
|
||||
Assert.Equal(1.0f, loaded.ActiveOpacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SaveChat_then_LoadChat_round_trips_opacity()
|
||||
{
|
||||
var store = new SettingsStore(_tempPath);
|
||||
var original = ChatSettings.Default with
|
||||
{
|
||||
DefaultOpacity = 0.2f,
|
||||
ActiveOpacity = 0.8f,
|
||||
};
|
||||
|
||||
store.SaveChat(original);
|
||||
ChatSettings loaded = store.LoadChat();
|
||||
|
||||
Assert.Equal(original.DefaultOpacity, loaded.DefaultOpacity);
|
||||
Assert.Equal(original.ActiveOpacity, loaded.ActiveOpacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void All_four_sections_coexist_in_one_settings_json()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue