using AcDream.App.Rendering; using AcDream.App.UI; using DatReaderWriter; using DatReaderWriter.Options; using SysEnv = System.Environment; namespace AcDream.App.Tests.UI; public sealed class RetailCursorCatalogTests { [Theory] [InlineData(CursorFeedbackKind.TargetPending, 0x27u, 14, 14)] [InlineData(CursorFeedbackKind.TargetValid, 0x28u, 14, 14)] [InlineData(CursorFeedbackKind.TargetInvalid, 0x29u, 14, 14)] public void TargetUseCursorSpecs_matchClientUISystemUpdateCursorState( CursorFeedbackKind kind, uint expectedEnum, int expectedHotspotX, int expectedHotspotY) { Assert.Equal(6u, RetailCursorCatalog.CursorEnumTable); Assert.True(RetailCursorCatalog.TryGetGlobalCursor(kind, out var spec)); Assert.Equal(expectedEnum, spec.EnumId); Assert.Equal(expectedHotspotX, spec.HotspotX); Assert.Equal(expectedHotspotY, spec.HotspotY); } [Fact] public void TargetUseCursorSpecs_resolveGoldenDatSurfaces() { string? datDir = ResolveDatDir(); if (datDir is null) return; using var dats = new DatCollection(datDir, DatAccessType.Read); var resolver = new RetailCursorResolver(dats, new object()); Assert.True(resolver.TryResolve(new RetailCursorSpec(0x27u, 14, 14), out var pending)); Assert.True(resolver.TryResolve(new RetailCursorSpec(0x28u, 14, 14), out var valid)); Assert.True(resolver.TryResolve(new RetailCursorSpec(0x29u, 14, 14), out var invalid)); Assert.Equal(new UiCursorMedia(0x06004D73u, 14, 14), pending); Assert.Equal(new UiCursorMedia(0x06005E6Bu, 14, 14), valid); Assert.Equal(new UiCursorMedia(0x06005E6Au, 14, 14), invalid); } private static string? ResolveDatDir() { string? fromEnv = SysEnv.GetEnvironmentVariable("ACDREAM_DAT_DIR"); if (!string.IsNullOrWhiteSpace(fromEnv) && Directory.Exists(fromEnv)) return fromEnv; string defaultDir = Path.Combine( SysEnv.GetFolderPath(SysEnv.SpecialFolder.UserProfile), "Documents", "Asheron's Call"); return Directory.Exists(defaultDir) ? defaultDir : null; } }