Skip to content
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 popups #11839

Merged

Conversation

LillyJadeKatrin
Copy link
Contributor

This is a portion of an integration with the RetroAchievements tools and libraries for connecting to the website, downloading data, unlocking achievements and submitting to leaderboards for games running in Dolphin. In this PR, the AchievementsManager created in a previous PR is further implemented to display on-screen popup messages to notify the player when important events such as achievement unlocks and leaderboard submissions take place, utilizing the imGui code in OnScreenDisplay to handle these messages.

Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
Source/Core/Core/AchievementManager.cpp Outdated Show resolved Hide resolved
@LillyJadeKatrin LillyJadeKatrin force-pushed the retroachievements-popups branch 3 times, most recently from 3fe0172 to 11fa0a5 Compare May 24, 2023 02:39
Added an OnScreenDisplay message to HandleAchievementTriggeredEvent to display a message when a player has unlocked an achievement. The message includes the title of the achievement and its point value based on the game data. To match RetroAchievements' website interface, the message is blue if the unlock is casual and gold for challenge.
Added an OnScreenDisplay message to HandleLeaderboardTriggeredEvent to display a message when a player has completed a leaderboard. The message includes the title of the achievement and the player's score/time.
Added HandleLeaderboardStartedEvent with an OnScreenDisplay message when a player has triggered a leaderboard's start conditions. The message includes the title of the achievement.
Added HandleLeaderboardStartedEvent with an OnScreenDisplay message when a player has triggered a leaderboard's failure conditions. The message includes the title of the achievement.
Added OnScreenDisplay messages to LoadGameByFilenameAsync to notify the player when any of the potential failures occur.
Added a TallyScore method to AchievementManager to calculate the player's current scores (soft and hard) against the total number of points across all achievements. Includes a PointSpread structure to hold all points and counts. The Unlock Map now includes point values for each achievement to aid in this calculation; this is populated at insert time, and Unofficial achievements are tallied as zero.
Added an OnScreenDisplay message to LoadGameByFilenameAsync to display a message when a player starts a game with achievements, notifying them of their current score. The score displayed is challenge points if the player is in challenge mode or challenge + casual if the player is in casual mode. A second message tells the player which mode they are in. To match RetroAchievements' website interface, the messages are blue for casual and gold for challenge.
Added OnScreenDisplay messages to HandleAchievementTriggeredEvent to display an extra congratulations message if the player has completed (unlocked all achievements in casual) or mastered (unlocked all achievements in challenge) the game. This also uses the display name retrieved when verifying credentials, which has now been added as a member field on AchievementManager.
Copy link
Contributor

@AdmiralCurtiss AdmiralCurtiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these messages are localized. Though if you don't have multilanguage server-side I'm not sure how useful localizing these would even be...

Though checking, none of our OSD messages seem to be localized, so whatever on that I guess.

Comment on lines +512 to +516
AchievementId game_data_index = it->second.game_data_index;
OSD::AddMessage(fmt::format("Unlocked: {} ({})", m_game_data.achievements[game_data_index].title,
m_game_data.achievements[game_data_index].points),
OSD::Duration::VERY_LONG,
(hardcore_mode_enabled) ? OSD::Color::YELLOW : OSD::Color::CYAN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this decouples the actual server-side unlocking process from the message displayed to the user. This might be fine, I'm not sure how other emulators handle this, but think about the implications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is actually deliberate. Some cases (unofficial achievements, Encore Mode) we want to send a message even if we're not actively posting to the site. And a later change will add retry functionality in case the player loses connection to the server - honestly that one's more of a self-serving thing, so I can bring my Deck on flights and the site unlocks everything for me when I land and can turn airplane mode off again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, to my understanding we want to notify the player as soon as the criteria are met, independent of what's going on with respect to the server, but I'll double check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then I suppose this is fine as-is for now. There probably also should be some kind of 'hey you're about to close Dolphin but there's still outstanding unlocks to RA, if you close Dolphin now you will lose achievement progress' kinda message in the future as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be, haven't quite worked through how that all is going to work yet.

@JosJuice
Copy link
Member

Though checking, none of our OSD messages seem to be localized, so whatever on that I guess.

This is because we unfortunately don't have proper multilingual font support for the OSD.

@AdmiralCurtiss AdmiralCurtiss merged commit afbc604 into dolphin-emu:master May 28, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants