diff --git a/config.def.h b/config.def.h index e5d8741bb6..0797e7dd6e 100644 --- a/config.def.h +++ b/config.def.h @@ -605,6 +605,9 @@ static const bool default_auto_shaders_enable = true; static const bool default_sort_savefiles_enable = false; static const bool default_sort_savestates_enable = false; +static const bool default_sort_savefiles_by_content_enable = false; +static const bool default_sort_savestates_by_content_enable = false; +static const bool default_sort_screenshots_by_content_enable = false; static const bool default_savestates_in_content_dir = false; static const bool default_savefiles_in_content_dir = false; diff --git a/configuration.c b/configuration.c index f534887137..752d125b24 100644 --- a/configuration.c +++ b/configuration.c @@ -1702,6 +1702,9 @@ static struct config_bool_setting *populate_settings_bool( SETTING_BOOL("scan_without_core_match", &settings->bools.scan_without_core_match, true, DEFAULT_SCAN_WITHOUT_CORE_MATCH, false); SETTING_BOOL("sort_savefiles_enable", &settings->bools.sort_savefiles_enable, true, default_sort_savefiles_enable, false); SETTING_BOOL("sort_savestates_enable", &settings->bools.sort_savestates_enable, true, default_sort_savestates_enable, false); + SETTING_BOOL("sort_savefiles_by_content_enable", &settings->bools.sort_savefiles_by_content_enable, true, default_sort_savefiles_by_content_enable, false); + SETTING_BOOL("sort_savestates_by_content_enable", &settings->bools.sort_savestates_by_content_enable, true, default_sort_savestates_by_content_enable, false); + SETTING_BOOL("sort_screenshots_by_content_enable", &settings->bools.sort_screenshots_by_content_enable, true, default_sort_screenshots_by_content_enable, false); SETTING_BOOL("config_save_on_exit", &settings->bools.config_save_on_exit, true, DEFAULT_CONFIG_SAVE_ON_EXIT, false); SETTING_BOOL("show_hidden_files", &settings->bools.show_hidden_files, true, DEFAULT_SHOW_HIDDEN_FILES, false); SETTING_BOOL("input_autodetect_enable", &settings->bools.input_autodetect_enable, true, input_autodetect_enable, false); diff --git a/configuration.h b/configuration.h index 61f3fd6e2d..94877a694f 100644 --- a/configuration.h +++ b/configuration.h @@ -730,6 +730,9 @@ typedef struct settings bool sort_savefiles_enable; bool sort_savestates_enable; + bool sort_savefiles_by_content_enable; + bool sort_savestates_by_content_enable; + bool sort_screenshots_by_content_enable; bool config_save_on_exit; bool show_hidden_files; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index d3ba039514..9edf8d3b17 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -2646,6 +2646,18 @@ MSG_HASH( MENU_ENUM_LABEL_SORT_SAVESTATES_ENABLE, "sort_savestates_enable" ) +MSG_HASH( + MENU_ENUM_LABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE, + "sort_savefiles_by_content_enable" + ) +MSG_HASH( + MENU_ENUM_LABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE, + "sort_savestates_by_content_enable" + ) +MSG_HASH( + MENU_ENUM_LABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE, + "sort_screenshots_by_content_enable" + ) MSG_HASH( MENU_ENUM_LABEL_SAVEFILES_IN_CONTENT_DIR_ENABLE, "savefiles_in_content_dir_enable" diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index 4aba897a6f..dd3895d9c4 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -284,6 +284,18 @@ int msg_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Sort save files in folders \n" "named after the libretro core used."); break; + case MENU_ENUM_LABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE: + snprintf(s, len, "Sort save states in folders named \n" + "after the folder in which the content lives."); + break; + case MENU_ENUM_LABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE: + snprintf(s, len, "Sort save files in folders named \n" + "after the folder in which the content lives."); + break; + case MENU_ENUM_LABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE: + snprintf(s, len, "Sort screenshots in folders named \n" + "after the folder in which the content lives."); + break; case MENU_ENUM_LABEL_RESUME_CONTENT: snprintf(s, len, "Exits from the menu and returns back \n" "to the content."); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index f68fd02e85..b6c71458d6 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2814,7 +2814,7 @@ MSG_HASH( MSG_HASH( MENU_ENUM_LABEL_VALUE_SORT_SAVEFILES_ENABLE, - "Sort Saves into Folders" + "Sort Saves into Folders by Core Name" ) MSG_HASH( MENU_ENUM_SUBLABEL_SORT_SAVEFILES_ENABLE, @@ -2822,12 +2822,28 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SORT_SAVESTATES_ENABLE, - "Sort Save States into Folders" + "Sort Save States into Folders by Core Name" ) MSG_HASH( MENU_ENUM_SUBLABEL_SORT_SAVESTATES_ENABLE, "Sort save states in folders named after the core used." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SORT_SAVEFILES_BY_CONTENT_ENABLE, + "Sort Saves into Folders by Content Directory" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE, + "Sort save files into folders named after the directory in which the content is located." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SORT_SAVESTATES_BY_CONTENT_ENABLE, + "Sort Save States into Folders by Content Directory" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE, + "Sort save states in folders named after the directory in which the content is located." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_BLOCK_SRAM_OVERWRITE, "Don't Overwrite SaveRAM on Loading Save State" @@ -2892,6 +2908,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_SAVESTATE_FILE_COMPRESSION, "Write save state files in an archived format. Dramatically reduces file size at the expense of increased saving/loading times." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_SORT_SCREENSHOTS_BY_CONTENT_ENABLE, + "Sort Screenshots into Folders by Content Directory" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE, + "Sort screenshots in folders named after the directory in which the content is located." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_SAVEFILES_IN_CONTENT_DIR_ENABLE, "Write Saves to Content Directory" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 94deec30fd..aae0f2fa60 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -561,6 +561,9 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_scan_directory, MENU_ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_video_swap_interval, MENU_ENUM_SUBLABEL_VIDEO_SWAP_INTERVAL) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savefiles_enable, MENU_ENUM_SUBLABEL_SORT_SAVEFILES_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savestates_enable, MENU_ENUM_SUBLABEL_SORT_SAVESTATES_ENABLE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savefiles_by_content_enable, MENU_ENUM_SUBLABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_savestates_by_content_enable, MENU_ENUM_SUBLABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_sort_screenshots_by_content_enable, MENU_ENUM_SUBLABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_core_updater_buildbot_url, MENU_ENUM_SUBLABEL_CORE_UPDATER_BUILDBOT_URL) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_physical_inputs, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_overlay_show_physical_inputs_port, MENU_ENUM_SUBLABEL_INPUT_OVERLAY_SHOW_PHYSICAL_INPUTS_PORT) @@ -2518,6 +2521,15 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_SORT_SAVESTATES_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sort_savestates_enable); break; + case MENU_ENUM_LABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sort_savefiles_by_content_enable); + break; + case MENU_ENUM_LABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sort_savestates_by_content_enable); + break; + case MENU_ENUM_LABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_sort_screenshots_by_content_enable); + break; case MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_video_swap_interval); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 213cc9262e..5599e4bcf3 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7943,6 +7943,8 @@ unsigned menu_displaylist_build_list( menu_displaylist_build_info_t build_list[] = { {MENU_ENUM_LABEL_SORT_SAVEFILES_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SORT_SAVESTATES_ENABLE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_BLOCK_SRAM_OVERWRITE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_AUTOSAVE_INTERVAL, PARSE_ONLY_UINT}, {MENU_ENUM_LABEL_SAVESTATE_AUTO_INDEX, PARSE_ONLY_BOOL}, @@ -7951,6 +7953,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_SAVESTATE_THUMBNAIL_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SAVE_FILE_COMPRESSION, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SAVESTATE_FILE_COMPRESSION, PARSE_ONLY_BOOL}, + {MENU_ENUM_LABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SAVEFILES_IN_CONTENT_DIR_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SAVESTATES_IN_CONTENT_DIR_ENABLE, PARSE_ONLY_BOOL}, {MENU_ENUM_LABEL_SYSTEMFILES_IN_CONTENT_DIR_ENABLE, PARSE_ONLY_BOOL}, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1be994469f..7ad9063576 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9086,7 +9086,7 @@ static bool setting_append_list( case SETTINGS_LIST_SAVING: { uint8_t i; - struct bool_entry bool_entries[11]; + struct bool_entry bool_entries[14]; START_GROUP(list, list_info, &group_info, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SAVING_SETTINGS), parent_group); parent_group = msg_hash_to_str(MENU_ENUM_LABEL_SAVING_SETTINGS); @@ -9106,60 +9106,78 @@ static bool setting_append_list( bool_entries[1].default_value = default_sort_savestates_enable; bool_entries[1].flags = SD_FLAG_ADVANCED; - bool_entries[2].target = &settings->bools.block_sram_overwrite; - bool_entries[2].name_enum_idx = MENU_ENUM_LABEL_BLOCK_SRAM_OVERWRITE; - bool_entries[2].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_BLOCK_SRAM_OVERWRITE; - bool_entries[2].default_value = DEFAULT_BLOCK_SRAM_OVERWRITE; - bool_entries[2].flags = SD_FLAG_NONE; + bool_entries[2].target = &settings->bools.sort_savefiles_by_content_enable; + bool_entries[2].name_enum_idx = MENU_ENUM_LABEL_SORT_SAVEFILES_BY_CONTENT_ENABLE; + bool_entries[2].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SORT_SAVEFILES_BY_CONTENT_ENABLE; + bool_entries[2].default_value = default_sort_savefiles_by_content_enable; + bool_entries[2].flags = SD_FLAG_ADVANCED; - bool_entries[3].target = &settings->bools.savestate_auto_index; - bool_entries[3].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_INDEX; - bool_entries[3].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_INDEX; - bool_entries[3].default_value = savestate_auto_index; - bool_entries[3].flags = SD_FLAG_NONE; + bool_entries[3].target = &settings->bools.sort_savestates_by_content_enable; + bool_entries[3].name_enum_idx = MENU_ENUM_LABEL_SORT_SAVESTATES_BY_CONTENT_ENABLE; + bool_entries[3].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SORT_SAVESTATES_BY_CONTENT_ENABLE; + bool_entries[3].default_value = default_sort_savestates_by_content_enable; + bool_entries[3].flags = SD_FLAG_ADVANCED; - bool_entries[4].target = &settings->bools.savestate_auto_save; - bool_entries[4].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_SAVE; - bool_entries[4].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE; - bool_entries[4].default_value = savestate_auto_save; - bool_entries[4].flags = SD_FLAG_NONE; + bool_entries[4].target = &settings->bools.sort_screenshots_by_content_enable; + bool_entries[4].name_enum_idx = MENU_ENUM_LABEL_SORT_SCREENSHOTS_BY_CONTENT_ENABLE; + bool_entries[4].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SORT_SCREENSHOTS_BY_CONTENT_ENABLE; + bool_entries[4].default_value = default_sort_screenshots_by_content_enable; + bool_entries[4].flags = SD_FLAG_ADVANCED; - bool_entries[5].target = &settings->bools.savestate_auto_load; - bool_entries[5].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_LOAD; - bool_entries[5].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD; - bool_entries[5].default_value = savestate_auto_load; + bool_entries[5].target = &settings->bools.block_sram_overwrite; + bool_entries[5].name_enum_idx = MENU_ENUM_LABEL_BLOCK_SRAM_OVERWRITE; + bool_entries[5].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_BLOCK_SRAM_OVERWRITE; + bool_entries[5].default_value = DEFAULT_BLOCK_SRAM_OVERWRITE; bool_entries[5].flags = SD_FLAG_NONE; - bool_entries[6].target = &settings->bools.savestate_thumbnail_enable; - bool_entries[6].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_THUMBNAIL_ENABLE; - bool_entries[6].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_THUMBNAIL_ENABLE; - bool_entries[6].default_value = savestate_thumbnail_enable; - bool_entries[6].flags = SD_FLAG_ADVANCED; + bool_entries[6].target = &settings->bools.savestate_auto_index; + bool_entries[6].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_INDEX; + bool_entries[6].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_INDEX; + bool_entries[6].default_value = savestate_auto_index; + bool_entries[6].flags = SD_FLAG_NONE; - bool_entries[7].target = &settings->bools.savefiles_in_content_dir; - bool_entries[7].name_enum_idx = MENU_ENUM_LABEL_SAVEFILES_IN_CONTENT_DIR_ENABLE; - bool_entries[7].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVEFILES_IN_CONTENT_DIR_ENABLE; - bool_entries[7].default_value = default_savefiles_in_content_dir; - bool_entries[7].flags = SD_FLAG_ADVANCED; + bool_entries[7].target = &settings->bools.savestate_auto_save; + bool_entries[7].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_SAVE; + bool_entries[7].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_SAVE; + bool_entries[7].default_value = savestate_auto_save; + bool_entries[7].flags = SD_FLAG_NONE; - bool_entries[8].target = &settings->bools.savestates_in_content_dir; - bool_entries[8].name_enum_idx = MENU_ENUM_LABEL_SAVESTATES_IN_CONTENT_DIR_ENABLE; - bool_entries[8].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATES_IN_CONTENT_DIR_ENABLE; - bool_entries[8].default_value = default_savestates_in_content_dir; - bool_entries[8].flags = SD_FLAG_ADVANCED; + bool_entries[8].target = &settings->bools.savestate_auto_load; + bool_entries[8].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_AUTO_LOAD; + bool_entries[8].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_AUTO_LOAD; + bool_entries[8].default_value = savestate_auto_load; + bool_entries[8].flags = SD_FLAG_NONE; - bool_entries[9].target = &settings->bools.systemfiles_in_content_dir; - bool_entries[9].name_enum_idx = MENU_ENUM_LABEL_SYSTEMFILES_IN_CONTENT_DIR_ENABLE; - bool_entries[9].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SYSTEMFILES_IN_CONTENT_DIR_ENABLE; - bool_entries[9].default_value = default_systemfiles_in_content_dir; + bool_entries[9].target = &settings->bools.savestate_thumbnail_enable; + bool_entries[9].name_enum_idx = MENU_ENUM_LABEL_SAVESTATE_THUMBNAIL_ENABLE; + bool_entries[9].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATE_THUMBNAIL_ENABLE; + bool_entries[9].default_value = savestate_thumbnail_enable; bool_entries[9].flags = SD_FLAG_ADVANCED; - bool_entries[10].target = &settings->bools.screenshots_in_content_dir; - bool_entries[10].name_enum_idx = MENU_ENUM_LABEL_SCREENSHOTS_IN_CONTENT_DIR_ENABLE; - bool_entries[10].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SCREENSHOTS_IN_CONTENT_DIR_ENABLE; - bool_entries[10].default_value = default_screenshots_in_content_dir; + bool_entries[10].target = &settings->bools.savefiles_in_content_dir; + bool_entries[10].name_enum_idx = MENU_ENUM_LABEL_SAVEFILES_IN_CONTENT_DIR_ENABLE; + bool_entries[10].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVEFILES_IN_CONTENT_DIR_ENABLE; + bool_entries[10].default_value = default_savefiles_in_content_dir; bool_entries[10].flags = SD_FLAG_ADVANCED; + bool_entries[11].target = &settings->bools.savestates_in_content_dir; + bool_entries[11].name_enum_idx = MENU_ENUM_LABEL_SAVESTATES_IN_CONTENT_DIR_ENABLE; + bool_entries[11].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SAVESTATES_IN_CONTENT_DIR_ENABLE; + bool_entries[11].default_value = default_savestates_in_content_dir; + bool_entries[11].flags = SD_FLAG_ADVANCED; + + bool_entries[12].target = &settings->bools.systemfiles_in_content_dir; + bool_entries[12].name_enum_idx = MENU_ENUM_LABEL_SYSTEMFILES_IN_CONTENT_DIR_ENABLE; + bool_entries[12].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SYSTEMFILES_IN_CONTENT_DIR_ENABLE; + bool_entries[12].default_value = default_systemfiles_in_content_dir; + bool_entries[12].flags = SD_FLAG_ADVANCED; + + bool_entries[13].target = &settings->bools.screenshots_in_content_dir; + bool_entries[13].name_enum_idx = MENU_ENUM_LABEL_SCREENSHOTS_IN_CONTENT_DIR_ENABLE; + bool_entries[13].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_SCREENSHOTS_IN_CONTENT_DIR_ENABLE; + bool_entries[13].default_value = default_screenshots_in_content_dir; + bool_entries[13].flags = SD_FLAG_ADVANCED; + for (i = 0; i < ARRAY_SIZE(bool_entries); i++) { CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index 14bc3502c8..eff1d07a8c 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1751,10 +1751,13 @@ enum msg_hash_enums MENU_LABEL(SORT_SAVEFILES_ENABLE), MENU_LABEL(SORT_SAVESTATES_ENABLE), + MENU_LABEL(SORT_SAVEFILES_BY_CONTENT_ENABLE), + MENU_LABEL(SORT_SAVESTATES_BY_CONTENT_ENABLE), MENU_LABEL(SAVEFILES_IN_CONTENT_DIR_ENABLE), MENU_LABEL(SAVESTATES_IN_CONTENT_DIR_ENABLE), MENU_LABEL(SYSTEMFILES_IN_CONTENT_DIR_ENABLE), MENU_LABEL(SCREENSHOTS_IN_CONTENT_DIR_ENABLE), + MENU_LABEL(SORT_SCREENSHOTS_BY_CONTENT_ENABLE), MENU_LABEL(NETPLAY_IP_ADDRESS), MENU_LABEL(NETPLAY_PASSWORD), MENU_LABEL(NETPLAY_SPECTATE_PASSWORD), diff --git a/retroarch.c b/retroarch.c index 1b126f16dd..2c206841ff 100644 --- a/retroarch.c +++ b/retroarch.c @@ -11001,6 +11001,7 @@ const char *char_list_new_special(enum string_list_type type, void *data) static void path_set_redirect(struct rarch_state *p_rarch) { + char content_dir_name[PATH_MAX_LENGTH]; char new_savefile_dir[PATH_MAX_LENGTH]; char new_savestate_dir[PATH_MAX_LENGTH]; global_t *global = &p_rarch->g_extern; @@ -11009,16 +11010,29 @@ static void path_set_redirect(struct rarch_state *p_rarch) struct retro_system_info *system = &p_rarch->runloop_system.info; settings_t *settings = p_rarch->configuration_settings; bool sort_savefiles_enable = settings->bools.sort_savefiles_enable; + bool sort_savefiles_by_content_enable = settings->bools.sort_savefiles_by_content_enable; bool sort_savestates_enable = settings->bools.sort_savestates_enable; + bool sort_savestates_by_content_enable = settings->bools.sort_savestates_by_content_enable; bool savefiles_in_content_dir = settings->bools.savefiles_in_content_dir; bool savestates_in_content_dir = settings->bools.savestates_in_content_dir; - new_savefile_dir[0] = new_savestate_dir[0] = '\0'; + + content_dir_name[0] = '\0'; + new_savefile_dir[0] = '\0'; + new_savestate_dir[0] = '\0'; /* Initialize current save directories * with the values from the config. */ strlcpy(new_savefile_dir, old_savefile_dir, sizeof(new_savefile_dir)); strlcpy(new_savestate_dir, old_savestate_dir, sizeof(new_savestate_dir)); + /* Get content directory name, if per-content-directory + * saves/states are enabled */ + if ((sort_savefiles_by_content_enable || + sort_savestates_by_content_enable) && + !string_is_empty(p_rarch->path_main_basename)) + fill_pathname_parent_dir_name(content_dir_name, + p_rarch->path_main_basename, sizeof(content_dir_name)); + if (system && !string_is_empty(system->library_name)) { #ifdef HAVE_MENU @@ -11026,15 +11040,25 @@ static void path_set_redirect(struct rarch_state *p_rarch) msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))) #endif { - /* per-core saves: append the library_name to the save location */ - if (sort_savefiles_enable + /* Per-core and/or per-content-directory saves */ + if ((sort_savefiles_enable || sort_savefiles_by_content_enable) && !string_is_empty(old_savefile_dir)) { - fill_pathname_join( - new_savefile_dir, - old_savefile_dir, - system->library_name, - sizeof(new_savefile_dir)); + /* Append content directory name to save location */ + if (sort_savefiles_by_content_enable) + fill_pathname_join( + new_savefile_dir, + old_savefile_dir, + content_dir_name, + sizeof(new_savefile_dir)); + + /* Append library_name to the save location */ + if (sort_savefiles_enable) + fill_pathname_join( + new_savefile_dir, + new_savefile_dir, + system->library_name, + sizeof(new_savefile_dir)); /* If path doesn't exist, try to create it, * if everything fails revert to the original path. */ @@ -11049,16 +11073,28 @@ static void path_set_redirect(struct rarch_state *p_rarch) } } - /* per-core states: append the library_name to the save location */ - if (sort_savestates_enable + /* Per-core and/or per-content-directory savestates */ + if ((sort_savestates_enable || sort_savestates_by_content_enable) && !string_is_empty(old_savestate_dir)) { - fill_pathname_join( - new_savestate_dir, - old_savestate_dir, - system->library_name, - sizeof(new_savestate_dir)); + /* Append content directory name to savestate location */ + if (sort_savestates_by_content_enable) + fill_pathname_join( + new_savestate_dir, + old_savestate_dir, + content_dir_name, + sizeof(new_savestate_dir)); + /* Append library_name to the savestate location */ + if (sort_savestates_enable) + { + fill_pathname_join( + new_savestate_dir, + new_savestate_dir, + system->library_name, + sizeof(new_savestate_dir)); + } + /* If path doesn't exist, try to create it. * If everything fails, revert to the original path. */ if (!path_is_directory(new_savestate_dir)) @@ -11081,6 +11117,13 @@ static void path_set_redirect(struct rarch_state *p_rarch) strlcpy(new_savefile_dir, p_rarch->path_main_basename, sizeof(new_savefile_dir)); path_basedir(new_savefile_dir); + + if (string_is_empty(new_savefile_dir)) + RARCH_LOG("Cannot resolve save file path.\n", + msg_hash_to_str(MSG_REVERTING_SAVEFILE_DIRECTORY_TO), + new_savefile_dir); + else if (sort_savefiles_enable || sort_savefiles_by_content_enable) + RARCH_LOG("Saving files in content directory is set. This overrides other save file directory settings.\n"); } /* Set savestate directory if empty based on content directory */ @@ -11089,6 +11132,13 @@ static void path_set_redirect(struct rarch_state *p_rarch) strlcpy(new_savestate_dir, p_rarch->path_main_basename, sizeof(new_savestate_dir)); path_basedir(new_savestate_dir); + + if (string_is_empty(new_savestate_dir)) + RARCH_LOG("Cannot resolve save state file path.\n", + msg_hash_to_str(MSG_REVERTING_SAVESTATE_DIRECTORY_TO), + new_savestate_dir); + else if (sort_savestates_enable || sort_savestates_by_content_enable) + RARCH_LOG("Saving save states in content directory is set. This overrides other save state file directory settings.\n"); } if (global) diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index d26b40fe54..af338f7b2c 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -268,7 +268,7 @@ static bool screenshot_dump( uint8_t *buf = NULL; settings_t *settings = config_get_ptr(); screenshot_task_state_t *state = (screenshot_task_state_t*) - calloc(1, sizeof(*state)); + calloc(1, sizeof(*state)); state->shotname[0] = '\0'; @@ -304,6 +304,36 @@ static bool screenshot_dump( } else { + char new_screenshot_dir[PATH_MAX_LENGTH]; + + new_screenshot_dir[0] = '\0'; + + if (!string_is_empty(screenshot_dir)) + { + const char *content_dir = path_get(RARCH_PATH_BASENAME); + + /* Append content directory name to screenshot + * path, if required */ + if (settings->bools.sort_screenshots_by_content_enable && + !string_is_empty(content_dir)) + { + char content_dir_name[PATH_MAX_LENGTH]; + + content_dir_name[0] = '\0'; + + fill_pathname_parent_dir_name(content_dir_name, + content_dir, sizeof(content_dir_name)); + fill_pathname_join( + new_screenshot_dir, + screenshot_dir, + content_dir_name, + sizeof(new_screenshot_dir)); + } + else + strlcpy(new_screenshot_dir, screenshot_dir, + sizeof(new_screenshot_dir)); + } + if (settings->bools.auto_screenshot_filename) { const char *screenshot_name = NULL; @@ -334,19 +364,22 @@ static bool screenshot_dump( strlcat(state->shotname, ".png", sizeof(state->shotname)); } - if ( string_is_empty(screenshot_dir) || + if ( string_is_empty(new_screenshot_dir) || settings->bools.screenshots_in_content_dir) { - char screenshot_path[PATH_MAX_LENGTH]; - screenshot_path[0] = '\0'; - fill_pathname_basedir(screenshot_path, name_base, - sizeof(screenshot_path)); - fill_pathname_join(state->filename, screenshot_path, + fill_pathname_basedir(new_screenshot_dir, name_base, + sizeof(new_screenshot_dir)); + fill_pathname_join(state->filename, new_screenshot_dir, state->shotname, sizeof(state->filename)); } else - fill_pathname_join(state->filename, screenshot_dir, + fill_pathname_join(state->filename, new_screenshot_dir, state->shotname, sizeof(state->filename)); + + /* Create screenshot directory, if required */ + if (!path_is_directory(new_screenshot_dir)) + if (!path_mkdir(new_screenshot_dir)) + return false; } }