add quick menu action to pause / resume hardcore mode for current session

This commit is contained in:
radius 2018-04-30 16:23:31 -05:00
parent 1037093d45
commit aa86d78183
10 changed files with 71 additions and 6 deletions

View File

@ -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++)

View File

@ -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;

View File

@ -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).")

View File

@ -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;
}

View File

@ -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;

View File

@ -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];

View File

@ -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;
}

View File

@ -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,
/*

View File

@ -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),

View File

@ -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)