Skip to content

Commit

Permalink
Merge pull request #17855 from hrydgard/more-achievement-ui-fixes
Browse files Browse the repository at this point in the history
Achievement list: Support the more detailed categorization.
  • Loading branch information
hrydgard authored Aug 6, 2023
2 parents e9431d0 + cd0f2eb commit c6c79a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 44 deletions.
2 changes: 1 addition & 1 deletion UI/DebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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;
Expand Down
69 changes: 26 additions & 43 deletions UI/RetroAchievementScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

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));
}
achievements->Add(locked);
rc_client_achievement_list_t *list = rc_client_create_achievement_list(Achievements::GetClient(),
filter, RC_CLIENT_ACHIEVEMENT_LIST_GROUPING_PROGRESS);

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));
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(other);
}

void RetroAchievementsListScreen::CreateLeaderboardsTab(UI::ViewGroup *viewGroup) {
Expand Down
4 changes: 4 additions & 0 deletions assets/lang/en_US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit c6c79a9

Please sign in to comment.