diff --git a/inara.json b/inara.json deleted file mode 100644 index 1c5cba8a9..000000000 --- a/inara.json +++ /dev/null @@ -1,267 +0,0 @@ -{ - "header": { - "appName": "EDMarketConnector", - "appVersion": "5.11.1+85f5c328.DIRTY" - }, - "data": { - "FuelCapacity": { - "Main": 128, - "Reserve": 0.81 - }, - "Ship": "belugaliner", - "ShipName": "HSRV Guiding Light", - "ShipIdent": "NFC-23", - "HullValue": 69924158, - "ModulesValue": 96918434, - "Rebuy": 8342132, - "MaxJumpRange": 52.615143, - "UnladenMass": 1233.057983, - "CargoCapacity": 16, - "Modules": [ - { - "Slot": "TinyHardpoint1", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "TinyHardpoint2", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3413 - }, - { - "Slot": "TinyHardpoint3", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "TinyHardpoint4", - "Item": "hpt_heatsinklauncher_turret_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 3072 - }, - { - "Slot": "PaintJob", - "Item": "paintjob_belugaliner_lrpo_azure", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Armour", - "Item": "belugaliner_armour_grade1", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "PowerPlant", - "Item": "int_powerplant_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 11382139 - }, - { - "Slot": "MainEngines", - "Item": "int_engine_size7_class2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 1666898 - }, - { - "Slot": "FrameShiftDrive", - "Item": "int_hyperdrive_size7_class5", - "ItemHealth": 1.0, - "On": true, - "Value": 45006196 - }, - { - "Slot": "LifeSupport", - "Item": "int_lifesupport_size8_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 1530326 - }, - { - "Slot": "PowerDistributor", - "Item": "int_powerdistributor_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 3049917 - }, - { - "Slot": "Radar", - "Item": "int_sensors_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 69713 - }, - { - "Slot": "FuelTank", - "Item": "int_fueltank_size7_class3", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 1562752 - }, - { - "Slot": "Decal1", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Decal2", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Decal3", - "Item": "decal_distantworlds2", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipName0", - "Item": "nameplate_practical01_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipName1", - "Item": "nameplate_practical01_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipID0", - "Item": "nameplate_shipid_singleline_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipID1", - "Item": "nameplate_shipid_singleline_black", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "Slot01_Size6", - "Item": "int_fuelscoop_size6_class5", - "ItemHealth": 1.0, - "On": true, - "Value": 25240068 - }, - { - "Slot": "Slot02_Size6", - "Item": "int_repairer_size6_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 497429 - }, - { - "Slot": "Slot03_Size6", - "Item": "int_shieldgenerator_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 165879 - }, - { - "Slot": "Slot04_Size6", - "Item": "int_dronecontrol_repair_size5_class2", - "ItemHealth": 1.0, - "On": true, - "Value": 85293 - }, - { - "Slot": "Slot05_Size5", - "Item": "int_guardianfsdbooster_size5", - "ItemHealth": 1.0, - "On": true, - "Value": 5688921 - }, - { - "Slot": "Slot07_Size4", - "Item": "int_cargorack_size4_class1", - "ItemHealth": 1.0, - "On": true, - "Priority": 1, - "Value": 30124 - }, - { - "Slot": "Slot11_Size3", - "Item": "int_detailedsurfacescanner_tiny", - "ItemHealth": 1.0, - "On": true, - "Value": 219375 - }, - { - "Slot": "Slot12_Size1", - "Item": "int_repairer_size1_class5", - "ItemHealth": 1.0, - "On": false, - "Value": 710775 - }, - { - "Slot": "PlanetaryApproachSuite", - "Item": "int_planetapproachsuite_advanced", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "WeaponColour", - "Item": "weaponcustomisation_red", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "EngineColour", - "Item": "enginecustomisation_orange", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "VesselVoice", - "Item": "voicepack_verity", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "ShipCockpit", - "Item": "belugaliner_cockpit", - "ItemHealth": 1.0, - "On": true, - "Priority": 1 - }, - { - "Slot": "CargoHatch", - "Item": "modularcargobaydoor", - "ItemHealth": 1.0, - "On": false, - "Priority": 1 - } - ] - } -} \ No newline at end of file diff --git a/monitor.py b/monitor.py index 9d33f5eb5..ae0f3ad75 100644 --- a/monitor.py +++ b/monitor.py @@ -21,9 +21,10 @@ from typing import TYPE_CHECKING, Any, BinaryIO, MutableMapping import semantic_version import util_ships -from config import config -from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised +from config import config, appname, appversion +from edmc_data import edmc_suit_shortnames, edmc_suit_symbol_localised, ship_name_map from EDMCLogging import get_main_logger +from edshipyard import ships if TYPE_CHECKING: import tkinter @@ -109,6 +110,7 @@ def __init__(self) -> None: self.group: str | None = None self.cmdr: str | None = None self.started: int | None = None # Timestamp of the LoadGame event + self.slef: str | None = None self._navroute_retries_remaining = 0 self._last_navroute_journal_timestamp: float | None = None @@ -701,6 +703,34 @@ def parse_entry(self, line: bytes) -> MutableMapping[str, Any]: # noqa: C901, C module.pop('AmmoInHopper') self.state['Modules'][module['Slot']] = module + # SLEF + initial_dict = { + "header": {"appName": appname, "appVersion": str(appversion())} + } + data_dict = {} + for module in entry['Modules']: + if module.get('Slot') == 'FuelTank': + cap = module['Item'].split('size') + cap = cap[1].split('_') + cap = 2 ** int(cap[0]) + ship = ship_name_map[entry["Ship"]] + fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} + data_dict.update({"FuelCapacity": fuel}) + data_dict.update({ + 'Ship': entry["Ship"], + 'ShipName': entry['ShipName'], + 'ShipIdent': entry['ShipIdent'], + 'HullValue': entry['HullValue'], + 'ModulesValue': entry['ModulesValue'], + 'Rebuy': entry['Rebuy'], + 'MaxJumpRange': entry['MaxJumpRange'], + 'UnladenMass': entry['UnladenMass'], + 'CargoCapacity': entry['CargoCapacity'], + 'Modules': entry['Modules'], + }) + initial_dict.update({'data': data_dict}) + output = json.dumps(initial_dict, indent=4) + self.slef = str(output) elif event_type == 'modulebuy': self.state['Modules'][entry['Slot']] = { diff --git a/plugins/inara.py b/plugins/inara.py index c3f030c44..a4cc0e557 100644 --- a/plugins/inara.py +++ b/plugins/inara.py @@ -35,7 +35,6 @@ import edmc_data import killswitch import myNotebook as nb # noqa: N813 -from edshipyard import ships import plug import timeout_session from companion import CAPIData @@ -872,7 +871,6 @@ def journal_entry( # noqa: C901, CCR001 cur_ship['shipRebuyCost'] = state['Rebuy'] new_add_event('setCommanderShip', entry['timestamp'], cur_ship) - make_slef(entry) # Stored modules if event_name == 'StoredModules': @@ -1479,39 +1477,6 @@ def make_loadout(state: dict[str, Any]) -> dict[str, Any]: # noqa: CCR001 } -def make_slef(entry) -> None: - initial_dict = { - "header": {"appName": appname, "appVersion": str(appversion())} - } - data_dict = {} - for module in entry['Modules']: - if module.get('Slot') == 'FuelTank': - cap = module['Item'].split('size') - cap = cap[1].split('_') - cap = 2 ** int(cap[0]) - ship = edmc_data.ship_name_map[entry["Ship"]] - fuel = {'Main': cap, 'Reserve': ships[ship]['reserveFuelCapacity']} - data_dict.update({"FuelCapacity": fuel}) - data_dict.update({ - 'Ship': entry["Ship"], - 'ShipName': entry['ShipName'], - 'ShipIdent': entry['ShipIdent'], - 'HullValue': entry['HullValue'], - 'ModulesValue': entry['ModulesValue'], - 'Rebuy': entry['Rebuy'], - 'MaxJumpRange': entry['MaxJumpRange'], - 'UnladenMass': entry['UnladenMass'], - 'CargoCapacity': entry['CargoCapacity'], - 'Modules': entry['Modules'], - }) - initial_dict.update({'data': data_dict}) - output = json.dumps(initial_dict, indent=4) - this.SLEF = str(output) - print('set output') - print(type(this.SLEF)) - return None - - def new_add_event( name: str, timestamp: str, diff --git a/ttkHyperlinkLabel.py b/ttkHyperlinkLabel.py index 95ebd2e75..5ca4feb4b 100644 --- a/ttkHyperlinkLabel.py +++ b/ttkHyperlinkLabel.py @@ -195,9 +195,9 @@ def _contextmenu(self, event: tk.Event) -> None: if self.name == 'ship': # TODO: Get SLEF from Inara - # print(self.SLEF) - # menu.add_command(label=tr.tl('Copy INARA SLEF'), command=lambda: self.copy_slef(self), state=tk.DISABLED) - # menu.entryconfigure(1, state=self.SLEF and tk.NORMAL or tk.DISABLED) + print(bool(monitor.slef)) + menu.add_command(label=tr.tl('Copy INARA SLEF'), command=self.copy_slef, state=tk.DISABLED) + menu.entryconfigure(1, state=monitor.slef and tk.NORMAL or tk.DISABLED) menu.add_separator() for url in plug.provides('shipyard_url'): @@ -230,7 +230,7 @@ def copy(self) -> None: self.clipboard_clear() self.clipboard_append(self['text']) - # def copy_slef(self, this) -> None: - # """Copy the current text to the clipboard.""" - # self.clipboard_clear() - # self.clipboard_append(this.SLEF) + def copy_slef(self) -> None: + """Copy the current text to the clipboard.""" + self.clipboard_clear() + self.clipboard_append(monitor.slef)