From d66db000c664f341bc73ce46bc77f6b65d7c2fda Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 16 Jun 2015 01:59:26 +0200 Subject: [PATCH] Create wrappers for accessing menu->begin --- menu/cbs/menu_cbs_get_value.c | 2 +- menu/drivers/glui.c | 14 +++++++------- menu/drivers/rgui.c | 35 ++++++++++++++++++----------------- menu/drivers/xmb.c | 11 ++++++----- menu/menu_entries.c | 11 +++++++++++ menu/menu_entry.h | 2 ++ menu/menu_hash.h | 2 ++ 7 files changed, 47 insertions(+), 30 deletions(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 0fda66a7f0..3088cf985b 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -503,7 +503,7 @@ static void menu_action_setting_disp_set_label_menu_disk_index( current = control->get_image_index(); if (current >= images) - strlcpy(s, "No Disk", len); + strlcpy(s, menu_hash_to_str(MENU_VALUE_NO_DISK), len); else snprintf(s, len, "%u", current + 1); } diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index a17e78d18a..fb7e3a30bf 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -302,7 +302,7 @@ static void glui_render_menu_list(glui_handle_t *glui, glui->list_block.carr.coords.vertices = 0; - for (i = menu->begin; i < end; i++) + for (i = menu_entries_get_start(); i < end; i++) { bool entry_selected; char entry_path[PATH_MAX_LENGTH]; @@ -667,14 +667,14 @@ static void glui_navigation_set(bool scroll) end = menu_entries_get_end(); if (nav->selection_ptr < num_lines / 2 || end <= num_lines) - menu->begin = 0; + menu_entries_set_start(0); else if (nav->selection_ptr < (end - num_lines / 2)) - menu->begin = nav->selection_ptr - num_lines / 2; + menu_entries_set_start(nav->selection_ptr - num_lines / 2); else - menu->begin = end - num_lines; + menu_entries_set_start(end - num_lines); - if (menu->begin > 5) - menu->begin -= 5; + if (menu_entries_get_start() > 5) + menu_entries_set_start(menu_entries_get_start() - 5); } menu_animation_push(disp->animation, 10, scroll_pos, @@ -687,7 +687,7 @@ static void glui_navigation_clear(bool pending_push) if (!menu) return; - menu->begin = 0; + menu_entries_set_start(0); menu->scroll_y = 0; } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 9f30ac7d38..09132f13c6 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -383,12 +383,12 @@ static void rgui_render(void) if (settings->menu.pointer.enable) { - menu_input->pointer.ptr = menu_input->pointer.y / 11 - 2 + menu->begin; + menu_input->pointer.ptr = menu_input->pointer.y / 11 - 2 + menu_entries_get_start(); if (menu_input->pointer.dragging) { menu->scroll_y += menu_input->pointer.dy; - menu->begin = -menu->scroll_y / 11 + 2; + menu_entries_set_start(-menu->scroll_y / 11 + 2); if (menu->scroll_y > 0) menu->scroll_y = 0; } @@ -397,25 +397,25 @@ static void rgui_render(void) if (settings->menu.mouse.enable) { if (menu_input->mouse.scrolldown - && menu->begin < menu_entries_get_end() - RGUI_TERM_HEIGHT) - menu->begin++; + && (menu_entries_get_start() < menu_entries_get_end() - RGUI_TERM_HEIGHT)) + menu_entries_set_start(menu_entries_get_start() + 1); - if (menu_input->mouse.scrollup && menu->begin > 0) - menu->begin--; + if (menu_input->mouse.scrollup && (menu_entries_get_start() > 0)) + menu_entries_set_start(menu_entries_get_start() - 1); - menu_input->mouse.ptr = menu_input->mouse.y / 11 - 2 + menu->begin; + menu_input->mouse.ptr = menu_input->mouse.y / 11 - 2 + menu_entries_get_start(); } /* Do not scroll if all items are visible. */ if (menu_entries_get_end() <= RGUI_TERM_HEIGHT) - menu->begin = 0; + menu_entries_set_start(0);; bottom = menu_entries_get_end() - RGUI_TERM_HEIGHT; - if (menu->begin > bottom) - menu->begin = bottom; + if (menu_entries_get_start() > bottom) + menu_entries_set_start(bottom); - end = (menu->begin + RGUI_TERM_HEIGHT <= menu_entries_get_end()) ? - menu->begin + RGUI_TERM_HEIGHT : menu_entries_get_end(); + end = ((menu_entries_get_start() + RGUI_TERM_HEIGHT) <= (menu_entries_get_end())) ? + menu_entries_get_start() + RGUI_TERM_HEIGHT : menu_entries_get_end(); rgui_render_background(); @@ -551,9 +551,10 @@ static void *rgui_init(void) frame_buf->width = 320; frame_buf->height = 240; menu->display.header_height = FONT_HEIGHT_STRIDE * 2; - menu->begin = 0; frame_buf->pitch = frame_buf->width * sizeof(uint16_t); + menu_entries_set_start(0); + ret = rguidisp_init_font(menu); if (!ret) @@ -622,7 +623,7 @@ static void rgui_navigation_clear(bool pending_push) if (!menu) return; - menu->begin = 0; + menu_entries_set_start(0); menu->scroll_y = 0; } @@ -641,12 +642,12 @@ static void rgui_navigation_set(bool scroll) return; if (nav->selection_ptr < RGUI_TERM_HEIGHT/2) - menu->begin = 0; + menu_entries_set_start(0); else if (nav->selection_ptr >= RGUI_TERM_HEIGHT/2 && nav->selection_ptr < (end - RGUI_TERM_HEIGHT/2)) - menu->begin = nav->selection_ptr - RGUI_TERM_HEIGHT/2; + menu_entries_set_start(nav->selection_ptr - RGUI_TERM_HEIGHT/2); else if (nav->selection_ptr >= (end - RGUI_TERM_HEIGHT/2)) - menu->begin = end - RGUI_TERM_HEIGHT; + menu_entries_set_start(end - RGUI_TERM_HEIGHT); } static void rgui_navigation_set_last(void) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4282bfe554..59b71b901d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1028,7 +1028,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, matrix_4x4_scale(&mscal, 1 /* scale_factor */, 1 /* scale_factor */, 1); matrix_4x4_multiply(&mymat, &mscal, &mymat); - i = menu->begin; + i = menu_entries_get_start(); if (list == xmb->selection_buf_old) i = 0; @@ -1248,7 +1248,8 @@ static void xmb_render(void) current = nav->selection_ptr; end = menu_list_get_size(menu_list); - menu->begin = 0; + menu_entries_set_start(0); + for (i = 0; i < end; i++) { float item_y1 = xmb->margins.screen.top + xmb_item_y(xmb, i, current); @@ -1256,7 +1257,7 @@ static void xmb_render(void) if (item_y2 < 0) { - menu->begin++; + menu_entries_set_start(menu_entries_get_start() + 1); continue; } @@ -1276,8 +1277,8 @@ static void xmb_render(void) } } - if (menu->begin > 5) - menu->begin -= 5; + if (menu_entries_get_start() > 5) + menu_entries_set_start(menu_entries_get_start() - 5); anim->is_active = false; anim->label.is_updated = false; diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f9bb66b994..96593d07b8 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -22,6 +22,17 @@ #include "../general.h" +/* Sets the starting index of the menu entry list. */ +void menu_entries_set_start(size_t i) +{ + menu_handle_t *menu = menu_driver_get_ptr(); + + if (!menu) + return; + + menu->begin = i; +} + /* Returns the starting index of the menu entry list. */ size_t menu_entries_get_start(void) { diff --git a/menu/menu_entry.h b/menu/menu_entry.h index f4359704ae..b4a05c05b2 100644 --- a/menu/menu_entry.h +++ b/menu/menu_entry.h @@ -118,6 +118,8 @@ int menu_entry_select(uint32_t i); int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action); +void menu_entries_set_start(size_t i); + size_t menu_entries_get_start(void); size_t menu_entries_get_end(void); diff --git a/menu/menu_hash.h b/menu/menu_hash.h index d36b5cdc41..cafcea094b 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -178,6 +178,8 @@ extern "C" { #define MENU_LABEL_VIDEO_SHADER_NUM_PASSES 0x79b2992fU #define MENU_LABEL_CHEAT_NUM_PASSES 0x1910eb87U +#define MENU_VALUE_NO_DISK 0x7d54e5cdU + #define MENU_VALUE_MD5 0x0b888fabU #define MENU_VALUE_SHA1 0x7c9de632U #define MENU_VALUE_CRC 0x0b88671dU