Refactor
This commit is contained in:
parent
fda45e4ddb
commit
901726bc4c
25
README.md
25
README.md
|
@ -1,8 +1,8 @@
|
||||||
# EliteRPC
|
# EDMC-Discord-Presence
|
||||||
|
|
||||||
Forked from https://github.com/Elite-Kode/EDMC-Discord-Presence/, which I thought was lacking a lot, and hadn't been updated in years.
|
A plugin for [Elite Dangerous Market Connector](https://github.com/Marginal/EDMarketConnector) that enables [Discord Rich Presence](https://discordapp.com/rich-presence) for [Elite Dangerous](https://www.elitedangerous.com/)
|
||||||
|
|
||||||
A plugin for [Elite Dangerous Market Connector](https://github.com/Marginal/EDMarketConnector), that enables [Discord Rich Presence](https://discordapp.com/rich-presence) for [Elite Dangerous](https://www.elitedangerous.com/)
|
Show your current location to your friends on Discord from your user profile.
|
||||||
|
|
||||||
![Presence Screenshot](EDMC_Discord_Presence_1.png?raw=true)
|
![Presence Screenshot](EDMC_Discord_Presence_1.png?raw=true)
|
||||||
|
|
||||||
|
@ -22,6 +22,25 @@ To check if the plugin is loaded correctly, go File -> Settings. Then browse to
|
||||||
|
|
||||||
![Plugin Installation Check](EDMC_Discord_Presence_3.png?raw=true)
|
![Plugin Installation Check](EDMC_Discord_Presence_3.png?raw=true)
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
You can set the plugin to not show your game data. Go to File -> Settings. Under the `DiscordPresence` tab, check `Disable Presence`
|
||||||
|
|
||||||
|
![Plugin Disable](EDMC_Discord_Presence_4.png?raw=true)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
If you find a bug, please create an issue in the issue tracker in Github, properly detailing the bug and reproduction steps.
|
||||||
|
|
||||||
|
If you are willing to contribute to the project, please work on a fork and create a pull request.
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
For the CMDRs by a CMDR. Created by [CMDR Garud](https://forums.frontier.co.uk/member.php/136073-Garud) for an awesome gaming community.
|
||||||
|
A big thanks to [Jonathan Harris (Marginal)](https://github.com/Marginal) for creating the Python boilerplate code for the Discord Rich Presence SDK. Without his input, the plugin would not have been done. Special mention for the awesome group I am in, [Knights of Karma](http://knightsofkarma.com/), for their continuous support.
|
||||||
|
|
||||||
|
Translate to french, migrate from python2 to python3 by [Poneyy](https://github.com/Poneyy)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Developed under [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/).
|
Developed under [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/).
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
253
load.py
253
load.py
|
@ -44,90 +44,50 @@ landingPad = '2'
|
||||||
|
|
||||||
this = sys.modules[__name__] # For holding module globals
|
this = sys.modules[__name__] # For holding module globals
|
||||||
|
|
||||||
def ship(ship_type):
|
ship_data = {
|
||||||
ship_name = ''
|
"sidewinder": "Sidewinder",
|
||||||
match ship_type:
|
"eagle": "Eagle",
|
||||||
case "sidewinder":
|
"hauler": "Hauler",
|
||||||
ship_name = "Sidewinder"
|
"adder": "Adder",
|
||||||
case "eagle":
|
"adder_taxi": "Apex Shuttle",
|
||||||
ship_name = "Eagle"
|
"empire_eagle": "Imperial Eagle",
|
||||||
case "hauler":
|
"viper": "Viper Mk III",
|
||||||
ship_name = "Hauler"
|
"cobramkiii": "Cobra Mk III",
|
||||||
case "adder":
|
"viper_mkiv": "Viper Mk IV",
|
||||||
ship_name = "Adder"
|
"diamondback": "Diamondback Scout",
|
||||||
case "adder_taxi":
|
"cobramkiv": "Cobra Mk IV",
|
||||||
ship_name = "Apex Shuttle"
|
"type6": "Type-6 Transporter",
|
||||||
case "empire_eagle":
|
"dolphin": "Dolphin",
|
||||||
ship_name = "Imperial Eagle"
|
"diamondbackxl": "Diamondback Explorer",
|
||||||
case "viper":
|
"empire_courier": "Imperial Courier",
|
||||||
ship_name = "Viper Mk III"
|
"independant_trader": "Keelback",
|
||||||
case "cobramkiii":
|
"asp_scout": "Asp Scout",
|
||||||
ship_name = "Cobra Mk III"
|
"vulture": "Vulture",
|
||||||
case "viper_mkiv":
|
"asp": "Asp Explorer",
|
||||||
ship_name = "Viper Mk IV"
|
"federation_dropship": "Federal Dropship",
|
||||||
case "diamondback":
|
"type7": "Type-7 Transporter",
|
||||||
ship_name = "Diamondback Scout"
|
"typex": "Alliance Chieftain",
|
||||||
case "cobramkiv":
|
"federation_dropship_mkii": "Federal Assault Ship",
|
||||||
ship_name = "Cobra Mk IV"
|
"empire_trader": "Imperial Clipper",
|
||||||
case "type6":
|
"typex_2": "Alliance Crusader",
|
||||||
ship_name = "Type-6 Transporter"
|
"typex_3": "Alliance Challenger",
|
||||||
case "dolphin":
|
"federation_gunship": "Federal Gunship",
|
||||||
ship_name = "Dolphin"
|
"krait_light": "Krait Phantom",
|
||||||
case "diamondbackxl":
|
"krait_mkii": "Krait Mk II",
|
||||||
ship_name = "Diamondback Explorer"
|
"orca": "Orca",
|
||||||
case "empire_courier":
|
"ferdelance": "Fer-de-Lance",
|
||||||
ship_name = "Imperial Courier"
|
"mamba": "Mamba",
|
||||||
case "independant_trader":
|
"python": "Python",
|
||||||
ship_name = "Keelback"
|
"type9": "Type-9 Heavy",
|
||||||
case "asp_scout":
|
"belugaliner": "Beluga Liner",
|
||||||
ship_name = "Asp Scout"
|
"type9_military": "Type-10 Defender",
|
||||||
case "vulture":
|
"anaconda": "Anaconda",
|
||||||
ship_name = "Vulture"
|
"federation_corvette": "Federal Corvette",
|
||||||
case "asp":
|
"cutter": "Imperial Cutter"
|
||||||
ship_name = "Asp Explorer"
|
}
|
||||||
case "federation_dropship":
|
|
||||||
ship_name = "Federal Dropship"
|
def get_ship_name(ship_type):
|
||||||
case "type7":
|
return ship_data.get(ship_type, "Unknown Ship")
|
||||||
ship_name = "Type-7 Transporter"
|
|
||||||
case "typex":
|
|
||||||
ship_name = "Alliance Chieftain"
|
|
||||||
case "federation_dropship_mkii":
|
|
||||||
ship_name = "Federal Assault Ship"
|
|
||||||
case "empire_trader":
|
|
||||||
ship_name = "Imperial Clipper"
|
|
||||||
case "typex_2":
|
|
||||||
ship_name = "Alliance Crusader"
|
|
||||||
case "typex_3":
|
|
||||||
ship_name = "Alliance Challenger"
|
|
||||||
case "federation_gunship":
|
|
||||||
ship_name = "Federal Gunship"
|
|
||||||
case "krait_light":
|
|
||||||
ship_name = "Krait Phantom"
|
|
||||||
case "krait_mkii":
|
|
||||||
ship_name = "Krait Mk II"
|
|
||||||
case "orca":
|
|
||||||
ship_name = "Orca"
|
|
||||||
case "ferdelance":
|
|
||||||
ship_name = "Fer-de-Lance"
|
|
||||||
case "mamba":
|
|
||||||
ship_name = "Mamba"
|
|
||||||
case "python":
|
|
||||||
ship_name = "Python"
|
|
||||||
case "type9":
|
|
||||||
ship_name = "Type-9 Heavy"
|
|
||||||
case "belugaliner":
|
|
||||||
ship_name = "Beluga Liner"
|
|
||||||
case "type9_military":
|
|
||||||
ship_name = "Type-10 Defender"
|
|
||||||
case "anaconda":
|
|
||||||
ship_name = "Anaconda"
|
|
||||||
case "federation_corvette":
|
|
||||||
ship_name = "Federal Corvette"
|
|
||||||
case "cutter":
|
|
||||||
ship_name = "Imperial Cutter"
|
|
||||||
case _: # Default case for any other value
|
|
||||||
ship_name = "Unknown Ship"
|
|
||||||
return ship_name
|
|
||||||
|
|
||||||
def callback(result):
|
def callback(result):
|
||||||
logger.info(f'Callback: {result}')
|
logger.info(f'Callback: {result}')
|
||||||
|
@ -227,79 +187,64 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||||
presence_largetext = this.presence_large_text
|
presence_largetext = this.presence_large_text
|
||||||
presence_smallimage = this.presence_small_image
|
presence_smallimage = this.presence_small_image
|
||||||
presence_smalltext = this.presence_small_text
|
presence_smalltext = this.presence_small_text
|
||||||
if entry['event'] == 'StartUp':
|
|
||||||
presence_largetext = ship(('{ship}').format(ship=state['ShipType']))
|
match entry['event']:
|
||||||
presence_smalltext = ('CMDR {cmdr}').format(cmdr=cmdr)
|
case 'StartUp':
|
||||||
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
|
presence_largetext = get_ship_name(('{ship}').format(ship=state['ShipType']))
|
||||||
presence_smallimage = 'edlogo'
|
presence_smalltext = ('CMDR {cmdr}').format(cmdr=cmdr)
|
||||||
#presence_smalltext = ('{cmdr}cr').format(credits=state['Credits'])
|
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
|
||||||
presence_state = _('In system {system}').format(system=system)
|
presence_smallimage = 'edlogo'
|
||||||
if station is None:
|
presence_state = _('In system {system}').format(system=system)
|
||||||
|
presence_details = _('Docked at {station}').format(station=station) if station else _('Flying in normal space')
|
||||||
|
case 'Location':
|
||||||
|
presence_state = _('In system {system}').format(system=system)
|
||||||
|
presence_details = _('Docked at {station}').format(station=station) if station else _('Flying in normal space')
|
||||||
|
case 'StartJump':
|
||||||
|
presence_state = _('Jumping')
|
||||||
|
presence_details = _('Jumping to system {system}').format(system=entry['StarSystem']) if entry['JumpType'] == 'Hyperspace' else _('Preparing for supercruise')
|
||||||
|
case 'SupercruiseEntry':
|
||||||
|
presence_state = _('In system {system}').format(system=system)
|
||||||
|
presence_details = _('Supercruising')
|
||||||
|
case 'SupercruiseExit':
|
||||||
|
presence_state = _('In system {system}').format(system=system)
|
||||||
presence_details = _('Flying in normal space')
|
presence_details = _('Flying in normal space')
|
||||||
else:
|
case 'FSDJump':
|
||||||
|
presence_state = _('In system {system}').format(system=system)
|
||||||
|
presence_details = _('Supercruising')
|
||||||
|
case 'Docked':
|
||||||
|
presence_state = _('In system {system}').format(system=system)
|
||||||
presence_details = _('Docked at {station}').format(station=station)
|
presence_details = _('Docked at {station}').format(station=station)
|
||||||
elif entry['event'] == 'Location':
|
case 'Undocked':
|
||||||
presence_state = _('In system {system}').format(system=system)
|
presence_state = _('In system {system}').format(system=system)
|
||||||
if station is None:
|
presence_details = _('Flying near {station}').format(station=entry['StationName']) if entry['event'] in ('Undocked', 'DockingCancelled', 'DockingTimeout') else _('Flying in normal space')
|
||||||
presence_details = _('Flying in normal space')
|
case 'ShutDown':
|
||||||
else:
|
presence_state = _('Main Menu')
|
||||||
presence_details = _('Docked at {station}').format(station=station)
|
|
||||||
elif entry['event'] == 'StartJump':
|
|
||||||
presence_state = _('Jumping')
|
|
||||||
if entry['JumpType'] == 'Hyperspace':
|
|
||||||
presence_details = _('Jumping to system {system}').format(system=entry['StarSystem'])
|
|
||||||
elif entry['JumpType'] == 'Supercruise':
|
|
||||||
presence_details = _('Preparing for supercruise')
|
|
||||||
elif entry['event'] == 'SupercruiseEntry':
|
|
||||||
presence_state = _('In system {system}').format(system=system)
|
|
||||||
presence_details = _('Supercruising')
|
|
||||||
elif entry['event'] == 'SupercruiseExit':
|
|
||||||
presence_state = _('In system {system}').format(system=system)
|
|
||||||
presence_details = _('Flying in normal space')
|
|
||||||
elif entry['event'] == 'FSDJump':
|
|
||||||
presence_state = _('In system {system}').format(system=system)
|
|
||||||
presence_details = _('Supercruising')
|
|
||||||
elif entry['event'] == 'Docked':
|
|
||||||
presence_state = _('In system {system}').format(system=system)
|
|
||||||
presence_details = _('Docked at {station}').format(station=station)
|
|
||||||
elif entry['event'] == 'Undocked':
|
|
||||||
presence_state = _('In system {system}').format(system=system)
|
|
||||||
presence_details = _('Flying in normal space')
|
|
||||||
elif entry['event'] == 'ShutDown':
|
|
||||||
presence_state = _('Main Menu')
|
|
||||||
presence_details = ''
|
|
||||||
elif entry['event'] == 'DockingGranted':
|
|
||||||
landingPad = entry['LandingPad']
|
|
||||||
elif entry['event'] == 'Music':
|
|
||||||
if entry['MusicTrack'] == 'MainMenu':
|
|
||||||
presence_state = _('In Main Menu')
|
|
||||||
presence_details = ''
|
presence_details = ''
|
||||||
# Todo: This elif might not be executed on undocked. Functionality can be improved
|
case 'DockingGranted':
|
||||||
elif entry['event'] == 'Undocked' or entry['event'] == 'DockingCancelled' or entry['event'] == 'DockingTimeout':
|
landingPad = entry['LandingPad']
|
||||||
presence_details = _('Flying near {station}').format(station=entry['StationName'])
|
case 'Music':
|
||||||
# Planetary events
|
if entry['MusicTrack'] == 'MainMenu':
|
||||||
elif entry['event'] == 'ApproachBody':
|
presence_state = _('In Main Menu')
|
||||||
presence_details = _('Approaching {body}').format(body=entry['Body'])
|
presence_details = ''
|
||||||
planet = entry['Body']
|
case 'ApproachBody':
|
||||||
elif entry['event'] == 'Touchdown' and entry['PlayerControlled']:
|
presence_details = _('Approaching {body}').format(body=entry['Body'])
|
||||||
presence_details = _('Landed on {body}').format(body=planet)
|
planet = entry['Body']
|
||||||
elif entry['event'] == 'Liftoff' and entry['PlayerControlled']:
|
case 'Touchdown' if entry['PlayerControlled']:
|
||||||
if entry['PlayerControlled']:
|
presence_details = _('Landed on {body}').format(body=planet)
|
||||||
presence_details = _('Flying around {body}').format(body=planet)
|
case 'Liftoff':
|
||||||
else:
|
presence_details = _('Flying around {body}').format(body=planet) if entry['PlayerControlled'] else _('In SRV on {body}, ship in orbit').format(body=planet)
|
||||||
presence_details = _('In SRV on {body}, ship in orbit').format(body=planet)
|
case 'LeaveBody':
|
||||||
elif entry['event'] == 'LeaveBody':
|
presence_details = _('Supercruising')
|
||||||
presence_details = _('Supercruising')
|
case 'Loadout':
|
||||||
|
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
|
||||||
elif entry['event'] == 'Loadout':
|
presence_largetext = get_ship_name(('{ship}').format(ship=state['ShipType']))
|
||||||
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
|
case 'LaunchSRV':
|
||||||
presence_largetext = ship(('{ship}').format(ship=state['ShipType']))
|
presence_details = _('In SRV on {body}').format(body=planet)
|
||||||
|
case 'DockSRV':
|
||||||
# EXTERNAL VEHICLE EVENTS
|
presence_details = _('Landed on {body}').format(body=planet)
|
||||||
elif entry['event'] == 'LaunchSRV':
|
case _:
|
||||||
presence_details = _('In SRV on {body}').format(body=planet)
|
# No specific action for other events
|
||||||
elif entry['event'] == 'DockSRV':
|
pass
|
||||||
presence_details = _('Landed on {body}').format(body=planet)
|
|
||||||
|
|
||||||
if (presence_state != this.presence_state or
|
if (presence_state != this.presence_state or
|
||||||
presence_details != this.presence_details or
|
presence_details != this.presence_details or
|
||||||
|
|
Loading…
Reference in a new issue