Add dropdown lists for core options

This commit is contained in:
twinaphex 2018-09-23 18:36:48 +02:00
parent 3b6f3d027c
commit baa909f296
3 changed files with 199 additions and 109 deletions

View File

@ -51,6 +51,7 @@
#include "../../core_info.h"
#include "../../frontend/frontend_driver.h"
#include "../../defaults.h"
#include "../../managers/core_option_manager.h"
#include "../../managers/cheat_manager.h"
#include "../../tasks/tasks_internal.h"
#include "../../input/input_remapping.h"
@ -2680,6 +2681,22 @@ static int action_ok_audio_run(const char *path,
#endif
}
static int action_ok_core_option_dropdown_list(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char core_option_lbl[256];
char core_option_idx[256];
snprintf(core_option_lbl, sizeof(core_option_lbl), "core_option_%d", (int)idx);
snprintf(core_option_idx, sizeof(core_option_idx), "%d",
type);
generic_action_ok_displaylist_push(
core_option_lbl, NULL,
core_option_idx, 0, 0, 0,
ACTION_OK_DL_DROPDOWN_BOX_LIST);
return 0;
}
static int action_ok_cheat_reload_cheats(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -4269,6 +4286,21 @@ int action_ok_push_filebrowser_list_file_select(const char *path,
entry_idx, ACTION_OK_DL_FILE_BROWSER_SELECT_DIR);
}
static int action_ok_push_dropdown_setting_core_options_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
core_option_manager_t *coreopts = NULL;
int core_option_idx = (int)atoi(label);
rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts);
if (!coreopts)
return -1;
core_option_manager_set_val(coreopts, core_option_idx, idx);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int action_ok_push_dropdown_setting_string_options_item(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
@ -5367,10 +5399,17 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs,
{
BIND_ACTION_OK(cbs, action_ok_cheat);
}
else if ((type >= MENU_SETTINGS_CORE_OPTION_START))
{
BIND_ACTION_OK(cbs, action_ok_core_option_dropdown_list);
}
else
{
switch (type)
{
case MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_core_options_item);
break;
case MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM:
BIND_ACTION_OK(cbs, action_ok_push_dropdown_setting_string_options_item);
break;

View File

@ -7692,12 +7692,60 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
use_filebrowser = true;
break;
case DISPLAYLIST_DROPDOWN_LIST:
{
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
if (strstr(info->path, "core_option_"))
{
struct string_list *tmp_str_list = string_split(info->path, "_");
if (tmp_str_list && tmp_str_list->size > 0)
{
core_option_manager_t *coreopts = NULL;
rarch_ctl(RARCH_CTL_CORE_OPTIONS_LIST_GET, &coreopts);
if (coreopts)
{
unsigned size = tmp_str_list->size;
unsigned i = atoi(tmp_str_list->elems[size-1].data);
struct core_option *option = NULL;
i--;
option = (struct core_option*)&coreopts->opts[i];
if (option)
{
unsigned k;
for (k = 0; k < option->vals->size; k++)
{
const char *str = option->vals->elems[k].data;
if (!string_is_empty(str))
{
char val_d[256];
snprintf(val_d, sizeof(val_d), "%d", i);
menu_entries_append_enum(info->list,
str,
val_d,
MENU_ENUM_LABEL_NO_ITEMS,
MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM, k, 0);
count++;
}
}
}
}
}
}
else
{
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path);
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
if (setting)
{
switch (setting->type)
{
case ST_STRING_OPTIONS:
@ -7823,6 +7871,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
default:
break;
}
}
}
info->need_refresh = true;
info->need_push = true;

View File

@ -148,6 +148,7 @@ enum menu_settings_type
MENU_ADD_TAB,
MENU_PLAYLISTS_TAB,
MENU_SETTING_DROPDOWN_ITEM,
MENU_SETTING_DROPDOWN_SETTING_CORE_OPTIONS_ITEM,
MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM,
MENU_SETTING_DROPDOWN_SETTING_INT_ITEM,
MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM,