XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
using XFEEDToolBox.Core.Galaxy;

namespace XFEEDToolBox.Controls;

public sealed partial class GalaxyMapView
{
    private readonly HashSet<long> supplementalRenderedAddresses=[];
    private readonly HashSet<string> supplementalRenderedNames=new(StringComparer.OrdinalIgnoreCase);
    internal int VisibleSupplementalPlaceLabelsForProbe {get;private set;}
    internal int VisibleSupplementalSupplyLabelsForProbe {get;private set;}

    private void DrawSupplementalLabels(GalaxyCamera camera)
    {
        var query=Filter?.IsQueryActive==true;
        supplementalRenderedAddresses.Clear();supplementalRenderedNames.Clear();
        if(query&&(supplyLabels.Count>0||placeLabels.Count>0))
            for(var i=0;i<hitCount;i++)
            {
                var system=hits[i].System;
                if(system.SystemAddress is >0)supplementalRenderedAddresses.Add(system.SystemAddress.Value);
                supplementalRenderedNames.Add(system.Name);
            }
        bool Retained(long? address,string name)=>!query||(address is >0
            ?supplementalRenderedAddresses.Contains(address.Value):supplementalRenderedNames.Contains(name));
        var supplyCount=0;
        if(Filter?.ShowRoute!=false)foreach(var point in cachedRoute)
        {
            if(!supplySites.Contains(point.SystemAddress)||!Retained(point.SystemAddress,point.Name))continue;
            var p=camera.ProjectForCatalogue(point.Position);
            if(!p.IsVisible||p.X>camera.Width-60||p.Y>camera.Height-22||supplyCount>=supplyLabels.Count)continue;
            var label=supplyLabels[supplyCount++];label.Text.Text=FuelOverlay?.RecommendedSupply==point.SystemAddress?"◇ 建议补给":"◇ 可补给";
            label.Position.X=p.X+9;label.Position.Y=p.Y+9;label.Text.Opacity=1;
        }
        for(var i=supplyCount;i<supplyLabels.Count;i++)supplyLabels[i].Text.Opacity=0;
        var placeCount=0;
        if(Filter?.ShowMarkers!=false)foreach(var place in (PointsOfInterest??[]).DistinctBy(p=>p.SystemName))
        {
            if(!Retained(place.SystemAddress,place.SystemName))continue;
            var p=camera.ProjectForCatalogue(place.Position);
            if(!p.IsVisible||p.X>camera.Width-100||p.Y>camera.Height-24||placeCount>=placeLabels.Count)continue;
            var label=placeLabels[placeCount++];label.Text.Text="◇ "+place.Name;
            label.Position.X=p.X+12;label.Position.Y=p.Y+15;label.Text.Opacity=1;
        }
        for(var i=placeCount;i<placeLabels.Count;i++)placeLabels[i].Text.Opacity=0;
        VisibleSupplementalPlaceLabelsForProbe=placeCount;VisibleSupplementalSupplyLabelsForProbe=supplyCount;
    }
}