Rewrite menu_entry_get_value

This commit is contained in:
twinaphex 2017-09-28 06:32:49 +02:00
parent c5255b1bff
commit b8e900cd32
7 changed files with 26 additions and 14 deletions

View File

@ -1017,7 +1017,7 @@ static void mui_render_menu_list(
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)i, NULL, true);
menu_entry_get_value((unsigned)i, NULL, entry_value, sizeof(entry_value));
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
menu_entry_get_rich_label(&entry, rich_label, sizeof(rich_label));
entry_selected = selection == i;

View File

@ -590,7 +590,7 @@ static void rgui_render(void *data, bool is_idle)
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)i, NULL, true);
menu_entry_get_value((unsigned)i, NULL, entry_value, sizeof(entry_value));
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
menu_entry_get_rich_label(&entry, entry_path, sizeof(entry_path));
ticker.s = entry_title_buf;

View File

@ -590,17 +590,23 @@ static void xui_render(void *data, bool is_idle)
end = menu_entries_get_end();
for (i = 0; i < end; i++)
{
menu_entry_t entry;
char entry_path[PATH_MAX_LENGTH] = {0};
char entry_value[PATH_MAX_LENGTH] = {0};
wchar_t msg_right[PATH_MAX_LENGTH] = {0};
wchar_t msg_left[PATH_MAX_LENGTH] = {0};
menu_entry_get_value(i, NULL, entry_value, sizeof(entry_value));
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, NULL, true);
menu_entry_get_value(&entry, entry_value, sizeof(entry_value));
menu_entry_get_path(i, entry_path, sizeof(entry_path));
mbstowcs(msg_left, entry_path, sizeof(msg_left) / sizeof(wchar_t));
mbstowcs(msg_right, entry_value, sizeof(msg_right) / sizeof(wchar_t));
xui_set_list_text(i, msg_left, msg_right);
menu_entry_free(&entry);
}
selection = menu_navigation_get_selection();

View File

@ -523,7 +523,7 @@ static int zarch_zui_render_lay_root_recent(
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, NULL, true);
menu_entry_get_rich_label(&entry, rich_label, sizeof(rich_label));
menu_entry_get_value(i, NULL, entry_value,sizeof(entry_value));
menu_entry_get_value(&entry, entry_value,sizeof(entry_value));
if (zarch_zui_list_item(
video_info,

View File

@ -272,14 +272,11 @@ void menu_entry_reset(uint32_t i)
menu_entry_action(&entry, i, MENU_ACTION_START);
}
void menu_entry_get_value(uint32_t i, void *data, char *s, size_t len)
void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len)
{
menu_entry_t entry;
file_list_t *list = (file_list_t*)data;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, i, list, true);
strlcpy(s, entry.value, len);
if (!entry)
return;
strlcpy(s, entry->value, len);
}
void menu_entry_set_value(uint32_t i, const char *s)

View File

@ -97,7 +97,7 @@ void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len);
bool menu_entry_get_sublabel(uint32_t i, char *s, size_t len);
void menu_entry_get_value(uint32_t i, void *data, char *s, size_t len);
void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len);
void menu_entry_set_value(uint32_t i, const char *s);

View File

@ -111,6 +111,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
- (UITableViewCell*)cellForTableView:(UITableView*)tableView
{
menu_entry_t entry;
char buffer[PATH_MAX_LENGTH];
char label[PATH_MAX_LENGTH];
static NSString* const cell_id = @"text";
@ -122,8 +123,10 @@ static void RunActionSheet(const char* title, const struct string_list* items,
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:cell_id];
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(self.i, label, sizeof(label));
menu_entry_get_value(self.i, NULL, buffer, sizeof(buffer));
menu_entry_get_value(&entry, buffer, sizeof(buffer));
result.textLabel.text = BOXSTRING(label);
@ -132,6 +135,7 @@ static void RunActionSheet(const char* title, const struct string_list* items,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(buffer));
result.detailTextLabel.text = BOXSTRING(buffer);
menu_entry_free(&entry);
return result;
}
@ -408,12 +412,15 @@ replacementString:(NSString *)string
- (void)wasSelectedOnTableView:(UITableView*)tableView
ofController:(UIViewController*)controller
{
menu_entry_t entry;
char buffer[PATH_MAX_LENGTH];
char label[PATH_MAX_LENGTH];
UIAlertView *alertView = NULL;
UITextField *field = NULL;
NSString *desc = NULL;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(self.i, label, sizeof(label));
desc = BOXSTRING(label);
@ -429,7 +436,7 @@ replacementString:(NSString *)string
field = [alertView textFieldAtIndex:0];
field.delegate = self.formatter;
menu_entry_get_value(self.i, NULL, buffer, sizeof(buffer));
menu_entry_get_value(&entry, buffer, sizeof(buffer));
if (string_is_empty(buffer))
strlcpy(buffer,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
@ -437,6 +444,8 @@ replacementString:(NSString *)string
field.placeholder = BOXSTRING(buffer);
menu_entry_free(&entry);
[alertView show];
}