1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

Change EDDB system_url to use SystemAddress

* This means storing this.system_address from both cmdr_data and journal_entry.  NB: If the current value in the event or data is 'None' it will retain the previous value.  Without this Journal entries without SystemAddress erase the stored value.
 * The station_url() fallback to system_url() similarly uses this.system_address in the call.

Addresses #512
This commit is contained in:
Athanasius 2020-06-29 12:06:57 +01:00
parent f6b3109a09
commit cd02d1664a

View File

@ -17,48 +17,42 @@ STATION_UNDOCKED = u'×' # "Station" name to display when not docked = U+00D7
this = sys.modules[__name__] # For holding module globals
# (system_id, is_populated) by system_name
with open(join(config.respath, 'systems.p'), 'rb') as h:
this.system_ids = pickle.load(h)
# station_id by (system_id, station_name)
with open(join(config.respath, 'stations.p'), 'rb') as h:
this.station_ids = pickle.load(h)
this.system_address = None
this.system_population = None
this.station_marketid = None # Frontier MarketID
# Main window clicks
def system_url(system_name):
if system_name:
return 'https://eddb.io/system/name/%s' % urllib.parse.quote(system_name)
def system_url(system_address):
if system_address:
return 'https://eddb.io/system/ed-address/%s' % system_address
else:
return ''
def station_url(system_name, station_name):
if this.station_marketid:
return 'https://eddb.io/station/market-id/{}'.format(this.station_marketid)
else:
return system_url(system_name)
return system_url(this.system_address)
def plugin_start3(plugin_dir):
return 'eddb'
def plugin_app(parent):
this.system_link = parent.children['system'] # system label in main window
this.system_population = None
this.system_address = 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)
def prefs_changed(cmdr, is_beta):
if config.get('system_provider') == 'eddb':
this.system_link['url'] = system_url(system_link['text']) # Override standard URL function
this.system_link['url'] = system_url(this.system_address) # Override standard URL function
def journal_entry(cmdr, is_beta, system, station, entry, state):
if config.get('system_provider') == 'eddb':
this.system_link['url'] = system_url(system) # Override standard URL function
this.system_address = entry.get('SystemAddress') or this.system_address
this.system_link['url'] = system_url(this.system_address) # Override standard URL function
if config.get('station_provider') == 'eddb':
if entry['event'] in ['StartUp', 'Location', 'FSDJump', 'CarrierJump']:
@ -69,13 +63,14 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
elif entry['event'] in ['Undocked']:
this.station_marketid = None
this.station_link['text'] = station or (this.system_population and this.system_population > 0 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()
def cmdr_data(data, is_beta):
if config.get('system_provider') == 'eddb':
this.system_link['url'] = system_url(data['lastSystem']['name']) # Override standard URL function
this.system_address = data['lastSystem']['id'] or this.system_address
this.system_link['url'] = system_url(this.system_address) # Override standard URL function
if config.get('station_provider') == 'eddb':
this.station_marketid = data['commander']['docked'] and data['lastStarport']['id']