Skip to content

Commit

Permalink
add rarity and points to achievement unlock widget
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Jun 11, 2024
1 parent 6e057ab commit ff18e0e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
25 changes: 23 additions & 2 deletions cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,29 @@ static void rcheevos_award_achievement(const rc_client_achievement_t* cheevo)
#if defined(HAVE_GFX_WIDGETS)
if (gfx_widgets_ready())
{
gfx_widgets_push_achievement(msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED),
cheevo->title, cheevo->badge_name);
char title[128], subtitle[96];
float rarity = rc_client_get_hardcore_enabled(rcheevos_locals.client) ?
cheevo->rarity_hardcore : cheevo->rarity;

if (rarity >= 10.0)
{
snprintf(title, sizeof(title), "%s - %0.2f%%",
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), rarity);
}
else if (rarity > 0.0)
{
snprintf(title, sizeof(title), "%s - %0.2f%%",
msg_hash_to_str(MSG_RARE_ACHIEVEMENT_UNLOCKED), rarity);
}
else
{
snprintf(title, sizeof(title), "%s",
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED));
}

snprintf(subtitle, sizeof(subtitle), "%s (%d)", cheevo->title, cheevo->points);

gfx_widgets_push_achievement(title, subtitle, cheevo->badge_name);
}
else
#endif
Expand Down
4 changes: 4 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -14975,6 +14975,10 @@ MSG_HASH(
MSG_ACHIEVEMENT_UNLOCKED,
"Achievement Unlocked"
)
MSG_HASH(
MSG_RARE_ACHIEVEMENT_UNLOCKED,
"Rare Achievement Unlocked"
)
MSG_HASH(
MSG_LEADERBOARD_STARTED,
"Leaderboard attempt started"
Expand Down
1 change: 1 addition & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ enum msg_hash_enums
MSG_TAKING_SCREENSHOT,
MSG_SCREENSHOT_SAVED,
MSG_ACHIEVEMENT_UNLOCKED,
MSG_RARE_ACHIEVEMENT_UNLOCKED,
MSG_LEADERBOARD_STARTED,
MSG_LEADERBOARD_FAILED,
MSG_LEADERBOARD_SUBMISSION,
Expand Down

0 comments on commit ff18e0e

Please sign in to comment.