(Manual content scanner) Add 'Arcade DAT Filter' Option

This commit is contained in:
jdgleaver 2020-03-04 11:52:20 +00:00
parent e2378680ef
commit 9d59fcaded
8 changed files with 81 additions and 25 deletions

View File

@ -2200,6 +2200,8 @@ MSG_HASH(MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_SEARCH_ARCHIVES,
"manual_content_scan_search_archives")
MSG_HASH(MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE,
"manual_content_scan_dat_file")
MSG_HASH(MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER,
"manual_content_scan_dat_file_filter")
MSG_HASH(MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_OVERWRITE,
"manual_content_scan_overwrite")
MSG_HASH(MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_START,

View File

@ -10299,6 +10299,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_DAT_FILE,
"Select a Logiqx or MAME List XML DAT file to enable automatic naming of scanned arcade content (MAME, FinalBurn Neo, etc.)."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER,
"Arcade DAT Filter"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER,
"When using an arcade DAT file, only add content to playlist if a matching DAT file entry is found."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_OVERWRITE,
"Overwrite Existing Playlist"

View File

@ -51,6 +51,7 @@ typedef struct
enum manual_content_scan_system_name_type system_name_type;
enum manual_content_scan_core_type core_type;
bool search_archives;
bool filter_dat_content;
bool overwrite_playlist;
} scan_settings_t;
@ -76,6 +77,7 @@ static scan_settings_t scan_settings = {
MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR, /* system_name_type */
MANUAL_CONTENT_SCAN_CORE_DETECT, /* core_type */
false, /* search_archives */
false, /* filter_dat_content */
false /* overwrite_playlist */
};
@ -134,6 +136,13 @@ bool *manual_content_scan_get_search_archives_ptr(void)
return &scan_settings.search_archives;
}
/* Returns a pointer to the internal
* 'filter_dat_content' bool */
bool *manual_content_scan_get_filter_dat_content_ptr(void)
{
return &scan_settings.filter_dat_content;
}
/* Returns a pointer to the internal
* 'overwrite_playlist' bool */
bool *manual_content_scan_get_overwrite_playlist_ptr(void)
@ -857,6 +866,9 @@ bool manual_content_scan_get_task_config(
/* Copy 'search inside archives' setting */
task_config->search_archives = scan_settings.search_archives;
/* Copy 'DAT file filter' setting */
task_config->filter_dat_content = scan_settings.filter_dat_content;
/* Copy 'overwrite playlist' setting */
task_config->overwrite_playlist = scan_settings.overwrite_playlist;
@ -1017,12 +1029,13 @@ error:
}
/* Extracts content 'label' (name) from content path
* > If a DAT file is specified and content is an
* archive, performs a lookup of content file name
* in an attempt to find a valid 'description' string.
* > If a DAT file is specified, performs a lookup
* of content file name in an attempt to find a
* valid 'description' string.
* Returns false if specified content is invalid. */
static bool manual_content_scan_get_playlist_content_label(
const char *content_path, logiqx_dat_t *dat_file,
bool filter_dat_content,
char *content_label, size_t len)
{
/* Sanity check */
@ -1040,33 +1053,34 @@ static bool manual_content_scan_get_playlist_content_label(
/* Check if a DAT file has been specified */
if (dat_file)
{
/* DAT files are only relevant for arcade
* content. We have no idea what kind of
* content we are dealing with here, but
* since arcade ROMs are always archives
* we can at least filter by file type... */
if (path_is_compressed_file(content_path))
bool content_found = false;
logiqx_dat_game_info_t game_info;
/* Search for current content
* > If content is not listed in DAT file,
* use existing filename without extension */
if (logiqx_dat_search(dat_file, content_label, &game_info))
{
logiqx_dat_game_info_t game_info;
/* BIOS files should always be skipped */
if (game_info.is_bios)
return false;
/* Search for current content
* > If content is not listed in DAT file,
* use existing filename without extension */
if (logiqx_dat_search(dat_file, content_label, &game_info))
/* Only include 'runnable' content */
if (!game_info.is_runnable)
return false;
/* Copy game description */
if (!string_is_empty(game_info.description))
{
/* BIOS files should always be skipped */
if (game_info.is_bios)
return false;
/* Only include 'runnable' content */
if (!game_info.is_runnable)
return false;
/* Copy game description */
if (!string_is_empty(game_info.description))
strlcpy(content_label, game_info.description, len);
strlcpy(content_label, game_info.description, len);
content_found = true;
}
}
/* If we are applying a DAT file filter,
* unlisted content should be skipped */
if (!content_found && filter_dat_content)
return false;
}
return true;
@ -1106,6 +1120,7 @@ void manual_content_scan_add_content_to_playlist(
/* Get entry label */
if (!manual_content_scan_get_playlist_content_label(
playlist_content_path, dat_file,
task_config->filter_dat_content,
label, sizeof(label)))
return;

View File

@ -79,6 +79,7 @@ typedef struct
char dat_file_path[PATH_MAX_LENGTH];
bool core_set;
bool search_archives;
bool filter_dat_content;
bool overwrite_playlist;
} manual_content_scan_task_config_t;
@ -120,6 +121,10 @@ size_t manual_content_scan_get_dat_file_path_size(void);
* 'search_archives' bool */
bool *manual_content_scan_get_search_archives_ptr(void);
/* Returns a pointer to the internal
* 'filter_dat_content' bool */
bool *manual_content_scan_get_filter_dat_content_ptr(void);
/* Returns a pointer to the internal
* 'overwrite_playlist' bool */
bool *manual_content_scan_get_overwrite_playlist_ptr(void);

View File

@ -764,6 +764,7 @@ default_sublabel_macro(action_bind_sublabel_manual_content_scan_core_name,
default_sublabel_macro(action_bind_sublabel_manual_content_scan_file_exts, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_FILE_EXTS)
default_sublabel_macro(action_bind_sublabel_manual_content_scan_search_archives, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_SEARCH_ARCHIVES)
default_sublabel_macro(action_bind_sublabel_manual_content_scan_dat_file, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_DAT_FILE)
default_sublabel_macro(action_bind_sublabel_manual_content_scan_dat_file_filter, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER)
default_sublabel_macro(action_bind_sublabel_manual_content_scan_overwrite, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_OVERWRITE)
default_sublabel_macro(action_bind_sublabel_manual_content_scan_start, MENU_ENUM_SUBLABEL_MANUAL_CONTENT_SCAN_START)
@ -3273,6 +3274,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_manual_content_scan_dat_file);
break;
case MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_manual_content_scan_dat_file_filter);
break;
case MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_OVERWRITE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_manual_content_scan_overwrite);
break;

View File

@ -3939,6 +3939,12 @@ static bool menu_displaylist_parse_manual_content_scan_list(
false) == 0)
count++;
/* Arcade DAT filter */
if (menu_displaylist_parse_settings_enum(info->list,
MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER, PARSE_ONLY_BOOL,
false) == 0)
count++;
/* Overwrite playlist */
if (menu_displaylist_parse_settings_enum(info->list,
MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_OVERWRITE, PARSE_ONLY_BOOL,

View File

@ -17080,6 +17080,21 @@ static bool setting_append_list(
general_read_handler);
menu_settings_list_current_add_values(list, list_info, "dat|xml");
CONFIG_BOOL(
list, list_info,
manual_content_scan_get_filter_dat_content_ptr(),
MENU_ENUM_LABEL_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER,
MENU_ENUM_LABEL_VALUE_MANUAL_CONTENT_SCAN_DAT_FILE_FILTER,
false,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE);
CONFIG_BOOL(
list, list_info,
manual_content_scan_get_overwrite_playlist_ptr(),

View File

@ -2754,6 +2754,7 @@ enum msg_hash_enums
MENU_LABEL(MANUAL_CONTENT_SCAN_FILE_EXTS),
MENU_LABEL(MANUAL_CONTENT_SCAN_SEARCH_ARCHIVES),
MENU_LABEL(MANUAL_CONTENT_SCAN_DAT_FILE),
MENU_LABEL(MANUAL_CONTENT_SCAN_DAT_FILE_FILTER),
MENU_LABEL(MANUAL_CONTENT_SCAN_OVERWRITE),
MENU_LABEL(MANUAL_CONTENT_SCAN_START),