Merge pull request #1693 from jeapostrophe/master

change menu_entries to my wish list of functionality
This commit is contained in:
Twinaphex 2015-05-14 22:19:42 +02:00
commit ae1a2ebcd8
8 changed files with 82 additions and 76 deletions

View File

@ -392,7 +392,7 @@ static void glui_frame(void)
if (settings->menu.core_enable)
{
get_core_title(title_msg, sizeof(title_msg));
menu_entries_get_core_title(title_msg, sizeof(title_msg));
glui_blit_line(glui->margin,
global->video_data.height - glui->line_height, title_msg,

View File

@ -426,7 +426,7 @@ static void rgui_render(void)
if (settings->menu.core_enable)
{
get_core_title(title_msg, sizeof(title_msg));
menu_entries_get_core_title(title_msg, sizeof(title_msg));
blit_line(menu,
RGUI_TERM_START_X,
(RGUI_TERM_HEIGHT * FONT_HEIGHT_STRIDE) +

View File

@ -1215,7 +1215,7 @@ static void xmb_frame(void)
if (settings->menu.core_enable)
{
get_core_title(title_msg, sizeof(title_msg));
menu_entries_get_core_title(title_msg, sizeof(title_msg));
xmb_draw_text(menu, xmb, title_msg, xmb->margins.title.left,
global->video_data.height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT);
}

View File

@ -20,8 +20,64 @@
#include "menu_setting.h"
#include "menu_input.h"
#include "../settings.h"
#include "drivers/shared.h"
void get_core_title(char *title_msg, size_t title_msg_len)
size_t menu_entries_get_start()
{
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return 0;
return menu->begin;
}
size_t menu_entries_get_end()
{
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return 0;
return menu_list_get_size(menu->menu_list);
}
void menu_entries_get_title(char *title, size_t title_len)
{
const char *dir = NULL;
const char *label = NULL;
unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
get_title(label, dir, menu_type, title, title_len);
return;
}
uint32_t menu_entries_show_back()
{
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return false;
return (menu_list_get_stack_size(menu->menu_list) > 1);
}
void menu_entries_select_back()
{
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return;
menu_apply_deferred_settings();
menu_list_pop_stack(menu_list);
}
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len)
{
global_t *global = global_get_ptr();
const char *core_name = global->menu.info.library_name;
@ -306,8 +362,10 @@ int menu_entry_get_current_id(bool use_representation)
return -1;
}
/* Returns true if the menu should reload */
uint32_t menu_entry_select(uint32_t i)
// JM: In the cases where this used to return true, it should actually
// arrange for menu_entries_* to start returning new things AND ensure
// that ui_companion_cocoatouch_notify_list_pushed is called.
void menu_entry_select(uint32_t i)
{
menu_entry_t entry;
menu_file_list_cbs_t *cbs = NULL;
@ -322,14 +380,14 @@ uint32_t menu_entry_select(uint32_t i)
menu_list_get_actiondata_at_offset(menu_list->selection_buf, i);
if (setting_is_of_path_type(setting))
return false;
return;
if (setting_is_of_general_type(setting))
{
nav->selection_ptr = i;
if (cbs && cbs->action_ok)
cbs->action_ok(entry.path, entry.label, entry.type, i);
return false;
return;
}
nav->selection_ptr = i;
@ -344,7 +402,7 @@ uint32_t menu_entry_select(uint32_t i)
menu_list_push(menu_list->menu_stack, "",
"info_screen", 0, i);
}
return true;
return;
}
int menu_entry_iterate(unsigned action)

View File

@ -47,7 +47,12 @@ typedef struct menu_entry
unsigned spacing;
} menu_entry_t;
void get_core_title(char *title_msg, size_t title_msg_len);
size_t menu_entries_get_start();
size_t menu_entries_get_end();
void menu_entries_get_title(char *title, size_t title_len);
uint32_t menu_entries_show_back();
void menu_entries_select_back();
void menu_entries_get_core_title(char *title_msg, size_t title_msg_len);
rarch_setting_t *menu_entry_get_setting(uint32_t i);
@ -104,7 +109,7 @@ void menu_entry_get(menu_entry_t *entry, size_t i,
int menu_entry_iterate(unsigned action);
uint32_t menu_entry_select(uint32_t i);
void menu_entry_select(uint32_t i);
int menu_entry_action(menu_entry_t *entry, unsigned i, unsigned action);

View File

@ -43,7 +43,6 @@
- (id)initWithStyle:(UITableViewStyle)style;
- (id)itemForIndexPath:(NSIndexPath*)indexPath;
- (void)menuRefresh;
@end

View File

@ -25,12 +25,6 @@
#include "../../../input/input_keymaps.h"
#include "../../../input/drivers/cocoa_input.h"
#include "../../../menu/menu_displaylist.h"
#include "../../../menu/menu_navigation.h"
#include "../../../menu/menu_list.h"
#include "../../../menu/menu_setting.h"
#include "../../../menu/drivers/shared.h"
#include "../../../menu/menu_entry.h"
// Menu Support
@ -123,8 +117,6 @@ static void RunActionSheet(const char* title, const struct string_list* items,
result.selectionStyle = UITableViewCellSelectionStyleNone;
result.textLabel.text = BOXSTRING(label);
if (buffer[0] == '\0')
strlcpy(buffer, "<default>", sizeof(buffer));
if (label[0] == '\0')
strlcpy(buffer, "N/A", sizeof(buffer));
result.detailTextLabel.text = BOXSTRING(buffer);
@ -641,10 +633,6 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath
[[self tableView] reloadData];
}
- (void)menuRefresh
{
}
@end
@interface RAMainMenu : RAMenuBase<RAMenuActioner>
@ -670,32 +658,24 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath
char title[256], title_msg[256];
NSMutableArray *everything;
RAMainMenu* __weak weakSelf;
const char *dir = NULL;
const char *label = NULL;
unsigned menu_type = 0;
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu)
return;
everything = [NSMutableArray array];
get_core_title(title_msg, sizeof(title_msg));
menu_entries_get_core_title(title_msg, sizeof(title_msg));
self.title = BOXSTRING(title_msg);
menu_list_get_last_stack(menu->menu_list, &dir, &label, &menu_type);
get_title(label, dir, menu_type, title, sizeof(title));
menu_entries_get_title(title, sizeof(title));
[everything addObject:BOXSTRING(title)];
end = menu_list_get_size(menu->menu_list);
for (i = menu->begin; i < end; i++)
end = menu_entries_get_end();
for (i = menu_entries_get_start(); i < end; i++)
[everything addObject:[self make_menu_item_for_entry: i]];
self.sections = [NSMutableArray array];
[self.sections addObject:everything];
weakSelf = self;
if (menu_list_get_stack_size(menu->menu_list) > 1)
if (menu_entries_show_back())
[self set_leftbutton:BOXSTRING("Back")
target:weakSelf
action:@selector(menuBack)];
@ -703,9 +683,6 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath
[self set_rightbutton:BOXSTRING("Switch")
target:[RetroArch_iOS get]
action:@selector(showGameView)];
if ( menu->message_contents[0] != '\0' )
apple_display_alert(menu->message_contents, NULL);
}
- (void) set_leftbutton:(NSString *)title target:(id)target action:(SEL)action
@ -763,35 +740,12 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- (void)menuSelect: (uint32_t) i
{
if (menu_entry_select(i))
{
[self menuRefresh];
[self reloadData];
}
}
- (void)menuRefresh
{
menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu || !menu_list)
return;
if (!menu->need_refresh)
return;
menu_displaylist_push(menu_list->selection_buf, menu_list->menu_stack);
menu_entry_select(i);
}
- (void)menuBack
{
menu_list_t *menu_list = menu_list_get_ptr();
if (!menu_list)
return;
menu_apply_deferred_settings();
menu_list_pop_stack(menu_list);
[self menuRefresh];
[self reloadData];
menu_entries_select_back();
}
@end

View File

@ -407,7 +407,7 @@ enum
- (void)mainMenuRefresh
{
[self.mainmenu menuRefresh];
[self.mainmenu reloadData];
}
@end
@ -519,24 +519,14 @@ static void ui_companion_cocoatouch_event_command(void *data,
static void ui_companion_cocoatouch_notify_list_pushed(void *data,
file_list_t *list, file_list_t *menu_list)
{
#if 0
(void)data;
(void)list;
(void)menu_list;
RetroArch_iOS *ap = (RetroArch_iOS *)apple_platform;
RARCH_WARN("notify list pushed (this log entry is not printed)");
// JM: Ideally, RA would have set this, but I'm going to force it
// for testing, because my menu refresh relies on it.
menu_handle_t *menu = menu_driver_get_ptr();
if (!menu) return;
menu->need_refresh = true;
if (ap)
[ap mainMenuRefresh];
#endif
}
const ui_companion_driver_t ui_companion_cocoatouch = {