This commit is contained in:
Zoey 2024-05-28 21:59:14 +02:00
parent fda45e4ddb
commit 901726bc4c
Signed by: SailorZoop
GPG key ID: 854F554AFF0A96D1
6 changed files with 147 additions and 183 deletions

View file

@ -1,27 +1,46 @@
# EliteRPC
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/)
![Presence Screenshot](EDMC_Discord_Presence_1.png?raw=true)
## Installation
1. [Install EDMC according to instructions](https://github.com/Marginal/EDMarketConnector)
2. Download the latest version of the plugin from [here](https://github.com/SayakMukhopadhyay/EDMC-Discord-Presence/releases). Make sure to download the release `.zip` and not the source code bundle.
3. Open Elite Dangerous Market Connector and go to File -> Settings. Then browse to the plugins tab:
![Plugin Installation](EDMC_Discord_Presence_2.png?raw=true)
4. Click "Open" to open the plugins directory.
5. Open the Zip file we have downloaded and drag the folder from within into the plugins directory
6. Restart EDMC for the plugin to take effect.
To check if the plugin is loaded correctly, go File -> Settings. Then browse to the plugins tab. `DiscordPresence` must be listed under `Enabled Plugins`
![Plugin Installation Check](EDMC_Discord_Presence_3.png?raw=true)
## License
Developed under [Apache License 2.0](https://choosealicense.com/licenses/apache-2.0/).
# EDMC-Discord-Presence
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)
## Installation
1. [Install EDMC according to instructions](https://github.com/Marginal/EDMarketConnector)
2. Download the latest version of the plugin from [here](https://github.com/SayakMukhopadhyay/EDMC-Discord-Presence/releases). Make sure to download the release `.zip` and not the source code bundle.
3. Open Elite Dangerous Market Connector and go to File -> Settings. Then browse to the plugins tab:
![Plugin Installation](EDMC_Discord_Presence_2.png?raw=true)
4. Click "Open" to open the plugins directory.
5. Open the Zip file we have downloaded and drag the folder from within into the plugins directory
6. Restart EDMC for the plugin to take effect.
To check if the plugin is loaded correctly, go File -> Settings. Then browse to the plugins tab. `DiscordPresence` must be listed under `Enabled Plugins`
![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
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.

257
load.py
View file

@ -44,90 +44,50 @@ landingPad = '2'
this = sys.modules[__name__] # For holding module globals
def ship(ship_type):
ship_name = ''
match ship_type:
case "sidewinder":
ship_name = "Sidewinder"
case "eagle":
ship_name = "Eagle"
case "hauler":
ship_name = "Hauler"
case "adder":
ship_name = "Adder"
case "adder_taxi":
ship_name = "Apex Shuttle"
case "empire_eagle":
ship_name = "Imperial Eagle"
case "viper":
ship_name = "Viper Mk III"
case "cobramkiii":
ship_name = "Cobra Mk III"
case "viper_mkiv":
ship_name = "Viper Mk IV"
case "diamondback":
ship_name = "Diamondback Scout"
case "cobramkiv":
ship_name = "Cobra Mk IV"
case "type6":
ship_name = "Type-6 Transporter"
case "dolphin":
ship_name = "Dolphin"
case "diamondbackxl":
ship_name = "Diamondback Explorer"
case "empire_courier":
ship_name = "Imperial Courier"
case "independant_trader":
ship_name = "Keelback"
case "asp_scout":
ship_name = "Asp Scout"
case "vulture":
ship_name = "Vulture"
case "asp":
ship_name = "Asp Explorer"
case "federation_dropship":
ship_name = "Federal Dropship"
case "type7":
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
ship_data = {
"sidewinder": "Sidewinder",
"eagle": "Eagle",
"hauler": "Hauler",
"adder": "Adder",
"adder_taxi": "Apex Shuttle",
"empire_eagle": "Imperial Eagle",
"viper": "Viper Mk III",
"cobramkiii": "Cobra Mk III",
"viper_mkiv": "Viper Mk IV",
"diamondback": "Diamondback Scout",
"cobramkiv": "Cobra Mk IV",
"type6": "Type-6 Transporter",
"dolphin": "Dolphin",
"diamondbackxl": "Diamondback Explorer",
"empire_courier": "Imperial Courier",
"independant_trader": "Keelback",
"asp_scout": "Asp Scout",
"vulture": "Vulture",
"asp": "Asp Explorer",
"federation_dropship": "Federal Dropship",
"type7": "Type-7 Transporter",
"typex": "Alliance Chieftain",
"federation_dropship_mkii": "Federal Assault Ship",
"empire_trader": "Imperial Clipper",
"typex_2": "Alliance Crusader",
"typex_3": "Alliance Challenger",
"federation_gunship": "Federal Gunship",
"krait_light": "Krait Phantom",
"krait_mkii": "Krait Mk II",
"orca": "Orca",
"ferdelance": "Fer-de-Lance",
"mamba": "Mamba",
"python": "Python",
"type9": "Type-9 Heavy",
"belugaliner": "Beluga Liner",
"type9_military": "Type-10 Defender",
"anaconda": "Anaconda",
"federation_corvette": "Federal Corvette",
"cutter": "Imperial Cutter"
}
def get_ship_name(ship_type):
return ship_data.get(ship_type, "Unknown Ship")
def 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_smallimage = this.presence_small_image
presence_smalltext = this.presence_small_text
if entry['event'] == 'StartUp':
presence_largetext = ship(('{ship}').format(ship=state['ShipType']))
presence_smalltext = ('CMDR {cmdr}').format(cmdr=cmdr)
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
presence_smallimage = 'edlogo'
#presence_smalltext = ('{cmdr}cr').format(credits=state['Credits'])
presence_state = _('In system {system}').format(system=system)
if station is None:
presence_details = _('Flying in normal space')
else:
presence_details = _('Docked at {station}').format(station=station)
elif entry['event'] == 'Location':
presence_state = _('In system {system}').format(system=system)
if station is None:
presence_details = _('Flying in normal space')
else:
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 = ''
# Todo: This elif might not be executed on undocked. Functionality can be improved
elif entry['event'] == 'Undocked' or entry['event'] == 'DockingCancelled' or entry['event'] == 'DockingTimeout':
presence_details = _('Flying near {station}').format(station=entry['StationName'])
# Planetary events
elif entry['event'] == 'ApproachBody':
presence_details = _('Approaching {body}').format(body=entry['Body'])
planet = entry['Body']
elif entry['event'] == 'Touchdown' and entry['PlayerControlled']:
presence_details = _('Landed on {body}').format(body=planet)
elif entry['event'] == 'Liftoff' and entry['PlayerControlled']:
if entry['PlayerControlled']:
presence_details = _('Flying around {body}').format(body=planet)
else:
presence_details = _('In SRV on {body}, ship in orbit').format(body=planet)
elif entry['event'] == 'LeaveBody':
presence_details = _('Supercruising')
elif entry['event'] == 'Loadout':
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
presence_largetext = ship(('{ship}').format(ship=state['ShipType']))
# EXTERNAL VEHICLE EVENTS
elif entry['event'] == 'LaunchSRV':
presence_details = _('In SRV on {body}').format(body=planet)
elif entry['event'] == 'DockSRV':
presence_details = _('Landed on {body}').format(body=planet)
match entry['event']:
case 'StartUp':
presence_largetext = get_ship_name(('{ship}').format(ship=state['ShipType']))
presence_smalltext = ('CMDR {cmdr}').format(cmdr=cmdr)
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
presence_smallimage = 'edlogo'
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')
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)
case 'Undocked':
presence_state = _('In system {system}').format(system=system)
presence_details = _('Flying near {station}').format(station=entry['StationName']) if entry['event'] in ('Undocked', 'DockingCancelled', 'DockingTimeout') else _('Flying in normal space')
case 'ShutDown':
presence_state = _('Main Menu')
presence_details = ''
case 'DockingGranted':
landingPad = entry['LandingPad']
case 'Music':
if entry['MusicTrack'] == 'MainMenu':
presence_state = _('In Main Menu')
presence_details = ''
case 'ApproachBody':
presence_details = _('Approaching {body}').format(body=entry['Body'])
planet = entry['Body']
case 'Touchdown' if entry['PlayerControlled']:
presence_details = _('Landed on {body}').format(body=planet)
case 'Liftoff':
presence_details = _('Flying around {body}').format(body=planet) if entry['PlayerControlled'] else _('In SRV on {body}, ship in orbit').format(body=planet)
case 'LeaveBody':
presence_details = _('Supercruising')
case 'Loadout':
presence_largeimage = ('{ship}').format(ship=state['ShipType'])
presence_largetext = get_ship_name(('{ship}').format(ship=state['ShipType']))
case 'LaunchSRV':
presence_details = _('In SRV on {body}').format(body=planet)
case 'DockSRV':
presence_details = _('Landed on {body}').format(body=planet)
case _:
# No specific action for other events
pass
if (presence_state != this.presence_state or
presence_details != this.presence_details or