From bac718aeffc75f65eb8dd272ffd6d5afcbd65151 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 25 May 2021 17:56:11 +0100 Subject: [PATCH] Store `Fileheader` language, gameversion and build in monitor.state --- PLUGINS.md | 3 +++ monitor.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PLUGINS.md b/PLUGINS.md index 1eb2a4a2..cff302ef 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -566,6 +566,9 @@ Content of `state` (updated to the current journal entry): | Field | Type | Description | | :------------- | :-------------------------: | :-------------------------------------------------------------------------------------------------------------- | +| `GameLanguage` | `Optional[str]` | `language` value from `Fileheader` event. | +| `GameVersion` | `Optional[str]` | `version` value from `Fileheader` event. | +| `GameBuild` | `Optional[str]` | `build` value from `Fileheader` event. | | `Captain` | `Optional[str]` | Name of the commander who's crew you're on, if any | | `Cargo` | `dict` | Current cargo. Note that this will be totals, and any mission specific duplicates will be counted together | | `CargoJSON` | `dict` | content of cargo.json as of last read. | diff --git a/monitor.py b/monitor.py index 3b01ab3e..1ae82c05 100644 --- a/monitor.py +++ b/monitor.py @@ -115,6 +115,9 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below # Cmdr state shared with EDSM and plugins # If you change anything here update PLUGINS.md documentation! self.state: Dict = { + 'GameLanguage': None, # From `Fileheader + 'GameVersion': None, # From `Fileheader + 'GameBuild': None, # From `Fileheader 'Captain': None, # On a crew 'Cargo': defaultdict(int), 'Credits': None, @@ -497,13 +500,15 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.systemaddress = None self.started = None self.__init_state() + # In self.state as well, as that's what plugins get + self.stat['GameLanguage'] = entry['language'] + self.stat['GameVersion'] = entry['gameversion'] + self.stat['GameBuild'] = entry['build'] elif event_type == 'Commander': self.live = True # First event in 3.0 elif event_type == 'LoadGame': - # alpha4 - # Odyssey: bool self.cmdr = entry['Commander'] # 'Open', 'Solo', 'Group', or None for CQC (and Training - but no LoadGame event) self.mode = entry.get('GameMode')