diff --git a/menu/disp/shared.h b/menu/disp/shared.h index 68faaf6002..6e93695356 100644 --- a/menu/disp/shared.h +++ b/menu/disp/shared.h @@ -68,6 +68,8 @@ static void get_title(const char *label, const char *dir, snprintf(title, sizeof_title, "SHADER %s", dir); else if (!strcmp(label, "video_shader_preset")) snprintf(title, sizeof_title, "SHADER PRESET %s", dir); + else if (!strcmp(label, "cheat_file_load")) + snprintf(title, sizeof_title, "CHEAT FILE %s", dir); else if (menu_type == MENU_SETTINGS_CUSTOM_VIEWPORT || !strcmp(label, "custom_viewport_2") || !strcmp(label, "help") || diff --git a/menu/menu_common.h b/menu/menu_common.h index ea4980cf29..e6e7424638 100644 --- a/menu/menu_common.h +++ b/menu/menu_common.h @@ -74,6 +74,7 @@ typedef enum MENU_FILE_SHADER, MENU_FILE_VIDEOFILTER, MENU_FILE_AUDIOFILTER, + MENU_FILE_CHEAT, MENU_FILE_OVERLAY, MENU_FILE_FONT, MENU_FILE_CONFIG, diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index cd8fd0100a..4e7f83ac0d 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -311,6 +311,40 @@ static int action_ok_shader_pass_load(const char *path, #endif } +static int action_ok_cheat_file(const char *path, + const char *label, unsigned type, size_t idx) +{ + if (!driver.menu) + return -1; + + menu_list_push_stack_refresh( + driver.menu->menu_list, + g_settings.cheat_database, + "cheat_file_load", + type, + driver.menu->selection_ptr); + + return 0; +} + +static int action_ok_cheat_file_load(const char *path, + const char *label, unsigned type, size_t idx) +{ + const char *menu_path = NULL; + char shader_path[PATH_MAX]; + if (!driver.menu) + return -1; + + (void)shader_path; + (void)menu_path; + menu_list_get_last_stack(driver.menu->menu_list, &menu_path, NULL, + NULL); + + menu_list_flush_stack_by_needle(driver.menu->menu_list, "core_cheat_options"); + + return 0; +} + static int action_ok_shader_preset_load(const char *path, const char *label, unsigned type, size_t idx) { @@ -1871,6 +1905,8 @@ static int deferred_push_core_cheat_options(void *data, void *userdata, return -1; menu_list_clear(list); + menu_list_push(list, "Cheat File Load", "cheat_file_load", + MENU_SETTING_ACTION, 0); menu_list_push(list, "Cheat Passes", "cheat_num_passes", 0, 0); menu_list_push(list, "Apply Cheat Changes", "cheat_apply_changes", @@ -2130,6 +2166,21 @@ static int deferred_push_audio_dsp_plugin(void *data, void *userdata, return 0; } +static int deferred_push_cheat_file_load(void *data, void *userdata, + const char *path, const char *label, unsigned type) +{ + file_list_t *list = (file_list_t*)data; + file_list_t *menu_list = (file_list_t*)userdata; + + if (!list || !menu_list) + return -1; + + menu_entries_parse_list(list, menu_list, path, label, + type, MENU_FILE_CHEAT, "cht"); + + return 0; +} + static int deferred_push_input_overlay(void *data, void *userdata, const char *path, const char *label, unsigned type) { @@ -2269,6 +2320,9 @@ static int menu_entries_cbs_init_bind_ok_first(menu_file_list_cbs_t *cbs, case MENU_FILE_CONTENTLIST_ENTRY: cbs->action_ok = action_ok_contentlist_entry; break; + case MENU_FILE_CHEAT: + cbs->action_ok = action_ok_cheat_file_load; + break; case MENU_FILE_SHADER_PRESET: cbs->action_ok = action_ok_shader_preset_load; break; @@ -2398,6 +2452,8 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs, cbs->action_ok = action_ok_shader_pass; else if (!strcmp(label, "video_shader_preset")) cbs->action_ok = action_ok_shader_preset; + else if (!strcmp(label, "cheat_file_load")) + cbs->action_ok = action_ok_cheat_file; else if (!strcmp(label, "video_shader_parameters")) cbs->action_ok = action_ok_shader_parameters; else if (!strcmp(label, "video_shader_preset_parameters")) @@ -2525,6 +2581,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs, if (!strcmp(label, "history_list")) cbs->action_deferred_push = deferred_push_history_list; + else if (!strcmp(label, "cheat_file_load")) + cbs->action_deferred_push = deferred_push_cheat_file_load; else if (!strcmp(label, "content_actions")) cbs->action_deferred_push = deferred_push_content_actions; else if (!strcmp(label, "Shader Options"))