1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

65 Commits

Author SHA1 Message Date
Athanasius
31e8d0372d
monitor/tracking: Move .station_marketid to state['MarketID']
1. plugins/eddb.py uses this for MarketID-based station URLs.

* So do the 'rename'.
* Remove EDDB tracking in favour of this.
* Update PLUGINS.md
2023-01-11 19:44:44 +00:00
Athanasius
2a8dd14e24
tracking/stationname; Minor fixups
* Missed a some `self.station` in monitor.py
* Fixed EDDB system *and* station link setting.  Brainfart had mixed them
  together in last commit.
2023-01-11 19:44:43 +00:00
Athanasius
dde0cf876c
monitor/tracking: Move .station to state['StationName']
1. EDDB tracks this.

* So move monitor.station to monitor.state['StationName'].
* PLUGINS.md updated to cite this.
2023-01-11 19:44:41 +00:00
Athanasius
df5eb5b270
monitor/tracking: Switch .systempopulation to state['SystemPopulation']
1. EDDB plugin tracked this for keeping the Station link text up to date.

* So moved it to monitor.state['SystemPopulation'].
* PLUGINS.md updated to cite this.
* PLUGINS.md also updated to note state entries that are set to None if
  remote multi-crew is detected.
2023-01-11 19:44:14 +00:00
Athanasius
dbad45cf3b
EDDB: Use only state['SystemName'] for this.system_name tracking 2023-01-11 19:44:13 +00:00
Athanasius
86e81adb3d
EDDB: Rename this.system to this.system_name 2023-01-11 19:44:12 +00:00
Athanasius
fa1c072d9e
monitor: Change .system to state['SystemName']
1. EDDB plugin needs to track the system name, but we're moving all of that
  into monitor.py.
2. monitor.py was tracking this in monitor.system, but it needs to be in
  monitor.state['SystemName'] in order for plugins to access it.

So, move monitor.system to monitor.state['SystemName'] and update all uses.
2023-01-11 19:44:08 +00:00
Athanasius
f2de70bad6
core plugins: Use nametowidget() to find system/station widgets
As we're experimenting with per-plugin frames up a level `parent.children`
would need to be `parent.parent.children`, but this way it will Just Work
without knowledge of the hierarchy.
2022-12-31 16:27:22 +00:00
Athanasius
3f91e57c7c
plugins/eddb: Fix journal_entry() and new_data types
plug.py does `dict(entry)` before calling a plugin's `journal_entry()`, so
`dict` is correct for `data`.  Thus also use that for `new_data`'s type.
2022-12-30 16:34:17 +00:00
aussig
3e295db061 Typing of return values from killswitch.check_killswitch() 2022-12-22 17:39:20 +00:00
Athanasius
73c4bcfcc7
plugins/eddb: flake8 & mypy now clean
* Converted to `class This` paradigm.
2022-12-04 15:57:09 +00:00
Athanasius
62ed12eba3
plugins/eddb: flake8 pass 2022-12-04 15:36:00 +00:00
Athanasius
ac7cfb9b14
core plugins: Add big obvious comment about imports and windows installer 2022-02-01 14:45:30 +00:00
A_D
c86b9790ca
updated eddb to new killswitches 2021-08-19 20:37:40 +02:00
A_D
9b542386fe added missing entry to eddb 2021-06-10 20:29:11 +01:00
Athanasius
b862f6b00a Translations: Add killswitch 'disabled' messages. 2021-05-17 10:18:04 +01:00
Athanasius
7f45953012 plugins/station: *Do* set station from BodyType/Body always
The 'if not this.station' was early paranoia when first getting things
working with Odyssey.  It prevents a relog from Horizons (i.e. different
location) from correctly picking up an Odyssey login station when
on-foot in concourse.

Also, EDSM was defaulting wrongly for this.station_marketid.  Not that
the plugin even *uses* that at this time.
2021-05-12 10:56:43 +01:00
Athanasius
02052dd90e EDDB: Don't blank station when Embarking OnStation to own ship. 2021-05-01 13:47:52 +01:00
Athanasius
5edf8d5b59 Change monitor.state['on_foot'] to 'OnFoot' for consistency 2021-04-12 08:30:51 +01:00
Athanasius
f45f817fa2 EDDB plugin now setting Station name correctly on_foot
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
  access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
  that data if needs be.  This avoids setting it to STATION_UNDOCKED if
  data['commander']['docked'] is False, when we're on_foot.
2021-04-12 08:30:51 +01:00
A_D
b5a8c03980 Added missing whitespace 2021-04-01 14:45:48 +01:00
A_D
6374fbbeb8 Added event disabling
You can now disable specific event handlers in plugins
2021-04-01 14:45:47 +01:00
A_D
70087a27e4 Added total journal cutoff killswitches 2021-04-01 14:45:47 +01:00
Athanasius
25852997c5 Updated all source to use new config methods
# Conflicts:
#	monitor.py
2021-04-01 14:45:46 +01:00
Athanasius
bd670b7ff1 Updated plugins to expect that CAPI data is safe
# Conflicts:
#	plugins/eddn.py
2021-04-01 14:45:45 +01:00
Athanasius
c1d8a61c60 Whitespace and keyring in requirements sync to develop 2020-08-27 12:56:34 +01:00
Athanasius
364aaf2aef Merge branch 'develop' into main 2020-08-27 12:53:03 +01:00
A_D
d31b0fdbf6 Fixed system link updating on FSDTarget
FSDTarget contains the target system under `SystemAddress`, meaning that
any time you selected a star other than the current one, plugins'
`this.system_address` was updated to that target, rather than the
current system. Said updating causes the links provided from system_url
to reflect that update (for providers that support ID64s).

This changes the journal_entry behaviour to only update
`this.system_address` when the event is any of Location, Docked,
or FSDJump, all of which contain only the current system.
2020-08-27 11:32:39 +01:00
Athanasius
daed08d206 system/station providers: Sanitise {system,station}_url logic
* Make all plugins use `requests.utils.requote_uri()`
* Make all plugins use roughly the same logic, without if/else trees
 (as the bodies do a `return ...`), ending with `return ''` if input
 parameters are None.

 This throws away the inara fallback to `this.station or this.system` as
 it's unlikely the in-plugin tracking did a better job than the
 monitor.py code.
2020-08-27 11:28:27 +01:00
Athanasius
7617ce7e9c system/station plugin providers: Don't override 'url'
By default the ttkHyperlinkLabels for 'system' and 'station' names have
their 'url' members set to the functions in EDMarketConnector.App.

The EDDB one used to override the function as it had to do that special
name -> EDDB ID lookup from systems.p.  When I changed the code to not
need that any more I didn't fully understand what these overrides were.

After updating the EDDB code I then made sure the same logic was also in
the other plugins which meant they *also* set static strings, overriding
the call to the EDMarketConnector.App functions (which chain through to
the current plugin providers).

Unfortunately I didn't quite update the EDSM code enough causing
journal_entry() code to *not* set a new system 'url' despite changing
the 'text'.  This meant that only CAPI updates (so docking and login)
caused the URL to change, despite updating the 'text' to the correct
system name.

Rather than have everything setting static strings just do away with the
overrides as they're not needed!
2020-08-27 11:25:30 +01:00
A_D
d635bd8469
Fixed system link updating on FSDTarget
FSDTarget contains the target system under `SystemAddress`, meaning that
any time you selected a star other than the current one, plugins'
`this.system_address` was updated to that target, rather than the
current system. Said updating causes the links provided from system_url
to reflect that update (for providers that support ID64s).

This changes the journal_entry behaviour to only update
`this.system_address` when the event is any of Location, Docked,
or FSDJump, all of which contain only the current system.
2020-08-26 18:59:14 +02:00
Athanasius
c9dee18d70 system/station providers: Sanitise {system,station}_url logic
* Make all plugins use `requests.utils.requote_uri()`
* Make all plugins use roughly the same logic, without if/else trees
 (as the bodies do a `return ...`), ending with `return ''` if input
 parameters are None.

 This throws away the inara fallback to `this.station or this.system` as
 it's unlikely the in-plugin tracking did a better job than the
 monitor.py code.
2020-08-26 10:18:10 +01:00
Athanasius
d46358796f system/station plugin providers: Don't override 'url'
By default the ttkHyperlinkLabels for 'system' and 'station' names have
their 'url' members set to the functions in EDMarketConnector.App.

The EDDB one used to override the function as it had to do that special
name -> EDDB ID lookup from systems.p.  When I changed the code to not
need that any more I didn't fully understand what these overrides were.

After updating the EDDB code I then made sure the same logic was also in
the other plugins which meant they *also* set static strings, overriding
the call to the EDMarketConnector.App functions (which chain through to
the current plugin providers).

Unfortunately I didn't quite update the EDSM code enough causing
journal_entry() code to *not* set a new system 'url' despite changing
the 'text'.  This meant that only CAPI updates (so docking and login)
caused the URL to change, despite updating the 'text' to the correct
system name.

Rather than have everything setting static strings just do away with the
overrides as they're not needed!
2020-08-25 21:38:22 +01:00
A_D
b27e4a3628
fixed tk import and type annotations 2020-07-27 15:15:56 +02:00
A_D
cad5f72b0a
updated type annotation 2020-07-27 15:15:55 +02:00
A_D
7b231fb244
removed unicode specifier from string
python3 strings are always unicode
2020-07-27 15:15:55 +02:00
A_D
07c43d3057
added type annotations to globals 2020-07-27 15:15:54 +02:00
A_D
e0462d8719
Replaced complex oneliner with multiline if 2020-07-27 15:15:54 +02:00
A_D
37181264c9
Added newline after scope changes 2020-07-27 15:15:53 +02:00
A_D
4eed4404c6
Added Any type hint to this
Resolves most type warnings
2020-07-27 15:15:53 +02:00
A_D
ab58aa6355
autoformatted file 2020-07-27 15:15:52 +02:00
Athanasius
b6f6365566 plugins/edsm: Fix missing line of code
Bad paste or something, who knows ?
2020-07-21 18:25:03 +01:00
Athanasius
99d1578780 plugins/eddb: Align with code tested in inara plugin
* Use same state logic as Inara plugin now has.
* this.system_link for the Tk item, this.system is the system name.
* List some tests to pass (and later to be implemented as unittests).
* Be paranoid about URIs, quote them.
* Ensure station text+link set on prefs change.
2020-07-21 17:29:03 +01:00
Athanasius
4c4511a66d plugins/eddb: Remove misleading comments about 'Only use CAPI...'
This is needed for "not even running the game" CAPI update to be useful.
2020-07-21 17:29:03 +01:00
Athanasius
ec32849a17 plugins/eddb: Fallback to system_name if no system_address
* Cleans up imports.
* Fixes some '<tab># ...' to use 2 spaces.
* Add type hints to system_url().
* Always store, even if not current provider: this.{system_address,
  station_marketid,system_population}
2020-07-13 22:12:29 +01:00
Athanasius
f3e25f0340 EDDB system URL: Don't pick up system_address from CAPI at all 2020-07-13 21:03:57 +01:00
Athanasius
317a0f6b63 EDDB is default station provider, do station_marketid as needed
We need a better way to do provider defaults.  Heck, settings defaults period.
Let's assume we'll put in place a "standard" config file once we move to one.
2020-07-11 19:47:30 +01:00
Athanasius
6932fdc883 EDDB: Use CAPI for system_address/station_marketid only if not already set
See issue #586 - a user had incorrect system_address set, but only sometimes.

This could possibly be due to CAPI errors/lag, so only use it as the source
when the values aren't yet set.  Otherwise Journal should always have provided
the correct value in a timely manner.
2020-07-11 18:57:04 +01:00
Athanasius
cd02d1664a Change EDDB system_url to use SystemAddress
* This means storing this.system_address from both cmdr_data and journal_entry.  NB: If the current value in the event or data is 'None' it will retain the previous value.  Without this Journal entries without SystemAddress erase the stored value.
 * The station_url() fallback to system_url() similarly uses this.system_address in the call.

Addresses #512
2020-07-01 15:51:14 +01:00
Athanasius
f6b3109a09 Remove the last of the {stations,systems}.p code from EDDB plugin
There is one tiny regression for a very, very corner case.

  In 3.46 if you use EDDB as the 'Station' provider and:

	1. Dock at Station A, in System X
	2. Jump out to System Y, which is also populated
	3. Exit out of the game
	4. (Re-)Start EDMC
	5. Hit 'Update' to manually trigger CAPI data retrieval

you will see a "×" character as the Station Name, and can click on it to
take you to the EDDB *System* page.  It is only there because of EDMC
using systems.p to check if System Y is populated.

  With this version in that circumstance there's no way to know that
System Y is populated, so the code assumes not and doesn't show the
"×", and thus there's nothing to click to go to the EDDB *System* page
for System Y.

  But so long as the user is actually running the game and EDMC together
then populated status is detected from Journal events and the "×" will
be there whenever you're undocked but in a populated system.
  Caveat: We know Frontier have allowed some systems that are
technically populated, but show a Population of zero.  This code assumes
that means they're *not* populated.
2020-07-01 15:51:14 +01:00