using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyColonisationHighlightProbeAsync(string directory,IReadOnlyList<GalacticSystem> recorded)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var actual=recorded.First(s=>s.SystemAddress is >0&&s.Position.IsValid);
var source=new GalaxyNativeColonisationHighlight(actual.SystemAddress!.Value,0,4,4,[.3f,1f,.2f]);
var appearance=new GalaxyOriginalStellarAppearance(0xffe0b070,null,1,1,4,.7f,.7f,false);
GalacticSystem Fixture(GalaxyNativeColonisationHighlight? highlight,int? normal=null,bool normalRequested=false)=>actual with{OriginalAppearance=appearance,Data=actual.Data with{
NativeFilterFacts=new("explicit-synthetic-colonisation-highlight",Environment.ProcessId,actual.SystemAddress.Value,ColonisationStatus:0)
{ColonisationHighlight=highlight,ColonisationHighlightRequested=true,ColonisationOwnershipRequested=true,
ColonisationNormalStatus=normal,ColonisationNormalStatusRequested=normalRequested}}};
var target=Fixture(source);var previous=MainWindow.Content;var host=new Grid();var map=new GalaxyMapView();host.Children.Add(map);MainWindow.Content=host;
var observations=new Dictionary<string,object>();
int GreenPixels()
{
var frame=map.CapturePixelsForProbe();var green=0;
for(var i=0;i<frame.Pixels.Length;i+=4)if(frame.Pixels[i+1]>frame.Pixels[i]+8&&frame.Pixels[i+1]>frame.Pixels[i+2]+8)green++;
return green;
}
async Task Save(string name)
{
map.RenderNowForProbe();observations[name]=new{map.VisibleStars,map.VisibleNameLabels,map.FilteredModels,greenPixels=GreenPixels()};
using(await map.FreezeForXamlProbeAsync())await CaptureRefinementElementAsync(host,Path.Combine(directory,name+".png"));
}
try
{
var filter=GalaxyMapFilter.Default with{Mode=GalaxyMapMode.Colonisation,Category=GalaxyFilterCategory.Colonisation,
Values=new HashSet<string>{"unclaimed"},IncludeUnknown=false,ShowLabels=true,ShowMarkers=false,ShowRoute=false,
ShowBackground=false,ShowGrid=false,ShowLinks=false,ShowConstellations=false,ShowCurrentTradeFlows=false,
ShowHistoricalTradeFlows=false,ShowRegionNames=false,ShowNebulaNames=false,ShowGalacticZonesPlane=false,ShowGalacticZoneNames=false};
map.Filter=filter;map.Systems=[target];await Task.Delay(180);map.SetCameraPoseForProbe(new(actual.Position,0,0,24));map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.VisibleNameLabels==1&&GreenPixels()>0,"The verified radius-gated colour did not reach the production point shader.");
await Save("colonisation-highlight");
foreach(var missing in new GalaxyNativeColonisationHighlight?[]{null,source with{DistanceSquared=4.01f}})
{map.Systems=[Fixture(missing)];map.RenderNowForProbe();Require(map.VisibleStars==1&&GreenPixels()==0,"Missing/outside range became a green eligible star.");}
await Save("colonisation-outside");
var normalRed=Fixture(null,5,true);map.Systems=[normalRed];map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.Filter.GetOriginalRgba(normalRed) is{} red&&red.X==1&&red.Y==.1f&&red.W==.35f,
"Mode1 eligibility replaced the independent original mode0 colour/alpha.");
await Save("colonisation-normal-red");
var normalGrey=Fixture(null,0,true);map.Systems=[normalGrey];map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.Filter.GetOriginalRgba(normalGrey) is{} grey&&grey.X==.8f&&grey.Y==.8f&&grey.W==1,
"A known original mode0 grey classification was left as an unproved fallback.");
await Save("colonisation-normal-grey");
map.Systems=[normalRed];map.Filter=filter with{Mode=GalaxyMapMode.Map};map.RenderNowForProbe();
Require(map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0,
"Ordinary Map filtering reused special mode1 eligibility instead of its mode0 classifier.");
map.SelectAt(map.ProjectForProbe(actual.Position));Require(map.Selection is null,"A normal-classification mismatch retained a pick target.");
await Save("colonisation-normal-map-strict");
map.Systems=[target];map.Filter=filter with{Mode=GalaxyMapMode.Map};map.RenderNowForProbe();
Require(map.VisibleStars==1&&GreenPixels()==0,"Ordinary map mode inherited the special Colonisation view colour.");
map.Filter=filter with{Values=new HashSet<string>()};map.RenderNowForProbe();
Require(map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0&&GreenPixels()==0,"The green branch bypassed the strict empty query.");
map.SelectAt(map.ProjectForProbe(actual.Position));Require(map.Selection is null,"A green star hidden by the query retained a pick target.");
await Save("colonisation-highlight-strict-empty");
var result=new{actual.Name,actual.SystemAddress,actual.Position,syntheticClassificationAndRadiusAndEligibilityAndRgb=true,
generatedCatalogueCoordinates=false,fixtureIsNotObservedColony=true,greenRequiresSourceRangeAndSpecialView=true,
sourceMissingAndOutsideNoGreen=true,normalClassificationIndependentFromEligibility=true,normalMapUsesItsOwnClassifier=true,
strictEmptyNoModelLabelOrHit=true,observations,gameAccess=false};
await File.WriteAllTextAsync(Path.Combine(directory,"colonisation-highlight-probe.json"),JsonSerializer.Serialize(result,new JsonSerializerOptions{WriteIndented=true}));
return result;
}
finally{map.SuspendPage();MainWindow.Content=previous;}
}
}
using System.Text.Json;
using XFEEDToolBox.Controls;
using XFEEDToolBox.Core.Galaxy;
namespace XFEEDToolBox;
public partial class App
{
private static async Task<object> RunGalaxyColonisationHighlightProbeAsync(string directory,IReadOnlyList<GalacticSystem> recorded)
{
static void Require(bool value,string message){if(!value)throw new InvalidOperationException(message);}
var actual=recorded.First(s=>s.SystemAddress is >0&&s.Position.IsValid);
var source=new GalaxyNativeColonisationHighlight(actual.SystemAddress!.Value,0,4,4,[.3f,1f,.2f]);
var appearance=new GalaxyOriginalStellarAppearance(0xffe0b070,null,1,1,4,.7f,.7f,false);
GalacticSystem Fixture(GalaxyNativeColonisationHighlight? highlight,int? normal=null,bool normalRequested=false)=>actual with{OriginalAppearance=appearance,Data=actual.Data with{
NativeFilterFacts=new("explicit-synthetic-colonisation-highlight",Environment.ProcessId,actual.SystemAddress.Value,ColonisationStatus:0)
{ColonisationHighlight=highlight,ColonisationHighlightRequested=true,ColonisationOwnershipRequested=true,
ColonisationNormalStatus=normal,ColonisationNormalStatusRequested=normalRequested}}};
var target=Fixture(source);var previous=MainWindow.Content;var host=new Grid();var map=new GalaxyMapView();host.Children.Add(map);MainWindow.Content=host;
var observations=new Dictionary<string,object>();
int GreenPixels()
{
var frame=map.CapturePixelsForProbe();var green=0;
for(var i=0;i<frame.Pixels.Length;i+=4)if(frame.Pixels[i+1]>frame.Pixels[i]+8&&frame.Pixels[i+1]>frame.Pixels[i+2]+8)green++;
return green;
}
async Task Save(string name)
{
map.RenderNowForProbe();observations[name]=new{map.VisibleStars,map.VisibleNameLabels,map.FilteredModels,greenPixels=GreenPixels()};
using(await map.FreezeForXamlProbeAsync())await CaptureRefinementElementAsync(host,Path.Combine(directory,name+".png"));
}
try
{
var filter=GalaxyMapFilter.Default with{Mode=GalaxyMapMode.Colonisation,Category=GalaxyFilterCategory.Colonisation,
Values=new HashSet<string>{"unclaimed"},IncludeUnknown=false,ShowLabels=true,ShowMarkers=false,ShowRoute=false,
ShowBackground=false,ShowGrid=false,ShowLinks=false,ShowConstellations=false,ShowCurrentTradeFlows=false,
ShowHistoricalTradeFlows=false,ShowRegionNames=false,ShowNebulaNames=false,ShowGalacticZonesPlane=false,ShowGalacticZoneNames=false};
map.Filter=filter;map.Systems=[target];await Task.Delay(180);map.SetCameraPoseForProbe(new(actual.Position,0,0,24));map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.VisibleNameLabels==1&&GreenPixels()>0,"The verified radius-gated colour did not reach the production point shader.");
await Save("colonisation-highlight");
foreach(var missing in new GalaxyNativeColonisationHighlight?[]{null,source with{DistanceSquared=4.01f}})
{map.Systems=[Fixture(missing)];map.RenderNowForProbe();Require(map.VisibleStars==1&&GreenPixels()==0,"Missing/outside range became a green eligible star.");}
await Save("colonisation-outside");
var normalRed=Fixture(null,5,true);map.Systems=[normalRed];map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.Filter.GetOriginalRgba(normalRed) is{} red&&red.X==1&&red.Y==.1f&&red.W==.35f,
"Mode1 eligibility replaced the independent original mode0 colour/alpha.");
await Save("colonisation-normal-red");
var normalGrey=Fixture(null,0,true);map.Systems=[normalGrey];map.RenderNowForProbe();
Require(map.VisibleStars==1&&map.Filter.GetOriginalRgba(normalGrey) is{} grey&&grey.X==.8f&&grey.Y==.8f&&grey.W==1,
"A known original mode0 grey classification was left as an unproved fallback.");
await Save("colonisation-normal-grey");
map.Systems=[normalRed];map.Filter=filter with{Mode=GalaxyMapMode.Map};map.RenderNowForProbe();
Require(map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0,
"Ordinary Map filtering reused special mode1 eligibility instead of its mode0 classifier.");
map.SelectAt(map.ProjectForProbe(actual.Position));Require(map.Selection is null,"A normal-classification mismatch retained a pick target.");
await Save("colonisation-normal-map-strict");
map.Systems=[target];map.Filter=filter with{Mode=GalaxyMapMode.Map};map.RenderNowForProbe();
Require(map.VisibleStars==1&&GreenPixels()==0,"Ordinary map mode inherited the special Colonisation view colour.");
map.Filter=filter with{Values=new HashSet<string>()};map.RenderNowForProbe();
Require(map.VisibleStars==0&&map.VisibleNameLabels==0&&map.FilteredModels==0&&GreenPixels()==0,"The green branch bypassed the strict empty query.");
map.SelectAt(map.ProjectForProbe(actual.Position));Require(map.Selection is null,"A green star hidden by the query retained a pick target.");
await Save("colonisation-highlight-strict-empty");
var result=new{actual.Name,actual.SystemAddress,actual.Position,syntheticClassificationAndRadiusAndEligibilityAndRgb=true,
generatedCatalogueCoordinates=false,fixtureIsNotObservedColony=true,greenRequiresSourceRangeAndSpecialView=true,
sourceMissingAndOutsideNoGreen=true,normalClassificationIndependentFromEligibility=true,normalMapUsesItsOwnClassifier=true,
strictEmptyNoModelLabelOrHit=true,observations,gameAccess=false};
await File.WriteAllTextAsync(Path.Combine(directory,"colonisation-highlight-probe.json"),JsonSerializer.Serialize(result,new JsonSerializerOptions{WriteIndented=true}));
return result;
}
finally{map.SuspendPage();MainWindow.Content=previous;}
}
}