fix(combat): restore retail combat bar controls
Resolve authored StringInfo labels from local.dat, port gmCombatUI's runtime option captions and checkbox widgets, and bind horizontal scrollbar media by retail structural roles so the green power jewel is a thumb instead of a tiled track. Persist the three combat options and make Auto Target govern target acquisition. Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
parent
2215c76c7e
commit
927fa7881a
19 changed files with 24591 additions and 48 deletions
|
|
@ -2,6 +2,7 @@ using AcDream.App.Combat;
|
|||
using AcDream.App.UI;
|
||||
using AcDream.App.UI.Layout;
|
||||
using AcDream.Core.Combat;
|
||||
using AcDream.UI.Abstractions.Panels.Settings;
|
||||
|
||||
namespace AcDream.App.Tests.UI.Layout;
|
||||
|
||||
|
|
@ -17,8 +18,10 @@ public sealed class CombatUiControllerTests
|
|||
using var attacks = CreateAttacks(combat, () => now, []);
|
||||
var (layout, _, _, power, high, medium, low) = BuildLayout();
|
||||
var visibility = new List<bool>();
|
||||
GameplaySettings gameplay = GameplaySettings.Default;
|
||||
using var controller = CombatUiController.Bind(
|
||||
layout, combat, attacks, visibility.Add)!;
|
||||
layout, combat, attacks, () => gameplay, value => gameplay = value,
|
||||
Labels, visibility.Add)!;
|
||||
|
||||
controller.SyncVisibility();
|
||||
combat.SetCombatMode(CombatMode.Melee);
|
||||
|
|
@ -39,8 +42,10 @@ public sealed class CombatUiControllerTests
|
|||
var combat = new CombatState();
|
||||
using var attacks = CreateAttacks(combat, () => now, sent);
|
||||
var (layout, basic, advanced, power, high, _, _) = BuildLayout();
|
||||
GameplaySettings gameplay = GameplaySettings.Default;
|
||||
using var controller = CombatUiController.Bind(
|
||||
layout, combat, attacks, _ => { })!;
|
||||
layout, combat, attacks, () => gameplay, value => gameplay = value,
|
||||
Labels, _ => { })!;
|
||||
combat.SetCombatMode(CombatMode.Melee);
|
||||
|
||||
high.OnEvent(new UiEvent(0, high, UiEventType.MouseDown, Data1: 2, Data2: 2));
|
||||
|
|
@ -55,6 +60,29 @@ public sealed class CombatUiControllerTests
|
|||
Assert.False(advanced.Visible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AuthoredOptionCheckbox_TogglesPersistedGameplayValue()
|
||||
{
|
||||
var combat = new CombatState();
|
||||
using var attacks = CreateAttacks(combat, () => 0d, []);
|
||||
var (layout, _, _, _, _, _, _) = BuildLayout();
|
||||
GameplaySettings gameplay = GameplaySettings.Default;
|
||||
using var controller = CombatUiController.Bind(
|
||||
layout, combat, attacks, () => gameplay, value => gameplay = value,
|
||||
Labels, _ => { })!;
|
||||
var autoTarget = Assert.IsType<UiButton>(layout.FindElement(CombatUiController.AutoTargetId));
|
||||
|
||||
autoTarget.OnEvent(new UiEvent(0, autoTarget, UiEventType.MouseDown, Data1: 3, Data2: 3));
|
||||
autoTarget.OnEvent(new UiEvent(0, autoTarget, UiEventType.MouseUp, Data1: 3, Data2: 3));
|
||||
autoTarget.OnEvent(new UiEvent(0, autoTarget, UiEventType.Click, Data1: 3, Data2: 3));
|
||||
|
||||
Assert.False(gameplay.AutoTarget);
|
||||
}
|
||||
|
||||
private static readonly CombatUiLabels Labels = new(
|
||||
"Speed", "Power", "Repeat Attacks", "Auto Target", "Keep in View",
|
||||
"High", "Medium", "Low");
|
||||
|
||||
private static CombatAttackController CreateAttacks(
|
||||
CombatState combat,
|
||||
Func<double> now,
|
||||
|
|
@ -89,9 +117,21 @@ public sealed class CombatUiControllerTests
|
|||
Width = 72,
|
||||
Height = 19,
|
||||
};
|
||||
UiButton ToggleButton(uint id)
|
||||
{
|
||||
var info = new ElementInfo { Id = id, Type = 0x10000035u, Width = 100, Height = 14 };
|
||||
var state = new UiStateInfo { Id = UiStateInfo.DirectStateId };
|
||||
state.Properties.Values[0x0Bu] = new UiPropertyValue
|
||||
{ Kind = UiPropertyKind.Bool, BoolValue = true };
|
||||
info.States[UiStateInfo.DirectStateId] = state;
|
||||
return new UiButton(info, NoTex) { Width = 100, Height = 14 };
|
||||
}
|
||||
var high = Button(CombatUiController.HighButtonId);
|
||||
var medium = Button(CombatUiController.MediumButtonId);
|
||||
var low = Button(CombatUiController.LowButtonId);
|
||||
var repeat = ToggleButton(CombatUiController.RepeatAttacksId);
|
||||
var autoTarget = ToggleButton(CombatUiController.AutoTargetId);
|
||||
var keepInView = ToggleButton(CombatUiController.KeepInViewId);
|
||||
var byId = new Dictionary<uint, UiElement>
|
||||
{
|
||||
[CombatUiController.BasicPanelId] = basic,
|
||||
|
|
@ -100,6 +140,9 @@ public sealed class CombatUiControllerTests
|
|||
[CombatUiController.HighButtonId] = high,
|
||||
[CombatUiController.MediumButtonId] = medium,
|
||||
[CombatUiController.LowButtonId] = low,
|
||||
[CombatUiController.RepeatAttacksId] = repeat,
|
||||
[CombatUiController.AutoTargetId] = autoTarget,
|
||||
[CombatUiController.KeepInViewId] = keepInView,
|
||||
};
|
||||
return (new ImportedLayout(root, byId), basic, advanced, power, high, medium, low);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue