2
0
mirror of https://github.com/9ParsonsB/Pulsar.git synced 2025-04-19 01:03:50 -04:00

Explorer: Show data for the current system only (#86)

Resolves #63

This behavior is suppressed during batch reads.
This commit is contained in:
F K 2022-05-28 09:03:36 -04:00 committed by GitHub
parent 6616b54852
commit 8106fbd0df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 7 deletions

View File

@ -20,6 +20,7 @@ namespace Observatory.Explorer
private Dictionary<ulong, Dictionary<int, ScanBaryCentre>> BarycentreHistory; private Dictionary<ulong, Dictionary<int, ScanBaryCentre>> BarycentreHistory;
private CustomCriteriaManager CustomCriteriaManager; private CustomCriteriaManager CustomCriteriaManager;
private DateTime CriteriaLastModified; private DateTime CriteriaLastModified;
private string currentSystem = string.Empty;
internal Explorer(ExplorerWorker explorerWorker, IObservatoryCore core, ObservableCollection<object> results) internal Explorer(ExplorerWorker explorerWorker, IObservatoryCore core, ObservableCollection<object> results)
{ {
@ -109,12 +110,24 @@ namespace Observatory.Explorer
return barycentreScan; 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) public void ProcessScan(Scan scanEvent, bool readAll)
{ {
if (!readAll) if (!readAll)
{ {
string criteriaFilePath = ((ExplorerSettings)ExplorerWorker.Settings).CustomCriteriaFile; string criteriaFilePath = ExplorerWorker.settings.CustomCriteriaFile;
if (File.Exists(criteriaFilePath)) if (File.Exists(criteriaFilePath))
{ {
@ -136,7 +149,7 @@ namespace Observatory.Explorer
Details = e.OriginalScript Details = e.OriginalScript
}; };
ObservatoryCore.AddGridItem(ExplorerWorker, exceptionResult); ObservatoryCore.AddGridItem(ExplorerWorker, exceptionResult);
((ExplorerSettings)ExplorerWorker.Settings).EnableCustomCriteria = false; ExplorerWorker.settings.EnableCustomCriteria = false;
} }
CriteriaLastModified = fileModified; CriteriaLastModified = fileModified;
@ -175,15 +188,15 @@ namespace Observatory.Explorer
if (scanEvent.SystemAddress != 0 && !systemBodies.ContainsKey(scanEvent.BodyID)) if (scanEvent.SystemAddress != 0 && !systemBodies.ContainsKey(scanEvent.BodyID))
systemBodies.Add(scanEvent.BodyID, scanEvent); 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)) 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); ProcessScan(ConvertBarycentre(BarycentreHistory[scanEvent.SystemAddress][scanEvent.Parent[0].Body], scanEvent), readAll);
} }
if (((ExplorerSettings)ExplorerWorker.Settings).EnableCustomCriteria) if (ExplorerWorker.settings.EnableCustomCriteria)
results.AddRange(CustomCriteriaManager.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, (ExplorerSettings)ExplorerWorker.Settings)); results.AddRange(CustomCriteriaManager.CheckInterest(scanEvent, SystemBodyHistory, BodySignalHistory, ExplorerWorker.settings));
if (results.Count > 0) if (results.Count > 0)
{ {

View File

@ -86,6 +86,9 @@ namespace Observatory.Explorer
[SettingDisplayName("Enable Custom Criteria")] [SettingDisplayName("Enable Custom Criteria")]
public bool EnableCustomCriteria { get; set; } public bool EnableCustomCriteria { get; set; }
[SettingDisplayName("Only Show Current System")]
public bool OnlyShowCurrentSystem { get; set; }
[SettingDisplayName("Custom Criteria File")] [SettingDisplayName("Custom Criteria File")]
[System.Text.Json.Serialization.JsonIgnore] [System.Text.Json.Serialization.JsonIgnore]
public System.IO.FileInfo CustomCriteria {get => new System.IO.FileInfo(CustomCriteriaFile); set => CustomCriteriaFile = value.FullName;} public System.IO.FileInfo CustomCriteria {get => new System.IO.FileInfo(CustomCriteriaFile); set => CustomCriteriaFile = value.FullName;}

View File

@ -69,6 +69,14 @@ namespace Observatory.Explorer
case ScanBaryCentre barycentre: case ScanBaryCentre barycentre:
explorer.RecordBarycentre(barycentre); explorer.RecordBarycentre(barycentre);
break; 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: case DiscoveryScan discoveryScan:
break; break;
case FSSDiscoveryScan discoveryScan: case FSSDiscoveryScan discoveryScan:
@ -96,13 +104,12 @@ namespace Observatory.Explorer
} }
} }
public object Settings public object Settings
{ {
get => settings; get => settings;
set => settings = (ExplorerSettings)value; set => settings = (ExplorerSettings)value;
} }
private ExplorerSettings settings; internal ExplorerSettings settings;
} }
} }