Reduce dependence on settings_t struct

This commit is contained in:
twinaphex 2020-01-02 17:52:37 +01:00
parent 05d71ebb67
commit 758a6c76ae
6 changed files with 44 additions and 19 deletions

View File

@ -26,7 +26,6 @@
#include <lists/dir_list.h>
#include <retro_miscellaneous.h>
#include "configuration.h"
#include "msg_hash.h"
#include "list_special.h"
#include "core_info.h"
@ -548,12 +547,10 @@ bool manual_content_scan_get_menu_core_name(const char **core_name)
* lists and 'menu_cbs_left/right'
* > Returns NULL in the event of failure
* > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_menu_system_name_list(void)
struct string_list *manual_content_scan_get_menu_system_name_list(
const char *path_content_database)
{
union string_list_elem_attr attr;
#ifdef HAVE_LIBRETRODB
settings_t *settings = config_get_ptr();
#endif
struct string_list *name_list = string_list_new();
/* Sanity check */
@ -575,14 +572,13 @@ struct string_list *manual_content_scan_get_menu_system_name_list(void)
#ifdef HAVE_LIBRETRODB
/* If platform has database support, get names
* of all installed database files */
if (settings)
{
/* Note: dir_list_new_special() is well behaved - the
* returned string list will only include database
* files (i.e. don't have to check for directories,
* or verify file extensions) */
struct string_list *rdb_list = dir_list_new_special(
settings->paths.path_content_database,
path_content_database,
DIR_LIST_DATABASES, NULL);
if (rdb_list && rdb_list->size)
@ -704,11 +700,12 @@ error:
* and extracts all information required to configure
* a manual content scan task.
* Returns false if current settings are invalid. */
bool manual_content_scan_get_task_config(manual_content_scan_task_config_t *task_config)
bool manual_content_scan_get_task_config(
manual_content_scan_task_config_t *task_config,
const char *path_dir_playlist
)
{
settings_t *settings = config_get_ptr();
if (!task_config || !settings)
if (!task_config)
return false;
/* Ensure all 'task_config' strings are
@ -785,12 +782,12 @@ bool manual_content_scan_get_task_config(manual_content_scan_task_config_t *task
/* ...which can in turn be used to generate the
* playlist path */
if (string_is_empty(settings->paths.directory_playlist))
if (string_is_empty(path_dir_playlist))
return false;
fill_pathname_join(
task_config->playlist_file,
settings->paths.directory_playlist,
path_dir_playlist,
task_config->database_name,
sizeof(task_config->playlist_file));

View File

@ -194,7 +194,8 @@ bool manual_content_scan_get_menu_core_name(const char **core_name);
* lists and 'menu_cbs_left/right'
* > Returns NULL in the event of failure
* > Returned string list must be free()'d */
struct string_list *manual_content_scan_get_menu_system_name_list(void);
struct string_list *manual_content_scan_get_menu_system_name_list(
const char *path_content_database);
/* Creates a list of all possible 'core name' menu
* strings, for use in 'menu_displaylist' drop-down
@ -211,7 +212,10 @@ struct string_list *manual_content_scan_get_menu_core_name_list(void);
* and extracts all information required to configure
* a manual content scan task.
* Returns false if current settings are invalid. */
bool manual_content_scan_get_task_config(manual_content_scan_task_config_t *task_config);
bool manual_content_scan_get_task_config(
manual_content_scan_task_config_t *task_config,
const char *path_dir_playlist
);
/* Creates a list of all valid content in the specified
* content directory

View File

@ -521,8 +521,14 @@ static int playlist_left_thumbnail_mode_left(unsigned type, const char *label,
static int manual_content_scan_system_name_left(unsigned type, const char *label,
bool wraparound)
{
#ifdef HAVE_LIBRETRODB
settings_t *settings = config_get_ptr();
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list();
manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database);
#else
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list(NULL);
#endif
const char *current_system_name = NULL;
enum manual_content_scan_system_name_type next_system_name_type =
MANUAL_CONTENT_SCAN_SYSTEM_NAME_DATABASE;

View File

@ -608,8 +608,14 @@ static int playlist_left_thumbnail_mode_right(unsigned type, const char *label,
static int manual_content_scan_system_name_right(unsigned type, const char *label,
bool wraparound)
{
#ifdef HAVE_LIBRETRODB
settings_t *settings = config_get_ptr();
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list();
manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database);
#else
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list(NULL);
#endif
const char *current_system_name = NULL;
enum manual_content_scan_system_name_type next_system_name_type =
MANUAL_CONTENT_SCAN_SYSTEM_NAME_DATABASE;

View File

@ -5189,7 +5189,14 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
case DISPLAYLIST_DROPDOWN_LIST_MANUAL_CONTENT_SCAN_SYSTEM_NAME:
{
/* Get system name list */
struct string_list *system_name_list = manual_content_scan_get_menu_system_name_list();
#ifdef HAVE_LIBRETRODB
settings_t *settings = config_get_ptr();
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list(settings->paths.path_content_database);
#else
struct string_list *system_name_list =
manual_content_scan_get_menu_system_name_list(NULL);
#endif
if (system_name_list)
{

View File

@ -29,6 +29,7 @@
#include "tasks_internal.h"
#include "../configuration.h"
#include "../retroarch.h"
#include "../msg_hash.h"
#include "../playlist.h"
@ -297,6 +298,7 @@ bool task_push_manual_content_scan(void)
task_finder_data_t find_data;
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = NULL;
settings_t *settings = config_get_ptr();
manual_scan_handle_t *manual_scan = (manual_scan_handle_t*)
calloc(1, sizeof(manual_scan_handle_t));
@ -322,7 +324,10 @@ bool task_push_manual_content_scan(void)
if (!manual_scan->task_config)
goto error;
if (!manual_content_scan_get_task_config(manual_scan->task_config))
if (!manual_content_scan_get_task_config(
manual_scan->task_config,
settings->paths.directory_playlist
))
{
runloop_msg_queue_push(
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_INVALID_CONFIG),