using CommunityToolkit.Mvvm.ComponentModel; using XFEEDToolBox.Core.Models; namespace XFEEDToolBox.ViewModels; public partial class ToolboxViewModel { [ObservableProperty] public partial string HomeDataState { get; set; }="等待本机数据"; [ObservableProperty] public partial string HomeUpdated { get; set; }="尚无快照"; [ObservableProperty] public partial string HomeShipDetail { get; set; }="等待装配快照"; [ObservableProperty] public partial string ShipOriginalName { get; set; }=""; [ObservableProperty] public partial string HomeShipType { get; set; }=""; [ObservableProperty] public partial string HomeFuelText { get; set; }="尚未记录"; [ObservableProperty] public partial bool HomeHasFuel { get; set; } [ObservableProperty] public partial double HomeFuelPercent { get; set; } [ObservableProperty] public partial string HomeJournalState { get; set; }="等待日志"; [ObservableProperty] public partial string HomeJournalAt { get; set; }="Journal"; [ObservableProperty] public partial string HomeLoadoutState { get; set; }="等待装配"; [ObservableProperty] public partial string HomeLoadoutAt { get; set; }="Loadout"; [ObservableProperty] public partial string HomeMarketState { get; set; }="等待行情"; [ObservableProperty] public partial string HomeRouteTitle { get; set; }="尚未设定目的地"; [ObservableProperty] public partial string HomeRouteBadge { get; set; }="等待目的地"; [ObservableProperty] public partial string HomeRouteHint { get; set; }="在星图中规划航线,核对下一跳与燃油。"; private static string HomeTime(DateTimeOffset? time)=>time is {} at?at.ToLocalTime().ToString("MM-dd HH:mm:ss"):"尚无快照"; private void RefreshDashboard(PlayerState player) { var ship=player.Ships.FirstOrDefault(s=>s.ShipId==player.CurrentShipId); HomeShipType=ship?.Type??player.Ship; ShipOriginalName=ship?.OriginalName??Core.Localization.ChineseNames.ShipEnglish(player.Ship); HomeDataState=player.Commander.Length==0?"等待本机数据":player.InGame?"游戏会话已接入":"本机档案已读取"; HomeUpdated=HomeTime(new[]{player.StatusAt,player.LocationAt,player.CreditsAt,player.MaterialsAt,player.EngineersAt}.Where(t=>t is not null).DefaultIfEmpty(null).Max()); HomeJournalState=player.Commander.Length>0?"已读取":"等待日志"; HomeJournalAt="Journal · "+HomeTime(player.MaterialsAt??player.CargoAt??player.LoadGameAt); HomeShipDetail=ship?.ConfigurationAt is null?"等待完整 Loadout":$"{ship.Modules.Count} 个模块 · "+(ship.ConfigurationChanged?"装配已变化":"装配已读取"); HomeLoadoutState=ship?.ConfigurationAt is null?"等待快照":ship.ConfigurationChanged?"需更新":"已读取"; HomeLoadoutAt="Loadout · "+HomeTime(ship?.ConfigurationAt); HomeMarketState=QuoteCountText is "0" or "—"?"等待行情":"有报价缓存"; var main=player.Navigation.FuelAt>player.StatusAt?player.Navigation.MainFuel:player.Status?.FuelMain??player.Navigation.MainFuel; HomeHasFuel=main is >=0 and {} fuel&&double.IsFinite(fuel)&&ship?.FuelMain is >0 and {} capacity&&double.IsFinite(capacity); HomeFuelPercent=HomeHasFuel?Math.Clamp(main!.Value/ship!.FuelMain!.Value*100,0,100):0; HomeFuelText=HomeHasFuel?$"{HomeFuelPercent:F0}% ({main:F2} / {ship!.FuelMain:F2} t)":main is {} known?$"{known:F2} t · 容量未记录":"尚未记录"; RefreshDashboardRoute(); } private void RefreshDashboardRoute() { var target=NavigationDestination.Trim(); HomeRouteTitle=target.Length>0?target:"尚未设定目的地"; HomeRouteBadge=NavigationRouteMatches?"航线已读取":target.Length>0?"等待游戏航线":"等待目的地"; HomeRouteHint=NavigationRouteMatches?NavigationRouteSummary:"选择目的地并规划航线,等待游戏返回完整航路。"; } }