diff --git a/ObservatoryExplorer/Explorer.cs b/ObservatoryExplorer/Explorer.cs index d1bc506..af8e7c2 100644 --- a/ObservatoryExplorer/Explorer.cs +++ b/ObservatoryExplorer/Explorer.cs @@ -20,6 +20,7 @@ namespace Observatory.Explorer private Dictionary> BarycentreHistory; private CustomCriteriaManager CustomCriteriaManager; private DateTime CriteriaLastModified; + private string currentSystem = string.Empty; internal Explorer(ExplorerWorker explorerWorker, IObservatoryCore core, ObservableCollection results) { @@ -109,12 +110,24 @@ namespace Observatory.Explorer return barycentreScan; } + public void SetSystem(string potentialNewSystem) + { + if (string.IsNullOrEmpty(currentSystem) || currentSystem != potentialNewSystem) + { + currentSystem = potentialNewSystem; + if (ExplorerWorker.settings.OnlyShowCurrentSystem && !ObservatoryCore.IsLogMonitorBatchReading) + { + ObservatoryCore.ClearGrid(ExplorerWorker, new ExplorerUIResults()); + Clear(); + } + } + } public void ProcessScan(Scan scanEvent, bool readAll) { if (!readAll) { - string criteriaFilePath = ((ExplorerSettings)ExplorerWorker.Settings).CustomCriteriaFile; + string criteriaFilePath = ExplorerWorker.settings.CustomCriteriaFile; if (File.Exists(criteriaFilePath)) { @@ -136,7 +149,7 @@ namespace Observatory.Explorer Details = e.OriginalScript }; ObservatoryCore.AddGridItem(ExplorerWorker, exceptionResult); - ((ExplorerSettings)ExplorerWorker.Settings).EnableCustomCriteria = false; + ExplorerWorker.settings.EnableCustomCriteria = false; } CriteriaLastModified = fileModified; @@ -175,15 +188,15 @@ namespace Observatory.Explorer if (scanEvent.SystemAddress != 0 && !systemBodies.ContainsKey(scanEvent.BodyID)) systemBodies.Add(scanEvent.BodyID, scanEvent); - var results = DefaultCriteria.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, (ExplorerSettings)ExplorerWorker.Settings); + var results = DefaultCriteria.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, ExplorerWorker.settings); if (BarycentreHistory.ContainsKey(scanEvent.SystemAddress) && scanEvent.Parent != null && BarycentreHistory[scanEvent.SystemAddress].ContainsKey(scanEvent.Parent[0].Body)) { ProcessScan(ConvertBarycentre(BarycentreHistory[scanEvent.SystemAddress][scanEvent.Parent[0].Body], scanEvent), readAll); } - if (((ExplorerSettings)ExplorerWorker.Settings).EnableCustomCriteria) - results.AddRange(CustomCriteriaManager.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, (ExplorerSettings)ExplorerWorker.Settings)); + if (ExplorerWorker.settings.EnableCustomCriteria) + results.AddRange(CustomCriteriaManager.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, ExplorerWorker.settings)); if (results.Count > 0) { diff --git a/ObservatoryExplorer/ExplorerSettings.cs b/ObservatoryExplorer/ExplorerSettings.cs index 9ef1ec3..2ab2bc5 100644 --- a/ObservatoryExplorer/ExplorerSettings.cs +++ b/ObservatoryExplorer/ExplorerSettings.cs @@ -86,6 +86,9 @@ namespace Observatory.Explorer [SettingDisplayName("Enable Custom Criteria")] public bool EnableCustomCriteria { get; set; } + [SettingDisplayName("Only Show Current System")] + public bool OnlyShowCurrentSystem { get; set; } + [SettingDisplayName("Custom Criteria File")] [System.Text.Json.Serialization.JsonIgnore] public System.IO.FileInfo CustomCriteria {get => new System.IO.FileInfo(CustomCriteriaFile); set => CustomCriteriaFile = value.FullName;} diff --git a/ObservatoryExplorer/Worker.cs b/ObservatoryExplorer/Worker.cs index 4fd38e9..2cd3a75 100644 --- a/ObservatoryExplorer/Worker.cs +++ b/ObservatoryExplorer/Worker.cs @@ -69,6 +69,14 @@ namespace Observatory.Explorer case ScanBaryCentre barycentre: explorer.RecordBarycentre(barycentre); break; + case FSDJump fsdjump: + if (fsdjump is CarrierJump && !((CarrierJump)fsdjump).Docked) + break; + explorer.SetSystem(fsdjump.StarSystem); + break; + case Location location: + explorer.SetSystem(location.StarSystem); + break; case DiscoveryScan discoveryScan: break; case FSSDiscoveryScan discoveryScan: @@ -95,7 +103,6 @@ namespace Observatory.Explorer explorer.Clear(); } } - public object Settings { @@ -103,6 +110,6 @@ namespace Observatory.Explorer set => settings = (ExplorerSettings)value; } - private ExplorerSettings settings; + internal ExplorerSettings settings; } }