From 0541e404ec79009f440813997a8f163ab6181ead Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sat, 27 Jun 2020 12:59:51 +0100 Subject: [PATCH] Track system population in monitor, and use in eddb EDDB station link now triggers off this.system_population, which is received via monitor passing 'Population' through in Startup, Location, FSDJump and CarrierJump events. One fewer use cases for systems.p (populated status in this case). --- monitor.py | 5 +++++ plugins/eddb.py | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index e88d37de..e5c8c4b2 100644 --- a/monitor.py +++ b/monitor.py @@ -223,6 +223,7 @@ class EDLogs(FileSystemEventHandler): ('StarSystem', self.system), ('StarPos', self.coordinates), ('SystemAddress', self.systemaddress), + ('Population', self.systempopulation), ]) if self.planet: entry['Body'] = self.planet @@ -446,6 +447,10 @@ class EDLogs(FileSystemEventHandler): elif self.system != entry['StarSystem']: self.coordinates = None # Docked event doesn't include coordinates self.systemaddress = entry.get('SystemAddress') + + if entry['event'] in ['Location', 'FSDJump', 'CarrierJump']: + self.systempopulation = entry.get('Population') + (self.system, self.station) = (entry['StarSystem'] == 'ProvingGround' and 'CQC' or entry['StarSystem'], entry.get('StationName')) # May be None self.station_marketid = entry.get('MarketID') # May be None diff --git a/plugins/eddb.py b/plugins/eddb.py index 7ef3fda4..ecfaecfe 100644 --- a/plugins/eddb.py +++ b/plugins/eddb.py @@ -59,6 +59,7 @@ def plugin_start3(plugin_dir): def plugin_app(parent): this.system_link = parent.children['system'] # system label in main window + this.system_population = None this.station_marketid = None # Frontier MarketID this.station_link = parent.children['station'] # station label in main window this.station_link.configure(popup_copy = lambda x: x != STATION_UNDOCKED) @@ -73,11 +74,15 @@ def journal_entry(cmdr, is_beta, system, station, entry, state): this.system_link['url'] = system_url(system) # Override standard URL function if config.get('station_provider') == 'eddb': + if entry['event'] in ['StartUp', 'Location', 'FSDJump', 'CarrierJump']: + this.system_population = entry.get('Population') + if entry['event'] in ['StartUp', 'Location', 'Docked', 'CarrierJump']: this.station_marketid = entry.get('MarketID') elif entry['event'] in ['Undocked']: this.station_marketid = None - this.station_link['text'] = station or (system_populated(system) and STATION_UNDOCKED or '') + + this.station_link['text'] = station or (this.system_population and this.system_population > 0 and STATION_UNDOCKED or '') this.station_link.update_idletasks()