diff --git a/cheevos.c b/cheevos.c index ff484de6c4..c824efab23 100644 --- a/cheevos.c +++ b/cheevos.c @@ -28,6 +28,7 @@ #include "configuration.h" #include "performance.h" #include "runloop.h" +#include "menu/menu.h" enum { @@ -1880,3 +1881,55 @@ int cheevos_load(const struct retro_game_info *info) rarch_main_msg_queue_push("Error loading achievements", 0, 5 * 60, false); return -1; } + +void cheevos_populate_menu(menu_displaylist_info_t *info) +{ + const cheevo_t *end; + cheevo_t *cheevo; + + RARCH_LOG("CHEEVOS POPULATING MENU"); + + menu_entries_push(info->list, "", "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + menu_entries_push(info->list, "Unlocked Achievements:", "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + + for (cheevo = cheevos_locals.core.cheevos, end = cheevos_locals.core.cheevos + cheevos_locals.core.count; cheevo < end; cheevo++) + { + if (cheevo->active) + { + menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + } + } + + if (config_get_ptr()->cheevos.test_unofficial) + { + for (cheevo = cheevos_locals.unofficial.cheevos, end = cheevos_locals.unofficial.cheevos + cheevos_locals.unofficial.count; cheevo < end; cheevo++) + { + if (cheevo->active) + { + menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + } + } + } + + menu_entries_push(info->list, "", "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + menu_entries_push(info->list, "Locked Achievements:", "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + + for (cheevo = cheevos_locals.core.cheevos, end = cheevos_locals.core.cheevos + cheevos_locals.core.count; cheevo < end; cheevo++) + { + if (!cheevo->active) + { + menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + } + } + + if (config_get_ptr()->cheevos.test_unofficial) + { + for (cheevo = cheevos_locals.unofficial.cheevos, end = cheevos_locals.unofficial.cheevos + cheevos_locals.unofficial.count; cheevo < end; cheevo++) + { + if (!cheevo->active) + { + menu_entries_push(info->list, cheevo->title, cheevo->description, MENU_SETTINGS_CORE_INFO_NONE, 0, 0); + } + } + } +} diff --git a/cheevos.h b/cheevos.h index f4d3632027..577a0b415c 100644 --- a/cheevos.h +++ b/cheevos.h @@ -20,6 +20,7 @@ #include #include "libretro.h" +#include "menu/menu_entries.h" typedef struct { @@ -31,6 +32,8 @@ extern cheevos_globals_t cheevos_globals; int cheevos_load(const struct retro_game_info *info); +void cheevos_populate_menu(menu_displaylist_info_t *info); + void cheevos_test(void); void cheevos_unload(void); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8184b099aa..5e0da9c648 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -36,6 +36,7 @@ #include "../input/input_common.h" #include "../dir_list_special.h" #include "../string_list_special.h" +#include "../cheevos.h" #ifdef __linux__ #include "../frontend/drivers/platform_linux.h" @@ -386,49 +387,6 @@ static int menu_displaylist_parse_debug_info(menu_displaylist_info_t *info) return 0; } -static int menu_displaylist_parse_achievement_list(menu_displaylist_info_t *info) -{ - char tmp[PATH_MAX_LENGTH]; - - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - bool ret; - - /* do these on a loop, process your data and add them to the list */ - - /* presentation idea 1: multiline */ - menu_entries_push(info->list, "Example Achievement 1 Name", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "- Example Achievement 1 Description", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "- Example Achievement 1 Status", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - - menu_entries_push(info->list, "", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - /* presentation idea 2: single line, ideally the description would be shown by pressing select */ - menu_entries_push(info->list, "Locked Achievements:", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "Example Achievement 2 Name", "Description", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "Example Achievement 3 Name", "Description", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "Unlocked Achievements:", "", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - menu_entries_push(info->list, "Example Achievement 4 Name", "Description", - MENU_SETTINGS_CORE_INFO_NONE, 0, 0); - - /* it would be cool to be able to show images per-list item (that would also allow showing boxart - for a list item in the future), it would make this whole thing nicer - */ - - return 0; -} - - static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) { int controller; @@ -2977,11 +2935,15 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) info->need_push = true; info->need_refresh = true; break; + +#ifdef HAVE_CHEEVOS case DISPLAYLIST_ACHIEVEMENT_LIST: - menu_displaylist_parse_achievement_list(info); + cheevos_populate_menu(info); info->need_push = true; info->need_refresh = true; break; +#endif + case DISPLAYLIST_CORES_SUPPORTED: case DISPLAYLIST_CORES_COLLECTION_SUPPORTED: info->need_sort = true; diff --git a/menu/menu_entries.h b/menu/menu_entries.h index 14ac995be6..e448616cc4 100644 --- a/menu/menu_entries.h +++ b/menu/menu_entries.h @@ -23,6 +23,7 @@ #include "menu_setting.h" #include "menu_entry.h" +#include "menu_displaylist.h" #ifdef __cplusplus extern "C" {