mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 15:57:14 +03:00
Make system and station links unclickable if URL not available
This commit is contained in:
parent
6887a225bb
commit
3a3827f168
@ -330,6 +330,11 @@ class AppWindow:
|
||||
self.prefsdialog = None
|
||||
self.set_labels() # in case language has changed
|
||||
|
||||
# Reset links in case plugins changed them
|
||||
self.ship.configure(url = self.shipyard_url)
|
||||
self.system.configure(url = self.system_url)
|
||||
self.station.configure(url = self.station_url)
|
||||
|
||||
# (Re-)install hotkey monitoring
|
||||
hotkeymgr.register(self.w, config.getint('hotkey_code'), config.getint('hotkey_mods'))
|
||||
|
||||
|
@ -55,15 +55,22 @@ def plugin_start():
|
||||
return 'eddb'
|
||||
|
||||
def plugin_app(parent):
|
||||
this.station = parent.children['station'] # station label in main window
|
||||
this.station.configure(popup_copy = lambda x: x != STATION_UNDOCKED)
|
||||
this.system_link = parent.children['system'] # system label in main window
|
||||
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
|
||||
|
||||
def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||
this.system = system
|
||||
this.station['text'] = station or (system_populated(system) and STATION_UNDOCKED or '')
|
||||
this.station.update_idletasks()
|
||||
if config.get('system_provider') == 'eddb':
|
||||
this.system_link['url'] = system_url(system) # Override standard URL function
|
||||
this.station_link['text'] = station or (system_populated(system) and STATION_UNDOCKED or '')
|
||||
this.station_link.update_idletasks()
|
||||
|
||||
def cmdr_data(data, is_beta):
|
||||
this.system = data['lastSystem']['name']
|
||||
this.station['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (system_populated(data['lastSystem']['name']) and STATION_UNDOCKED or '')
|
||||
this.station.update_idletasks()
|
||||
if config.get('system_provider') == 'eddb':
|
||||
this.system_link['url'] = system_url(data['lastSystem']['name']) # Override standard URL function
|
||||
this.station_link['text'] = data['commander']['docked'] and data['lastStarport']['name'] or (system_populated(data['lastSystem']['name']) and STATION_UNDOCKED or '')
|
||||
this.station_link.update_idletasks()
|
||||
|
@ -47,8 +47,10 @@ def system_url(system_name):
|
||||
return 'https://www.edsm.net/en/system?systemName=%s' % urllib2.quote(system_name)
|
||||
|
||||
def station_url(system_name, station_name):
|
||||
return 'https://www.edsm.net/en/system?systemName=%s&stationName=%s' % (urllib2.quote(system_name), urllib2.quote(station_name))
|
||||
|
||||
if station_name:
|
||||
return 'https://www.edsm.net/en/system?systemName=%s&stationName=%s' % (urllib2.quote(system_name), urllib2.quote(station_name))
|
||||
else:
|
||||
return system_url(system_name)
|
||||
|
||||
def plugin_start():
|
||||
# Can't be earlier since can only call PhotoImage after window is created
|
||||
|
@ -48,7 +48,9 @@ this.shipswap = False # just swapped ship
|
||||
|
||||
|
||||
# Main window clicks
|
||||
this.system_link = None
|
||||
this.system = None
|
||||
this.station_link = None
|
||||
this.station = None
|
||||
|
||||
def system_url(system_name):
|
||||
@ -64,6 +66,10 @@ def plugin_start():
|
||||
this.thread.start()
|
||||
return 'Inara'
|
||||
|
||||
def plugin_app(parent):
|
||||
this.system_link = parent.children['system'] # system label in main window
|
||||
this.station_link = parent.children['station'] # station label in main window
|
||||
|
||||
def plugin_stop():
|
||||
# Send any unsent events
|
||||
call()
|
||||
@ -116,6 +122,12 @@ def prefs_changed(cmdr, is_beta):
|
||||
changed = config.getint('inara_out') != this.log.get()
|
||||
config.set('inara_out', this.log.get())
|
||||
|
||||
# Override standard URL functions
|
||||
if config.get('system_provider') == 'Inara':
|
||||
this.system_link['url'] = this.system
|
||||
if config.get('station_provider') == 'Inara':
|
||||
this.station_link['url'] = this.station or this.system
|
||||
|
||||
if cmdr and not is_beta:
|
||||
this.cmdr = cmdr
|
||||
cmdrs = config.get('inara_cmdrs') or []
|
||||
@ -325,8 +337,15 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||
]))
|
||||
|
||||
|
||||
# Override standard URL functions
|
||||
if config.get('system_provider') == 'Inara':
|
||||
this.system_link['url'] = this.system
|
||||
if config.get('station_provider') == 'Inara':
|
||||
this.station_link['url'] = this.station or this.system
|
||||
|
||||
|
||||
# Send event(s) to Inara
|
||||
if entry['event'] == 'ShutDown' or len(this.events) > old_events:
|
||||
# We have new event(s) so send to Inara
|
||||
|
||||
# Send cargo and materials if changed
|
||||
cargo = [ OrderedDict([('itemName', k), ('itemCount', state['Cargo'][k])]) for k in sorted(state['Cargo']) ]
|
||||
@ -616,6 +635,12 @@ def cmdr_data(data, is_beta):
|
||||
|
||||
this.cmdr = data['commander']['name']
|
||||
|
||||
# Override standard URL functions
|
||||
if config.get('system_provider') == 'Inara':
|
||||
this.system_link['url'] = this.system
|
||||
if config.get('station_provider') == 'Inara':
|
||||
this.station_link['url'] = this.station or this.system
|
||||
|
||||
if config.getint('inara_out') and not is_beta and not this.multicrew and credentials(this.cmdr):
|
||||
if not (CREDIT_RATIO > this.lastcredits / data['commander']['credits'] > 1/CREDIT_RATIO):
|
||||
this.events = [x for x in this.events if x['eventName'] != 'setCommanderCredits'] # Remove any unsent
|
||||
@ -731,7 +756,11 @@ def worker():
|
||||
if data_event['eventName'] in ['addCommanderTravelDock', 'addCommanderTravelFSDJump', 'setCommanderTravelLocation']:
|
||||
eventData = reply_event.get('eventData', {})
|
||||
this.system = eventData.get('starsystemInaraURL')
|
||||
if config.get('system_provider') == 'Inara':
|
||||
this.system_link['url'] = this.system # Override standard URL function
|
||||
this.station = eventData.get('stationInaraURL')
|
||||
if config.get('station_provider') == 'Inara':
|
||||
this.station_link['url'] = this.station or this.system # Override standard URL function
|
||||
break
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
|
5
prefs.py
5
prefs.py
@ -600,11 +600,12 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
config.set('anonymous', self.out_anon.get())
|
||||
|
||||
# Notify
|
||||
if self.callback:
|
||||
self.callback()
|
||||
plug.notify_prefs_changed(monitor.cmdr, monitor.is_beta)
|
||||
|
||||
self._destroy()
|
||||
if self.callback:
|
||||
self.callback()
|
||||
|
||||
def _destroy(self):
|
||||
if self.cmdrchanged_alarm is not None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user