using System.Text.Json; using XFEEDToolBox.Views; namespace XFEEDToolBox; public partial class App { private static async Task RunSystemCompositionProbeAsync(string directory) { var recording=GetArgument(Environment.GetCommandLineArgs(),"--recorded-system-map"); if(ViewModel.DemoMode)throw new InvalidOperationException("Composition acceptance must not use demonstration data."); if(recording is not null) { var isolated=Path.GetFullPath(Path.Combine(directory,"isolated-data")); if(!ViewModel.OfflinePreview||!Path.GetFullPath(Runtime.DataDirectory).Equals(isolated,StringComparison.OrdinalIgnoreCase)||!Path.IsPathFullyQualified(recording)) throw new InvalidOperationException("Recorded actual locations require the explicit offline report-directory fixture."); var snapshot=JsonSerializer.Deserialize(await File.ReadAllTextAsync(recording),XFEEDToolBox.Core.Models.ToolboxSettings.JsonOptions) ??throw new InvalidDataException("Missing recorded actual snapshot."); if(snapshot.SystemAddress<=0||snapshot.Locations.Count==0||snapshot.ObservedAt==default)throw new InvalidDataException("Recorded actual location identity is missing."); ViewModel.ApplyCurrentSystemSnapshot(snapshot); } else if(ViewModel.OfflinePreview)throw new InvalidOperationException("Live composition acceptance requires actual game observations."); var observations=new List();var selectionChecks=new List(); var createdAt=DateTimeOffset.UtcNow; MainWindow.AppWindow.Resize(new(3840,2088)); AppShellPage.Current!.Navigate(typeof(CurrentSystemPage)); var page=(CurrentSystemPage)AppShellPage.Current.CurrentPage!; var until=DateTimeOffset.UtcNow.AddSeconds(30); while((ViewModel.CurrentSystemSceneSnapshot is null||page.MapForProbe.FrameCount==0)&&DateTimeOffset.UtcNow0) throw new InvalidOperationException("The natural composition path has no nonzero presentation area: "+presentation); var ready=new{stage=name,pid=Environment.ProcessId,hwnd=WinRT.Interop.WindowNative.GetWindowHandle(MainWindow).ToInt64(), presentation,orbits,system=ViewModel.CurrentSystemTitle,locationCount=ViewModel.CurrentSystemLocations.Count, observedAt=ViewModel.CurrentSystemSceneSnapshot?.ObservedAt,freezeForXamlCalled=false,renderNowForProbeCalled=false, recordedActualLocations=recording is not null,gameCommandsInvoked=false,tradeOrdersSubmitted=false}; await File.WriteAllTextAsync(Path.Combine(directory,"composition-ready.json"),JsonSerializer.Serialize(ready)); var acknowledgement=Path.Combine(directory,"captured-"+name+".json"); var expires=DateTimeOffset.UtcNow.AddSeconds(35); while(!File.Exists(acknowledgement)&&DateTimeOffset.UtcNoworbit.Renderable)?.ChildIdentity; var row=ViewModel.CurrentSystemLocations.FirstOrDefault(value=>value.Record.Identity==preferred) ??ViewModel.CurrentSystemLocations.First(value=>value.Record.Position is {Finite:true}); list.SelectedItem=row;list.ScrollIntoView(row);await Task.Delay(200); var fromList=ViewModel.SelectedSystemLocation?.Record.Identity==row.Record.Identity &&page.MapForProbe.ProjectedLocations.Any(point=>point.Selected&&point.Node.Location.Identity==row.Record.Identity); selectionChecks.Add(new{direction="list-to-3D",passed=fromList,identity=row.Record.Identity}); if(!fromList)throw new InvalidOperationException("List selection did not reach the naturally rendered 3D scene."); page.MapForProbe.ResetCamera();await Task.Delay(150); var hit=page.MapForProbe.InteractiveLocations.FirstOrDefault(point=>point.X>18&&point.X80&&point.Yorbit.Renderable), recordedActualLocations=recording is not null,recording,syntheticLocations=false,freezeForXamlCalled=false,renderNowForProbeCalled=false, gameCommandsInvoked=false,tradeOrdersSubmitted=false,visualReview="External PrintWindow images must be inspected; nonzero sizes and successful capture alone are not a pixel verdict."}; } }