New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RetroAchievements - Discord Presence #12755
RetroAchievements - Discord Presence #12755
Conversation
01bf4cb
to
92d2fdc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM. Untested.
if (state_string.length() >= 128) | ||
{ | ||
// 124 characters + 3 dots + null terminator - thanks to Stenzek for format | ||
state_string.replace(124, 4, "..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is right? I think for strings > 128 this would insert the ...
in the middle of the string instead of replacing the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah, I was thinking of it wrong too.
Probably should be something like: state_string = fmt::format("{}...", state_string.substr(0, 124));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding was that this would insert ...\0 into the middle of the string and thus cut it off when it copies to a cstring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah you're right, but that's really not obvious with how the code is written. But yeah fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more easily verifiable approach is this:
state_string.replace(124, 4, "..."); | |
state_string.resize(124); | |
state_string += "..."; |
(not that it mattered here, but this won't have overhead since down-sizing string never re-allocates)
As a side note, std::string
's null terminator is not included in its length()
, but the comment suggests a different assumption was made. Might be worth double-checking.
Please hide the Discord presence option in the Achievement UI if RetroAchievements is enabled but Discord is disabled. ( |
Completely hide, or could I just gray it out like with other settings here when they're not active? |
Since we have a discoverability issue here (two related settings at completely different places in the GUI), I'd be in favor of leaving the option in the achievements UI always visible but grayed out when Discord integration is disabled (bonus points if the tooltip also explains why it can't be enabled)... |
Ah, I was talking about the compile time switch that disables Discord integration from being compiled altogether, but yes that is a good point too. So:
The tooltip for the box should indeed contain that the regular Discord integration needs to be enabled. |
OH right good call, got it. |
When enabled, this will send Rich Presence to Discord to be displayed in players' statuses.
If Rich Presence and Discord Presence are enabled in Achievement Settings, the string generated by rcheevos as the player's current Rich Presence will be sent to the Status field in the Discord Presence object. This will be updated whenever Rich Presence updates.
Setting is only enabled when Rich Presence is enabled. Toggling either Rich Presence or Discord Presence will immediately update the Discord status.
92d2fdc
to
2328539
Compare
I'm not entirely sure whether the |
FYI the reset_timer flag was because we noticed while testing that without specifying this, the "time played" timer was resetting every time the RP was updating instead of actually reporting the amount of time spent in game. But let me know if we want to change the specific implementation of it. |
Sends RetroAchievements Rich Presence to Discord as its presence text provided the correct settings are enabled.
Rebase of #12594 after the refactor to rc_client.