From 2253e4c23685950589dcf6c6614045c1865c0c2f Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 8 Nov 2015 16:42:23 -0200 Subject: [PATCH] added cheevos_get_description to get a cheevo's description given its index --- cheevos.c | 26 +++++++++++++++++++++----- cheevos.h | 2 ++ menu/drivers/menu_generic.c | 9 ++++++--- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cheevos.c b/cheevos.c index 4beb836af8..d0572a6eab 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1891,9 +1891,9 @@ int cheevos_load(const struct retro_game_info *info) void cheevos_populate_menu(menu_displaylist_info_t *info) { unsigned i; - const cheevo_t *end = NULL; - cheevo_t *cheevo = NULL; - settings_t *settings = config_get_ptr(); + const cheevo_t *end; + cheevo_t *cheevo; + settings_t *settings = config_get_ptr(); menu_entries_push(info->list, "Unlocked Achievements:", "", MENU_SETTINGS_CHEEVOS_NONE, 0, 0); menu_entries_push(info->list, "", "", MENU_SETTINGS_CHEEVOS_NONE, 0, 0); @@ -1912,7 +1912,7 @@ void cheevos_populate_menu(menu_displaylist_info_t *info) cheevo = cheevos_locals.unofficial.cheevos; end = cheevos_locals.unofficial.cheevos + cheevos_locals.unofficial.count; - for (i = 0; cheevo < end; i++, cheevo++) + for (i = cheevos_locals.core.count; cheevo < end; i++, cheevo++) { if (!cheevo->active) menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CHEEVOS_START + i, 0, 0); @@ -1937,10 +1937,26 @@ void cheevos_populate_menu(menu_displaylist_info_t *info) cheevo = cheevos_locals.unofficial.cheevos; end = cheevos_locals.unofficial.cheevos + cheevos_locals.unofficial.count; - for (i = 0; cheevo < end; i++, cheevo++) + for (i = cheevos_locals.core.count; cheevo < end; i++, cheevo++) { if (cheevo->active) menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CHEEVOS_START + i, 0, 0); } } } + +void cheevos_get_description(unsigned cheevo_ndx, char *str, size_t len) +{ + cheevo_t *cheevos; + + if (cheevo_ndx >= cheevos_locals.core.count) + { + cheevos = cheevos_locals.unofficial.cheevos; + cheevo_ndx -= cheevos_locals.unofficial.count; + } + else + cheevos = cheevos_locals.core.cheevos; + + strncpy(str, cheevos[cheevo_ndx].description, len); + str[len - 1] = 0; +} diff --git a/cheevos.h b/cheevos.h index 577a0b415c..0bfe5c47d3 100644 --- a/cheevos.h +++ b/cheevos.h @@ -34,6 +34,8 @@ int cheevos_load(const struct retro_game_info *info); void cheevos_populate_menu(menu_displaylist_info_t *info); +void cheevos_get_description(unsigned cheevo_ndx, char *str, size_t len); + void cheevos_test(void); void cheevos_unload(void); diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index a3de2776c7..8d98aad662 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -31,6 +31,7 @@ #include "../../performance.h" #include "../../input/input_autodetect.h" #include "../../input/input_common.h" +#include "../../cheevos.h" #include "../../runloop.h" @@ -136,11 +137,13 @@ static int action_iterate_help(char *s, size_t len, const char *label) ); } break; + +#ifdef HAVE_CHEEVOS case MENU_HELP_CHEEVOS_DESCRIPTION: - RARCH_LOG("id is: %d\n", menu->help_screen_id); - menu_hash_get_help(MENU_LABEL_VALUE_WHAT_IS_A_CORE_DESC, - s, len); + cheevos_get_description(menu->help_screen_id, s, len); break; +#endif + case MENU_HELP_WHAT_IS_A_CORE: menu_hash_get_help(MENU_LABEL_VALUE_WHAT_IS_A_CORE_DESC, s, len);