mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Add dropdown lists for core options
This commit is contained in:
parent
3b6f3d027c
commit
baa909f296
@ -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;
|
||||
|
@ -7693,135 +7693,185 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
|
||||
break;
|
||||
case DISPLAYLIST_DROPDOWN_LIST:
|
||||
{
|
||||
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);
|
||||
|
||||
switch (setting->type)
|
||||
if (strstr(info->path, "core_option_"))
|
||||
{
|
||||
case ST_STRING_OPTIONS:
|
||||
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)
|
||||
{
|
||||
struct string_list *tmp_str_list = string_split(setting->values, "|");
|
||||
unsigned size = tmp_str_list->size;
|
||||
unsigned i = atoi(tmp_str_list->elems[size-1].data);
|
||||
struct core_option *option = NULL;
|
||||
|
||||
if (tmp_str_list && tmp_str_list->size > 0)
|
||||
i--;
|
||||
|
||||
option = (struct core_option*)&coreopts->opts[i];
|
||||
|
||||
if (option)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned size = tmp_str_list->size;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
unsigned k;
|
||||
for (k = 0; k < option->vals->size; k++)
|
||||
{
|
||||
char val_d[256];
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
tmp_str_list->elems[i].data,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM, i, 0);
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ST_INT:
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
enum msg_hash_enums enum_idx = (enum msg_hash_enums)atoi(info->path);
|
||||
rarch_setting_t *setting = menu_setting_find_enum(enum_idx);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
switch (setting->type)
|
||||
{
|
||||
float i;
|
||||
int32_t orig_value = *setting->value.target.integer;
|
||||
unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_INT_ITEM;
|
||||
float step = setting->step;
|
||||
double min = setting->enforce_minrange ? setting->min : 0.00;
|
||||
double max = setting->enforce_maxrange ? setting->max : 999.00;
|
||||
|
||||
if (setting->get_string_representation)
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
case ST_STRING_OPTIONS:
|
||||
{
|
||||
char val_s[256], val_d[256];
|
||||
int val = (int)i;
|
||||
struct string_list *tmp_str_list = string_split(setting->values, "|");
|
||||
|
||||
*setting->value.target.integer = val;
|
||||
if (tmp_str_list && tmp_str_list->size > 0)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned size = tmp_str_list->size;
|
||||
|
||||
setting->get_string_representation(setting,
|
||||
val_s, sizeof(val_s));
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
char val_d[256];
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
tmp_str_list->elems[i].data,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
MENU_SETTING_DROPDOWN_SETTING_STRING_OPTIONS_ITEM, i, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*setting->value.target.integer = orig_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
break;
|
||||
case ST_INT:
|
||||
{
|
||||
char val_s[16], val_d[16];
|
||||
int val = (int)i;
|
||||
float i;
|
||||
int32_t orig_value = *setting->value.target.integer;
|
||||
unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_INT_ITEM;
|
||||
float step = setting->step;
|
||||
double min = setting->enforce_minrange ? setting->min : 0.00;
|
||||
double max = setting->enforce_maxrange ? setting->max : 999.00;
|
||||
|
||||
snprintf(val_s, sizeof(val_s), "%d", val);
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
if (setting->get_string_representation)
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[256], val_d[256];
|
||||
int val = (int)i;
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
*setting->value.target.integer = val;
|
||||
|
||||
setting->get_string_representation(setting,
|
||||
val_s, sizeof(val_s));
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
|
||||
*setting->value.target.integer = orig_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[16], val_d[16];
|
||||
int val = (int)i;
|
||||
|
||||
snprintf(val_s, sizeof(val_s), "%d", val);
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ST_UINT:
|
||||
{
|
||||
float i;
|
||||
unsigned orig_value = *setting->value.target.unsigned_integer;
|
||||
unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM;
|
||||
float step = setting->step;
|
||||
double min = setting->enforce_minrange ? setting->min : 0.00;
|
||||
double max = setting->enforce_maxrange ? setting->max : 999.00;
|
||||
|
||||
if (setting->get_string_representation)
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[256], val_d[256];
|
||||
int val = (int)i;
|
||||
|
||||
*setting->value.target.unsigned_integer = val;
|
||||
|
||||
setting->get_string_representation(setting,
|
||||
val_s, sizeof(val_s));
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
|
||||
*setting->value.target.unsigned_integer = orig_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[16], val_d[16];
|
||||
int val = (int)i;
|
||||
|
||||
snprintf(val_s, sizeof(val_s), "%d", val);
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case ST_UINT:
|
||||
{
|
||||
float i;
|
||||
unsigned orig_value = *setting->value.target.unsigned_integer;
|
||||
unsigned setting_type = MENU_SETTING_DROPDOWN_SETTING_UINT_ITEM;
|
||||
float step = setting->step;
|
||||
double min = setting->enforce_minrange ? setting->min : 0.00;
|
||||
double max = setting->enforce_maxrange ? setting->max : 999.00;
|
||||
|
||||
if (setting->get_string_representation)
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[256], val_d[256];
|
||||
int val = (int)i;
|
||||
|
||||
*setting->value.target.unsigned_integer = val;
|
||||
|
||||
setting->get_string_representation(setting,
|
||||
val_s, sizeof(val_s));
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
|
||||
*setting->value.target.unsigned_integer = orig_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = min; i <= max; i += step)
|
||||
{
|
||||
char val_s[16], val_d[16];
|
||||
int val = (int)i;
|
||||
|
||||
snprintf(val_s, sizeof(val_s), "%d", val);
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
info->need_refresh = true;
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user