fix(combat): charge power bar from speed

Read the authored meter direction instead of inferring it from the combat element id, so the bright charge texture grows left-to-right from Speed. Keep the user-approved dark-red middle baseline visible independently and record its exact retail Recklessness visibility edge.

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-12 21:25:24 +02:00
parent 256c1930bd
commit 707add8539
13 changed files with 50 additions and 49 deletions

View file

@ -28,7 +28,7 @@ public sealed class CombatLayoutConformanceTests
Assert.Equal(0x06001923u, power.ThumbSprite);
Assert.Equal(0x06001200u, power.ScalarFillSprite);
Assert.Equal(0x0600715Eu, power.ScalarRangeSprite);
Assert.True(power.ScalarFillFromRight);
Assert.False(power.ScalarFillFromRight);
var repeat = Assert.IsType<UiButton>(
layout.FindElement(CombatUiController.RepeatAttacksId));

View file

@ -21,7 +21,6 @@ public sealed class CombatUiControllerTests
GameplaySettings gameplay = GameplaySettings.Default;
using var controller = CombatUiController.Bind(
layout, combat, attacks, () => gameplay, value => gameplay = value,
() => false,
Labels, visibility.Add)!;
controller.SyncVisibility();
@ -46,14 +45,12 @@ public sealed class CombatUiControllerTests
GameplaySettings gameplay = GameplaySettings.Default;
using var controller = CombatUiController.Bind(
layout, combat, attacks, () => gameplay, value => gameplay = value,
() => true,
Labels, _ => { })!;
combat.SetCombatMode(CombatMode.Melee);
high.OnEvent(new UiEvent(0, high, UiEventType.MouseDown, Data1: 2, Data2: 2));
now = 4.5d;
Assert.Equal(0.5f, power.ScalarFill()!.Value, 3);
Assert.True(power.ScalarRangeVisible());
Assert.Equal(104f, power.ScalarRangeLeft, 3);
Assert.Equal(299f, power.ScalarRangeWidth, 3);
high.OnEvent(new UiEvent(0, high, UiEventType.MouseUp, Data1: 2, Data2: 2));
@ -74,7 +71,6 @@ public sealed class CombatUiControllerTests
GameplaySettings gameplay = GameplaySettings.Default;
using var controller = CombatUiController.Bind(
layout, combat, attacks, () => gameplay, value => gameplay = value,
() => false,
Labels, _ => { })!;
var autoTarget = Assert.IsType<UiButton>(layout.FindElement(CombatUiController.AutoTargetId));
@ -94,7 +90,7 @@ public sealed class CombatUiControllerTests
GameplaySettings gameplay = GameplaySettings.Default;
using var controller = CombatUiController.Bind(
layout, combat, attacks, () => gameplay, value => gameplay = value,
() => true, Labels, _ => { })!;
Labels, _ => { })!;
var speed = Assert.IsType<UiText>(layout.FindElement(CombatUiController.SpeedLabelId));
var powerLabel = Assert.IsType<UiText>(layout.FindElement(CombatUiController.PowerLabelId));

View file

@ -485,6 +485,10 @@ public class DatWidgetFactoryTests
Height = 14,
Children = [fill, range],
};
var meterState = new UiStateInfo { Id = UiStateInfo.DirectStateId };
meterState.Properties.Values[0x6Fu] = new UiPropertyValue
{ Kind = UiPropertyKind.Enum, UnsignedValue = 1u };
meter.States[UiStateInfo.DirectStateId] = meterState;
var info = new ElementInfo
{
Id = CombatUiController.PowerControlId,
@ -502,7 +506,7 @@ public class DatWidgetFactoryTests
Assert.Equal(0x06001923u, bar.ThumbSprite);
Assert.Equal(0x06001200u, bar.ScalarFillSprite);
Assert.Equal(0x0600715Eu, bar.ScalarRangeSprite);
Assert.True(bar.ScalarFillFromRight);
Assert.False(bar.ScalarFillFromRight);
}
private static ElementInfo TextInfo(params (uint Id, UiPropertyValue Value)[] properties)

View file

@ -104,26 +104,26 @@ public class UiScrollbarTests
}
[Theory]
[InlineData(0f, 100f, 0f)]
[InlineData(0.5f, 50f, 50f)]
[InlineData(1f, 0f, 100f)]
public void ScalarFillRect_CombatPower_GrowsRightToLeft(
[InlineData(0f, 0f, 0f)]
[InlineData(0.5f, 0f, 50f)]
[InlineData(1f, 0f, 100f)]
public void ScalarFillRect_CombatPower_GrowsLeftToRight(
float fill, float expectedX, float expectedWidth)
{
var (x, width) = UiScrollbar.ScalarFillRect(100f, fill, fromRight: true);
var (x, width) = UiScrollbar.ScalarFillRect(100f, fill, fromRight: false);
Assert.Equal(expectedX, x, 3);
Assert.Equal(expectedWidth, width, 3);
}
[Theory]
[InlineData(0f, 403f, 0f)]
[InlineData(0.5f, 253.5f, 149.5f)]
[InlineData(0f, 104f, 0f)]
[InlineData(0.5f, 104f, 149.5f)]
[InlineData(1f, 104f, 299f)]
public void ScalarFillRect_CombatPower_StaysBetweenAuthoredLabels(
float fill, float expectedX, float expectedWidth)
{
var (x, width) = UiScrollbar.ScalarFillRect(
rangeLeft: 104f, rangeWidth: 299f, fill, fromRight: true);
rangeLeft: 104f, rangeWidth: 299f, fill, fromRight: false);
Assert.Equal(expectedX, x, 3);
Assert.Equal(expectedWidth, width, 3);
}