Merge pull request #1236 from jeapostrophe/master

Improving iOS configuration menus, specifically for default paths, directory selection, and give example enumeration for strings.
This commit is contained in:
Twinaphex 2014-11-11 18:15:30 +01:00
commit f16187337d
3 changed files with 85 additions and 21 deletions

View File

@ -253,9 +253,12 @@ static void file_action(enum file_action action, NSString* source, NSString* tar
const char* basename = path_basename(contents->elems[i].data);
uint32_t section = isalpha(basename[0]) ? (toupper(basename[0]) - 'A') + 2 : 1;
section = (contents->elems[i].attr.i == RARCH_DIRECTORY) ? 0 : section;
char is_directory = (contents->elems[i].attr.i == RARCH_DIRECTORY);
section = is_directory ? 0 : section;
[self.sections[section] addObject:[RADirectoryItem directoryItemFromElement:&contents->elems[i]]];
if (! ( self.forDirectory && ! is_directory )) {
[self.sections[section] addObject:[RADirectoryItem directoryItemFromElement:&contents->elems[i]]];
}
}
dir_list_free(contents);

View File

@ -201,25 +201,40 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
+ (id)itemForSetting:(rarch_setting_t*)setting
{
switch (setting->type)
{
case ST_BOOL:
return [[RAMenuItemBooleanSetting alloc] initWithSetting:setting];
case ST_PATH:
return [[RAMenuItemPathSetting alloc] initWithSetting:setting];
case ST_BIND:
return [[RAMenuItemBindSetting alloc] initWithSetting:setting];
default:
break;
}
switch (setting->type) {
case ST_NONE:
case ST_ACTION:
return [RAMenuItemBasic itemWithDescription:BOXSTRING("Shouldn't be called with ST_NONE or ST_ACTION")
action:^{}];
case ST_BOOL:
return [[RAMenuItemBooleanSetting alloc] initWithSetting:setting];
case ST_INT:
case ST_UINT:
case ST_FLOAT:
break;
case ST_PATH:
case ST_DIR:
return [[RAMenuItemPathSetting alloc] initWithSetting:setting];
case ST_STRING:
case ST_HEX:
break;
case ST_BIND:
return [[RAMenuItemBindSetting alloc] initWithSetting:setting];
case ST_GROUP:
case ST_SUB_GROUP:
case ST_END_GROUP:
case ST_END_SUB_GROUP:
default:
return [RAMenuItemBasic itemWithDescription:BOXSTRING("Shouldn't be called with ST_*GROUP")
action:^{}];
}
if (setting->type == ST_STRING && setting->values)
return [[RAMenuItemEnumSetting alloc] initWithSetting:setting];
RAMenuItemGeneralSetting* item = [[RAMenuItemGeneralSetting alloc] initWithSetting:setting];
if (
item.setting->type == ST_INT ||
if (item.setting->type == ST_INT ||
item.setting->type == ST_UINT ||
item.setting->type == ST_FLOAT)
item.formatter = [[RANumberFormatter alloc] initWithSetting:item.setting];
@ -250,7 +265,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[self attachDefaultingGestureTo:result];
result.textLabel.text = BOXSTRING("N/A");
result.textLabel.text = BOXSTRING("<Uninitialized>");
if (self.setting)
{
@ -259,7 +274,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
setting_data_get_string_representation(self.setting, buffer, sizeof(buffer));
if (buffer[0] == '\0')
strlcpy(buffer, "N/A", sizeof(buffer));
strlcpy(buffer, "<default>", sizeof(buffer));
result.detailTextLabel.text = BOXSTRING(buffer);
@ -412,7 +427,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
[weakSelf.parentTable reloadData];
}];
list.allowBlank = (self.setting->flags & SD_FLAG_ALLOW_EMPTY);
list.forDirectory = (self.setting->flags & SD_FLAG_PATH_DIR);
@ -641,6 +656,10 @@ static void RunActionSheet(const char* title, const struct string_list* items, U
} else {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:BOXSTRING("Resume") style:UIBarButtonItemStyleBordered target:[RetroArch_iOS get] action:@selector(showGameView)];
}
if ( driver.menu->message_contents[0] != '\0' ) {
apple_display_alert(driver.menu->message_contents, NULL);
}
}
- (void)menuRefresh {

View File

@ -1134,6 +1134,18 @@ rarch_setting_t setting_data_string_setting(enum setting_type type,
return result;
}
rarch_setting_t setting_data_string_setting_options
(enum setting_type type,
const char* name, const char* short_description, char* target,
unsigned size, const char* default_value, const char *empty, const char *values,
const char *group, const char *subgroup, change_handler_t change_handler,
change_handler_t read_handler)
{
rarch_setting_t result = setting_data_string_setting(type, name, short_description, target, size, default_value, empty, group, subgroup, change_handler, read_handler);
result.values = values;
return result;
}
static int setting_data_bind_action_start(void *data)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
@ -2576,6 +2588,11 @@ static void general_write_handler(void *data)
if (!(settings_list_append(list, list_info, setting_data_string_setting(ST_STRING, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER)))) return false; \
}
#define CONFIG_STRING_OPTIONS(TARGET, NAME, SHORT, DEF, OPTS, group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER) \
{ \
if (!(settings_list_append(list, list_info, setting_data_string_setting_options(ST_STRING, NAME, SHORT, TARGET, sizeof(TARGET), DEF, "", OPTS, group_info, subgroup_info, CHANGE_HANDLER, READ_HANDLER)))) return false; \
}
#define CONFIG_HEX(TARGET, NAME, SHORT, group_info, subgroup_info)
#define CONFIG_BIND(TARGET, PLAYER, PLAYER_OFFSET, NAME, SHORT, DEF, group_info, subgroup_info) \
@ -2866,22 +2883,47 @@ static bool setting_data_append_list_main_menu_options(
return true;
}
// JM: This is a very painful function to write, especially because
// we'll have to do it to all the drivers.
const char* config_get_input_driver_options() {
int input_option_k = 0;
int input_options_len = 0;
while (input_drivers[input_option_k]) {
const char *opt = input_drivers[input_option_k]->ident;
input_options_len += strlen(opt) + 1;
input_option_k++;
}
uint offset = 0;
char *input_options = (char*)calloc(input_options_len, sizeof(char));
for (int i = 0; i < input_option_k; i++) {
const char *opt = input_drivers[i]->ident;
strlcpy(input_options + offset, opt, input_options_len - offset);
offset += strlen(opt);
input_options[offset] = '|';
offset += 1;
}
input_options[input_options_len] = '\0';
return input_options;
}
static bool setting_data_append_list_driver_options(
rarch_setting_t **list,
rarch_setting_info_t *list_info)
{
rarch_setting_group_info_t group_info;
rarch_setting_group_info_t subgroup_info;
START_GROUP(group_info, "Driver Options");
START_SUB_GROUP(list, list_info, "State", group_info.name, subgroup_info);
CONFIG_STRING(
CONFIG_STRING_OPTIONS(
g_settings.input.driver,
"input_driver",
"Input Driver",
config_get_default_input(),
config_get_input_driver_options(),
group_info.name,
subgroup_info.name,
NULL,