From 4402685627641542d898867613fc24609a6a94e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 May 2015 00:00:37 +0200 Subject: [PATCH] (iOS) Cleanups --- ui/drivers/cocoa/cocoatouch_menu.m | 69 ++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index a3149f35c8..f453735b16 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -341,6 +341,28 @@ static void RunActionSheet(const char* title, const struct string_list* items, U @end +enum +{ + MENU_ITEM_BASIC = 0, +}; + +typedef struct ios_menu_item +{ + char description[PATH_MAX_LENGTH]; +} ios_menu_item_t; + +static id *menu_item_init(ios_menu_item_t *item, unsigned type) +{ + switch (type) + { + case MENU_ITEM_BASIC: + return [RAMenuItemBasic itemWithDescription:BOXSTRING(item->description) + action:^{}] + } + + return nil; +} + /*********************************************/ /* RAMenuItemGeneralSetting */ /* A simple menu item that displays the */ @@ -355,32 +377,35 @@ static void RunActionSheet(const char* title, const struct string_list* items, U + (id)itemForSetting:(rarch_setting_t*)setting action:(void (^)())action { - switch (setting->type) { + ios_menu_item_t item; + + 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 action:action]; - case ST_INT: - case ST_UINT: - case ST_FLOAT: - break; - case ST_PATH: - case ST_DIR: - return [[RAMenuItemPathSetting alloc] initWithSetting:setting action:action]; - case ST_STRING: + case ST_ACTION: + strlcpy(item.description, "Shouldn't be called with ST_NONE or ST_ACTION", sizeof(item.description)); + return menu_item_init(&item, MENU_ITEM_BASIC); + case ST_BOOL: + return [[RAMenuItemBooleanSetting alloc] initWithSetting:setting action:action]; + case ST_INT: + case ST_UINT: + case ST_FLOAT: + break; + case ST_PATH: + case ST_DIR: + return [[RAMenuItemPathSetting alloc] initWithSetting:setting action:action]; + case ST_STRING: case ST_HEX: - break; + break; case ST_BIND: - return [[RAMenuItemBindSetting alloc] initWithSetting:setting action:action]; + return [[RAMenuItemBindSetting alloc] initWithSetting:setting action:action]; 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:^{}]; + case ST_SUB_GROUP: + case ST_END_GROUP: + case ST_END_SUB_GROUP: + default: + strlcpy(item.description, "Shouldn't be called with ST_GROUP", sizeof(item.description)); + return menu_item_init(&item, MENU_ITEM_BASIC); } if (setting->type == ST_STRING && setting->values)