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 - Default Badges #12778

Conversation

LillyJadeKatrin
Copy link
Contributor

This PR adds the infrastructure to use default Achievements-related badges/icons located in the Sys folder when badges normally downloaded from the RetroAchievements website are unavailable. The badges provided here are placeholders for when a graphics designer within Dolphin can provide better replacements.

@iwubcode
Copy link
Contributor

iwubcode commented May 13, 2024

I think I originally gave you the instruction to put your resources in the "Load" folder. However, I wasn't remembering correctly from my reference implementation (editor PR). I'd like to keep the Load folder rather clean. As to me that folder should mirror the "User/Load" folder and refers to loaded content that Dolphin team maintains.

Not sure if we need another folder ("resources"?) to keep the root from getting too chaotic.

EDIT: Oh we have a resources folder already. Maybe we just need better organization under that.

@@ -68,24 +68,20 @@ void AchievementHeaderWidget::UpdateData()

QString user_name = QtUtils::FromStdString(instance.GetPlayerDisplayName());
QString game_name = QtUtils::FromStdString(instance.GetGameDisplayName());
AchievementManager::BadgeStatus player_badge = instance.GetPlayerBadge();
AchievementManager::BadgeStatus game_badge = instance.GetGameBadge();
AchievementManager::Badge player_badge = instance.GetPlayerBadge();
Copy link
Contributor

Choose a reason for hiding this comment

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

const AchievementManager::Badge& player_badge = instance.GetPlayerBadge();

AchievementManager::BadgeStatus player_badge = instance.GetPlayerBadge();
AchievementManager::BadgeStatus game_badge = instance.GetGameBadge();
AchievementManager::Badge player_badge = instance.GetPlayerBadge();
AchievementManager::Badge game_badge = instance.GetGameBadge();
Copy link
Contributor

Choose a reason for hiding this comment

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

const AchievementManager::Badge& game_badge = instance.GetGameBadge();

return LoadPNGTexture(level, buffer);
}

bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::vector<u8> buffer)
Copy link
Contributor

Choose a reason for hiding this comment

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

bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::vector<u8>& buffer)

Copy link
Contributor

@mbc07 mbc07 left a comment

Choose a reason for hiding this comment

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

AFAICT the default badges aren't intended to be user replaceable, so I don't think those PNGs should reside anywhere under Sys\Load, they should all go to Sys\Resources, after all that's where the other image assets we use in Dolphin's GUI are stored...

@LillyJadeKatrin
Copy link
Contributor Author

I think I originally gave you the instruction to put your resources in the "Load" folder. However, I wasn't remembering correctly from my reference implementation (editor PR). I'd like to keep the Load folder rather clean. As to me that folder should mirror the "User/Load" folder and refers to loaded content that Dolphin team maintains.

Not sure if we need another folder ("resources"?) to keep the root from getting too chaotic.

EDIT: Oh we have a resources folder already. Maybe we just need better organization under that.

Instructions unclear, moved files to Licenses folder :p

Kidding, but where should I put these? Resources/RetroAchievements?

@mbc07
Copy link
Contributor

mbc07 commented May 14, 2024

I'd just drop them under Sys\Resources, without a subfolder. The existing ones aren't separated anyway, and this can be handled in a later PR if it bothers enough...

@LillyJadeKatrin LillyJadeKatrin force-pushed the retroachievements-default-badges-v2 branch 2 times, most recently from 6660638 to 2970af6 Compare May 14, 2024 04:19
@MayImilae
Copy link
Contributor

Is there anything else needed to merge this? I'm already working on the permanent badges, and this will need to be merged before I can make a PR with those.

@iwubcode Please review!

@AdmiralCurtiss
Copy link
Contributor

I swear someone else pointed this out but I don't see it... but the trophy and trophy_color icons should be called something like trophy_locked and trophy_unlocked instead.

Also, shouldn't they be achievement rather than trophy? Trophy is Sony terminology.

@MayImilae
Copy link
Contributor

The current plan as I discussed with Lilly is for them to be padlocks, so that will change. But I could delete the trophies in the upcoming PR with the new icons. Depends on what Lilly wants to do.

Comment on lines 174 to 185
for (u32 bx = 0; bx < achievement_list->num_buckets; bx++)
{
auto& bucket = achievement_list->buckets[bx];
for (u32 achievement = 0; achievement < bucket.num_achievements; achievement++)
{
u32 achievement_id = bucket.achievements[achievement]->id;
// I need these defaults to be set before making any FetchBadge calls, because FetchBadge
// will update the UI and attempt to retrieve these badges.
m_unlocked_badges[achievement_id] = m_default_unlocked_badge;
m_locked_badges[achievement_id] = m_default_locked_badge;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems rather wasteful of memory, and also unnecessary. You already have a GetAchievementBadge() function that falls back to the default icon if it's not in the m_unlocked_badges/m_locked_badges maps, just use that consistently everywhere?

@AdmiralCurtiss
Copy link
Contributor

The current plan as I discussed with Lilly is for them to be padlocks, so that will change. But I could delete the trophies in the upcoming PR with the new icons. Depends on what Lilly wants to do.

The point is that currently one would need to update the code when the contents of the images changes, since the filenames refer to a specific object rather than a generic concept.

if (m_default_player_badge.data.empty())
{
if (!LoadPNGTexture(&m_default_player_badge,
directory + static_cast<std::string>(DEFAULT_PLAYER_BADGE_FILENAME)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Err what? Can you even cast a string_view to a string...? This feels super sketchy, please just use a constructor or fmt::format or anything else here.

Comment on lines 737 to 744
OSD::AddMessage(
fmt::format("Unlocked: {} ({})", client_event->achievement->title,
client_event->achievement->points),
OSD::Duration::VERY_LONG,
(rc_client_get_hardcore_enabled(AchievementManager::GetInstance().m_client)) ?
OSD::Color::YELLOW :
OSD::Color::CYAN,
&AchievementManager::GetInstance().m_unlocked_badges[client_event->achievement->id]);
Copy link
Contributor

Choose a reason for hiding this comment

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

For readability I would suggest using a local reference for multiple calls to AchievementManager::GetInstance(). Something like:

  auto& instance = AchievementManager::GetInstance();
  OSD::AddMessage(fmt::format("Unlocked: {} ({})", client_event->achievement->title,
                              client_event->achievement->points),
                  OSD::Duration::VERY_LONG,
                  (rc_client_get_hardcore_enabled(instance.m_client)) ? OSD::Color::YELLOW :
                                                                        OSD::Color::CYAN,
                  &instance.m_unlocked_badges[client_event->achievement->id]);

@mbc07
Copy link
Contributor

mbc07 commented May 19, 2024

I swear someone else pointed this out but I don't see it...

It was me, but I commented on Discord. I'll leave the message here too, for reference:

achievements_player.png and achievements_game.png closely resembles the const names used in code (DEFAULT_PLAYER_BADGE_FILENAME and DEFAULT_GAME_BADGE_FILENAME), but achievements_trophy.png and achievements_trophy_color.png do not

In the previous PR regarding the default badges (from before the rc_client refactor), May pointed out Dolphin assets doesn't use color to represent different states, so with that in mind, I'd suggest updating the placeholder trophy filenames to achievements_locked.png and achievements_unlocked.png, respectively.

@LillyJadeKatrin LillyJadeKatrin force-pushed the retroachievements-default-badges-v2 branch from 2970af6 to bc6cf9e Compare May 23, 2024 14:21
Was informed by the RetroAchievements team that this isn't an option in most emulators, and as the next commits will be to enable default icons, there will always be something to display.
Achievement badges/icons are refactored into the type CustomTextureData::ArraySlice::Level as that is the data type images loaded from the filesystem will be. This includes everything that uses the badges in the Qt UI and OnScreenDisplay, and similarly removes the OSD::Icon type because Level already contains that information.
@LillyJadeKatrin LillyJadeKatrin force-pushed the retroachievements-default-badges-v2 branch from bc6cf9e to fbb6be2 Compare May 23, 2024 14:41
The defaults get loaded in by Dolphin at emulator start, and are used if the badge that would normally be displayed has not for whatever reason been downloaded yet. Badges attached to this PR are placeholders (MayIMilae is designing permanent badges) and reside in Sys\Load\RetroAchievements.
The names attached to the BadgeStatus object are obsolete and unneeded and are removed from everything that uses them. All BadgeStatus references are updated to just Badge.
@AdmiralCurtiss AdmiralCurtiss force-pushed the retroachievements-default-badges-v2 branch from fbb6be2 to 1e9e0cd Compare May 23, 2024 19:29
@AdmiralCurtiss AdmiralCurtiss merged commit f991610 into dolphin-emu:master May 23, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants