From 565e916ef915528fc1234205f68747b095359386 Mon Sep 17 00:00:00 2001 From: Sven <40953353+RetroSven@users.noreply.github.com> Date: Sun, 29 Jul 2018 15:55:40 -0400 Subject: [PATCH] add "reload game-specific cheats" option to cheats menu --- intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.c | 4 ++++ intl/msg_hash_us.h | 6 ++++++ menu/cbs/menu_cbs_ok.c | 16 +++++++++++++++- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 5 +++++ msg_hash.h | 1 + 7 files changed, 37 insertions(+), 1 deletion(-) diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index e4eb56b8ed..8b1dda3d77 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1625,6 +1625,8 @@ MSG_HASH(MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM, "cheat_add_new_bottom") MSG_HASH(MENU_ENUM_LABEL_CHEAT_DELETE_ALL, "cheat_delete_all") +MSG_HASH(MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS, + "cheat_reload_cheats") MSG_HASH(MENU_ENUM_LABEL_CHEAT_BIG_ENDIAN, "cheat_big_endian") MSG_HASH(MENU_ENUM_LABEL_CHEAT_MATCH_IDX, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 10b9396111..b30e8076c6 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -2013,6 +2013,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, " "); break; + case MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS: + snprintf(s, len, + " "); + break; case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: snprintf(s, len, " "); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 09d0cb4ebe..97aa84fee4 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2918,6 +2918,10 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_DELETE_ALL, "" ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CHEAT_RELOAD_CHEATS, + "" +) MSG_HASH( MENU_ENUM_SUBLABEL_CHEAT_BIG_ENDIAN, "Big endian : 258 = 0x0102,\nLittle endian : 258 = 0x0201" @@ -4080,6 +4084,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_CHEAT_ADD_NEW_BOTTOM, "Add New Code to Bottom") MSG_HASH(MENU_ENUM_LABEL_VALUE_CHEAT_DELETE_ALL, "Delete All Codes") +MSG_HASH(MENU_ENUM_LABEL_VALUE_CHEAT_RELOAD_CHEATS, + "Reload Game-Specific Cheats") MSG_HASH(MENU_ENUM_LABEL_CHEAT_SEARCH_EXACT_VAL, "Equal to %u (%X)") MSG_HASH(MENU_ENUM_LABEL_CHEAT_SEARCH_LT_VAL, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index ad7957c2d0..9126a3bf30 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2656,7 +2656,18 @@ static int action_ok_audio_run(const char *path, #endif } -static int action_ok_cheat_add_top(const char *path, +static int action_ok_cheat_reload_cheats(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + bool refresh = false ; + cheat_manager_realloc(0, CHEAT_HANDLER_TYPE_EMU); + cheat_manager_load_game_specific_cheats() ; + menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); + menu_driver_ctl(RARCH_MENU_CTL_SET_PREVENT_POPULATE, NULL); + return 0 ; +} + + static int action_ok_cheat_add_top(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { int i; @@ -4564,6 +4575,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: BIND_ACTION_OK(cbs, action_ok_cheat_add_top); break; + case MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS: + BIND_ACTION_OK(cbs, action_ok_cheat_reload_cheats); + break; case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: BIND_ACTION_OK(cbs, action_ok_cheat_add_bottom); break; diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 592ccea299..974634a546 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -227,6 +227,7 @@ default_sublabel_macro(action_bind_sublabel_cheat_create_option, MENU_ default_sublabel_macro(action_bind_sublabel_cheat_delete_option, MENU_ENUM_SUBLABEL_CHEAT_DELETE_OPTION) default_sublabel_macro(action_bind_sublabel_cheat_add_new_top, MENU_ENUM_SUBLABEL_CHEAT_ADD_NEW_TOP) default_sublabel_macro(action_bind_sublabel_cheat_add_new_bottom, MENU_ENUM_SUBLABEL_CHEAT_ADD_NEW_BOTTOM) +default_sublabel_macro(action_bind_sublabel_cheat_reload_cheats, MENU_ENUM_SUBLABEL_CHEAT_RELOAD_CHEATS) default_sublabel_macro(action_bind_sublabel_cheat_address_bit_position, MENU_ENUM_SUBLABEL_CHEAT_ADDRESS_BIT_POSITION) default_sublabel_macro(action_bind_sublabel_cheat_delete_all, MENU_ENUM_SUBLABEL_CHEAT_DELETE_ALL) default_sublabel_macro(action_bind_sublabel_libretro_log_level, MENU_ENUM_SUBLABEL_LIBRETRO_LOG_LEVEL) @@ -1451,6 +1452,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CHEAT_ADD_NEW_TOP: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cheat_add_new_top); break; + case MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cheat_reload_cheats); + break; case MENU_ENUM_LABEL_CHEAT_ADD_NEW_BOTTOM: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_cheat_add_new_bottom); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index ec13de8fa1..cd1d106d79 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3179,6 +3179,11 @@ static int menu_displaylist_parse_options_cheats( msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_LOAD_APPEND), MENU_ENUM_LABEL_CHEAT_FILE_LOAD_APPEND, MENU_SETTING_ACTION, 0, 0); + menu_entries_append_enum(info->list, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CHEAT_RELOAD_CHEATS), + msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS), + MENU_ENUM_LABEL_CHEAT_RELOAD_CHEATS, + MENU_SETTING_ACTION, 0, 0); menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CHEAT_FILE_SAVE_AS), msg_hash_to_str(MENU_ENUM_LABEL_CHEAT_FILE_SAVE_AS), diff --git a/msg_hash.h b/msg_hash.h index d0ba76205e..4d061841fe 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1242,6 +1242,7 @@ enum msg_hash_enums MENU_LABEL(CHEAT_ADD_NEW_TOP), MENU_LABEL(CHEAT_ADD_NEW_BOTTOM), MENU_LABEL(CHEAT_DELETE_ALL), + MENU_LABEL(CHEAT_RELOAD_CHEATS), MENU_LABEL(CHEAT_BIG_ENDIAN), MENU_LABEL(CHEAT_MATCH_IDX), MENU_LABEL(CHEAT_MATCH),