This commit is contained in:
twinaphex 2020-06-07 20:55:27 +02:00
parent 3b93c7c36d
commit d15942f6c8
6 changed files with 29 additions and 84 deletions

View File

@ -2308,7 +2308,6 @@ static unsigned materialui_count_sublabel_lines(
{
menu_entry_t entry;
char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH];
const char *sublabel_str = NULL;
int sublabel_width_max = 0;
wrapped_sublabel_str[0] = '\0';
@ -2321,10 +2320,8 @@ static unsigned materialui_count_sublabel_lines(
entry.value_enabled = false;
menu_entry_get(&entry, 0, entry_idx, NULL, true);
menu_entry_get_sublabel(&entry, &sublabel_str);
/* If sublabel is empty, return immediately */
if (string_is_empty(sublabel_str))
if (string_is_empty(entry.sublabel))
return 0;
/* Wrap sublabel string to fit available width */
@ -2332,7 +2329,7 @@ static unsigned materialui_count_sublabel_lines(
(has_icon ? (int)mui->icon_size : 0);
word_wrap(
wrapped_sublabel_str, sublabel_str,
wrapped_sublabel_str, entry.sublabel,
sublabel_width_max / (int)mui->font_data.hint.glyph_width,
true, 0);
@ -3441,7 +3438,6 @@ static void materialui_render_menu_entry_default(
{
const char *entry_value = NULL;
const char *entry_label = NULL;
const char *entry_sublabel = NULL;
unsigned entry_type = 0;
enum materialui_entry_value_type entry_value_type = MUI_ENTRY_VALUE_NONE;
unsigned entry_value_width = 0;
@ -3470,7 +3466,6 @@ static void materialui_render_menu_entry_default(
/* Read entry parameters */
menu_entry_get_rich_label(entry, &entry_label);
menu_entry_get_value(entry, &entry_value);
menu_entry_get_sublabel(entry, &entry_sublabel);
entry_type = entry->type;
entry_file_type = msg_hash_to_file_type(
@ -3532,7 +3527,7 @@ static void materialui_render_menu_entry_default(
/* Draw entry sublabel
* > Must be done before label + value, since it
* affects y offset positions */
if (!string_is_empty(entry_sublabel))
if (!string_is_empty(entry->sublabel))
{
/* Note: Due to the way the selection highlight
* marker is drawn (height is effectively 1px larger
@ -3559,7 +3554,7 @@ static void materialui_render_menu_entry_default(
sublabel_y = entry_y + vertical_margin + mui->font_data.list.line_height + (int)mui->sublabel_gap + mui->font_data.hint.line_ascender;
/* Wrap sublabel string */
word_wrap(wrapped_sublabel, entry_sublabel,
word_wrap(wrapped_sublabel, entry->sublabel,
(int)((usable_width - (int)mui->sublabel_padding) / mui->font_data.hint.glyph_width),
true, 0);
@ -3765,7 +3760,6 @@ static void materialui_render_menu_entry_playlist_list(
int x_offset)
{
const char *entry_label = NULL;
const char *entry_sublabel = NULL;
int entry_x = x_offset + node->x;
int entry_y = header_height - mui->scroll_y + node->y;
int divider_y = entry_y + (int)node->entry_height;
@ -3788,7 +3782,6 @@ static void materialui_render_menu_entry_playlist_list(
/* Read entry parameters */
menu_entry_get_rich_label(entry, &entry_label);
menu_entry_get_sublabel(entry, &entry_sublabel);
/* If thumbnails are *not* enabled, increase entry
* margin and decrease usable width by landscape
@ -3859,7 +3852,7 @@ static void materialui_render_menu_entry_playlist_list(
/* Draw entry sublabel
* > Must be done before label, since it
* affects y offset positions */
if (!string_is_empty(entry_sublabel))
if (!string_is_empty(entry->sublabel))
{
/* Note: Due to the way the selection highlight
* marker is drawn (height is effectively 1px larger
@ -3880,7 +3873,7 @@ static void materialui_render_menu_entry_playlist_list(
sublabel_y = entry_y + vertical_margin + mui->font_data.list.line_height + (int)mui->sublabel_gap + mui->font_data.hint.line_ascender;
/* Wrap sublabel string */
word_wrap(wrapped_sublabel, entry_sublabel,
word_wrap(wrapped_sublabel, entry->sublabel,
(int)((usable_width - (int)mui->sublabel_padding) / mui->font_data.hint.glyph_width),
true, 0);

View File

@ -240,7 +240,6 @@ void ozone_compute_entries_position(ozone_handle_t *ozone)
/* Entry */
menu_entry_t entry;
ozone_node_t *node = NULL;
const char *sublabel_str = NULL;
menu_entry_init(&entry);
entry.path_enabled = false;
@ -270,11 +269,9 @@ void ozone_compute_entries_position(ozone_handle_t *ozone)
node->wrap = false;
node->sublabel_lines = 0;
menu_entry_get_sublabel(&entry, &sublabel_str);
if (menu_show_sublabels)
{
if (!string_is_empty(sublabel_str))
if (!string_is_empty(entry.sublabel))
{
int sublabel_max_width;
char wrapped_sublabel_str[MENU_SUBLABEL_MAX_LENGTH];
@ -293,7 +290,9 @@ void ozone_compute_entries_position(ozone_handle_t *ozone)
sublabel_max_width -= ozone->dimensions.thumbnail_bar_width;
}
word_wrap(wrapped_sublabel_str, sublabel_str, sublabel_max_width / ozone->fonts.entries_sublabel.glyph_width, false, 0);
word_wrap(wrapped_sublabel_str, entry.sublabel,
sublabel_max_width /
ozone->fonts.entries_sublabel.glyph_width, false, 0);
node->sublabel_lines = ozone_count_lines(wrapped_sublabel_str);
@ -625,7 +624,7 @@ border_iterate:
y = video_info_height / 2 - 60 * scale_factor;
}
menu_entry_get_sublabel(&entry, &sublabel_str);
sublabel_str = entry.sublabel;
if (menu_show_sublabels)
{

View File

@ -4869,7 +4869,6 @@ static void rgui_update_menu_sublabel(rgui_t *rgui)
if (menu_show_sublabels && selection < menu_entries_get_size())
{
menu_entry_t entry;
const char *sublabel = NULL;
menu_entry_init(&entry);
entry.path_enabled = false;
@ -4878,9 +4877,7 @@ static void rgui_update_menu_sublabel(rgui_t *rgui)
entry.value_enabled = false;
menu_entry_get(&entry, 0, (unsigned)selection, NULL, true);
menu_entry_get_sublabel(&entry, &sublabel);
if (!string_is_empty(sublabel))
if (!string_is_empty(entry.sublabel))
{
size_t line_index;
static const char* const
@ -4889,7 +4886,7 @@ static void rgui_update_menu_sublabel(rgui_t *rgui)
/* Sanitise sublabel
* > Replace newline characters with standard delimiter
* > Remove whitespace surrounding each sublabel line */
struct string_list *list = string_split(sublabel, "\n");
struct string_list *list = string_split(entry.sublabel, "\n");
if (list)
{

View File

@ -202,10 +202,6 @@ typedef struct menu_entry
enum menu_entry_type menu_entry_get_type(uint32_t i);
void menu_entry_get_path(menu_entry_t *entry, const char **path);
void menu_entry_get_label(menu_entry_t *entry, const char **label);
uint32_t menu_entry_get_bool_value(uint32_t i);
struct string_list *menu_entry_enum_values(uint32_t i);
@ -232,8 +228,6 @@ void menu_entry_reset(uint32_t i);
void menu_entry_get_rich_label(menu_entry_t *entry, const char **rich_label);
void menu_entry_get_sublabel(menu_entry_t *entry, const char **sublabel);
void menu_entry_get_value(menu_entry_t *entry, const char **value);
void menu_entry_set_value(uint32_t i, const char *s);

View File

@ -3748,14 +3748,6 @@ void menu_entry_init(menu_entry_t *entry)
entry->sublabel_enabled = true;
}
void menu_entry_get_path(menu_entry_t *entry, const char **path)
{
if (!entry || !path)
return;
*path = entry->path;
}
void menu_entry_get_rich_label(menu_entry_t *entry, const char **rich_label)
{
if (!entry || !rich_label)
@ -3767,22 +3759,6 @@ void menu_entry_get_rich_label(menu_entry_t *entry, const char **rich_label)
*rich_label = entry->path;
}
void menu_entry_get_sublabel(menu_entry_t *entry, const char **sublabel)
{
if (!entry || !sublabel)
return;
*sublabel = entry->sublabel;
}
void menu_entry_get_label(menu_entry_t *entry, const char **label)
{
if (!entry || !label)
return;
*label = entry->label;
}
uint32_t menu_entry_get_bool_value(uint32_t i)
{
struct rarch_state *p_rarch = &rarch_st;
@ -5189,11 +5165,10 @@ static bool menu_init(struct rarch_state *p_rarch)
const char *menu_driver_ident(void)
{
struct rarch_state *p_rarch = &rarch_st;
if (!p_rarch->menu_driver_alive)
return NULL;
if (!p_rarch->menu_driver_ctx || !p_rarch->menu_driver_ctx->ident)
return NULL;
return p_rarch->menu_driver_ctx->ident;
if (p_rarch->menu_driver_alive)
if (p_rarch->menu_driver_ctx && p_rarch->menu_driver_ctx->ident)
return p_rarch->menu_driver_ctx->ident;
return NULL;
}
void menu_driver_frame(bool menu_is_alive, video_frame_info_t *video_info)

View File

@ -36,7 +36,7 @@
#include "../../../menu/menu_driver.h"
#endif
// Menu Support
/* Menu Support */
static const void* const associated_delegate_key = &associated_delegate_key;
@ -111,7 +111,6 @@ static void RunActionSheet(const char* title, const struct string_list* items,
{
menu_entry_t entry;
char buffer[PATH_MAX_LENGTH];
const char *label = NULL;
static NSString* const cell_id = @"text";
self.parentTable = tableView;
@ -123,16 +122,15 @@ static void RunActionSheet(const char* title, const struct string_list* items,
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(&entry, &label);
menu_entry_get_value(&entry, &buffer);
if (string_is_empty(label))
if (string_is_empty(entry.label))
strlcpy(buffer,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE),
sizeof(buffer));
if (!string_is_empty(label))
result.textLabel.text = BOXSTRING(label);
if (!string_is_empty(entry.label))
result.textLabel.text = BOXSTRING(entry.label);
result.detailTextLabel.text = BOXSTRING(buffer);
return result;
@ -152,10 +150,8 @@ static void RunActionSheet(const char* title, const struct string_list* items,
- (UITableViewCell*)cellForTableView:(UITableView*)tableView
{
menu_entry_t entry;
const char *label = NULL;
static NSString* const cell_id = @"boolean_setting";
UITableViewCell* result =
UITableViewCell * result =
(UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:cell_id];
if (!result)
@ -169,10 +165,8 @@ static void RunActionSheet(const char* title, const struct string_list* items,
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(&entry, &label);
if (!string_is_empty(label))
result.textLabel.text = BOXSTRING(label);
if (!string_is_empty(entry.path))
result.textLabel.text = BOXSTRING(entry.path);
[(id)result.accessoryView removeTarget:nil
action:NULL
@ -217,17 +211,15 @@ static void RunActionSheet(const char* title, const struct string_list* items,
{
menu_entry_t entry;
struct string_list* items = NULL;
const char *label = NULL;
RAMenuItemEnum __weak* weakSelf = self;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(&entry, &label);
items = menu_entry_enum_values(self.i);
if (!string_is_empty(label))
if (!string_is_empty(entry.path))
{
RunActionSheet(label, items, self.parentTable,
RunActionSheet(entry.path, items, self.parentTable,
^(UIActionSheet* actionSheet, NSInteger buttonIndex)
{
if (buttonIndex == actionSheet.cancelButtonIndex)
@ -253,16 +245,14 @@ static void RunActionSheet(const char* title, const struct string_list* items,
ofController:(UIViewController *)controller
{
menu_entry_t entry;
const char *label = NULL;
menu_entry_init(&entry);
menu_entry_get(&entry, 0, (unsigned)self.i, NULL, true);
menu_entry_get_path(&entry, &label);
self.alert = [[UIAlertView alloc]
initWithTitle:BOXSTRING("RetroArch")
message:BOXSTRING(label)
message:BOXSTRING(entry.path)
delegate:self
cancelButtonTitle:BOXSTRING("Cancel")
otherButtonTitles:BOXSTRING("Clear Keyboard"),
@ -429,18 +419,15 @@ replacementString:(NSString *)string
{
menu_entry_t entry;
char buffer[PATH_MAX_LENGTH];
const char *label = NULL;
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(&entry, &label);
desc = BOXSTRING(label);
alertView =
desc = BOXSTRING(entry.path);
alertView =
[[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new value")
message:desc
delegate:self