add mastery placard (#13575)

This commit is contained in:
Jamiras 2022-01-31 08:33:23 -07:00 committed by GitHub
parent 900675ad23
commit c092fa33e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 0 deletions

View File

@ -65,6 +65,7 @@
#include "../performance_counters.h"
#include "../msg_hash.h"
#include "../retroarch.h"
#include "../runtime_file.h"
#include "../core.h"
#include "../core_option_manager.h"
@ -1322,6 +1323,64 @@ static void rc_hash_handle_cd_close_track(void* track_handle)
/* end hooks */
void rcheevos_show_mastery_placard()
{
const settings_t* settings = config_get_ptr();
char title[256];
if (rcheevos_locals.game.mastery_placard_shown)
return;
rcheevos_locals.game.mastery_placard_shown = true;
snprintf(title, sizeof(title),
msg_hash_to_str(rcheevos_locals.hardcore_active ? MSG_CHEEVOS_MASTERED_GAME : MSG_CHEEVOS_COMPLETED_GAME),
rcheevos_locals.game.title);
title[sizeof(title) - 1] = '\0';
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", title);
#if defined (HAVE_GFX_WIDGETS)
if (gfx_widgets_ready())
{
const bool content_runtime_log = settings->bools.content_runtime_log;
const bool content_runtime_log_aggr = settings->bools.content_runtime_log_aggregate;
char msg[128];
size_t len;
len = snprintf(msg, sizeof(msg), "%s", rcheevos_locals.username);
if (len < sizeof(msg) - 12 &&
(content_runtime_log || content_runtime_log_aggr))
{
const char* content_path = path_get(RARCH_PATH_CONTENT);
const char* core_path = path_get(RARCH_PATH_CORE);
runtime_log_t* runtime_log = runtime_log_init(
content_path, core_path,
settings->paths.directory_runtime_log,
settings->paths.directory_playlist,
!content_runtime_log_aggr);
if (runtime_log)
{
const runloop_state_t* runloop_state = runloop_state_get_ptr();
runtime_log_add_runtime_usec(runtime_log,
runloop_state->core_runtime_usec);
len += snprintf(msg + len, sizeof(msg) - len, " | ");
runtime_log_get_runtime_str(runtime_log, msg + len, sizeof(msg) - len);
msg[sizeof(msg) - 1] = '\0';
free(runtime_log);
}
}
gfx_widgets_push_achievement(title, msg, rcheevos_locals.game.badge_name);
}
else
#endif
runloop_msg_queue_push(title, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
static void rcheevos_show_game_placard()
{
char msg[256];
@ -1794,6 +1853,7 @@ bool rcheevos_load(const void *data)
rcheevos_locals.loaded = false;
rcheevos_locals.game.id = -1;
rcheevos_locals.game.console_id = 0;
rcheevos_locals.game.mastery_placard_shown = false;
#ifdef HAVE_THREADS
rcheevos_locals.queued_command = CMD_EVENT_NONE;
#endif

View File

@ -1746,6 +1746,9 @@ static void rcheevos_async_award_achievement_callback(
CHEEVOS_LOG(RCHEEVOS_TAG "Achievement %u: %s\n",
request->id, api_response.response.error_message);
}
if (api_response.achievements_remaining == 0)
rcheevos_show_mastery_placard();
}
rc_api_destroy_award_achievement_response(&api_response);

View File

@ -135,6 +135,7 @@ typedef struct rcheevos_game_info_t
char* title;
char badge_name[16];
char* hash;
bool mastery_placard_shown;
rcheevos_hash_entry_t* hashes;
@ -194,6 +195,8 @@ void rcheevos_begin_load_state(enum rcheevos_load_state state);
int rcheevos_end_load_state(void);
bool rcheevos_load_aborted(void);
void rcheevos_show_mastery_placard(void);
#ifdef HAVE_THREADS
#define CHEEVOS_LOCK(l) do { slock_lock(l); } while (0)
#define CHEEVOS_UNLOCK(l) do { slock_unlock(l); } while (0)

View File

@ -12278,6 +12278,14 @@ MSG_HASH(
MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT,
"A cheat was activated. Achievements Hardcore Mode disabled for the current session."
)
MSG_HASH(
MSG_CHEEVOS_MASTERED_GAME,
"Mastered %s"
)
MSG_HASH(
MSG_CHEEVOS_COMPLETED_GAME,
"Completed %s"
)
MSG_HASH(
MSG_RESAMPLER_QUALITY_LOWEST,
"Lowest"

View File

@ -3174,6 +3174,8 @@ enum msg_hash_enums
MSG_CHEEVOS_LOAD_STATE_PREVENTED_BY_HARDCORE_MODE,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED,
MSG_CHEEVOS_HARDCORE_MODE_DISABLED_CHEAT,
MSG_CHEEVOS_MASTERED_GAME,
MSG_CHEEVOS_COMPLETED_GAME,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HMS,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD_HM,
MENU_ENUM_LABEL_VALUE_TIMEDATE_YMD,