Implement retail character management screen

This commit is contained in:
Erik 2026-08-14 20:29:19 +02:00
parent 5535d0adac
commit 6cfab727f1
19 changed files with 2435 additions and 6 deletions

View file

@ -11,6 +11,7 @@ using AcDream.App.World;
using AcDream.Core.Net;
using AcDream.Core.World;
using AcDream.Runtime;
using AcDream.Runtime.Session;
using AcDream.UI.Abstractions;
namespace AcDream.App.Tests.Composition;
@ -106,6 +107,44 @@ public sealed class InteractionUiRuntimeSourcesTests
Assert.Throws<ObjectDisposedException>(() => source.Bind(first, first));
}
[Fact]
public void CharacterSelectionProjectionBorrowsExactAdapterAndEveryRouteBecomesInert()
{
var source = new DeferredGameRuntimeStateCommands();
var target = new RuntimeTarget(new RuntimeGenerationToken(11));
Assert.Null(source.CharacterSelection);
Assert.Equal(RuntimeCommandStatus.Inactive,
source.CharacterSelectionEnter().Status);
IDisposable binding = source.Bind(target, target);
Assert.Same(target, source.CharacterSelection);
RuntimeCommandResult[] accepted =
[
source.CharacterSelectionHighlight(0x50000001u),
source.CharacterSelectionEnter(),
source.CharacterSelectionRequestDelete(),
source.CharacterSelectionConfirmDelete(),
source.CharacterSelectionRestore(),
source.CharacterSelectionCancel(),
];
Assert.All(accepted, result =>
{
Assert.True(result.Accepted);
Assert.Equal(new RuntimeGenerationToken(11), result.Generation);
});
binding.Dispose();
Assert.Null(source.CharacterSelection);
Assert.Equal(RuntimeCommandStatus.Inactive,
source.CharacterSelectionRestore().Status);
source.Deactivate();
Assert.Null(source.CharacterSelection);
Assert.Equal(RuntimeCommandStatus.Inactive,
source.CharacterSelectionCancel().Status);
}
[Fact]
public void RadarNeverCachesAnUnboundBootstrapSnapshot()
{
@ -216,7 +255,9 @@ public sealed class InteractionUiRuntimeSourcesTests
IGameRuntimeCommands,
IRuntimeInventoryStateCommands,
IRuntimeSpellbookCommands,
IRuntimeCharacterCommands
IRuntimeCharacterCommands,
IRuntimeCharacterSelectionView,
IRuntimeCharacterSelectionCommands
{
public RuntimeTarget(RuntimeGenerationToken generation)
{
@ -234,6 +275,7 @@ public sealed class InteractionUiRuntimeSourcesTests
public IRuntimeCharacterView Character => null!;
public IRuntimeSocialView Social => null!;
public IRuntimeChatView Chat => null!;
public IRuntimeCharacterSelectionView CharacterSelection => this;
public IRuntimeFellowshipView Fellowship => null!;
public IRuntimeAllegianceView Allegiance => null!;
public IRuntimeActionView Actions => null!;
@ -242,6 +284,7 @@ public sealed class InteractionUiRuntimeSourcesTests
null!;
public IRuntimePortalView Portal => null!;
public IRuntimeSessionCommands Session => null!;
IRuntimeCharacterSelectionCommands IGameRuntimeCommands.CharacterSelection => this;
public IRuntimeSelectionCommands Selection => null!;
public IRuntimeCombatCommands Combat => null!;
public IRuntimeMagicCommands Magic => null!;
@ -257,6 +300,67 @@ public sealed class InteractionUiRuntimeSourcesTests
public RuntimeStateCheckpoint CaptureCheckpoint() => default;
RuntimeCharacterSelectionSnapshot IRuntimeCharacterSelectionView.Snapshot =>
new(
Generation,
RuntimeCharacterSelectionLifecycle.AwaitingSelection,
Revision: 1,
AccountName: "account",
SlotCount: 0,
RosterCount: 0,
HighlightedCharacterId: 0u,
HighlightedDisplayIndex: -1,
PendingDeleteCharacterId: 0u,
LastRestoreRequestedCharacterId: 0u,
Operation: RuntimeCharacterSelectionOperation.None,
Error: null,
Buttons: RuntimeCharacterSelectionButtons.None);
public bool TryGetAt(
int displayIndex,
out RuntimeCharacterSelectionEntry character)
{
character = default;
return false;
}
public bool TryGet(
uint characterId,
out RuntimeCharacterSelectionEntry character)
{
character = default;
return false;
}
public void Visit(IRuntimeCharacterSelectionVisitor visitor) { }
public IDisposable Subscribe(IRuntimeCharacterSelectionObserver observer) =>
EmptyDisposable.Instance;
public RuntimeCommandResult Highlight(
RuntimeGenerationToken expectedGeneration,
uint characterId) => Accepted(expectedGeneration, characterId);
public RuntimeCommandResult Enter(
RuntimeGenerationToken expectedGeneration) =>
Accepted(expectedGeneration);
public RuntimeCommandResult RequestDelete(
RuntimeGenerationToken expectedGeneration) =>
Accepted(expectedGeneration);
public RuntimeCommandResult ConfirmDelete(
RuntimeGenerationToken expectedGeneration) =>
Accepted(expectedGeneration);
public RuntimeCommandResult Restore(
RuntimeGenerationToken expectedGeneration) =>
Accepted(expectedGeneration);
public RuntimeCommandResult Cancel(
RuntimeGenerationToken expectedGeneration) =>
Accepted(expectedGeneration);
public RuntimeCommandResult AddShortcut(
RuntimeGenerationToken expectedGeneration,
in RuntimeShortcutCommand command) =>
@ -392,6 +496,12 @@ public sealed class InteractionUiRuntimeSourcesTests
}
}
private sealed class EmptyDisposable : IDisposable
{
public static EmptyDisposable Instance { get; } = new();
public void Dispose() { }
}
private sealed class EmptyRadarSource : ILiveEntityRadarSource
{
public static EmptyRadarSource Instance { get; } = new();