Skip to content

Discord Rich Presence

Tristan Duncombe edited this page Oct 16, 2023 · 7 revisions

Discord Rich Presence

This feature adds the ability for Discord to display the activity of a user playing Gardens of the Galaxy.

Programming Choices

As Discord's own library, Discord Game SDK, uses C, C++, or C# and they do not provide any other way to enable this functionality, it was necessary to implement this featuring using an external wrapper library. The implementation used was to use discord-rpc by Vatuu. This library and the library it is a wrapper for Discord RPC are both depreciated, but there is no way to implement this functionality without using these library, thus, it was chosen to do so.

Developer Information

Setting the Presence

Within the current implementation, the Rich Presence is set through GDXGame, as this Class is the game itself. This allows it so that activity can be updated as the screen changes such as between MAIN_MENU, MAIN_GAME, and SETTINGS updating the state of activity between Perusing the Main Menu, Planting Crops, and Changing Settings respectively. Additionally, any time a state is updated, startTimer() is called to show how long a user has been active on one task.

What the Presence Does

Within the image below, an annotated description of each of the aspects of the rich presence is outlined. Through the Discord Activity Class the majority of this can be updated - excluding the Discord Application Name which is set through the Discord Developer Portal and is linked to its unique ID. The state, timer, small image, and large image can be updated by calling updateDiscordStatus(), startTimer() or stopTimer(), updateSmallImage(), and updateLargeImage().

Discord Rich Presence and its roles

Current Implementation

Currently, the implementation was chosen to be only use the necessary sections, specifically, it was chosen to show no detail or small image. This was because these were redundant, took up more space while not conveying any important information as well as extending the text beyond the new icon designed by Team 2. This can be easily changed by updating the DiscordActivity class.

Current Implentation of Discord Activity

UML Diagram

Discord Activity UML Diagram

Testing

Testing of this feature was not possible as it as it would require the ability to determine a users discord activity (which is not possible) or testing the library itself (which is not feasible or within the scope of this issue).

Issues with Implementation

One issue that was not directly apparent from the offset was that discord-rpc does not support ARM based processors such as M1, or M2. Hence, when members of the studio attempted to build the project they ran into issue. Through the assistance of Team 1, a solution was implement that just simply does not run this functionality when a user is on MacOS. Whilst this may not be the most effective solution (as the user misses out on functionality), it was the only feasible solution to complete within the timeline of the sprint as otherwise it would have been necessary to re implement the feature in another manner.

Clone this wiki locally