diff --git a/menu/disp/glui.c b/menu/disp/glui.c index 67dfdbcc97..dbe3ce887f 100644 --- a/menu/disp/glui.c +++ b/menu/disp/glui.c @@ -41,6 +41,7 @@ typedef struct glui_handle static void glui_blit_line(float x, float y, const char *message, bool green) { + struct font_params params = {0}; gl_t *gl = (gl_t*)driver_video_resolve(NULL); if (!driver.menu || !gl) @@ -48,7 +49,6 @@ static void glui_blit_line(float x, float y, const char *message, bool green) gl_set_viewport(gl, gl->win_width, gl->win_height, false, false); - struct font_params params = {0}; params.x = x / gl->win_width; params.y = 1.0f - y / gl->win_height; @@ -65,6 +65,20 @@ static void glui_blit_line(float x, float y, const char *message, bool green) static void glui_render_background(bool force_transparency) { + static const GLfloat vertex[] = { + 0, 0, + 1, 0, + 0, 1, + 1, 1, + }; + + static const GLfloat tex_coord[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0, + }; + struct gl_coords coords; float alpha = 0.75f; gl_t *gl = NULL; glui_handle_t *glui = NULL; @@ -98,24 +112,9 @@ static void glui_render_background(bool force_transparency) glViewport(0, 0, gl->win_width, gl->win_height); - static const GLfloat vertex[] = { - 0, 0, - 1, 0, - 0, 1, - 1, 1, - }; - - static const GLfloat tex_coord[] = { - 0, 1, - 1, 1, - 0, 0, - 1, 0, - }; - - struct gl_coords coords; - coords.vertices = 4; - coords.vertex = vertex; - coords.tex_coord = tex_coord; + coords.vertices = 4; + coords.vertex = vertex; + coords.tex_coord = tex_coord; coords.lut_tex_coord = tex_coord; if ((g_settings.menu.pause_libretro @@ -145,31 +144,6 @@ static void glui_render_background(bool force_transparency) static void glui_draw_cursor(float x, float y) { - gl_t *gl = NULL; - glui_handle_t *glui = NULL; - - if (!driver.menu) - return; - - glui = (glui_handle_t*)driver.menu->userdata; - - if (!glui) - return; - - GLfloat color[] = { - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - 1.0f, 1.0f, 1.0f, 1.0f, - }; - - gl = (gl_t*)driver_video_resolve(NULL); - - if (!gl) - return; - - glViewport(x - 5, gl->win_height - y, 11, 11); - static const GLfloat vertex[] = { 0, 0, 1, 0, @@ -183,11 +157,34 @@ static void glui_draw_cursor(float x, float y) 0, 0, 1, 0, }; - + GLfloat color[] = { + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, + }; struct gl_coords coords; - coords.vertices = 4; - coords.vertex = vertex; - coords.tex_coord = tex_coord; + gl_t *gl = NULL; + glui_handle_t *glui = NULL; + + if (!driver.menu) + return; + + glui = (glui_handle_t*)driver.menu->userdata; + + if (!glui) + return; + + gl = (gl_t*)driver_video_resolve(NULL); + + if (!gl) + return; + + glViewport(x - 5, gl->win_height - y, 11, 11); + + coords.vertices = 4; + coords.vertex = vertex; + coords.tex_coord = tex_coord; coords.lut_tex_coord = tex_coord; coords.color = color; @@ -272,6 +269,8 @@ static void glui_frame(void) size_t end; gl_t *gl = (gl_t*)driver_video_resolve(NULL); glui_handle_t *glui = NULL; + const char *core_name = NULL; + const char *core_version = NULL; if (!driver.menu || !gl) return; @@ -288,8 +287,8 @@ static void glui_frame(void) glui->line_height = g_settings.video.font_size * 4 / 3; glui->glyph_width = glui->line_height / 2; - glui->margin = gl->win_width / 20 ; - glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width; + glui->margin = gl->win_width / 20 ; + glui->term_width = (gl->win_width - glui->margin * 2) / glui->glyph_width; glui->term_height = (gl->win_height - glui->margin * 2) / glui->line_height - 2; driver.menu->mouse.ptr = (driver.menu->mouse.y - glui->margin) / @@ -324,13 +323,13 @@ static void glui_frame(void) glui_blit_line(glui->margin * 2, glui->margin + glui->line_height, title_buf, true); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) core_name = "No Core"; - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) @@ -427,10 +426,9 @@ static void glui_init_core_info(void *data) core_info_list_free(g_extern.core_info); g_extern.core_info = NULL; + if (*g_settings.libretro_directory) - { g_extern.core_info = core_info_list_new(g_settings.libretro_directory); - } } static void glui_update_core_info(void *data) @@ -490,14 +488,14 @@ static void glui_free(void *data) static GLuint glui_png_texture_load_(const char * file_name) { + GLuint texture = 0; + struct texture_image ti = {0}; if (! path_file_exists(file_name)) return 0; - struct texture_image ti = {0}; texture_image_load(&ti, file_name); /* Generate the OpenGL texture object */ - GLuint texture = 0; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ti.width, ti.height, 0, diff --git a/menu/disp/rgui.c b/menu/disp/rgui.c index 0fb408b0b5..34fc8df343 100644 --- a/menu/disp/rgui.c +++ b/menu/disp/rgui.c @@ -45,6 +45,10 @@ typedef struct rgui_handle static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) { int y, x; + + if (!glyph) + return; + for (y = 0; y < FONT_HEIGHT; y++) { for (x = 0; x < FONT_WIDTH; x++) @@ -65,9 +69,12 @@ static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) static uint16_t gray_filler(unsigned x, unsigned y) { + unsigned col; + x >>= 1; y >>= 1; - unsigned col = ((x + y) & 1) + 1; + col = ((x + y) & 1) + 1; + #if defined(GEKKO) || defined(PSP) return (6 << 12) | (col << 8) | (col << 4) | (col << 0); #else @@ -77,9 +84,11 @@ static uint16_t gray_filler(unsigned x, unsigned y) static uint16_t green_filler(unsigned x, unsigned y) { + unsigned col; + x >>= 1; y >>= 1; - unsigned col = ((x + y) & 1) + 1; + col = ((x + y) & 1) + 1; #if defined(GEKKO) || defined(PSP) return (6 << 12) | (col << 8) | (col << 5) | (col << 0); #else @@ -107,6 +116,10 @@ static void color_rect(uint16_t *buf, unsigned pitch, uint16_t color) { unsigned j, i; + + if (!buf) + return; + for (j = y; j < y + height; j++) for (i = x; i < x + width; i++) if (i < driver.menu->width && j < driver.menu->height) @@ -200,6 +213,9 @@ static void rgui_render_background(void *data) { rgui_handle_t *rgui = (rgui_handle_t*)data; + if (!rgui) + return; + fill_rect(rgui->frame_buf, rgui->frame_buf_pitch, 0, 0, driver.menu->width, driver.menu->height, gray_filler); @@ -248,7 +264,7 @@ static void rgui_render_messagebox(const char *message) for (i = 0; i < list->size; i++) { unsigned line_width; - char *msg = list->elems[i].data; + char *msg = list->elems[i].data; unsigned msglen = strlen(msg); if (msglen > RGUI_TERM_WIDTH) @@ -297,11 +313,12 @@ static void rgui_render_messagebox(const char *message) static void rgui_blit_cursor(void* data) { - int16_t x, y; rgui_handle_t *rgui = (rgui_handle_t*)data; + int16_t x = driver.menu->mouse.x; + int16_t y = driver.menu->mouse.y; - x = driver.menu->mouse.x; - y = driver.menu->mouse.y; + if (!rgui) + return; color_rect(rgui->frame_buf, rgui->frame_buf_pitch, x, y-5, 1, 11, 0xFFFF); @@ -317,6 +334,8 @@ static void rgui_render(void) const char *dir = NULL; const char *label = NULL; rgui_handle_t *rgui = NULL; + const char *core_name = NULL; + const char *core_version = NULL; if (driver.menu->need_refresh && g_extern.is_menu @@ -361,13 +380,13 @@ static void rgui_render(void) g_extern.frame_count / RGUI_TERM_START_X, title, true); blit_line(RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) core_name = "No Core"; - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) diff --git a/menu/disp/xmb.c b/menu/disp/xmb.c index 9c562b853b..f3aad6ae68 100644 --- a/menu/disp/xmb.c +++ b/menu/disp/xmb.c @@ -237,6 +237,7 @@ static void xmb_draw_icon(GLuint texture, float x, float y, static void xmb_draw_text(const char *str, float x, float y, float scale_factor, float alpha) { + gl_t *gl; uint8_t a8 = 0; struct font_params params = {0}; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; @@ -250,7 +251,7 @@ static void xmb_draw_text(const char *str, float x, if (a8 == 0) return; - gl_t *gl = (gl_t*)driver_video_resolve(NULL); + gl = (gl_t*)driver_video_resolve(NULL); if (!gl) return; @@ -276,9 +277,24 @@ static void xmb_draw_text(const char *str, float x, static void xmb_render_background(bool force_transparency) { - float alpha = 0.75f; - gl_t *gl = NULL; - xmb_handle_t *xmb = NULL; + static const GLfloat vertex[] = { + 0, 0, + 1, 0, + 0, 1, + 1, 1, + }; + + static const GLfloat tex_coord[] = { + 0, 1, + 1, 1, + 0, 0, + 1, 0, + }; + + float alpha = 0.75f; + gl_t *gl = NULL; + xmb_handle_t *xmb = NULL; + struct gl_coords coords; if (!driver.menu) return; @@ -312,21 +328,7 @@ static void xmb_render_background(bool force_transparency) glViewport(0, 0, gl->win_width, gl->win_height); - static const GLfloat vertex[] = { - 0, 0, - 1, 0, - 0, 1, - 1, 1, - }; - static const GLfloat tex_coord[] = { - 0, 1, - 1, 1, - 0, 0, - 1, 0, - }; - - struct gl_coords coords; coords.vertices = 4; coords.vertex = vertex; coords.tex_coord = tex_coord; @@ -359,8 +361,6 @@ static void xmb_render_background(bool force_transparency) static void xmb_get_message(const char *message) { - size_t i; - (void)i; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb || !message || !*message) @@ -371,24 +371,27 @@ static void xmb_get_message(const char *message) static void xmb_render_messagebox(const char *message) { + int x, y; unsigned i; + struct string_list *list = NULL; gl_t *gl = (gl_t*)driver_video_resolve(NULL); xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!gl || !xmb) return; - struct string_list *list = string_split(message, "\n"); + list = string_split(message, "\n"); if (!list) return; + if (list->elems == 0) { string_list_free(list); return; } - int x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; - int y = gl->win_height / 2 - list->size * xmb->font_size / 2; + x = gl->win_width / 2 - strlen(list->elems[0].data) * xmb->font_size / 4; + y = gl->win_height / 2 - list->size * xmb->font_size / 2; for (i = 0; i < list->size; i++) { @@ -456,10 +459,16 @@ static void xmb_list_open_old(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { - xmb_node_t *node = NULL; - node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); - float ia = i == current ? xmb->i_active_alpha : 0; - if (dir == -1) ia = 0; + float ia = 0; + xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); + + if (!node) + continue; + + if (i == current) + ia = xmb->i_active_alpha; + if (dir == -1) + ia = 0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->label_alpha, &inOutQuad, NULL); //if (i == current) @@ -479,6 +488,7 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { + float iy = 0; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) @@ -492,8 +502,6 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) //else // node->x = xmb->icon_size*dir; - float iy = 0; - if (i < current) if (xmb->depth > 1) iy = xmb->vspacing * (i - (int)current + xmb->above_subitem_offset); @@ -512,12 +520,13 @@ static void xmb_list_open_new(file_list_t *list, int dir, size_t current) } for (i = 0; i < file_list_get_size(list); i++) { + float ia; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) continue; - float ia = i == current ? xmb->i_active_alpha : xmb->i_passive_alpha; + ia = (i == current) ? xmb->i_active_alpha : xmb->i_passive_alpha; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); @@ -647,6 +656,7 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) for (i = 0; i < file_list_get_size(list); i++) { + float ia = 0.5; xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(list, i); if (!xmb) @@ -656,7 +666,8 @@ static void xmb_list_switch_new(file_list_t *list, int dir, size_t current) node->alpha = 0; node->label_alpha = 0; - float ia = (i == current) ? 1.0 : 0.5; + if (i == current) + ia = 1.0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, ia, &node->label_alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, 0, &node->x, &inOutQuad, NULL); @@ -716,13 +727,14 @@ static void xmb_populate_entries(void *data, const char *path, for (j = 0; j < xmb->num_categories; j++) { + float ia, iz; xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; if (!node) continue; - float ia = j == xmb->active_category ? xmb->c_active_alpha : xmb->c_passive_alpha; - float iz = j == xmb->active_category ? xmb->c_active_zoom : xmb->c_passive_zoom; + ia = (j == xmb->active_category) ? xmb->c_active_alpha : xmb->c_passive_alpha; + iz = (j == xmb->active_category) ? xmb->c_active_zoom : xmb->c_passive_zoom; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); add_tween(XMB_DELAY, iz, &node->zoom, &inOutQuad, NULL); } @@ -745,13 +757,14 @@ static void xmb_populate_entries(void *data, const char *path, for (j = 0; j < xmb->num_categories; j++) { + float ia; xmb_node_t *node = j ? xmb_node_for_core(j-1) : &xmb->settings_node; if (!node) continue; - float ia = j == xmb->active_category ? xmb->c_active_alpha - : xmb->depth <= 1 ? xmb->c_passive_alpha : 0; + ia = (j == xmb->active_category) ? xmb->c_active_alpha + : (xmb->depth <= 1) ? xmb->c_passive_alpha : 0; add_tween(XMB_DELAY, ia, &node->alpha, &inOutQuad, NULL); } @@ -777,6 +790,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, const char *dir = NULL; const char *label = NULL; unsigned menu_type = 0; + xmb_node_t *core_node = NULL; size_t end = file_list_get_size(list); xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; @@ -785,8 +799,8 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, file_list_get_last(stack, &dir, &label, &menu_type); - xmb_node_t *core_node = xmb->active_category ? - xmb_node_for_core(cat_selection_ptr - 1) : NULL; + if (xmb->active_category) + core_node = xmb_node_for_core(cat_selection_ptr - 1); for (i = 0; i < end; i++) { @@ -841,7 +855,7 @@ static void xmb_draw_items(file_list_t *list, file_list_t *stack, icon = xmb->textures[XMB_TEXTURE_RELOAD].id; break; case MENU_SETTING_ACTION: - icon = xmb->depth == 3 ? + icon = (xmb->depth == 3) ? xmb->textures[XMB_TEXTURE_SUBSETTING].id : xmb->textures[XMB_TEXTURE_SETTING].id; break; @@ -914,6 +928,8 @@ static void xmb_frame(void) { int i, depth; char title_msg[64]; + const char *core_name = NULL; + const char *core_version = NULL; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; gl_t *gl = (gl_t*)driver_video_resolve(NULL); @@ -927,7 +943,8 @@ static void xmb_frame(void) xmb_render_background(false); - const char *core_name = g_extern.menu.info.library_name; + core_name = g_extern.menu.info.library_name; + if (!core_name) core_name = g_extern.system.info.library_name; if (!core_name) @@ -936,7 +953,8 @@ static void xmb_frame(void) xmb_draw_text( xmb->title, xmb->title_margin_left, xmb->title_margin_top, 1, 1); - const char *core_version = g_extern.menu.info.library_version; + core_version = g_extern.menu.info.library_version; + if (!core_version) core_version = g_extern.system.info.library_version; if (!core_version) @@ -1026,9 +1044,7 @@ static void xmb_init_core_info(void *data) core_info_list_free(g_extern.core_info); g_extern.core_info = NULL; if (*g_settings.libretro_directory) - { g_extern.core_info = core_info_list_new(g_settings.libretro_directory); - } } static void xmb_update_core_info(void *data) @@ -1041,6 +1057,7 @@ static void *xmb_init(void) menu_handle_t *menu = NULL; xmb_handle_t *xmb = NULL; const video_driver_t *video_driver = NULL; + float scale_factor = 1; gl_t *gl = (gl_t*)driver_video_resolve(&video_driver); if (video_driver != &video_gl || !gl) @@ -1091,13 +1108,18 @@ static void *xmb_init(void) xmb->active_item_factor = 3.0; xmb->under_item_offset = 5.0; - float scale_factor = 1; - if (gl->win_width >= 3840) scale_factor = 2.0; - else if (gl->win_width >= 2560) scale_factor = 1.5; - else if (gl->win_width >= 1920) scale_factor = 1.0; - else if (gl->win_width >= 1280) scale_factor = 0.75; - else if (gl->win_width >= 640) scale_factor = 0.5; - else if (gl->win_width >= 320) scale_factor = 0.25; + if (gl->win_width >= 3840) + scale_factor = 2.0; + else if (gl->win_width >= 2560) + scale_factor = 1.5; + else if (gl->win_width >= 1920) + scale_factor = 1.0; + else if (gl->win_width >= 1280) + scale_factor = 0.75; + else if (gl->win_width >= 640) + scale_factor = 0.5; + else if (gl->win_width >= 320) + scale_factor = 0.25; strlcpy(xmb->icon_dir, "256", sizeof(xmb->icon_dir)); @@ -1166,6 +1188,8 @@ static void xmb_context_reset(void *data) fontpath[PATH_MAX_LENGTH], core_id[PATH_MAX_LENGTH], texturepath[PATH_MAX_LENGTH], content_texturepath[PATH_MAX_LENGTH]; + core_info_t* info = NULL; + core_info_list_t* info_list = NULL; gl_t *gl = NULL; xmb_handle_t *xmb = NULL; menu_handle_t *menu = (menu_handle_t*)data; @@ -1241,8 +1265,7 @@ static void xmb_context_reset(void *data) xmb->settings_node.alpha = xmb->c_active_alpha; xmb->settings_node.zoom = xmb->c_active_zoom; - core_info_list_t* info_list = (core_info_list_t*)g_extern.core_info; - core_info_t* info = NULL; + info_list = (core_info_list_t*)g_extern.core_info; if (!info_list) return; @@ -1290,8 +1313,9 @@ static void xmb_navigation_clear(void *data, bool pending_push) { (void)data; - if (!pending_push) - xmb_selection_pointer_changed(); + if (pending_push) + return; + xmb_selection_pointer_changed(); } static void xmb_navigation_decrement(void *data) @@ -1342,7 +1366,9 @@ static void xmb_navigation_ascend_alphabet(void *data, size_t *unused) static void xmb_list_insert(void *data, const char *path, const char *unused, size_t list_size) { + float iy; int current = 0, i = list_size; + xmb_node_t *node = NULL; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; file_list_t *list = (file_list_t*)data; @@ -1357,14 +1383,14 @@ static void xmb_list_insert(void *data, return; } - xmb_node_t *node = (xmb_node_t*)list->list[i].userdata; + node = (xmb_node_t*)list->list[i].userdata; if (!node) return; current = driver.menu->selection_ptr; - float iy = (i < current) ? xmb->vspacing * + iy = (i < current) ? xmb->vspacing * (i - current + xmb->above_item_offset) : xmb->vspacing * (i - current + xmb->under_item_offset); @@ -1398,6 +1424,7 @@ static void xmb_list_clear(void *data) static void xmb_list_cache(bool horizontal, unsigned action) { + size_t stack_size; xmb_handle_t *xmb = (xmb_handle_t*)driver.menu->userdata; if (!xmb) @@ -1413,7 +1440,8 @@ static void xmb_list_cache(bool horizontal, unsigned action) xmb->cat_selection_ptr_old = driver.menu->cat_selection_ptr; driver.menu->cat_selection_ptr += action == MENU_ACTION_LEFT ? -1 : 1; - size_t stack_size = driver.menu->menu_list->menu_stack->size; + stack_size = driver.menu->menu_list->menu_stack->size; + if (driver.menu->cat_selection_ptr == 0) { strlcpy(driver.menu->menu_list->menu_stack->list[stack_size-1].label, "Main Menu", PATH_MAX_LENGTH);