-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
RetroAchievements - Default Badges #12778
Conversation
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(); |
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.
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(); |
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.
const AchievementManager::Badge& game_badge = instance.GetGameBadge();
return LoadPNGTexture(level, buffer); | ||
} | ||
|
||
bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::vector<u8> buffer) |
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.
bool LoadPNGTexture(CustomTextureData::ArraySlice::Level* level, const std::vector<u8>& buffer)
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.
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...
Instructions unclear, moved files to Licenses folder :p Kidding, but where should I put these? Resources/RetroAchievements? |
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... |
6660638
to
2970af6
Compare
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! |
I swear someone else pointed this out but I don't see it... but the Also, shouldn't they be |
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. |
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; | ||
} | ||
} |
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.
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?
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))) |
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.
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.
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]); |
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.
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]);
It was me, but I commented on Discord. I'll leave the message here too, for reference:
|
2970af6
to
bc6cf9e
Compare
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.
bc6cf9e
to
fbb6be2
Compare
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.
fbb6be2
to
1e9e0cd
Compare
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.