From d500efb4541b212f3741ae4b033f3b5b695109c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 May 2015 12:44:32 +0200 Subject: [PATCH] Change menu_entry_get_label --- menu/menu_entry.c | 10 +++--- menu/menu_entry.h | 2 +- ui/drivers/cocoa/cocoatouch_menu.m | 55 ++++++++++++++++++++---------- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/menu/menu_entry.c b/menu/menu_entry.c index b4bdeaab0e..4c85a746ef 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -106,12 +106,12 @@ enum menu_entry_type menu_entry_get_type(uint32_t i) return MENU_ENTRY_ACTION; } -const char *menu_entry_get_label(uint32_t i) +void menu_entry_get_label(uint32_t i, char *label, size_t sizeof_label) { - rarch_setting_t *setting = menu_entry_get_setting(i); - if (setting) - return setting->short_description; - return ""; + menu_entry_t entry; + menu_entry_get_entry(&entry, i, NULL, true); + + strlcpy(label, entry.path, sizeof(label)); } uint32_t menu_entry_get_bool_value(uint32_t i) diff --git a/menu/menu_entry.h b/menu/menu_entry.h index 59b34831b2..2afa4a1897 100644 --- a/menu/menu_entry.h +++ b/menu/menu_entry.h @@ -53,7 +53,7 @@ rarch_setting_t *menu_entry_get_setting(uint32_t i); enum menu_entry_type menu_entry_get_type(uint32_t i); -const char *menu_entry_get_label(uint32_t i); +void menu_entry_get_label(uint32_t i, char *label, size_t sizeof_label); uint32_t menu_entry_get_bool_value(uint32_t i); diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index abacd7070c..73d216c58b 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -107,6 +107,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, - (UITableViewCell*)cellForTableView:(UITableView*)tableView { char buffer[PATH_MAX_LENGTH]; + char label[PATH_MAX_LENGTH]; static NSString* const cell_id = @"text"; self.parentTable = tableView; @@ -115,12 +116,17 @@ static void RunActionSheet(const char* title, const struct string_list* items, if (!result) result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cell_id]; + + menu_entry_get_label(self.i, label, sizeof(label)); + menu_entry_get_value(self.i, buffer, sizeof(buffer)); result.selectionStyle = UITableViewCellSelectionStyleNone; - result.textLabel.text = BOXSTRING(menu_entry_get_label(self.i)); - menu_entry_get_value(self.i, buffer, sizeof(buffer)); + result.textLabel.text = BOXSTRING(label); + if (buffer[0] == '\0') strlcpy(buffer, "", sizeof(buffer)); + if (label[0] == '\0') + strlcpy(buffer, "N/A", sizeof(buffer)); result.detailTextLabel.text = BOXSTRING(buffer); return result; } @@ -138,6 +144,7 @@ static void RunActionSheet(const char* title, const struct string_list* items, - (UITableViewCell*)cellForTableView:(UITableView*)tableView { + char label[PATH_MAX_LENGTH]; static NSString* const cell_id = @"boolean_setting"; UITableViewCell* result = @@ -150,8 +157,10 @@ static void RunActionSheet(const char* title, const struct string_list* items, result.selectionStyle = UITableViewCellSelectionStyleNone; result.accessoryView = [UISwitch new]; } + + menu_entry_get_label(self.i, label, sizeof(label)); - result.textLabel.text = BOXSTRING(menu_entry_get_label(self.i)); + result.textLabel.text = BOXSTRING(label); [(id)result.accessoryView removeTarget:nil action:NULL forControlEvents:UIControlEventValueChanged]; @@ -195,10 +204,13 @@ static void RunActionSheet(const char* title, const struct string_list* items, ofController:(UIViewController*)controller { struct string_list* items; + char label[PATH_MAX_LENGTH]; RAMenuItemEnum __weak* weakSelf = self; - + + menu_entry_get_label(self.i, label, sizeof(label)); items = menu_entry_enum_values(self.i); - RunActionSheet(menu_entry_get_label(self.i), items, self.parentTable, + + RunActionSheet(label, items, self.parentTable, ^(UIActionSheet* actionSheet, NSInteger buttonIndex) { if (buttonIndex == actionSheet.cancelButtonIndex) @@ -222,24 +234,28 @@ static void RunActionSheet(const char* title, const struct string_list* items, - (void)wasSelectedOnTableView:(UITableView *)tableView ofController:(UIViewController *)controller { - self.alert = [[UIAlertView alloc] - initWithTitle:BOXSTRING("RetroArch") - message:BOXSTRING(menu_entry_get_label(self.i)) - delegate:self + char label[PATH_MAX_LENGTH]; + + menu_entry_get_label(self.i, label, sizeof(label)); + + self.alert = [[UIAlertView alloc] + initWithTitle:BOXSTRING("RetroArch") + message:BOXSTRING(label) + delegate:self cancelButtonTitle:BOXSTRING("Cancel") otherButtonTitles:BOXSTRING("Clear Keyboard"), - BOXSTRING("Clear Joystick"), BOXSTRING("Clear Axis"), nil]; + BOXSTRING("Clear Joystick"), BOXSTRING("Clear Axis"), nil]; [self.alert show]; - + [self.parentTable reloadData]; - + self.bindTimer = [NSTimer - scheduledTimerWithTimeInterval:.1f - target:self - selector:@selector(checkBind:) - userInfo:nil - repeats:YES]; + scheduledTimerWithTimeInterval:.1f + target:self + selector:@selector(checkBind:) + userInfo:nil + repeats:YES]; } - (void)finishWithClickedButton:(bool)clicked @@ -437,11 +453,14 @@ replacementString:(NSString *)string ofController:(UIViewController*)controller { char buffer[PATH_MAX_LENGTH]; + char label[PATH_MAX_LENGTH]; NSString *desc = BOXSTRING("N/A"); UIAlertView *alertView; UITextField *field; - desc = BOXSTRING(menu_entry_get_label(self.i)); + menu_entry_get_label(self.i, label, sizeof(label)); + + desc = BOXSTRING(label); alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new value")