Add label_display_mode to playlist.

Add label_display_mode to JSON format.
Add label_display_mode to old playlist format.
Add label_display_mode to configuration.
Add label sanitization functions to libretro common.
This commit is contained in:
Tim Van den Langenbergh 2019-07-18 21:13:14 +02:00
parent fcf5d6bcdd
commit 55f4c04ff2
16 changed files with 428 additions and 136 deletions

View File

@ -273,6 +273,8 @@ MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION,
"deferred_dropdown_box_list_resolution")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,
"deferred_dropdown_box_list_playlist_default_core")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE,
"deferred_dropdown_box_list_playlist_label_display_mode")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST,
"deferred_configurations_list")
MSG_HASH(MENU_ENUM_LABEL_DEFERRED_PLAYLIST_LIST,
@ -887,6 +889,22 @@ MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE,
"playlist_manager_default_core")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_RESET_CORES,
"playlist_manager_reset_cores")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE,
"playlist_manager_label_display_mode")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT,
"playlist_manager_label_display_mode_default")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS,
"playlist_manager_label_display_mode_remove_parens")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_BRACKETS,
"playlist_manager_label_display_mode_remove_brackets")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS_AND_BRACKETS,
"playlist_manager_label_display_mode_remove_parens_and_brackets")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION,
"playlist_manager_label_display_mode_keep_region")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_DISC_INDEX,
"playlist_manager_label_display_mode_keep_disc_index")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX,
"playlist_manager_label_display_mode_keep_region_and_disc_index")
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_SETTINGS_BEGIN,
"playlist_settings_begin")
MSG_HASH(MENU_ENUM_LABEL_POINTER_ENABLE,

View File

@ -2196,6 +2196,42 @@ MSG_HASH(
MSG_PLAYLIST_MANAGER_CORES_RESET,
"Cores reset: "
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE,
"Label Display Mode"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE,
"Change how the content labels are displayed in this playlist."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT,
"Show full labels"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS,
"Remove parentheses"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_BRACKETS,
"Remove brackets"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS_AND_BRACKETS,
"Remove parentheses and brackets"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION,
"Keep region"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_DISC_INDEX,
"Keep disc index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX,
"Keep region and disc index"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_POINTER_ENABLE,
"Touch Support"

View File

@ -20,8 +20,24 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stddef.h>
#include <boolean.h>
void label_sanitize(char *label, size_t size, char *lchars, char *rchars, int dcount);
void label_sanitize(char *label, size_t size, bool (*left)(char*), bool (*right)(char*));
bool left_parens(char *left);
bool right_parens(char *right);
bool left_brackets(char *left);
bool right_brackets(char *right);
bool left_parens_or_brackets(char *left);
bool right_parens_or_brackets(char *right);
bool left_parens_or_brackets_excluding_region(char *left);
bool left_parens_or_brackets_excluding_disc(char *left);
bool left_parens_or_brackets_excluding_region_or_disc(char *left);
void label_default_display(char *label, size_t size);

View File

@ -21,13 +21,12 @@
*/
#include <playlists/label_sanitization.h>
#include <boolean.h>
#include <string.h>
/*
* Does not work with nested blocks.
*/
void label_sanitize(char *label, size_t size, char *lchars, char *rchars, int dcount)
void label_sanitize(char *label, size_t size, bool (*left)(char*), bool (*right)(char*))
{
bool copy = true;
int rindex = 0;
@ -39,24 +38,14 @@ void label_sanitize(char *label, size_t size, char *lchars, char *rchars, int dc
if (copy)
{
// check for the start of the range
for (int dindex = 0; dindex < dcount; dindex++)
{
if (label[lindex] == lchars[dindex])
copy = false;
}
if ((*left)(&label[lindex]))
copy = false;
if (copy)
new_label[rindex++] = label[lindex];
}
else
{
// check for the end of the range
for (int dindex = 0; dindex < dcount; dindex++)
{
if (label[lindex] == rchars[dindex])
copy = true;
}
}
else if ((*right)(&label[lindex]))
copy = true;
}
new_label[rindex] = label[lindex];
@ -64,6 +53,124 @@ void label_sanitize(char *label, size_t size, char *lchars, char *rchars, int dc
strcpy(label, new_label);
}
bool left_parens(char *left)
{
return left[0] == '(';
}
bool right_parens(char *right)
{
return right[0] == ')';
}
bool left_brackets(char *left)
{
return left[0] == '[';
}
bool right_brackets(char *right)
{
return right[0] == ']';
}
bool left_parens_or_brackets(char *left)
{
return left[0] == '(' || left[0] == '[';
}
bool right_parens_or_brackets(char *right)
{
return right[0] == ']' || right[0] == ']';
}
bool left_parens_or_brackets_excluding_region(char *left)
{
if (left_parens_or_brackets(left))
{
if ((left[1] == 'A'
&& left[2] == 'u'
&& left[3] == 's'
&& left[4] == 'r'
&& left[5] == 'a'
&& left[6] == 'l'
&& left[7] == 'i'
&& left[8] == 'a')
|| (left[1] == 'E'
&& left[2] == 'u'
&& left[3] == 'r'
&& left[4] == 'o'
&& left[5] == 'p'
&& left[6] == 'e')
|| (left[1] == 'J'
&& left[2] == 'a'
&& left[3] == 'p'
&& left[4] == 'a'
&& left[5] == 'n')
|| (left[1] == 'U'
&& left[2] == 'S'
&& left[3] == 'A'))
return false;
else
return true;
}
else
return false;
}
bool left_parens_or_brackets_excluding_disc(char *left)
{
if (left_parens_or_brackets(left))
{
if (left[1] == 'D'
&& left[2] == 'i'
&& left[3] == 's'
&& left[4] == 'c')
return false;
else
return true;
}
else
return false;
}
bool left_parens_or_brackets_excluding_region_or_disc(char *left)
{
if (left_parens_or_brackets(left))
{
if ((left[1] == 'A'
&& left[2] == 'u'
&& left[3] == 's'
&& left[4] == 'r'
&& left[5] == 'a'
&& left[6] == 'l'
&& left[7] == 'i'
&& left[8] == 'a')
|| (left[1] == 'E'
&& left[2] == 'u'
&& left[3] == 'r'
&& left[4] == 'o'
&& left[5] == 'p'
&& left[6] == 'e')
|| (left[1] == 'J'
&& left[2] == 'a'
&& left[3] == 'p'
&& left[4] == 'a'
&& left[5] == 'n')
|| (left[1] == 'U'
&& left[2] == 'S'
&& left[3] == 'A')
|| (left[1] == 'D'
&& left[2] == 'i'
&& left[3] == 's'
&& left[4] == 'c'))
return false;
else
return true;
}
else
return false;
}
void label_default_display(char *label, size_t size)
{
return;
@ -71,135 +178,30 @@ void label_default_display(char *label, size_t size)
void label_remove_parens(char *label, size_t size)
{
label_sanitize(label, size, "(", ")", 1);
label_sanitize(label, size, left_parens, right_parens);
}
void label_remove_brackets(char *label, size_t size)
{
label_sanitize(label, size, "[", "]", 1);
label_sanitize(label, size, left_brackets, right_brackets);
}
void label_remove_parens_and_brackets(char *label, size_t size)
{
label_sanitize(label, size, "([", ")]", 2);
label_sanitize(label, size, left_parens_or_brackets, right_parens_or_brackets);
}
void label_keep_region(char *label, size_t size)
{
bool copy = true;
int rindex = 0;
int lindex = 0;
char new_label[size];
for (; lindex < size && label[lindex] != '\0'; lindex++)
{
if (copy)
{
if (label[lindex] == '(' || label[lindex] == '[')
{
if (!(label[lindex + 1] == 'E'
&& label[lindex + 2] == 'u'
&& label[lindex + 3] == 'r'
&& label[lindex + 4] == 'o'
&& label[lindex + 5] == 'p'
&& label[lindex + 6] == 'e')
&& !(label[lindex + 1] == 'J'
&& label[lindex + 2] == 'a'
&& label[lindex + 3] == 'p'
&& label[lindex + 4] == 'a'
&& label[lindex + 5] == 'n')
&& !(label[lindex + 1] == 'U'
&& label[lindex + 2] == 'S'
&& label[lindex + 3] == 'A'))
copy = false;
}
if (copy)
new_label[rindex++] = label[lindex];
}
else if (label[lindex] == ')' || label[lindex] == ']')
copy = true;
}
new_label[rindex] = label[lindex];
strcpy(label, new_label);
label_sanitize(label, size, left_parens_or_brackets_excluding_region, right_parens_or_brackets);
}
void label_keep_disc(char *label, size_t size)
{
bool copy = true;
int rindex = 0;
int lindex = 0;
char new_label[size];
for (; lindex < size && label[lindex] != '\0'; lindex++)
{
if (copy)
{
if (label[lindex] == '(' || label[lindex] == '[')
{
if (!(label[lindex + 1] == 'D'
&& label[lindex + 2] == 'i'
&& label[lindex + 3] == 's'
&& label[lindex + 4] == 'c'))
copy = false;
}
if (copy)
new_label[rindex++] = label[lindex];
}
else if (label[lindex] == ')' || label[lindex] == ']')
copy = true;
}
new_label[rindex] = label[lindex];
strcpy(label, new_label);
label_sanitize(label, size, left_parens_or_brackets_excluding_disc, right_parens_or_brackets);
}
void label_keep_region_and_disc(char *label, size_t size)
{
bool copy = true;
int rindex = 0;
int lindex = 0;
char new_label[size];
for (; lindex < size && label[lindex] != '\0'; lindex++)
{
if (copy)
{
if (label[lindex] == '(' || label[lindex] == '[')
{
if (!(label[lindex + 1] == 'D'
&& label[lindex + 2] == 'i'
&& label[lindex + 3] == 's'
&& label[lindex + 4] == 'c')
&& !(label[lindex + 1] == 'E'
&& label[lindex + 2] == 'u'
&& label[lindex + 3] == 'r'
&& label[lindex + 4] == 'o'
&& label[lindex + 5] == 'p'
&& label[lindex + 6] == 'e')
&& !(label[lindex + 1] == 'J'
&& label[lindex + 2] == 'a'
&& label[lindex + 3] == 'p'
&& label[lindex + 4] == 'a'
&& label[lindex + 5] == 'n')
&& !(label[lindex + 1] == 'U'
&& label[lindex + 2] == 'S'
&& label[lindex + 3] == 'A'))
copy = false;
}
if (copy)
new_label[rindex++] = label[lindex];
}
else if (label[lindex] == ')' || label[lindex] == ']')
copy = true;
}
new_label[rindex] = label[lindex];
strcpy(label, new_label);
label_sanitize(label, size, left_parens_or_brackets_excluding_region_or_disc, right_parens_or_brackets);
}

View File

@ -640,6 +640,7 @@ generic_deferred_push_clear_general(deferred_push_dropdown_box_list, PUSH_DEFAUL
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_special, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_SPECIAL)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_resolution, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_RESOLUTION)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_playlist_default_core, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE)
generic_deferred_push_clear_general(deferred_push_dropdown_box_list_playlist_label_display_mode, PUSH_DEFAULT, DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE)
static int menu_cbs_init_bind_deferred_push_compare_label(
menu_file_list_cbs_t *cbs,
@ -680,6 +681,11 @@ static int menu_cbs_init_bind_deferred_push_compare_label(
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_dropdown_box_list_playlist_default_core);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE)))
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_dropdown_box_list_playlist_label_display_mode);
return 0;
}
else if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_BROWSE_URL_LIST)))
{
BIND_ACTION_DEFERRED_PUSH(cbs, deferred_push_browse_url_list);

View File

@ -1098,6 +1098,24 @@ static void menu_action_setting_disp_set_label_playlist_associations(file_list_t
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len);
}
static void menu_action_setting_disp_set_label_playlist_label_display_mode(
file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
char *s, size_t len,
const char *path,
char *s2, size_t len2)
{
playlist_t *playlist = playlist_get_cached();
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
*w = 19;
strlcpy(s2, path, len2);
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + label_display_mode * 3), len);
}
static void menu_action_setting_disp_set_label_core_options(file_list_t* list,
unsigned *w, unsigned type, unsigned i,
const char *label,
@ -1345,6 +1363,10 @@ static int menu_cbs_init_bind_get_string_representation_compare_label(
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_playlist_associations);
break;
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE:
BIND_ACTION_GET_VALUE(cbs,
menu_action_setting_disp_set_label_playlist_label_display_mode);
break;
default:
return - 1;
}

View File

@ -247,7 +247,7 @@ static int action_left_mainmenu(unsigned type, const char *label,
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
menu_file_list_cbs_t *cbs = selection_buf ?
menu_file_list_cbs_t *cbs = selection_buf ?
(menu_file_list_cbs_t*)
selection_buf->list[selection].actiondata : NULL;
@ -434,6 +434,27 @@ static int playlist_association_left(unsigned type, const char *label,
return 0;
}
static int playlist_label_display_mode_left(unsigned type, const char *label,
bool wraparound)
{
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
if (label_display_mode != LABEL_DISPLAY_MODE_DEFAULT)
label_display_mode--;
else if (wraparound)
label_display_mode = LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX;
playlist_set_label_display_mode(playlist, label_display_mode);
playlist_write_file(playlist);
return 0;
}
static int core_setting_left(unsigned type, const char *label,
bool wraparound)
{
@ -676,6 +697,9 @@ static int menu_cbs_init_bind_left_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE:
BIND_ACTION_LEFT(cbs, playlist_association_left);
break;
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE:
BIND_ACTION_LEFT(cbs, playlist_label_display_mode_left);
break;
default:
return -1;
}

View File

@ -177,6 +177,8 @@ static enum msg_hash_enums action_ok_dl_to_enum(unsigned lbl)
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE:
return MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE;
case ACTION_OK_DL_MIXER_STREAM_SETTINGS_LIST:
return MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST;
case ACTION_OK_DL_ACCOUNTS_LIST:
@ -390,6 +392,15 @@ int generic_action_ok_displaylist_push(const char *path,
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE:
info.type = type;
info.directory_ptr = idx;
info_path = path;
info_label = msg_hash_to_str(
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE);
info.enum_idx = MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE;
dl_type = DISPLAYLIST_GENERIC;
break;
case ACTION_OK_DL_USER_BINDS_LIST:
info.type = type;
info.directory_ptr = idx;
@ -5359,6 +5370,19 @@ static int action_ok_push_dropdown_item_playlist_default_core(const char *path,
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_item_playlist_label_display_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_t *playlist = playlist_get_cached();
playlist_set_label_display_mode(playlist, idx);
/* In all cases, update file on disk */
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_default(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5547,6 +5571,16 @@ static int action_ok_playlist_default_core(const char *path,
return 0;
}
static int action_ok_playlist_label_display_mode(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
generic_action_ok_displaylist_push(
NULL,
NULL, NULL, 0, 0, 0,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE);
return 0;
}
static int action_ok_netplay_enable_host(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -6364,6 +6398,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE:
BIND_ACTION_OK(cbs, action_ok_playlist_default_core);
break;
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE:
BIND_ACTION_OK(cbs, action_ok_playlist_label_display_mode);
break;
case MENU_ENUM_LABEL_UPDATE_ASSETS:
BIND_ACTION_OK(cbs, action_ok_update_assets);
break;
@ -6530,6 +6567,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs,
case MENU_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE:
BIND_ACTION_OK(cbs, action_ok_playlist_default_core);
break;
case MENU_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE:
BIND_ACTION_OK(cbs, action_ok_playlist_label_display_mode);
break;
default:
return -1;
}
@ -6653,6 +6693,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
case MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_DEFAULT_CORE:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_playlist_default_core);
break;
case MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_item_playlist_label_display_mode);
break;
case MENU_SETTING_ACTION_CORE_DISK_OPTIONS:
BIND_ACTION_OK(cbs, action_ok_push_default);
break;

View File

@ -547,6 +547,27 @@ static int playlist_association_right(unsigned type, const char *label,
return 0;
}
static int playlist_label_display_mode_right(unsigned type, const char *label,
bool wraparound)
{
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
if (label_display_mode != LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX)
label_display_mode++;
else if (wraparound)
label_display_mode = LABEL_DISPLAY_MODE_DEFAULT;
playlist_set_label_display_mode(playlist, label_display_mode);
playlist_write_file(playlist);
return 0;
}
int core_setting_right(unsigned type, const char *label,
bool wraparound)
{
@ -825,6 +846,9 @@ static int menu_cbs_init_bind_right_compare_label(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE:
BIND_ACTION_RIGHT(cbs, playlist_association_right);
break;
case MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE:
BIND_ACTION_RIGHT(cbs, playlist_label_display_mode_right);
break;
default:
return -1;
}

View File

@ -1366,6 +1366,12 @@ int menu_cbs_init_bind_title(menu_file_list_cbs_t *cbs,
BIND_ACTION_GET_TITLE(cbs, action_get_title_dropdown_item);
return 0;
}
if (string_is_equal(label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE)))
{
BIND_ACTION_GET_TITLE(cbs, action_get_title_dropdown_item);
return 0;
}
if (string_is_equal(label, msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS)))
{
BIND_ACTION_GET_TITLE(cbs, action_get_quick_menu_views_settings_list);

View File

@ -49,6 +49,7 @@ enum
ACTION_OK_DL_DROPDOWN_BOX_LIST_SPECIAL,
ACTION_OK_DL_DROPDOWN_BOX_LIST_RESOLUTION,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,
ACTION_OK_DL_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE,
ACTION_OK_DL_OPEN_ARCHIVE,
ACTION_OK_DL_OPEN_ARCHIVE_DETECT_CORE,
ACTION_OK_DL_MUSIC,

View File

@ -2729,8 +2729,14 @@ static bool menu_displaylist_parse_playlist_manager_settings(
MENU_ENUM_LABEL_PLAYLIST_MANAGER_RESET_CORES,
FILE_TYPE_PLAYLIST_ENTRY, 0, 0);
/* Label display mode */
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE),
msg_hash_to_str(MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE),
MENU_ENUM_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE,
MENU_SETTING_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE, 0, 0);
/* TODO: Add
* - Label display mode
* - Remove invalid entries */
return true;
@ -3739,6 +3745,37 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
}
}
break;
case DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE:
{
playlist_t *playlist = playlist_get_cached();
if (playlist)
{
enum playlist_label_display_mode label_display_mode = playlist_get_label_display_mode(playlist);
for (int i = 0; MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i != MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX; i += 3)
{
if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT + i),
"",
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE,
0, 0))
count++;
}
if (menu_entries_append_enum(list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX),
"",
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE,
0, 0))
count++;
menu_entries_set_checked(list, label_display_mode, true);
}
}
break;
case DISPLAYLIST_PERFCOUNTERS_CORE:
case DISPLAYLIST_PERFCOUNTERS_FRONTEND:
{
@ -6616,6 +6653,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
case DISPLAYLIST_NETWORK_INFO:
case DISPLAYLIST_DROPDOWN_LIST_RESOLUTION:
case DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE:
case DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE:
case DISPLAYLIST_PERFCOUNTERS_CORE:
case DISPLAYLIST_PERFCOUNTERS_FRONTEND:
case DISPLAYLIST_MENU_SETTINGS_LIST:
@ -6636,6 +6674,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
break;
case DISPLAYLIST_DROPDOWN_LIST_RESOLUTION:
case DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE:
case DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE:
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_ENTRIES_TO_DISPLAY),
msg_hash_to_str(MENU_ENUM_LABEL_NO_ENTRIES_TO_DISPLAY),

View File

@ -61,6 +61,7 @@ enum menu_displaylist_ctl_state
DISPLAYLIST_DROPDOWN_LIST_SPECIAL,
DISPLAYLIST_DROPDOWN_LIST_RESOLUTION,
DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_DEFAULT_CORE,
DISPLAYLIST_DROPDOWN_LIST_PLAYLIST_LABEL_DISPLAY_MODE,
DISPLAYLIST_CDROM_DETAIL_INFO,
DISPLAYLIST_INFO,
DISPLAYLIST_HELP,

View File

@ -87,6 +87,7 @@ enum menu_settings_type
MENU_SETTING_DROPDOWN_ITEM,
MENU_SETTING_DROPDOWN_ITEM_RESOLUTION,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_DEFAULT_CORE,
MENU_SETTING_DROPDOWN_ITEM_PLAYLIST_LABEL_DISPLAY_MODE,
MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM,
MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM,
MENU_SETTING_DROPDOWN_SETTING_FLOAT_ITEM,
@ -121,6 +122,7 @@ enum menu_settings_type
MENU_SETTING_ACTION_PAUSE_ACHIEVEMENTS,
MENU_SETTING_ACTION_RESUME_ACHIEVEMENTS,
MENU_SETTING_PLAYLIST_MANAGER_DEFAULT_CORE,
MENU_SETTING_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE,
MENU_WIFI,
MENU_ROOM,
MENU_ROOM_LAN,

View File

@ -1148,6 +1148,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_SPECIAL,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_RESOLUTION,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_DEFAULT_CORE,
MENU_ENUM_LABEL_DEFERRED_DROPDOWN_BOX_LIST_PLAYLIST_LABEL_DISPLAY_MODE,
MENU_ENUM_LABEL_DEFERRED_MIXER_STREAM_SETTINGS_LIST,
MENU_ENUM_LABEL_DEFERRED_CONFIGURATIONS_LIST,
MENU_ENUM_LABEL_DEFERRED_FAVORITES_LIST,
@ -1833,6 +1834,16 @@ enum msg_hash_enums
MSG_PLAYLIST_MANAGER_RESETTING_CORES,
MSG_PLAYLIST_MANAGER_CORES_RESET,
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_DEFAULT),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_BRACKETS),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_REMOVE_PARENS_AND_BRACKETS),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_DISC_INDEX),
MENU_LABEL(PLAYLIST_MANAGER_LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX),
MENU_LABEL(CORE_UPDATER_SETTINGS),
MENU_LABEL(LAKKA_SERVICES),
MENU_LABEL(SHADER_APPLY_CHANGES),
@ -2534,6 +2545,8 @@ enum msg_hash_enums
#define MENU_LABEL_PLAYLIST_MANAGER_DEFAULT_CORE 0x86EDE19DU
#define MENU_LABEL_PLAYLIST_MANAGER_LABEL_DISPLAY_MODE 0xE0E1CD5BU
/* Menu settings */
#define MENU_LABEL_XMB_FONT 0x0ECA56CA2

View File

@ -68,6 +68,7 @@ typedef struct
struct string_list **current_entry_string_list_val;
char *current_meta_string;
char **current_meta_val;
int *current_meta_int_val;
char *current_items_string;
bool in_items;
bool in_subsystem_roms;
@ -1211,9 +1212,10 @@ void playlist_write_file(playlist_t *playlist)
if (!string_is_empty(playlist->default_core_path) &&
!string_is_empty(playlist->default_core_name))
{
filestream_printf(file, "default_core_path = \"%s\"\ndefault_core_name = \"%s\"\n",
filestream_printf(file, "default_core_path = \"%s\"\ndefault_core_name = \"%s\"\nlabel_display_mode = \"%d\"\n",
playlist->default_core_path,
playlist->default_core_name
playlist->default_core_name,
playlist->label_display_mode
);
}
}
@ -1242,8 +1244,8 @@ void playlist_write_file(playlist_t *playlist)
STRLEN_CONST("version"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteString(context.writer, "1.1",
STRLEN_CONST("1.1"), JSON_UTF8);
JSON_Writer_WriteString(context.writer, "1.2",
STRLEN_CONST("1.2"), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
@ -1279,6 +1281,19 @@ void playlist_write_file(playlist_t *playlist)
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
char label_display_mode[4];
snprintf(label_display_mode, sizeof(label_display_mode), "%u", playlist->label_display_mode);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "label_display_mode",
STRLEN_CONST("label_display_mode"), JSON_UTF8);
JSON_Writer_WriteColon(context.writer);
JSON_Writer_WriteSpace(context.writer, 1);
JSON_Writer_WriteNumber(context.writer, label_display_mode,
strlen(label_display_mode), JSON_UTF8);
JSON_Writer_WriteComma(context.writer);
JSON_Writer_WriteNewLine(context.writer);
JSON_Writer_WriteSpace(context.writer, 2);
JSON_Writer_WriteString(context.writer, "items",
STRLEN_CONST("items"), JSON_UTF8);
@ -1729,6 +1744,8 @@ static JSON_Parser_HandlerResult JSONNumberHandler(JSON_Parser parser, char *pVa
free(pCtx->current_meta_string);
pCtx->current_meta_string = NULL;
*pCtx->current_meta_int_val = (int)strtoul(pValue, NULL, 10);
}
}
}
@ -1828,6 +1845,8 @@ static JSON_Parser_HandlerResult JSONObjectMemberHandler(JSON_Parser parser, cha
pCtx->current_meta_val = &pCtx->playlist->default_core_path;
else if (string_is_equal(pValue, "default_core_name"))
pCtx->current_meta_val = &pCtx->playlist->default_core_name;
else if (string_is_equal(pValue, "label_display_mode"))
pCtx->current_meta_int_val = (int*)&pCtx->playlist->label_display_mode;
else
{
/* ignore unknown members */
@ -2017,8 +2036,8 @@ json_cleanup:
metadata_char = filestream_getc(file);
}
/* Search backwards for the next two newlines */
while (metadata_counter < 2)
/* Search backwards for the next three newlines */
while (metadata_counter < 3)
{
filestream_seek(file, -2, SEEK_CUR);
if (filestream_error(file))
@ -2049,6 +2068,26 @@ json_cleanup:
get_old_format_metadata_value(
metadata_line, default_core_name, sizeof(default_core_name));
/* > Get label_display_mode */
if (!filestream_gets(file, metadata_line, sizeof(metadata_line)))
goto end;
if (strncmp("label_display_mode",
metadata_line,
STRLEN_CONST("label_display_mode")) == 0)
{
char *start = NULL;
start = strchr(metadata_line, '\"');
if (start)
{
start++;
if (*start >= '0' && *start <= '9')
playlist->label_display_mode = *start - '0';
}
}
/* > Populate playlist fields, if required */
if (!string_is_empty(default_core_path) &&
!string_is_empty(default_core_name))