using System.Diagnostics;
using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
using XFEEDToolBox.Core.Rendering;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyNebulaProbeAsync(string directory)
{
if(Environment.GetCommandLineArgs().Contains("--probe-galaxy-rework"))return await RunGalaxyReworkProbeAsync(directory);
if(Environment.GetCommandLineArgs().Contains("--probe-galaxy-ui"))return await RunGalaxyUi0416ProbeAsync(directory);
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
static double Difference(byte[] a,byte[] b)=>a.Zip(b,(x,y)=>Math.Abs((int)x-y)).Average();
async Task Save(GalaxyMapView map,string name){var p=map.CapturePixelsForProbe();await SaveModelFrameAsync(new ShipModelView.RenderedFrame(p.Width,p.Height,p.Pixels,0),Path.Combine(directory,name+".png"));}
var host=new Grid();MainWindow.Content=host;var map=new GalaxyMapView{Width=1400,Height=850,HorizontalAlignment=HorizontalAlignment.Left,VerticalAlignment=VerticalAlignment.Top};host.Children.Add(map);await Task.Delay(200);
var scenes=new List<object>();
foreach(var name in new[]{"Coalsack","Pleiades Nebula","Barnard's Loop"})
{
var nebula=EliteNebulae.Reference.Nebulae.Single(n=>n.Name==name);map.Systems=[];map.Centre=nebula.Position;map.ResetCamera();map.Zoom(210/(nebula.HalfSize*4));map.RenderNowForProbe();
var clock=Stopwatch.StartNew();while((map.VisibleNebulae==0||map.PendingNebulaLoads>0)&&clock.ElapsedMilliseconds<18000){await Task.Delay(100);map.RenderNowForProbe();}
Require(map.MapGraphicsBackend.StartsWith("Direct3D"),map.GraphicsError);Require(map.VisibleNebulae>0,name+" volume did not load.");
map.EnableNebulaeForProbe(false);map.RenderNowForProbe();var clear=map.CapturePixelsForProbe();
map.EnableNebulaeForProbe(true);map.RenderNowForProbe();var withCloud=map.CapturePixelsForProbe();var difference=Difference(clear.Pixels,withCloud.Pixels);
Require(difference>.015,name+" produced no visible volumetric contribution.");await Save(map,name.Replace(' ','-'));
map.ApplyDragDelta(100,24,false);map.RenderNowForProbe();clock.Restart();while(map.PendingNebulaLoads>0&&clock.ElapsedMilliseconds<18000){await Task.Delay(100);map.RenderNowForProbe();}await Save(map,name.Replace(' ','-')+"-rotated");
var rotated=map.CapturePixelsForProbe();map.EnableNebulaeForProbe(false);map.RenderNowForProbe();var rotatedClear=map.CapturePixelsForProbe();map.EnableNebulaeForProbe(true);map.RenderNowForProbe();
var initialMask=withCloud.Pixels.Zip(clear.Pixels,(a,b)=>(byte)Math.Abs(a-b)).ToArray();var rotatedMask=rotated.Pixels.Zip(rotatedClear.Pixels,(a,b)=>(byte)Math.Abs(a-b)).ToArray();
var changes=Difference(initialMask,rotatedMask);Require(changes>.005,name+" is not changing as a three-dimensional volume.");
await Task.Delay(180);map.RenderNowForProbe();var atRest=map.FrameCount;await Task.Delay(120);Require(map.FrameCount==atRest,"Idle map kept rendering.");
scenes.Add(new{name,visible=map.VisibleNebulae,resident=map.ResidentNebulaTextures,gpuBytes=map.NebulaGpuBytes,meanPixelDifference=difference,rotationMaskDifference=changes,idleDoesNotRedraw=true});
}
map.Centre=new(80000,0,80000);map.RenderNowForProbe();Require(map.VisibleNebulae==0&&map.ResidentNebulaTextures==0,"Offscreen clouds retained GPU textures.");
object? core=null;var fixture=GetArgument(Environment.GetCommandLineArgs(),"--core-fixture");
if(fixture is not null)
{
using var json=JsonDocument.Parse(await File.ReadAllTextAsync(fixture));var stars=JsonSerializer.Deserialize<GalacticSystem[]>(json.RootElement.GetProperty("systems"),ToolboxSettings.JsonOptions)!;
Require(stars.Length==24000&&stars.Select(s=>s.SystemAddress).Distinct().Count()==stars.Length,"Native core fixture is incomplete or contains duplicates.");
var centre=new Coordinates(25.21875,-20.90625,25899.96875);Require(stars.All(s=>s.Position.DistanceTo(centre)<=700.01),"Native core coordinates exceed the queried region.");
map.Systems=stars;map.Centre=centre;map.ResetCamera();map.Zoom(.0045);map.RenderNowForProbe();
Require(map.VisibleStars==stars.Length,"Overview zoom hid ordinary native stars.");var far=map.VisibleStars;await Save(map,"native-core-overview");
map.ResetCamera();map.Zoom(.125);map.RenderNowForProbe();Require(map.VisibleStars==stars.Length,"Core detail frame dropped loaded stars.");await Save(map,"native-core-detail");
var timings=new List<double>();for(var i=0;i<40;i++){map.ApplyDragDelta(.1,.02,false);map.RenderNowForProbe();timings.Add(map.LastFrameMilliseconds);}
timings.Sort();core=new{nativeCount=stars.Length,overviewDrawn=far,detailDrawn=map.VisibleStars,uniqueAddresses=true,insideNativeQuery=true,meanCpuMilliseconds=timings.Average(),p95CpuMilliseconds=timings[38],drawCalls=map.GraphicsDrawCalls,source="actual read-only Stellar Forge response",generatedStars=false};
}
return new{scenes,offscreenGpuResourcesReleased=true,nativeCore=core,originalTextures=EliteNebulae.Reference.Templates.Length,authoredNebulaPositions=EliteNebulae.Reference.Nebulae.Length,gameFlightCommandsInvoked=false,gameRestartInvoked=false};
}
private static async Task<object> RunGalaxyUi0416ProbeAsync(string directory)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var shell=MainWindow.Content;var host=new Grid();MainWindow.Content=host;
var map=new GalaxyMapView{Width=1000,Height=650,Centre=new(0,0,0)};host.Children.Add(map);
// Deliberately overlapping screen positions reproduce a neighbour under
// the searched star's ring. These are UI fixtures, never catalogue data.
var searched=new GalacticSystem("Adnyayar",new(0,0,0),5070343382393,"M");
var neighbour=new GalacticSystem("Col 285 Sector MC-I b11-2",new(2,0,0),42,"K");
map.Systems=[searched,neighbour];map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();
GalacticSystem? submitted=null;var plans=0;map.TargetChosen+=(_,target)=>{submitted=target;plans++;map.Planning=true;};
var point=map.ProjectForProbe(neighbour.Position);map.BeginPointer(point,false);await Task.Delay(700);map.EndPointer(point);
Require(plans==1&&submitted?.Name==searched.Name&&submitted.SystemAddress==searched.SystemAddress,"Long press replaced the searched star with its projected neighbour.");
map.Planning=false;map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();
plans=0;point=map.ProjectForProbe(searched.Position);map.BeginPointer(point,false);await Task.Delay(180);map.Selection=neighbour;await Task.Delay(520);map.EndPointer(point);
Require(plans==0,"Changing selection retained a stale hold target.");
map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();plans=0;
point=map.ProjectForProbe(searched.Position);point.X+=45;map.BeginPointer(point,false);await Task.Delay(700);map.EndPointer(point);
Require(plans==1&&submitted?.Name==searched.Name,"Holding the selected caption planned another star.");map.Planning=false;
MainWindow.AppWindow.Resize(new(1510,980));await Task.Delay(180);
var navigationWindowSize=MainWindow.AppWindow.Size;
Require(navigationWindowSize.Width==1510&&navigationWindowSize.Height==980,"Navigation overlay layout must be checked at the actual 1510x980 window size.");
MainWindow.Content=shell;ViewModel.DemoMode=true;await ViewModel.RefreshCommand.ExecuteAsync(null);
Views.AppShellPage.Current!.Navigate(typeof(Views.NavigationPage));await Task.Delay(120);
var navigation=(Views.NavigationPage)Views.AppShellPage.Current.CurrentPage!;
var pageMap=(GalaxyMapView)navigation.FindName("Map");pageMap.SuspendPage();
var region=(Grid)navigation.FindName("MapRegion");
var selected=new GalacticSystem("Adnyayar",new(103.53125,65.0625,-117.3125),5070343382393,"M");
await ViewModel.ChooseNavigationTargetAsync(selected);ViewModel.GalaxyCentre=selected.Position;pageMap.FocusSystem(selected,false);await Task.Delay(100);
var input=(AutoSuggestBox)navigation.FindName("DestinationInput");input.Text="Unsubmitted query";await Task.Delay(50);
Require(ViewModel.NavigationDestination=="Adnyayar","Editing search text changed the committed planning destination.");input.Text="Adnyayar";
var selectedCard=(Border)navigation.FindName("SelectedStarOverlay");selectedCard.StartBringIntoView(new(){AnimationDesired=false});await Task.Delay(80);
var cardAt=selectedCard.TransformToVisual(region).TransformPoint(new(0,0));
var routeCard=(Border)navigation.FindName("NavigationOverlay");var routeAt=routeCard.TransformToVisual(region).TransformPoint(new(0,0));
var sidebarScroll=(ScrollViewer)navigation.FindName("SidebarScroll");var sidebarAt=sidebarScroll.TransformToVisual(region).TransformPoint(new(0,0));
Require(cardAt.X>=sidebarAt.X+sidebarScroll.ActualWidth&&cardAt.Y>=routeAt.Y+routeCard.ActualHeight+8
&&cardAt.X+selectedCard.ActualWidth<=region.ActualWidth&&cardAt.Y+selectedCard.ActualHeight<=region.ActualHeight,
"Selected star information overlaps a navigation drawer, route card or map edge.");
var lane=(ScrollViewer)navigation.FindName("NavigationLane");var laneAt=lane.TransformToVisual(region).TransformPoint(new(0,0));
Require(cardAt.Y>=laneAt.Y&&cardAt.Y+selectedCard.ActualHeight<=laneAt.Y+lane.ActualHeight,"The selected system card is clipped by its scrolling lane.");
Require(selectedCard.Opacity>0&&selectedCard.IsHitTestVisible
&&navigation.FindName("OpenLocalMapButton") is Button{IsEnabled:true,Visibility:Visibility.Visible,IsHitTestVisible:true},"The selected system local-map action is unavailable.");
if(Environment.GetCommandLineArgs().Contains("--probe-navigation-overlap"))
{
var localMapButton=(Button)navigation.FindName("OpenLocalMapButton");
Require(ReferenceEquals(AsyncAction.GetCommand(localMapButton),ViewModel.OpenSelectedSystemMapCommand),"The local-map entry lost its selected-system command binding.");
object Bounds(FrameworkElement element)
{
var at=element.TransformToVisual(region).TransformPoint(new(0,0));
return new{left=at.X,top=at.Y,width=element.ActualWidth,height=element.ActualHeight};
}
var screenshot=Path.Combine(directory,"selected-star-unobstructed.png");await CapturePageAsync(navigation,screenshot);
return new{scope="navigation-overlap",fixture=true,navigationWindow=new{width=navigationWindowSize.Width,height=navigationWindowSize.Height},
rasterizationScale=navigation.XamlRoot.RasterizationScale,boundsCoordinateSpace="MapRegion XAML DIPs",
bounds=new{map=new{width=region.ActualWidth,height=region.ActualHeight},sidebar=Bounds(sidebarScroll),route=Bounds(routeCard),
selection=Bounds(selectedCard),lane=Bounds(lane),localMapButton=Bounds(localMapButton),commands=Bounds((CommandBar)navigation.FindName("MapCommands"))},
selectedInformationUnobstructed=true,localMapActionAvailable=true,screenshot,gameFlightCommandsInvoked=false,gameRouteRequestsInvoked=false,gameRestartInvoked=false};
}
var overlay=(Border)navigation.FindName("SidebarOverlay");Require(overlay.Background is Microsoft.UI.Xaml.Media.AcrylicBrush brush&&Math.Abs(brush.Opacity-.78)<.00001&&Math.Abs(brush.TintOpacity-.32)<.00001&&brush.TintLuminosityOpacity is {} luminosity&&Math.Abs(luminosity-.08)<.00001,"Map overlay must retain its translucent acrylic finish: "+(overlay.Background is Microsoft.UI.Xaml.Media.AcrylicBrush actual?$"opacity={actual.Opacity:R}, tint={actual.TintOpacity:R}, luminosity={actual.TintLuminosityOpacity:R}":overlay.Background?.GetType().Name));
ViewModel.GalaxyPlaceKindIndex=6;await Task.Delay(80);
Require(((ItemsControl)navigation.FindName("PlaceKindInput")).Items.Count==7&&ViewModel.GalaxyGatheringChoices.Count==8,"Manufactured material choices are missing.");
ViewModel.GalaxyGatheringCategoryIndex=1;ViewModel.GalaxyGatheringMaterial=ViewModel.GalaxyGatheringChoices.Single(c=>c.Name=="Tin");await ViewModel.SearchGalacticPlacesCommand.ExecuteAsync(null);await Task.Delay(100);
Require(ViewModel.GalaxyPlaces.Count==2&&ViewModel.GalaxyPlaces.Zip(ViewModel.GalaxyPlaces.Skip(1),(a,b)=>a.Distance<=b.Distance).All(v=>v),"Raw material sites are not filtered and sorted by distance.");
await CapturePageAsync(navigation,Path.Combine(directory,"raw-gathering.png"));
ViewModel.GalaxyGatheringCategoryIndex=2;await ViewModel.SearchGalacticPlacesCommand.ExecuteAsync(null);await Task.Delay(100);
Require(ViewModel.GalaxyPlaces.Single().SystemName=="HIP 12099"&&!ViewModel.PlacesNeedGatheringMaterial,"Encoded gathering did not select the fixed Jameson location.");
await CapturePageAsync(navigation,Path.Combine(directory,"jameson-gathering.png"));
((HorizontalPanel)navigation.FindName("PlacesExpander")).IsExpanded=false;
((HorizontalPanel)navigation.FindName("SidebarExpander")).IsExpanded=true;
await ViewModel.ChooseNavigationTargetAsync(selected);ViewModel.GalaxyCentre=selected.Position;selectedCard.StartBringIntoView(new(){AnimationDesired=false});await Task.Delay(80);
await CapturePageAsync(navigation,Path.Combine(directory,"selected-star-unobstructed.png"));
Views.AppShellPage.Current.Navigate(typeof(Views.RefitPage));await Task.Delay(120);
var editor=(Views.RefitPage)Views.AppShellPage.Current.CurrentPage!;
foreach(var name in new[]{"CategoryPanel","SlotPanel","InspectorPanel"})Require(((Border)editor.FindName(name)).Background is not Microsoft.UI.Xaml.Media.AcrylicBrush,"Refit panel retained acrylic.");
var definition=Core.Outfitting.OutfittingCatalog.Default.Modules.First(m=>m.Name=="Multi-Cannon"&&m.Size==4);
var module=new FittedModule{Slot="HugeHardpoint1",Item=definition.Item};
ViewModel.LoadRefitProbeDocument(new(123,"cutter","UI fixture",null,[new(){Slot=module.Slot,Capacity=4,Category="hardpoint",Module=module}]));await Task.Delay(180);
Require(Descendants(editor).OfType<FontIcon>().Any(i=>i.Glyph=="\uF1CB"),"Module replacement button has the wrong glyph.");
ViewModel.BeginRefitModuleSelection(ViewModel.RefitVisibleSlots.First());Views.AppShellPage.Current.Navigate(typeof(Views.RefitModulePickerPage));await Task.Delay(600);
Require(ViewModel.RefitModuleTypes.Count==12,"Weapon picker does not show the game's 12 families.");
ViewModel.RefitSelectedModuleType=ViewModel.RefitModuleTypes.Single(t=>t.Key=="weapon.pulse");
Require(ViewModel.RefitTypeModels.Any(c=>c.Definition.Name=="Pulse Disruptor Laser"),"Pulse Disruptor is missing from Pulse Lasers.");
ViewModel.RefitSelectedModuleType=null;await CapturePageAsync(Views.AppShellPage.Current.CurrentPage!,Path.Combine(directory,"translated-weapon-families.png"));
return new{navigationWindow=new{width=navigationWindowSize.Width,height=navigationWindowSize.Height},selectedRingAndCaptionKeepSearchTarget=true,changedSelectionCancelsHold=true,unsubmittedSearchCannotChangeDestination=true,selectedInformationUnobstructed=true,localMapActionAvailable=true,rawSitesFilteredAndSorted=true,jamesonFixedLocation=true,mapLighterAcrylic=true,refitSolidPanels=true,replacementGlyph="F1CB",weaponFamilies=ViewModel.RefitModuleTypes.Select(t=>t.Name),gameFlightCommandsInvoked=false,gameRouteRequestsInvoked=false};
}
}
using System.Diagnostics;
using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
using XFEEDToolBox.Core.Rendering;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyNebulaProbeAsync(string directory)
{
if(Environment.GetCommandLineArgs().Contains("--probe-galaxy-rework"))return await RunGalaxyReworkProbeAsync(directory);
if(Environment.GetCommandLineArgs().Contains("--probe-galaxy-ui"))return await RunGalaxyUi0416ProbeAsync(directory);
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
static double Difference(byte[] a,byte[] b)=>a.Zip(b,(x,y)=>Math.Abs((int)x-y)).Average();
async Task Save(GalaxyMapView map,string name){var p=map.CapturePixelsForProbe();await SaveModelFrameAsync(new ShipModelView.RenderedFrame(p.Width,p.Height,p.Pixels,0),Path.Combine(directory,name+".png"));}
var host=new Grid();MainWindow.Content=host;var map=new GalaxyMapView{Width=1400,Height=850,HorizontalAlignment=HorizontalAlignment.Left,VerticalAlignment=VerticalAlignment.Top};host.Children.Add(map);await Task.Delay(200);
var scenes=new List<object>();
foreach(var name in new[]{"Coalsack","Pleiades Nebula","Barnard's Loop"})
{
var nebula=EliteNebulae.Reference.Nebulae.Single(n=>n.Name==name);map.Systems=[];map.Centre=nebula.Position;map.ResetCamera();map.Zoom(210/(nebula.HalfSize*4));map.RenderNowForProbe();
var clock=Stopwatch.StartNew();while((map.VisibleNebulae==0||map.PendingNebulaLoads>0)&&clock.ElapsedMilliseconds<18000){await Task.Delay(100);map.RenderNowForProbe();}
Require(map.MapGraphicsBackend.StartsWith("Direct3D"),map.GraphicsError);Require(map.VisibleNebulae>0,name+" volume did not load.");
map.EnableNebulaeForProbe(false);map.RenderNowForProbe();var clear=map.CapturePixelsForProbe();
map.EnableNebulaeForProbe(true);map.RenderNowForProbe();var withCloud=map.CapturePixelsForProbe();var difference=Difference(clear.Pixels,withCloud.Pixels);
Require(difference>.015,name+" produced no visible volumetric contribution.");await Save(map,name.Replace(' ','-'));
map.ApplyDragDelta(100,24,false);map.RenderNowForProbe();clock.Restart();while(map.PendingNebulaLoads>0&&clock.ElapsedMilliseconds<18000){await Task.Delay(100);map.RenderNowForProbe();}await Save(map,name.Replace(' ','-')+"-rotated");
var rotated=map.CapturePixelsForProbe();map.EnableNebulaeForProbe(false);map.RenderNowForProbe();var rotatedClear=map.CapturePixelsForProbe();map.EnableNebulaeForProbe(true);map.RenderNowForProbe();
var initialMask=withCloud.Pixels.Zip(clear.Pixels,(a,b)=>(byte)Math.Abs(a-b)).ToArray();var rotatedMask=rotated.Pixels.Zip(rotatedClear.Pixels,(a,b)=>(byte)Math.Abs(a-b)).ToArray();
var changes=Difference(initialMask,rotatedMask);Require(changes>.005,name+" is not changing as a three-dimensional volume.");
await Task.Delay(180);map.RenderNowForProbe();var atRest=map.FrameCount;await Task.Delay(120);Require(map.FrameCount==atRest,"Idle map kept rendering.");
scenes.Add(new{name,visible=map.VisibleNebulae,resident=map.ResidentNebulaTextures,gpuBytes=map.NebulaGpuBytes,meanPixelDifference=difference,rotationMaskDifference=changes,idleDoesNotRedraw=true});
}
map.Centre=new(80000,0,80000);map.RenderNowForProbe();Require(map.VisibleNebulae==0&&map.ResidentNebulaTextures==0,"Offscreen clouds retained GPU textures.");
object? core=null;var fixture=GetArgument(Environment.GetCommandLineArgs(),"--core-fixture");
if(fixture is not null)
{
using var json=JsonDocument.Parse(await File.ReadAllTextAsync(fixture));var stars=JsonSerializer.Deserialize<GalacticSystem[]>(json.RootElement.GetProperty("systems"),ToolboxSettings.JsonOptions)!;
Require(stars.Length==24000&&stars.Select(s=>s.SystemAddress).Distinct().Count()==stars.Length,"Native core fixture is incomplete or contains duplicates.");
var centre=new Coordinates(25.21875,-20.90625,25899.96875);Require(stars.All(s=>s.Position.DistanceTo(centre)<=700.01),"Native core coordinates exceed the queried region.");
map.Systems=stars;map.Centre=centre;map.ResetCamera();map.Zoom(.0045);map.RenderNowForProbe();
Require(map.VisibleStars==stars.Length,"Overview zoom hid ordinary native stars.");var far=map.VisibleStars;await Save(map,"native-core-overview");
map.ResetCamera();map.Zoom(.125);map.RenderNowForProbe();Require(map.VisibleStars==stars.Length,"Core detail frame dropped loaded stars.");await Save(map,"native-core-detail");
var timings=new List<double>();for(var i=0;i<40;i++){map.ApplyDragDelta(.1,.02,false);map.RenderNowForProbe();timings.Add(map.LastFrameMilliseconds);}
timings.Sort();core=new{nativeCount=stars.Length,overviewDrawn=far,detailDrawn=map.VisibleStars,uniqueAddresses=true,insideNativeQuery=true,meanCpuMilliseconds=timings.Average(),p95CpuMilliseconds=timings[38],drawCalls=map.GraphicsDrawCalls,source="actual read-only Stellar Forge response",generatedStars=false};
}
return new{scenes,offscreenGpuResourcesReleased=true,nativeCore=core,originalTextures=EliteNebulae.Reference.Templates.Length,authoredNebulaPositions=EliteNebulae.Reference.Nebulae.Length,gameFlightCommandsInvoked=false,gameRestartInvoked=false};
}
private static async Task<object> RunGalaxyUi0416ProbeAsync(string directory)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var shell=MainWindow.Content;var host=new Grid();MainWindow.Content=host;
var map=new GalaxyMapView{Width=1000,Height=650,Centre=new(0,0,0)};host.Children.Add(map);
// Deliberately overlapping screen positions reproduce a neighbour under
// the searched star's ring. These are UI fixtures, never catalogue data.
var searched=new GalacticSystem("Adnyayar",new(0,0,0),5070343382393,"M");
var neighbour=new GalacticSystem("Col 285 Sector MC-I b11-2",new(2,0,0),42,"K");
map.Systems=[searched,neighbour];map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();
GalacticSystem? submitted=null;var plans=0;map.TargetChosen+=(_,target)=>{submitted=target;plans++;map.Planning=true;};
var point=map.ProjectForProbe(neighbour.Position);map.BeginPointer(point,false);await Task.Delay(700);map.EndPointer(point);
Require(plans==1&&submitted?.Name==searched.Name&&submitted.SystemAddress==searched.SystemAddress,"Long press replaced the searched star with its projected neighbour.");
map.Planning=false;map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();
plans=0;point=map.ProjectForProbe(searched.Position);map.BeginPointer(point,false);await Task.Delay(180);map.Selection=neighbour;await Task.Delay(520);map.EndPointer(point);
Require(plans==0,"Changing selection retained a stale hold target.");
map.FocusSystem(searched,false);await Task.Delay(300);map.RenderNowForProbe();plans=0;
point=map.ProjectForProbe(searched.Position);point.X+=45;map.BeginPointer(point,false);await Task.Delay(700);map.EndPointer(point);
Require(plans==1&&submitted?.Name==searched.Name,"Holding the selected caption planned another star.");map.Planning=false;
MainWindow.AppWindow.Resize(new(1510,980));await Task.Delay(180);
var navigationWindowSize=MainWindow.AppWindow.Size;
Require(navigationWindowSize.Width==1510&&navigationWindowSize.Height==980,"Navigation overlay layout must be checked at the actual 1510x980 window size.");
MainWindow.Content=shell;ViewModel.DemoMode=true;await ViewModel.RefreshCommand.ExecuteAsync(null);
Views.AppShellPage.Current!.Navigate(typeof(Views.NavigationPage));await Task.Delay(120);
var navigation=(Views.NavigationPage)Views.AppShellPage.Current.CurrentPage!;
var pageMap=(GalaxyMapView)navigation.FindName("Map");pageMap.SuspendPage();
var region=(Grid)navigation.FindName("MapRegion");
var selected=new GalacticSystem("Adnyayar",new(103.53125,65.0625,-117.3125),5070343382393,"M");
await ViewModel.ChooseNavigationTargetAsync(selected);ViewModel.GalaxyCentre=selected.Position;pageMap.FocusSystem(selected,false);await Task.Delay(100);
var input=(AutoSuggestBox)navigation.FindName("DestinationInput");input.Text="Unsubmitted query";await Task.Delay(50);
Require(ViewModel.NavigationDestination=="Adnyayar","Editing search text changed the committed planning destination.");input.Text="Adnyayar";
var selectedCard=(Border)navigation.FindName("SelectedStarOverlay");selectedCard.StartBringIntoView(new(){AnimationDesired=false});await Task.Delay(80);
var cardAt=selectedCard.TransformToVisual(region).TransformPoint(new(0,0));
var routeCard=(Border)navigation.FindName("NavigationOverlay");var routeAt=routeCard.TransformToVisual(region).TransformPoint(new(0,0));
var sidebarScroll=(ScrollViewer)navigation.FindName("SidebarScroll");var sidebarAt=sidebarScroll.TransformToVisual(region).TransformPoint(new(0,0));
Require(cardAt.X>=sidebarAt.X+sidebarScroll.ActualWidth&&cardAt.Y>=routeAt.Y+routeCard.ActualHeight+8
&&cardAt.X+selectedCard.ActualWidth<=region.ActualWidth&&cardAt.Y+selectedCard.ActualHeight<=region.ActualHeight,
"Selected star information overlaps a navigation drawer, route card or map edge.");
var lane=(ScrollViewer)navigation.FindName("NavigationLane");var laneAt=lane.TransformToVisual(region).TransformPoint(new(0,0));
Require(cardAt.Y>=laneAt.Y&&cardAt.Y+selectedCard.ActualHeight<=laneAt.Y+lane.ActualHeight,"The selected system card is clipped by its scrolling lane.");
Require(selectedCard.Opacity>0&&selectedCard.IsHitTestVisible
&&navigation.FindName("OpenLocalMapButton") is Button{IsEnabled:true,Visibility:Visibility.Visible,IsHitTestVisible:true},"The selected system local-map action is unavailable.");
if(Environment.GetCommandLineArgs().Contains("--probe-navigation-overlap"))
{
var localMapButton=(Button)navigation.FindName("OpenLocalMapButton");
Require(ReferenceEquals(AsyncAction.GetCommand(localMapButton),ViewModel.OpenSelectedSystemMapCommand),"The local-map entry lost its selected-system command binding.");
object Bounds(FrameworkElement element)
{
var at=element.TransformToVisual(region).TransformPoint(new(0,0));
return new{left=at.X,top=at.Y,width=element.ActualWidth,height=element.ActualHeight};
}
var screenshot=Path.Combine(directory,"selected-star-unobstructed.png");await CapturePageAsync(navigation,screenshot);
return new{scope="navigation-overlap",fixture=true,navigationWindow=new{width=navigationWindowSize.Width,height=navigationWindowSize.Height},
rasterizationScale=navigation.XamlRoot.RasterizationScale,boundsCoordinateSpace="MapRegion XAML DIPs",
bounds=new{map=new{width=region.ActualWidth,height=region.ActualHeight},sidebar=Bounds(sidebarScroll),route=Bounds(routeCard),
selection=Bounds(selectedCard),lane=Bounds(lane),localMapButton=Bounds(localMapButton),commands=Bounds((CommandBar)navigation.FindName("MapCommands"))},
selectedInformationUnobstructed=true,localMapActionAvailable=true,screenshot,gameFlightCommandsInvoked=false,gameRouteRequestsInvoked=false,gameRestartInvoked=false};
}
var overlay=(Border)navigation.FindName("SidebarOverlay");Require(overlay.Background is Microsoft.UI.Xaml.Media.AcrylicBrush brush&&Math.Abs(brush.Opacity-.78)<.00001&&Math.Abs(brush.TintOpacity-.32)<.00001&&brush.TintLuminosityOpacity is {} luminosity&&Math.Abs(luminosity-.08)<.00001,"Map overlay must retain its translucent acrylic finish: "+(overlay.Background is Microsoft.UI.Xaml.Media.AcrylicBrush actual?$"opacity={actual.Opacity:R}, tint={actual.TintOpacity:R}, luminosity={actual.TintLuminosityOpacity:R}":overlay.Background?.GetType().Name));
ViewModel.GalaxyPlaceKindIndex=6;await Task.Delay(80);
Require(((ItemsControl)navigation.FindName("PlaceKindInput")).Items.Count==7&&ViewModel.GalaxyGatheringChoices.Count==8,"Manufactured material choices are missing.");
ViewModel.GalaxyGatheringCategoryIndex=1;ViewModel.GalaxyGatheringMaterial=ViewModel.GalaxyGatheringChoices.Single(c=>c.Name=="Tin");await ViewModel.SearchGalacticPlacesCommand.ExecuteAsync(null);await Task.Delay(100);
Require(ViewModel.GalaxyPlaces.Count==2&&ViewModel.GalaxyPlaces.Zip(ViewModel.GalaxyPlaces.Skip(1),(a,b)=>a.Distance<=b.Distance).All(v=>v),"Raw material sites are not filtered and sorted by distance.");
await CapturePageAsync(navigation,Path.Combine(directory,"raw-gathering.png"));
ViewModel.GalaxyGatheringCategoryIndex=2;await ViewModel.SearchGalacticPlacesCommand.ExecuteAsync(null);await Task.Delay(100);
Require(ViewModel.GalaxyPlaces.Single().SystemName=="HIP 12099"&&!ViewModel.PlacesNeedGatheringMaterial,"Encoded gathering did not select the fixed Jameson location.");
await CapturePageAsync(navigation,Path.Combine(directory,"jameson-gathering.png"));
((HorizontalPanel)navigation.FindName("PlacesExpander")).IsExpanded=false;
((HorizontalPanel)navigation.FindName("SidebarExpander")).IsExpanded=true;
await ViewModel.ChooseNavigationTargetAsync(selected);ViewModel.GalaxyCentre=selected.Position;selectedCard.StartBringIntoView(new(){AnimationDesired=false});await Task.Delay(80);
await CapturePageAsync(navigation,Path.Combine(directory,"selected-star-unobstructed.png"));
Views.AppShellPage.Current.Navigate(typeof(Views.RefitPage));await Task.Delay(120);
var editor=(Views.RefitPage)Views.AppShellPage.Current.CurrentPage!;
foreach(var name in new[]{"CategoryPanel","SlotPanel","InspectorPanel"})Require(((Border)editor.FindName(name)).Background is not Microsoft.UI.Xaml.Media.AcrylicBrush,"Refit panel retained acrylic.");
var definition=Core.Outfitting.OutfittingCatalog.Default.Modules.First(m=>m.Name=="Multi-Cannon"&&m.Size==4);
var module=new FittedModule{Slot="HugeHardpoint1",Item=definition.Item};
ViewModel.LoadRefitProbeDocument(new(123,"cutter","UI fixture",null,[new(){Slot=module.Slot,Capacity=4,Category="hardpoint",Module=module}]));await Task.Delay(180);
Require(Descendants(editor).OfType<FontIcon>().Any(i=>i.Glyph=="\uF1CB"),"Module replacement button has the wrong glyph.");
ViewModel.BeginRefitModuleSelection(ViewModel.RefitVisibleSlots.First());Views.AppShellPage.Current.Navigate(typeof(Views.RefitModulePickerPage));await Task.Delay(600);
Require(ViewModel.RefitModuleTypes.Count==12,"Weapon picker does not show the game's 12 families.");
ViewModel.RefitSelectedModuleType=ViewModel.RefitModuleTypes.Single(t=>t.Key=="weapon.pulse");
Require(ViewModel.RefitTypeModels.Any(c=>c.Definition.Name=="Pulse Disruptor Laser"),"Pulse Disruptor is missing from Pulse Lasers.");
ViewModel.RefitSelectedModuleType=null;await CapturePageAsync(Views.AppShellPage.Current.CurrentPage!,Path.Combine(directory,"translated-weapon-families.png"));
return new{navigationWindow=new{width=navigationWindowSize.Width,height=navigationWindowSize.Height},selectedRingAndCaptionKeepSearchTarget=true,changedSelectionCancelsHold=true,unsubmittedSearchCannotChangeDestination=true,selectedInformationUnobstructed=true,localMapActionAvailable=true,rawSitesFilteredAndSorted=true,jamesonFixedLocation=true,mapLighterAcrylic=true,refitSolidPanels=true,replacementGlyph="F1CB",weaponFamilies=ViewModel.RefitModuleTypes.Select(t=>t.Name),gameFlightCommandsInvoked=false,gameRouteRequestsInvoked=false};
}
}