mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-21 11:27:38 +03:00
Merge pull request #1071 from EDCD/enhancement/odyssey-launch-journal-v31
Adjust Odyssey support re: Journal v31
This commit is contained in:
commit
0b9991b092
@ -633,6 +633,14 @@ class AppWindow(object):
|
||||
loadout_name = suitloadout['name']
|
||||
self.suit['text'] = f'{suitname} ({loadout_name})'
|
||||
|
||||
def suit_show_if_set(self) -> None:
|
||||
"""Show UI Suit row if we have data, else hide."""
|
||||
if self.suit['text'] != '':
|
||||
self.toggle_suit_row(visible=True)
|
||||
|
||||
else:
|
||||
self.toggle_suit_row(visible=False)
|
||||
|
||||
def toggle_suit_row(self, visible: Optional[bool] = None) -> None:
|
||||
"""
|
||||
Toggle the visibility of the 'Suit' row.
|
||||
@ -922,10 +930,7 @@ class AppWindow(object):
|
||||
|
||||
self.suit['text'] = f'{suitname} ({loadout_name})'
|
||||
|
||||
self.toggle_suit_row(visible=True)
|
||||
|
||||
else:
|
||||
self.toggle_suit_row(visible=False)
|
||||
self.suit_show_if_set()
|
||||
|
||||
if data['commander'].get('credits') is not None:
|
||||
monitor.state['Credits'] = data['commander']['credits']
|
||||
@ -1052,6 +1057,7 @@ class AppWindow(object):
|
||||
self.cmdr['text'] += ' (beta)'
|
||||
|
||||
self.update_suit_text()
|
||||
self.suit_show_if_set()
|
||||
|
||||
self.edit_menu.entryconfigure(0, state=monitor.system and tk.NORMAL or tk.DISABLED) # Copy
|
||||
|
||||
|
@ -429,6 +429,11 @@ Flags2Cold = 1 << 8
|
||||
Flags2Hot = 1 << 9
|
||||
Flags2VeryCold = 1 << 10
|
||||
Flags2VeryHot = 1 << 11
|
||||
Flags2GlideMode = 1 << 12
|
||||
Flags2OnFootInHangar = 1 << 13
|
||||
Flags2OnFootSocialSpace = 1 << 14
|
||||
Flags2OnFootExterior = 1 << 15
|
||||
Flags2BreathableAtmosphere = 1 << 16
|
||||
|
||||
# Dashboard GuiFocus constants
|
||||
GuiFocusNoFocus = 0
|
||||
|
138
monitor.py
138
monitor.py
@ -835,6 +835,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_data}
|
||||
)
|
||||
|
||||
# Journal v31 implies this was removed before Odyssey launch
|
||||
elif event_type == 'BackPackMaterials':
|
||||
# alpha4 -
|
||||
# Lists the contents of the backpack, eg when disembarking from ship
|
||||
@ -865,6 +866,76 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_data}
|
||||
)
|
||||
|
||||
elif event_type == 'Backpack':
|
||||
# TODO: v31 doc says this is`backpack.json` ... but Howard Chalkley
|
||||
# said it's `Backpack.json`
|
||||
with open(join(self.currentdir, 'Backpack.json'), 'rb') as backpack: # type: ignore
|
||||
try:
|
||||
entry = json.load(backpack)
|
||||
|
||||
except json.JSONDecodeError:
|
||||
logger.exception('Failed decoding Backpack.json', exc_info=True)
|
||||
|
||||
else:
|
||||
# Assume this reflects the current state when written
|
||||
self.state['BackPack']['Component'] = defaultdict(int)
|
||||
self.state['BackPack']['Consumable'] = defaultdict(int)
|
||||
self.state['BackPack']['Item'] = defaultdict(int)
|
||||
self.state['BackPack']['Data'] = defaultdict(int)
|
||||
|
||||
clean_components = self.coalesce_cargo(entry['Components'])
|
||||
self.state['BackPack']['Component'].update(
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_components}
|
||||
)
|
||||
|
||||
clean_consumables = self.coalesce_cargo(entry['Consumables'])
|
||||
self.state['BackPack']['Consumable'].update(
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_consumables}
|
||||
)
|
||||
|
||||
clean_items = self.coalesce_cargo(entry['Items'])
|
||||
self.state['BackPack']['Item'].update(
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_items}
|
||||
)
|
||||
|
||||
clean_data = self.coalesce_cargo(entry['Data'])
|
||||
self.state['BackPack']['Data'].update(
|
||||
{self.canonicalise(x['Name']): x['Count'] for x in clean_data}
|
||||
)
|
||||
|
||||
elif event_type == 'BackpackChange':
|
||||
# Changes to Odyssey Backpack contents *other* than from a Transfer
|
||||
# See TransferMicroResources event for that.
|
||||
|
||||
if entry.get('Added') is not None:
|
||||
changes = 'Added'
|
||||
|
||||
elif entry.get('Removed') is not None:
|
||||
changes = 'Removed'
|
||||
|
||||
else:
|
||||
logger.warning(f'BackpackChange with neither Added nor Removed: {entry=}')
|
||||
changes = ''
|
||||
|
||||
if changes != '':
|
||||
for c in entry[changes]:
|
||||
category = self.category(c['Type'])
|
||||
name = self.canonicalise(c['Name'])
|
||||
|
||||
if changes == 'Removed':
|
||||
self.state['BackPack'][category][name] -= c['Count']
|
||||
|
||||
elif changes == 'Added':
|
||||
self.state['BackPack'][category][name] += c['Count']
|
||||
|
||||
# Paranoia check to see if anything has gone negative.
|
||||
# As of Odyssey Alpha Phase 1 Hotfix 2 keeping track of BackPack
|
||||
# materials is impossible when used/picked up anyway.
|
||||
for c in self.state['BackPack']:
|
||||
for m in self.state['BackPack'][c]:
|
||||
if self.state['BackPack'][c][m] < 0:
|
||||
self.state['BackPack'][c][m] = 0
|
||||
|
||||
elif event_type == 'BuyMicroResources':
|
||||
# Buying from a Pioneer Supplies, goes directly to ShipLocker.
|
||||
# One event per Item, not an array.
|
||||
@ -948,18 +1019,63 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
|
||||
self.state['BackPack'][entry['Type']][i] = 0
|
||||
|
||||
elif event_type == 'UseConsumable':
|
||||
# alpha4
|
||||
# When using an item from the player’s inventory (backpack)
|
||||
# TODO: XXX: From v31 doc
|
||||
# 12.2 BackpackChange
|
||||
# This is written when there is any change to the contents of the
|
||||
# suit backpack – note this can be written at the same time as other
|
||||
# events like UseConsumable
|
||||
|
||||
# In 4.0.0.100 it is observed that:
|
||||
#
|
||||
# Parameters:
|
||||
# • Name
|
||||
# • Type
|
||||
for c in self.state['BackPack']['Consumable']:
|
||||
if c == entry['Name']:
|
||||
self.state['BackPack']['Consumable'][c] -= 1
|
||||
# Paranoia in case we lost track
|
||||
if self.state['BackPack']['Consumable'][c] < 0:
|
||||
self.state['BackPack']['Consumable'][c] = 0
|
||||
# 1. Throw of any grenade type *only* causes a BackpackChange event, no
|
||||
# accompanying 'UseConsumable'.
|
||||
# 2. Using an Energy Cell causes both UseConsumable and BackpackChange,
|
||||
# in that order.
|
||||
# 3. Medkit acts the same as Energy Cell.
|
||||
#
|
||||
# Thus we'll just ignore 'UseConsumable' for now.
|
||||
# for c in self.state['BackPack']['Consumable']:
|
||||
# if c == entry['Name']:
|
||||
# self.state['BackPack']['Consumable'][c] -= 1
|
||||
# # Paranoia in case we lost track
|
||||
# if self.state['BackPack']['Consumable'][c] < 0:
|
||||
# self.state['BackPack']['Consumable'][c] = 0
|
||||
pass
|
||||
|
||||
# TODO:
|
||||
# <https://forums.frontier.co.uk/threads/575010/>
|
||||
# also there's one additional journal event that was missed out from
|
||||
# this version of the docs: "SuitLoadout": # when starting on foot, or
|
||||
# when disembarking from a ship, with the same info as found in "CreateSuitLoadout"
|
||||
elif event_type == 'SuitLoadout':
|
||||
suit_slotid = self.suit_loadout_id_from_loadoutid(entry['LoadoutID'])
|
||||
# Initial suit containing just the data that is then embedded in
|
||||
# the loadout
|
||||
new_suit = {
|
||||
'name': entry['SuitName'],
|
||||
'locName': entry.get('SuitName_Localised', entry['SuitName']),
|
||||
'suitId': entry['SuitID'],
|
||||
}
|
||||
|
||||
# Make the new loadout, in the CAPI format
|
||||
new_loadout = {
|
||||
'loadoutSlotId': suit_slotid,
|
||||
'suit': new_suit,
|
||||
'name': entry['LoadoutName'],
|
||||
'slots': self.suit_loadout_slots_array_to_dict(entry['Modules']),
|
||||
}
|
||||
|
||||
# Assign this loadout into our state
|
||||
self.state['SuitLoadouts'][new_loadout['loadoutSlotId']] = new_loadout
|
||||
self.state['SuitLoadoutCurrent'] = new_loadout
|
||||
|
||||
# Now add in the extra fields for new_suit to be a 'full' Suit structure
|
||||
new_suit['id'] = None # Not available in 4.0.0.100 journal event
|
||||
new_suit['slots'] = new_loadout['slots'] # 'slots', not 'Modules', to match CAPI
|
||||
|
||||
# Ensure new_suit is in self.state['Suits']
|
||||
self.state['Suits'][suit_slotid] = new_suit
|
||||
self.state['SuitCurrent'] = new_suit
|
||||
|
||||
elif event_type == 'SwitchSuitLoadout':
|
||||
loadoutid = entry['LoadoutID']
|
||||
|
Loading…
x
Reference in New Issue
Block a user