Achievement list: Support the more detailed categorization, RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS

This commit is contained in:
Henrik Rydgård 2023-08-06 15:43:33 +02:00
parent 63cfe28f61
commit cd0f2eb401
3 changed files with 31 additions and 44 deletions

View File

@ -111,7 +111,7 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
for (int i = 0; i < 8; i++) {
FrameTimeData data = ctx->GetDrawContext()->GetFrameTimeData(6 + i);
if (data.frameBegin == 0.0) {
snprintf(statBuf, sizeof(statBuf), "(Frame timing collection not supported on this backend)");
snprintf(statBuf, sizeof(statBuf), "(No frame time data)");
} else {
double fenceLatency_s = data.afterFenceWait - data.frameBegin;
double submitLatency_s = data.firstSubmit - data.frameBegin;

View File

@ -77,6 +77,19 @@ void RetroAchievementsListScreen::CreateTabs() {
#endif
}
inline const char *AchievementBucketTitle(int bucketType) {
switch (bucketType) {
case RC_CLIENT_ACHIEVEMENT_BUCKET_LOCKED: return "Locked achievements";
case RC_CLIENT_ACHIEVEMENT_BUCKET_UNLOCKED: return "Unlocked achievements";
case RC_CLIENT_ACHIEVEMENT_BUCKET_UNSUPPORTED: return "Unsupported achievements";
case RC_CLIENT_ACHIEVEMENT_BUCKET_UNOFFICIAL: return "Unofficial achievements";
case RC_CLIENT_ACHIEVEMENT_BUCKET_RECENTLY_UNLOCKED: return "Recently unlocked achievements";
case RC_CLIENT_ACHIEVEMENT_BUCKET_ACTIVE_CHALLENGE: return "Achievements with active challenges";
case RC_CLIENT_ACHIEVEMENT_BUCKET_ALMOST_THERE: return "Almost completed achievements";
default: return "?";
}
}
void RetroAchievementsListScreen::CreateAchievementsTab(UI::ViewGroup *achievements) {
auto di = GetI18NCategory(I18NCat::DIALOG);
auto ac = GetI18NCategory(I18NCat::ACHIEVEMENTS);
@ -88,58 +101,28 @@ void RetroAchievementsListScreen::CreateAchievementsTab(UI::ViewGroup *achieveme
filter = RC_CLIENT_ACHIEVEMENT_CATEGORY_CORE_AND_UNOFFICIAL;
}
rc_client_achievement_list_t *list = rc_client_create_achievement_list(Achievements::GetClient(),
filter, RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_LOCK_STATE);
std::vector<const rc_client_achievement_t *> unlockedAchievements;
std::vector<const rc_client_achievement_t *> lockedAchievements;
std::vector<const rc_client_achievement_t *> otherAchievements;
for (uint32_t i = 0; i < list->num_buckets; i++) {
const rc_client_achievement_bucket_t &bucket = list->buckets[i];
for (uint32_t j = 0; j < bucket.num_achievements; j++) {
switch (bucket.bucket_type) {
case RC_CLIENT_ACHIEVEMENT_BUCKET_LOCKED:
lockedAchievements.push_back(bucket.achievements[j]);
break;
case RC_CLIENT_ACHIEVEMENT_BUCKET_UNLOCKED:
unlockedAchievements.push_back(bucket.achievements[j]);
break;
default:
otherAchievements.push_back(bucket.achievements[j]);
break;
}
}
}
achievements->Add(new ItemHeader(ac->T("Achievements")));
achievements->Add(new GameAchievementSummaryView());
if (Achievements::EncoreModeActive()) {
achievements->Add(new NoticeView(NoticeLevel::WARN, ac->T("In Encore mode - unlock state may not be accurate"), ""));
}
CollapsibleSection *unlocked = new CollapsibleSection(StringFromFormat("%s (%d)", ac->T("Unlocked achievements"), (int)unlockedAchievements.size()));
unlocked->SetSpacing(2.0f);
for (auto &achievement : unlockedAchievements) {
unlocked->Add(new AchievementView(achievement));
}
achievements->Add(unlocked);
rc_client_achievement_list_t *list = rc_client_create_achievement_list(Achievements::GetClient(),
filter, RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS);
CollapsibleSection *locked = new CollapsibleSection(StringFromFormat("%s (%d)", ac->T("Locked achievements"), (int)lockedAchievements.size()));
unlocked->SetSpacing(2.0f);
for (auto &achievement : lockedAchievements) {
locked->Add(new AchievementView(achievement));
for (uint32_t i = 0; i < list->num_buckets; i++) {
const rc_client_achievement_bucket_t &bucket = list->buckets[i];
if (!bucket.num_achievements) {
continue;
}
std::string title = StringFromFormat("%s (%d)", ac->T(AchievementBucketTitle(bucket.bucket_type)), bucket.num_achievements);
CollapsibleSection *section = achievements->Add(new CollapsibleSection(title));
section->SetSpacing(2.0f);
for (uint32_t j = 0; j < bucket.num_achievements; j++) {
section->Add(new AchievementView(bucket.achievements[j]));
}
}
achievements->Add(locked);
CollapsibleSection *other = new CollapsibleSection(StringFromFormat("%s (%d)", ac->T("Other achievements"), (int)otherAchievements.size()));
unlocked->SetSpacing(2.0f);
for (auto &achievement : otherAchievements) {
other->Add(new AchievementView(achievement));
}
achievements->Add(other);
}
void RetroAchievementsListScreen::CreateLeaderboardsTab(UI::ViewGroup *viewGroup) {

View File

@ -32,6 +32,8 @@ Achievement progress = Achievement progress
Achievements = Achievements
Achievements enabled = Achievements enabled
Achievements are disabled = Achievements are disabled
Achievements with active challenges = Achievements with active challenges
Almost completed achievements = Almost completed achievements
Can't log in to RetroAchievements right now = Can't log in to RetroAchievements right now
Challenge indicator = Challenge indicator
Challenge Mode = Challenge Mode
@ -55,6 +57,7 @@ Log bad memory accesses = Log bad memory accesses
Mastered %1 = Mastered %1
Around me = Around me
Notifications = Notifications
Recently unlocked achievements = Recently unlocked achievements
Register on www.retroachievements.org = Register on www.retroachievements.org
RetroAchievements are not available for this game = RetroAchievements are not available for this game
RetroAchievements website = RetroAchievements website
@ -70,6 +73,7 @@ This feature is not available in Challenge Mode = This feature is not available
This game has no achievements = This game has no achievements
Top players = Top players
Unlocked achievements = Unlocked achievements
Unsupported achievements = Unsupported achievements
Unofficial achievements = Unofficial achievements
[Audio]