Created
January 9, 2017 04:11
-
-
Save andres-asm/bc4b00f60652fdbe22f418409d06c9e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void nuk_layout_ps3(nuk_handle_t *xmb, int width) | |
| { | |
| unsigned new_font_size, new_header_height; | |
| settings_t *settings = config_get_ptr(); | |
| float scale_factor = (settings->menu.xmb.scale_factor * width) / (1920.0 * 100); | |
| xmb->above_subitem_offset = 1.5; | |
| xmb->above_item_offset = -1.0; | |
| xmb->active_item_factor = 3.0; | |
| xmb->under_item_offset = 5.0; | |
| xmb->categories.active.zoom = 1.0; | |
| xmb->categories.passive.zoom = 0.5; | |
| xmb->items.active.zoom = 1.0; | |
| xmb->items.passive.zoom = 0.5; | |
| xmb->categories.active.alpha = 1.0; | |
| xmb->categories.passive.alpha = 0.85; | |
| xmb->items.active.alpha = 1.0; | |
| xmb->items.passive.alpha = 0.85; | |
| xmb->shadow_offset = 2.0; | |
| new_font_size = 32.0 * scale_factor; | |
| xmb->font2_size = 24.0 * scale_factor; | |
| new_header_height = 128.0 * scale_factor; | |
| xmb->thumbnail_width = 460.0 * scale_factor; | |
| xmb->savestate_thumbnail_width= 460.0 * scale_factor; | |
| xmb->cursor.size = 64.0; | |
| xmb->icon.spacing.horizontal = 200.0 * scale_factor; | |
| xmb->icon.spacing.vertical = 64.0 * scale_factor; | |
| xmb->margins.screen.top = (256+32) * scale_factor; | |
| xmb->margins.screen.left = 336.0 * scale_factor; | |
| xmb->margins.title.left = 60 * scale_factor; | |
| xmb->margins.title.top = 60 * scale_factor + new_font_size / 3; | |
| xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3; | |
| xmb->margins.label.left = 85.0 * scale_factor; | |
| xmb->margins.label.top = new_font_size / 3.0; | |
| xmb->margins.setting.left = 600.0 * scale_factor; | |
| xmb->icon.size = 128.0 * scale_factor; | |
| xmb->font_size = new_font_size; | |
| #ifdef XMB_DEBUG | |
| RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins.screen.left); | |
| RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins.screen.top); | |
| RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins.title.left); | |
| RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins.title.top); | |
| RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins.title.bottom); | |
| RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins.label.left); | |
| RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins.label.top); | |
| RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins.setting.left); | |
| RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon.spacing.horizontal); | |
| RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon.spacing.vertical); | |
| RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon.size); | |
| #endif | |
| menu_display_set_header_height(new_header_height); | |
| } | |
| static void nuk_layout_psp(nuk_handle_t *xmb, int width) | |
| { | |
| unsigned new_font_size, new_header_height; | |
| settings_t *settings = config_get_ptr(); | |
| float scale_factor = ((settings->menu.xmb.scale_factor * width) / (1920.0 * 100)) * 1.5; | |
| #ifdef _3DS | |
| scale_factor = settings->menu.xmb.scale_factor / 400.0; | |
| #endif | |
| xmb->above_subitem_offset = 1.5; | |
| xmb->above_item_offset = -1.0; | |
| xmb->active_item_factor = 2.0; | |
| xmb->under_item_offset = 3.0; | |
| xmb->categories.active.zoom = 1.0; | |
| xmb->categories.passive.zoom = 1.0; | |
| xmb->items.active.zoom = 1.0; | |
| xmb->items.passive.zoom = 1.0; | |
| xmb->categories.active.alpha = 1.0; | |
| xmb->categories.passive.alpha = 0.85; | |
| xmb->items.active.alpha = 1.0; | |
| xmb->items.passive.alpha = 0.85; | |
| xmb->shadow_offset = 1.0; | |
| new_font_size = 32.0 * scale_factor; | |
| xmb->font2_size = 24.0 * scale_factor; | |
| new_header_height = 128.0 * scale_factor; | |
| xmb->margins.screen.top = (256+32) * scale_factor; | |
| xmb->thumbnail_width = 460.0 * scale_factor; | |
| xmb->savestate_thumbnail_width= 460.0 * scale_factor; | |
| xmb->cursor.size = 64.0; | |
| xmb->icon.spacing.horizontal = 250.0 * scale_factor; | |
| xmb->icon.spacing.vertical = 108.0 * scale_factor; | |
| xmb->margins.screen.left = 136.0 * scale_factor; | |
| xmb->margins.title.left = 60 * scale_factor; | |
| xmb->margins.title.top = 60 * scale_factor + new_font_size / 3; | |
| xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3; | |
| xmb->margins.label.left = 85.0 * scale_factor; | |
| xmb->margins.label.top = new_font_size / 3.0; | |
| xmb->margins.setting.left = 600.0 * scale_factor; | |
| xmb->icon.size = 128.0 * scale_factor; | |
| xmb->font_size = new_font_size; | |
| #ifdef XMB_DEBUG | |
| RARCH_LOG("[XMB] margin screen left: %.2f\n", xmb->margins.screen.left); | |
| RARCH_LOG("[XMB] margin screen top: %.2f\n", xmb->margins.screen.top); | |
| RARCH_LOG("[XMB] margin title left: %.2f\n", xmb->margins.title.left); | |
| RARCH_LOG("[XMB] margin title top: %.2f\n", xmb->margins.title.top); | |
| RARCH_LOG("[XMB] margin title bott: %.2f\n", xmb->margins.title.bottom); | |
| RARCH_LOG("[XMB] margin label left: %.2f\n", xmb->margins.label.left); | |
| RARCH_LOG("[XMB] margin label top: %.2f\n", xmb->margins.label.top); | |
| RARCH_LOG("[XMB] margin sett left: %.2f\n", xmb->margins.setting.left); | |
| RARCH_LOG("[XMB] icon spacing hor: %.2f\n", xmb->icon.spacing.horizontal); | |
| RARCH_LOG("[XMB] icon spacing ver: %.2f\n", xmb->icon.spacing.vertical); | |
| RARCH_LOG("[XMB] icon size: %.2f\n", xmb->icon.size); | |
| #endif | |
| menu_display_set_header_height(new_header_height); | |
| } | |
| static void nuk_layout(nuk_handle_t *xmb) | |
| { | |
| size_t selection; | |
| unsigned width, height, i, current, end; | |
| file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); | |
| if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) | |
| return; | |
| video_driver_get_size(&width, &height); | |
| /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ | |
| if (width > 320 && height > 240) | |
| nuk_layout_ps3(xmb, width); | |
| else | |
| nuk_layout_psp(xmb, width); | |
| current = selection; | |
| end = menu_entries_get_end(); | |
| for (i = 0; i < end; i++) | |
| { | |
| float ia = xmb->items.passive.alpha; | |
| float iz = xmb->items.passive.zoom; | |
| nuk_node_t *node = (nuk_node_t*)menu_entries_get_userdata_at_offset( | |
| selection_buf, i); | |
| if (!node) | |
| continue; | |
| if (i == current) | |
| { | |
| ia = xmb->items.active.alpha; | |
| iz = xmb->items.active.alpha; | |
| } | |
| node->alpha = ia; | |
| node->label_alpha = ia; | |
| node->zoom = iz; | |
| node->y = nuk_item_y(xmb, i, current); | |
| } | |
| if (xmb->depth <= 1) | |
| return; | |
| current = xmb->selection_ptr_old; | |
| end = file_list_get_size(xmb->selection_buf_old); | |
| for (i = 0; i < end; i++) | |
| { | |
| float ia = 0; | |
| float iz = xmb->items.passive.zoom; | |
| nuk_node_t *node = (nuk_node_t*)menu_entries_get_userdata_at_offset( | |
| xmb->selection_buf_old, i); | |
| if (!node) | |
| continue; | |
| if (i == current) | |
| { | |
| ia = xmb->items.active.alpha; | |
| iz = xmb->items.active.alpha; | |
| } | |
| node->alpha = ia; | |
| node->label_alpha = 0; | |
| node->zoom = iz; | |
| node->y = nuk_item_y(xmb, i, current); | |
| node->x = xmb->icon.size * 1 * -2; | |
| } | |
| } | |
| static void nuk_ribbon_set_vertex(float *ribbon_verts, unsigned idx, unsigned row, unsigned col) | |
| { | |
| ribbon_verts[idx++] = ((float)col) / (XMB_RIBBON_COLS-1) * 2.0f - 1.0f; | |
| ribbon_verts[idx++] = ((float)row) / (XMB_RIBBON_ROWS-1) * 2.0f - 1.0f; | |
| } | |
| static void nuk_init_ribbon(nuk_handle_t * xmb) | |
| { | |
| video_coords_t coords; | |
| unsigned vertices_total; | |
| unsigned r, c, col; | |
| unsigned i = 0; | |
| float *ribbon_verts = NULL; | |
| float *dummy = NULL; | |
| video_coord_array_t *ca = menu_display_get_coords_array(); | |
| vertices_total = XMB_RIBBON_VERTICES; | |
| dummy = (float*)calloc(4 * vertices_total, sizeof(float)); | |
| ribbon_verts = (float*)calloc(2 * vertices_total, sizeof(float)); | |
| /* Set up vertices */ | |
| for (r = 0; r < XMB_RIBBON_ROWS - 1; r++) | |
| { | |
| for (c = 0; c < XMB_RIBBON_COLS; c++) | |
| { | |
| col = r % 2 ? XMB_RIBBON_COLS - c - 1 : c; | |
| nuk_ribbon_set_vertex(ribbon_verts, i, r, col); | |
| nuk_ribbon_set_vertex(ribbon_verts, i + 2, r + 1, col); | |
| i += 4; | |
| } | |
| } | |
| coords.color = dummy; | |
| coords.vertex = ribbon_verts; | |
| coords.tex_coord = dummy; | |
| coords.lut_tex_coord = dummy; | |
| coords.vertices = vertices_total; | |
| video_coord_array_append(ca, &coords, coords.vertices); | |
| free(dummy); | |
| free(ribbon_verts); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment