mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 01:22:19 +03:00
Add multicrew Captain and Role to state passed to plugins
This commit is contained in:
parent
33b435e556
commit
220475c941
@ -345,7 +345,7 @@ class AppWindow:
|
||||
# set main window labels, e.g. after language change
|
||||
def set_labels(self):
|
||||
self.cmdr_label['text'] = _('Cmdr') + ':' # Main window
|
||||
self.ship_label['text'] = (monitor.captain and _('Role') or # Multicrew role label in main window
|
||||
self.ship_label['text'] = (monitor.state['Captain'] and _('Role') or # Multicrew role label in main window
|
||||
_('Ship')) + ':' # Main window
|
||||
self.system_label['text'] = _('System') + ':' # Main window
|
||||
self.button['text'] = self.theme_button['text'] = _('Update') # Update button in main window
|
||||
@ -415,7 +415,7 @@ class AppWindow:
|
||||
play_sound = (auto_update or int(event.type) == self.EVENT_VIRTUAL) and not config.getint('hotkey_mute')
|
||||
play_bad = False
|
||||
|
||||
if not monitor.cmdr or not monitor.mode or monitor.captain:
|
||||
if not monitor.cmdr or not monitor.mode or monitor.state['Captain']:
|
||||
return # In CQC or on crew - do nothing
|
||||
|
||||
if auto_update and monitor.carrying_rares():
|
||||
@ -626,10 +626,10 @@ class AppWindow:
|
||||
system_changed = monitor.system and self.system['text'] != monitor.system
|
||||
|
||||
# Update main window
|
||||
if monitor.cmdr and monitor.captain:
|
||||
self.cmdr['text'] = '%s / %s' % (monitor.cmdr, monitor.captain)
|
||||
if monitor.cmdr and monitor.state['Captain']:
|
||||
self.cmdr['text'] = '%s / %s' % (monitor.cmdr, monitor.state['Captain'])
|
||||
self.ship_label['text'] = _('Role') + ':' # Multicrew role label in main window
|
||||
self.ship.configure(state = tk.NORMAL, text = crewroletext(monitor.role), url = None)
|
||||
self.ship.configure(state = tk.NORMAL, text = crewroletext(monitor.state['Role']), url = None)
|
||||
elif monitor.cmdr:
|
||||
if monitor.group:
|
||||
self.cmdr['text'] = '%s / %s' % (monitor.cmdr, monitor.group)
|
||||
@ -727,7 +727,7 @@ class AppWindow:
|
||||
self.status['text'] = 'Error: Check %s' % _('E:D interaction log location') # Setting for the log file that contains recent interactions with other Cmdrs
|
||||
|
||||
# Don't send to EDDN while on crew
|
||||
if monitor.captain:
|
||||
if monitor.state['Captain']:
|
||||
return
|
||||
|
||||
# Plugin backwards compatibility
|
||||
|
22
monitor.py
22
monitor.py
@ -125,8 +125,6 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.mode = None
|
||||
self.group = None
|
||||
self.cmdr = None
|
||||
self.captain = None # On a crew
|
||||
self.role = None # Crew role - None, FireCon, FighterCon
|
||||
self.body = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
@ -136,6 +134,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
|
||||
# Cmdr state shared with EDSM and plugins
|
||||
self.state = {
|
||||
'Captain' : None, # On a crew
|
||||
'Cargo' : defaultdict(int),
|
||||
'Credits' : None,
|
||||
'Loan' : None,
|
||||
@ -144,6 +143,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
'Encoded' : defaultdict(int),
|
||||
'PaintJob' : None,
|
||||
'Rank' : { 'Combat': None, 'Trade': None, 'Explore': None, 'Empire': None, 'Federation': None, 'CQC': None },
|
||||
'Role' : None, # Crew role - None, Idle, FireCon, FighterCon
|
||||
'ShipID' : None,
|
||||
'ShipIdent' : None,
|
||||
'ShipName' : None,
|
||||
@ -302,8 +302,6 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.cmdr = None
|
||||
self.mode = None
|
||||
self.group = None
|
||||
self.captain = None
|
||||
self.role = None
|
||||
self.body = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
@ -311,6 +309,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.coordinates = None
|
||||
self.started = None
|
||||
self.state = {
|
||||
'Captain' : None,
|
||||
'Cargo' : defaultdict(int),
|
||||
'Credits' : None,
|
||||
'Loan' : None,
|
||||
@ -319,6 +318,7 @@ class EDLogs(FileSystemEventHandler):
|
||||
'Encoded' : defaultdict(int),
|
||||
'PaintJob' : None,
|
||||
'Rank' : { 'Combat': None, 'Trade': None, 'Explore': None, 'Empire': None, 'Federation': None, 'CQC': None },
|
||||
'Role' : None,
|
||||
'ShipID' : None,
|
||||
'ShipIdent' : None,
|
||||
'ShipName' : None,
|
||||
@ -329,8 +329,6 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.cmdr = entry['Commander']
|
||||
self.mode = entry.get('GameMode') # 'Open', 'Solo', 'Group', or None for CQC (and Training - but no LoadGame event)
|
||||
self.group = entry.get('Group')
|
||||
self.captain = None
|
||||
self.role = None
|
||||
self.body = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
@ -338,9 +336,11 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.coordinates = None
|
||||
self.started = timegm(strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ'))
|
||||
self.state.update({
|
||||
'Captain' : None,
|
||||
'Credits' : entry['Credits'],
|
||||
'Loan' : entry['Loan'],
|
||||
'Rank' : { 'Combat': None, 'Trade': None, 'Explore': None, 'Empire': None, 'Federation': None, 'CQC': None },
|
||||
'Role' : None,
|
||||
})
|
||||
elif entry['event'] == 'NewCommander':
|
||||
self.cmdr = entry['Name']
|
||||
@ -454,18 +454,18 @@ class EDLogs(FileSystemEventHandler):
|
||||
self.state[category].pop(material)
|
||||
|
||||
elif entry['event'] == 'JoinACrew':
|
||||
self.captain = entry['Captain']
|
||||
self.role = None
|
||||
self.state['Captain'] = entry['Captain']
|
||||
self.state['Role'] = 'Idle'
|
||||
self.body = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
self.stationtype = None
|
||||
self.coordinates = None
|
||||
elif entry['event'] == 'ChangeCrewRole':
|
||||
self.role = entry['Role'] != 'Idle' and entry['Role'] or None
|
||||
self.state['Role'] = entry['Role']
|
||||
elif entry['event'] == 'QuitACrew':
|
||||
self.captain = None
|
||||
self.role = None
|
||||
self.state['Captain'] = None
|
||||
self.state['Role'] = None
|
||||
self.body = None
|
||||
self.system = None
|
||||
self.station = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user