From aa86d7818325ed0c9c0d31169b37f447251186ed Mon Sep 17 00:00:00 2001 From: radius Date: Mon, 30 Apr 2018 16:23:31 -0500 Subject: [PATCH] add quick menu action to pause / resume hardcore mode for current session --- cheevos/cheevos.c | 12 +++++++----- cheevos/cheevos.h | 1 + intl/msg_hash_us.h | 12 ++++++++++++ menu/cbs/menu_cbs_ok.c | 16 ++++++++++++++++ menu/cbs/menu_cbs_sublabel.c | 8 ++++++++ menu/drivers/xmb.c | 4 ++++ menu/menu_displaylist.c | 18 ++++++++++++++++++ menu/menu_driver.h | 2 ++ msg_hash.h | 2 ++ retroarch.c | 2 +- 10 files changed, 71 insertions(+), 6 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 67180efa91..98d5706af2 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -287,6 +287,7 @@ static cheevos_locals_t cheevos_locals = bool cheevos_loaded = false; bool cheevos_hardcore_active = false; +bool cheevos_hardcore_paused = false; int cheats_are_enabled = 0; int cheats_were_enabled = 0; @@ -1546,7 +1547,7 @@ static void cheevos_make_unlock_url(const cheevo_t *cheevo, settings->arrays.cheevos_username, cheevos_locals.token, cheevo->id, - settings->bools.cheevos_hardcore_mode_enable ? 1 : 0 + settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused ? 1 : 0 ); url[url_size - 1] = 0; @@ -1589,7 +1590,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) end = set->cheevos + set->count; - if (settings && settings->bools.cheevos_hardcore_mode_enable) + if (settings && settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused) mode = CHEEVOS_ACTIVE_HARDCORE; for (cheevo = set->cheevos; cheevo < end; cheevo++) @@ -2219,7 +2220,7 @@ bool cheevos_toggle_hardcore_mode(void) return false; /* reset and deinit rewind to avoid cheat the score */ - if (settings->bools.cheevos_hardcore_mode_enable) + if (settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused) { const char *msg = msg_hash_to_str( MSG_CHEEVOS_HARDCORE_MODE_ENABLE); @@ -2420,7 +2421,8 @@ void cheevos_test(void) cheevos_test_cheevo_set(&cheevos_locals.unofficial); if (settings->bools.cheevos_hardcore_mode_enable && - settings->bools.cheevos_leaderboards_enable) + settings->bools.cheevos_leaderboards_enable && + !cheevos_hardcore_paused) cheevos_test_leaderboards(); } } @@ -2827,7 +2829,7 @@ found: const cheevo_t* end = cheevo + cheevos_locals.core.count; int number_of_unlocked = cheevos_locals.core.count; - if (coro->settings->bools.cheevos_hardcore_mode_enable) + if (coro->settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused) mode = CHEEVOS_ACTIVE_HARDCORE; for (; cheevo < end; cheevo++) diff --git a/cheevos/cheevos.h b/cheevos/cheevos.h index ccc0953bc5..45c799dfe3 100644 --- a/cheevos/cheevos.h +++ b/cheevos/cheevos.h @@ -154,6 +154,7 @@ cheevos_console_t cheevos_get_console(void); extern bool cheevos_loaded; extern bool cheevos_hardcore_active; +extern bool cheevos_hardcore_paused; extern int cheats_are_enabled; extern int cheats_were_enabled; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 8bada4ed75..ecba60e6bf 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -214,6 +214,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_LIST, "Achievements" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE, + "Pause Achievements Hardcore Mode" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_RESUME, + "Resume Achievements Hardcore Mode" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_LIST_HARDCORE, "Achievements (Hardcore)" @@ -3696,3 +3704,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_DETECT_CORE_LIST_OK_CURRENT_CORE, "Current core") MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_MENU_SEARCH_CLEAR, "Clear") +MSG_HASH(MENU_ENUM_SUBLABEL_ACHIEVEMENT_PAUSE, + "Pause achievements for current session (This action will enable savestates, cheats, rewind, pause, and slow-motion).") +MSG_HASH(MENU_ENUM_SUBLABEL_ACHIEVEMENT_RESUME, + "Resume achievements for current session (This action will disable savestates, cheats, rewind, pause, and slow-motion and reset the current game).") diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 13bc35f1a5..93a07a9c16 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -67,6 +67,10 @@ #include "../../network/netplay/netplay_discovery.h" #endif +#ifdef HAVE_CHEEVOS +#include "../cheevos/cheevos.h" +#endif + enum { ACTION_OK_LOAD_PRESET = 0, @@ -2634,6 +2638,14 @@ static int action_ok_save_state(const char *path, return generic_action_ok_command(CMD_EVENT_RESUME); } +static int action_ok_toggle_hardcode_mode(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + cheevos_hardcore_paused = !cheevos_hardcore_paused; + generic_action_ok_command(CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE); + return generic_action_ok_command(CMD_EVENT_RESUME); +} + static int action_ok_undo_load_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -4649,6 +4661,10 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CORE_DELETE: BIND_ACTION_OK(cbs, action_ok_core_delete); break; + case MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE: + case MENU_ENUM_LABEL_ACHIEVEMENT_RESUME: + BIND_ACTION_OK(cbs, action_ok_toggle_hardcode_mode); + break; default: return -1; } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 71918beaf5..11bc28a7a1 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -417,6 +417,8 @@ default_sublabel_macro(action_bind_sublabel_video_viewport_custom_y, default_sublabel_macro(action_bind_sublabel_netplay_use_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_USE_MITM_SERVER) default_sublabel_macro(action_bind_sublabel_netplay_mitm_server, MENU_ENUM_SUBLABEL_NETPLAY_MITM_SERVER) default_sublabel_macro(action_bind_sublabel_core_delete, MENU_ENUM_SUBLABEL_CORE_DELETE) +default_sublabel_macro(action_bind_sublabel_pause_hardcode_mode, MENU_ENUM_SUBLABEL_ACHIEVEMENT_PAUSE) +default_sublabel_macro(action_bind_sublabel_resume_hardcode_mode, MENU_ENUM_SUBLABEL_ACHIEVEMENT_RESUME) static int action_bind_sublabel_cheevos_entry( file_list_t *list, @@ -1746,6 +1748,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, break; case MENU_ENUM_LABEL_CORE_DELETE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_delete); + case MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_pause_hardcode_mode); + break; + case MENU_ENUM_LABEL_ACHIEVEMENT_RESUME: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_resume_hardcode_mode); + break; default: case MSG_UNKNOWN: return -1; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 57dffb84b5..c4b9024823 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2313,6 +2313,10 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, return xmb->textures.list[XMB_TEXTURE_CLOSE]; case MENU_SETTING_ACTION_RESET: return xmb->textures.list[XMB_TEXTURE_RELOAD]; + case MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS: + return xmb->textures.list[XMB_TEXTURE_RESUME]; + case MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS: + return xmb->textures.list[XMB_TEXTURE_RUN]; case MENU_SETTING_ACTION: if (xmb->depth == 3) return xmb->textures.list[XMB_TEXTURE_SUBSETTING]; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 83faeb0b5e..2ee3e1656d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2732,6 +2732,24 @@ static int menu_displaylist_parse_load_content_settings( MENU_ENUM_LABEL_NO_ITEMS, MENU_SETTING_NO_ITEM, 0, 0); +#ifdef HAVE_CHEEVOS + if(settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable) + { + if (!cheevos_hardcore_paused) + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE), + msg_hash_to_str(MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE), + MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE, + MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS, 0, 0); + else + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_RESUME), + msg_hash_to_str(MENU_ENUM_LABEL_ACHIEVEMENT_RESUME), + MENU_ENUM_LABEL_ACHIEVEMENT_RESUME, + MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS, 0, 0); + } +#endif + return 0; } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 67f25c8e18..2a5189b012 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -168,6 +168,8 @@ enum menu_settings_type MENU_SETTING_GROUP, MENU_SETTING_SUBGROUP, MENU_SETTING_HORIZONTAL_MENU, + MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS, + MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS, MENU_WIFI, MENU_ROOM, /* diff --git a/msg_hash.h b/msg_hash.h index def5316963..d111f05478 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1447,6 +1447,8 @@ enum msg_hash_enums MENU_LABEL(SYSTEM_INFORMATION), MENU_LABEL(ACHIEVEMENT_LIST), MENU_LABEL(ACHIEVEMENT_LIST_HARDCORE), + MENU_LABEL(ACHIEVEMENT_PAUSE), + MENU_LABEL(ACHIEVEMENT_RESUME), MENU_LABEL(CORE_INFORMATION), MENU_LABEL(CORE_DELETE), diff --git a/retroarch.c b/retroarch.c index 997edd15cf..a1418c9b67 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2988,7 +2988,7 @@ static enum runloop_state runloop_check_state( cheevos_hardcore_active = settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable - && cheevos_loaded; + && cheevos_loaded && !cheevos_hardcore_paused; #ifdef HAVE_CHEEVOS if (!cheevos_hardcore_active)