From 63883a113139a01ff4331aa3495894657a9b6afa Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Mar 2013 20:05:05 +0100 Subject: [PATCH] Combine render_msg and render_msg_place with params argument --- frontend/menu/rmenu.c | 337 +++++++++++++++++++++++++++++-------- gfx/fonts/d3d_font.h | 4 +- gfx/fonts/gl_font.h | 4 +- gfx/fonts/gl_raster_font.c | 33 ++-- gfx/fonts/ps_libdbgfont.c | 35 ++-- gfx/fonts/xdk1_xfonts.c | 24 ++- gfx/fonts/xdk360_fonts.cpp | 29 ++-- gfx/gfx_common.h | 9 +- gfx/gl.c | 12 +- xdk/xdk_d3d.cpp | 24 ++- 10 files changed, 377 insertions(+), 134 deletions(-) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index e2430e22bd..590a1c13c3 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -643,18 +643,23 @@ static void display_menubar(void *data) menu *current_menu = (menu*)data; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; filebrowser_t *fb = browser; - char current_path[256], rarch_version[128], msg[128]; + char msg[128]; + font_params_t font_parms = {0}; rmenu_default_positions_t default_pos; menu_set_default_pos(&default_pos); - snprintf(rarch_version, sizeof(rarch_version), "v%s", PACKAGE_VERSION); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.current_path_y_position; + font_parms.scale = default_pos.current_path_font_size; + font_parms.color = WHITE; + switch(current_menu->enum_id) { case GENERAL_VIDEO_MENU: snprintf(msg, sizeof(msg), "NEXT -> [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.current_path_y_position, default_pos.current_path_font_size, WHITE, msg); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); break; case GENERAL_AUDIO_MENU: case EMU_GENERAL_MENU: @@ -662,12 +667,12 @@ static void display_menubar(void *data) case EMU_AUDIO_MENU: case PATH_MENU: snprintf(msg, sizeof(msg), "[%s] <- PREV | NEXT -> [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L), rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.current_path_y_position, default_pos.current_path_font_size, WHITE, msg); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); break; case CONTROLS_MENU: case INGAME_MENU_RESIZE: snprintf(msg, sizeof(msg), "[%s] <- PREV", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.current_path_y_position, default_pos.current_path_font_size, WHITE, msg); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); break; default: break; @@ -689,8 +694,8 @@ static void display_menubar(void *data) case PATH_SYSTEM_DIR_CHOICE: fb = tmpBrowser; case FILE_BROWSER_MENU: - snprintf(current_path, sizeof(current_path), "PATH: %s", filebrowser_get_current_dir(fb)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.current_path_y_position, default_pos.current_path_font_size, WHITE, current_path); + snprintf(msg, sizeof(msg), "PATH: %s", filebrowser_get_current_dir(fb)); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); break; default: break; @@ -698,11 +703,27 @@ static void display_menubar(void *data) rarch_position_t position = {0}; device_ptr->ctx_driver->rmenu_draw_bg(&position); + + font_parms.x = default_pos.core_msg_x_position; + font_parms.y = default_pos.core_msg_y_position; + font_parms.scale = default_pos.core_msg_font_size; + font_parms.color = WHITE; - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.core_msg_x_position, default_pos.core_msg_y_position, default_pos.core_msg_font_size, WHITE, g_extern.title_buf); + device_ptr->font_ctx->render_msg(device_ptr, g_extern.title_buf, &font_parms); #ifdef __CELLOS_LV2__ - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, 0.05f, 1.4f, WHITE, current_menu->title); - device_ptr->font_ctx->render_msg_place(device_ptr,0.80f, 0.015f, 0.82f, WHITE, rarch_version); + + font_parms.x = default_pos.x_position; + font_parms.y = 0.05f; + font_parms.scale = 1.4f; + font_parms.color = WHITE; + device_ptr->font_ctx->render_msg(device_ptr, current_menu->title, &font_parms); + + font_parms.x = 0.80f; + font_parms.y = 0.015f; + font_parms.scale = 0.82f; + font_parms.color = WHITE; + snprintf(msg, sizeof(msg), "v%s", PACKAGE_VERSION); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); #endif } @@ -746,14 +767,17 @@ void browser_render(void *data) DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; unsigned file_count = b->current_dir.list->size; unsigned int current_index, page_number, page_base, i; + font_params_t font_parms = {0}; + rmenu_default_positions_t default_pos = {0}; - rmenu_default_positions_t default_pos; menu_set_default_pos(&default_pos); current_index = b->current_dir.ptr; page_number = current_index / default_pos.entries_per_page; page_base = page_number * default_pos.entries_per_page; + font_parms.scale = default_pos.variable_font_size; + for (i = page_base; i < file_count && i < page_base + default_pos.entries_per_page; ++i) { char fname_tmp[256]; @@ -770,7 +794,11 @@ void browser_render(void *data) device_ptr->ctx_driver->rmenu_draw_panel(&position); } - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.starting_y_position, default_pos.variable_font_size, i == current_index ? RED : b->current_dir.list->elems[i].attr.b ? GREEN : WHITE, fname_tmp); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.starting_y_position; + font_parms.color = i == current_index ? RED : b->current_dir.list->elems[i].attr.b ? GREEN : WHITE; + + device_ptr->font_ctx->render_msg(device_ptr, fname_tmp, &font_parms); } } @@ -778,6 +806,7 @@ int select_file(void *data, void *state) { menu *current_menu = (menu*)data; rmenu_state_t *rstate = (rmenu_state_t*)state; + font_params_t font_parms = {0}; uint64_t input = rstate->input; @@ -914,9 +943,16 @@ int select_file(void *data, void *state) display_menubar(current_menu); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, comment); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = WHITE; + + device_ptr->font_ctx->render_msg(device_ptr, comment, &font_parms); snprintf(comment, sizeof(comment), "[%s] - return to settings [%s] - Reset Startdir", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_X), rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_START)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, comment); + font_parms.y = default_pos.comment_two_y_position; + font_parms.color = YELLOW; + device_ptr->font_ctx->render_msg(device_ptr, comment, &font_parms); if(current_menu->browser_draw) current_menu->browser_draw(filebrowser); @@ -928,6 +964,7 @@ int select_directory(void *data, void *state) { menu *current_menu = (menu*)data; rmenu_state_t *rstate = (rmenu_state_t*)state; + font_params_t font_parms = {0}; uint64_t input = rstate->input; @@ -1010,13 +1047,24 @@ int select_directory(void *data, void *state) display_menubar(current_menu); snprintf(msg, sizeof(msg), "[%s] - Enter dir | [%s] - Go back", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_B), rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_X)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_two_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = YELLOW; + + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); snprintf(msg, sizeof(msg), "[%s] - Reset to startdir", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_START)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg); + + font_parms.y = default_pos.comment_two_y_position + (default_pos.y_position_increment * 1); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); snprintf(msg, sizeof(msg), "INFO - Browse to a directory and assign it as the path by\npressing [%s].", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_Y)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg); + + font_parms.y = default_pos.comment_y_position; + font_parms.color = WHITE; + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); if(current_menu->browser_draw) current_menu->browser_draw(filebrowser); @@ -1973,6 +2021,7 @@ static int select_setting(void *data, void *state) { menu *current_menu = (menu*)data; rmenu_state_t *rstate = (rmenu_state_t*)state; + font_params_t font_parms = {0}; uint64_t input = rstate->input; int ret = 0; @@ -2055,8 +2104,16 @@ static int select_setting(void *data, void *state) if(items[i].page == current_menu->page) { default_pos.starting_y_position += default_pos.y_position_increment; - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.starting_y_position, default_pos.variable_font_size, current_menu->selected == items[i].enum_id ? YELLOW : WHITE, items[i].text); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position_center, default_pos.starting_y_position, default_pos.variable_font_size, WHITE, items[i].setting_text); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.starting_y_position; + font_parms.scale = default_pos.variable_font_size; + font_parms.color = current_menu->selected == items[i].enum_id ? YELLOW : WHITE; + device_ptr->font_ctx->render_msg(device_ptr, items[i].text, &font_parms); + + font_parms.x = default_pos.x_position_center; + font_parms.color = WHITE; + device_ptr->font_ctx->render_msg(device_ptr, items[i].setting_text, &font_parms); if(current_menu->selected == items[i].enum_id) { @@ -2065,7 +2122,12 @@ static int select_setting(void *data, void *state) position.y = default_pos.starting_y_position; device_ptr->ctx_driver->rmenu_draw_panel(&position); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, items[i].comment); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = WHITE; + device_ptr->font_ctx->render_msg(device_ptr, items[i].comment, &font_parms); } } } @@ -2073,9 +2135,16 @@ static int select_setting(void *data, void *state) free(items); snprintf(msg, sizeof(msg), "[%s] + [%s] - Resume game", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L3), rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R3)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_two_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = YELLOW; + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + snprintf(msg, sizeof(msg), "[%s] - Reset to default", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_START)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg); + font_parms.y = default_pos.comment_two_y_position + (default_pos.y_position_increment * 1); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); if(current_menu->browser_draw) current_menu->browser_draw(filebrowser); @@ -2088,6 +2157,7 @@ int select_rom(void *data, void *state) { menu *current_menu = (menu*)data; rmenu_state_t *rstate = (rmenu_state_t*)state; + font_params_t font_parms = {0}; uint64_t input = rstate->input; @@ -2146,15 +2216,25 @@ int select_rom(void *data, void *state) else snprintf(msg, sizeof(msg), "INFO - Press [%s] to load the game.", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_B)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = WHITE; + + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); display_menubar(current_menu); snprintf(msg, sizeof(msg), "[%s] + [%s] - resume game", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L3), rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R3)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position, default_pos.font_size, YELLOW, msg); + + font_parms.y = default_pos.comment_two_y_position; + font_parms.color = YELLOW; + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); snprintf(msg, sizeof(msg), "[%s] - Settings", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_SELECT)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_two_y_position + (default_pos.y_position_increment * 1), default_pos.font_size, YELLOW, msg); + + font_parms.y = default_pos.comment_two_y_position + (default_pos.y_position_increment * 1); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); if(current_menu->browser_draw) current_menu->browser_draw(filebrowser); @@ -2166,6 +2246,7 @@ int ingame_menu_resize(void *data, void *state) { menu *current_menu = (menu*)data; rmenu_state_t *rstate = (rmenu_state_t*)state; + font_params_t font_parms = {0}; uint64_t input = rstate->input; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; @@ -2272,60 +2353,127 @@ int ingame_menu_resize(void *data, void *state) snprintf(viewport_w, sizeof(viewport_w), "Viewport W: #%d", g_extern.console.screen.viewports.custom_vp.width); snprintf(viewport_h, sizeof(viewport_h), "Viewport H: #%d", g_extern.console.screen.viewports.custom_vp.height); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position, default_pos.font_size, GREEN, viewport_x); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*1), default_pos.font_size, GREEN, viewport_y); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*2), default_pos.font_size, GREEN, viewport_w); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*3), default_pos.font_size, GREEN, viewport_h); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = GREEN; - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*4), default_pos.font_size, WHITE, "CONTROLS:"); + device_ptr->font_ctx->render_msg(device_ptr, viewport_x, &font_parms); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 1); + device_ptr->font_ctx->render_msg(device_ptr, viewport_y, &font_parms); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 2); + device_ptr->font_ctx->render_msg(device_ptr, viewport_w, &font_parms); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 3); + device_ptr->font_ctx->render_msg(device_ptr, viewport_h, &font_parms); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 4); + device_ptr->font_ctx->render_msg(device_ptr, "CONTROLS:", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_LEFT_X_DPAD_LEFT)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*5), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*5), default_pos.font_size, WHITE, "- Viewport X --"); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 5); + font_parms.color = WHITE; + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 5); + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport X--", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_RIGHT), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_LEFT_X_DPAD_RIGHT)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*6), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*6), default_pos.font_size, WHITE, "- Viewport X ++"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 6); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport X++", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_UP), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_LEFT_Y_DPAD_UP)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*7), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*7), default_pos.font_size, WHITE, "- Viewport Y ++"); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 7); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport Y++", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_LEFT_Y_DPAD_DOWN)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*8), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*8), default_pos.font_size, WHITE, "- Viewport Y --"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 8); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport Y--", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_RIGHT_X_DPAD_LEFT)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*9), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*9), default_pos.font_size, WHITE, "- Viewport W --"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 9); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport W--", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_RIGHT_X_DPAD_RIGHT)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*10), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*10), default_pos.font_size, WHITE, "- Viewport W ++"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 10); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport W++", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_L2), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_UP)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*11), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*11), default_pos.font_size, WHITE, "- Viewport H ++"); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 11); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport H++", &font_parms); snprintf(msg, sizeof(msg), "[%s] or [%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_R2), rarch_input_find_platform_key_label(1ULL << RARCH_ANALOG_RIGHT_Y_DPAD_DOWN)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*12), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*12), default_pos.font_size, WHITE, "- Viewport H --"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 12); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Viewport H--", &font_parms); snprintf(msg, sizeof(msg), "[%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_X)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*13), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*13), default_pos.font_size, WHITE, "- Reset To Defaults"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 13); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Reset To Defaults", &font_parms); snprintf(msg, sizeof(msg), "[%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_Y)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*14), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*14), default_pos.font_size, WHITE, "- Show Game"); + + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 14); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Show Game", &font_parms); snprintf(msg, sizeof(msg), "[%s]", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_A)); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*15), default_pos.font_size, WHITE, msg); - device_ptr->font_ctx->render_msg_place (device_ptr, default_pos.x_position_center, default_pos.y_position+(default_pos.y_position_increment*15), default_pos.font_size, WHITE, "- Go back"); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * 15); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); + + font_parms.x = default_pos.x_position_center; + device_ptr->font_ctx->render_msg(device_ptr, "- Go back", &font_parms); snprintf(msg, sizeof(msg), "Press [%s] to reset to defaults.", rarch_input_find_platform_key_label(1ULL << RETRO_DEVICE_ID_JOYPAD_X)); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, msg); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_y_position; + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); } if(current_menu->browser_draw) @@ -2378,6 +2526,7 @@ int ingame_menu(void *data, void *state) char strw_buffer[256]; unsigned menuitem_colors[MENU_ITEM_LAST]; static unsigned menu_idx = 0; + font_params_t font_parms = {0}; filebrowser_t *filebrowser = tmpBrowser; rmenu_default_positions_t default_pos; @@ -2580,47 +2729,88 @@ int ingame_menu(void *data, void *state) display_menubar(current_menu); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, default_pos.comment_y_position, default_pos.font_size, WHITE, strw_buffer); + font_parms.x = default_pos.x_position; + font_parms.y = default_pos.comment_y_position; + font_parms.scale = default_pos.font_size; + font_parms.color = WHITE; + + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); menu_settings_create_menu_item_label(strw_buffer, S_LBL_LOAD_STATE_SLOT, sizeof(strw_buffer)); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, default_pos.y_position, default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_LOAD_STATE), strw_buffer); + + font_parms.y = default_pos.y_position; + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_LOAD_STATE); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); menu_settings_create_menu_item_label(strw_buffer, S_LBL_SAVE_STATE_SLOT, sizeof(strw_buffer)); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_SAVE_STATE), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_SAVE_STATE), strw_buffer); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_SAVE_STATE); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_SAVE_STATE); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); menu_settings_create_menu_item_label(strw_buffer, S_LBL_ASPECT_RATIO, sizeof(strw_buffer)); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO), strw_buffer); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_KEEP_ASPECT_RATIO); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); snprintf(strw_buffer, sizeof(strw_buffer), "Overscan: %f", g_extern.console.screen.overscan_amount); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_OVERSCAN_AMOUNT)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_OVERSCAN_AMOUNT), strw_buffer); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_OVERSCAN_AMOUNT); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_OVERSCAN_AMOUNT); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); menu_settings_create_menu_item_label(strw_buffer, S_LBL_ROTATION, sizeof(strw_buffer)); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_ORIENTATION)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_ORIENTATION), strw_buffer); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_ORIENTATION); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_ORIENTATION); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); #ifdef HAVE_FBO menu_settings_create_menu_item_label(strw_buffer, S_LBL_SCALE_FACTOR, sizeof(strw_buffer)); - device_ptr->font_ctx->render_msg_place(device_ptr, default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_SCALE_FACTOR)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCALE_FACTOR), strw_buffer); + + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_SCALE_FACTOR); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_SCALE_FACTOR); + device_ptr->font_ctx->render_msg(device_ptr, strw_buffer, &font_parms); #endif - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_RESIZE_MODE)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_RESIZE_MODE), "Resize Mode"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_RESIZE_MODE); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_RESIZE_MODE); + device_ptr->font_ctx->render_msg(device_ptr, "Resize Mode", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_FRAME_ADVANCE)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_FRAME_ADVANCE), "Frame Advance"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_FRAME_ADVANCE); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_FRAME_ADVANCE); + device_ptr->font_ctx->render_msg(device_ptr, "Frame Advance", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_SCREENSHOT_MODE)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_SCREENSHOT_MODE), "Screenshot Mode"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_SCREENSHOT_MODE); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_SCREENSHOT_MODE); + device_ptr->font_ctx->render_msg(device_ptr, "Screenshot Mode", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_RESET)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_RESET), "Reset"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_RESET); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_RESET); + device_ptr->font_ctx->render_msg(device_ptr, "Reset", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_RETURN_TO_GAME)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_GAME), "Return to Game"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_RETURN_TO_GAME); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_GAME); + device_ptr->font_ctx->render_msg(device_ptr, "Return To Game", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_RETURN_TO_MENU)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MENU), "Return to Menu"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_RETURN_TO_MENU); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MENU); + device_ptr->font_ctx->render_msg(device_ptr, "Return To Menu", &font_parms); - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_CHANGE_LIBRETRO)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_CHANGE_LIBRETRO), "Change libretro core"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_CHANGE_LIBRETRO); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_CHANGE_LIBRETRO); + device_ptr->font_ctx->render_msg(device_ptr, "Change libretro core", &font_parms); #ifdef HAVE_MULTIMAN - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_RETURN_TO_MULTIMAN)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MULTIMAN), "Return to multiMAN"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_RETURN_TO_MULTIMAN); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_RETURN_TO_MULTIMAN); + device_ptr->font_ctx->render_msg(device_ptr, "Return to multiMAN", &font_parms); #endif - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.x_position, (default_pos.y_position+(default_pos.y_position_increment*MENU_ITEM_QUIT_RARCH)), default_pos.font_size, MENU_ITEM_SELECTED(MENU_ITEM_QUIT_RARCH), "Quit RetroArch"); + font_parms.y = default_pos.y_position + (default_pos.y_position_increment * MENU_ITEM_QUIT_RARCH); + font_parms.color = MENU_ITEM_SELECTED(MENU_ITEM_QUIT_RARCH); + device_ptr->font_ctx->render_msg(device_ptr, "Quit RetroArch", &font_parms); rarch_position_t position = {0}; position.x = default_pos.x_position; @@ -2790,7 +2980,7 @@ void menu_free(void) bool menu_iterate(void) { const char *msg; - + font_params_t font_parms = {0}; DEVICE_CAST device_ptr = (DEVICE_CAST)driver.video_data; static menu current_menu; @@ -2865,8 +3055,13 @@ bool menu_iterate(void) msg = msg_queue_pull(g_extern.msg_queue); + font_parms.x = default_pos.msg_queue_x_position; + font_parms.y = default_pos.msg_queue_y_position; + font_parms.scale = default_pos.msg_queue_font_size; + font_parms.color = WHITE; + if (msg && (g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW))) - device_ptr->font_ctx->render_msg_place(device_ptr,default_pos.msg_queue_x_position, default_pos.msg_queue_y_position, default_pos.msg_queue_font_size, WHITE, msg); + device_ptr->font_ctx->render_msg(device_ptr, msg, &font_parms); device_ptr->ctx_driver->swap_buffers(); diff --git a/gfx/fonts/d3d_font.h b/gfx/fonts/d3d_font.h index 64b30af386..db5dab2f6b 100644 --- a/gfx/fonts/d3d_font.h +++ b/gfx/fonts/d3d_font.h @@ -23,9 +23,7 @@ typedef struct d3d_font_renderer { bool (*init)(void *data, const char *font_path, unsigned font_size); void (*deinit)(void *data); - void (*render_msg)(void *data, const char *msg); - void (*render_msg_place)(void *data, float x, float y, - float scale, uint32_t color, const char *str_msg); + void (*render_msg)(void *data, const char *msg, void *parms); const char *ident; } d3d_font_renderer_t; diff --git a/gfx/fonts/gl_font.h b/gfx/fonts/gl_font.h index 5566f0f15e..98991f738a 100644 --- a/gfx/fonts/gl_font.h +++ b/gfx/fonts/gl_font.h @@ -23,9 +23,7 @@ typedef struct gl_font_renderer { bool (*init)(void *data, const char *font_path, float font_size); void (*deinit)(void *data); - void (*render_msg)(void *data, const char *msg); - void (*render_msg_place)(void *data, float x, float y, - float scale, uint32_t color, const char *msg); + void (*render_msg)(void *data, const char *msg, void *parms); const char *ident; } gl_font_renderer_t; diff --git a/gfx/fonts/gl_raster_font.c b/gfx/fonts/gl_raster_font.c index c0490e4e74..c72de6acf5 100644 --- a/gfx/fonts/gl_raster_font.c +++ b/gfx/fonts/gl_raster_font.c @@ -14,6 +14,7 @@ * If not, see . */ +#include "../gfx_common.h" #include "../gl_common.h" static bool gl_init_font(void *data, const char *font_path, float font_size) @@ -297,33 +298,35 @@ static void setup_font(void *data, const char *msg, GLfloat scale, GLfloat pos_x gl_set_projection(gl, &ortho, true); } -static void gl_render_msg(void *data, const char *msg) +static void gl_render_msg(void *data, const char *msg, void *parms) { (void)data; (void)msg; - + GLfloat x, y, scale; + gl_t *gl = (gl_t*)data; - setup_font(data, msg, - g_settings.video.font_scale ? (GLfloat)gl->vp.width / (GLfloat)gl->full_x : 1.0f, - g_settings.video.msg_pos_x, g_settings.video.msg_pos_y); -} + font_params_t *params = (font_params_t*)parms; -static void gl_render_msg_place(void *data, float pos_x, float pos_y, float scale, uint32_t color, const char *msg) -{ - (void)data; - (void)msg; - (void)color; + if (params) + { + x = params->x; + y = params->y; + scale = params->scale; + } + else + { + x = g_settings.video.msg_pos_x; + y = g_settings.video.msg_pos_y; + scale = g_settings.video.font_scale ? (GLfloat)gl->vp.width / (GLfloat)gl->full_x : 1.0f; + } -#ifdef HAVE_FREETYPE - setup_font(data, msg, scale, pos_x, pos_y); -#endif + setup_font(data, msg, scale, x, y); } const gl_font_renderer_t gl_raster_font = { gl_init_font, gl_deinit_font, gl_render_msg, - gl_render_msg_place, "GL raster", }; diff --git a/gfx/fonts/ps_libdbgfont.c b/gfx/fonts/ps_libdbgfont.c index 90174972a7..c4de04e1fa 100644 --- a/gfx/fonts/ps_libdbgfont.c +++ b/gfx/fonts/ps_libdbgfont.c @@ -15,6 +15,7 @@ */ #include "fonts.h" +#include "../gfx_common.h" #if defined(SN_TARGET_PSP2) #include @@ -66,22 +67,33 @@ static void gl_deinit_font(void *data) DbgFontExit(); } -static void gl_render_msg(void *data, const char *msg) +static void gl_render_msg(void *data, const char *msg, void *parms) { (void)data; - float x = g_settings.video.msg_pos_x; - float y = 0.76f; - float scale = 1.04f; - unsigned color = SILVER; + float x, y, scale; + unsigned color; + font_params_t *params = (font_params_t*)parms; + + if (params) + { + x = params->x; + y = params->y; + scale = params->scale; + color = params->color; + } + else + { + x = g_settings.video.msg_pos_x; + y = 0.76f; + scale = 1.04f; + color = SILVER; + } DbgFontPrint(x, y, scale, color, msg); - DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); - DbgFontDraw(); -} -static void gl_render_msg_place(void *data, float x, float y, float scale, uint32_t color, const char *msg) -{ - DbgFontPrint(x, y, scale, color, msg); + if (!params) + DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); + DbgFontDraw(); } @@ -89,6 +101,5 @@ const gl_font_renderer_t libdbg_font = { gl_init_font, gl_deinit_font, gl_render_msg, - gl_render_msg_place, "GL raster", }; diff --git a/gfx/fonts/xdk1_xfonts.c b/gfx/fonts/xdk1_xfonts.c index 7147e93013..64a1dbabde 100644 --- a/gfx/fonts/xdk1_xfonts.c +++ b/gfx/fonts/xdk1_xfonts.c @@ -16,6 +16,7 @@ #include #include "d3d_font.h" +#include "../gfx_common.h" #include "../../general.h" static XFONT *debug_font; @@ -42,28 +43,35 @@ static void xfonts_deinit_font(void *data) (void)data; } -static void xfonts_render_msg_place(void *data, float x, float y, float scale, uint32_t color, const char *msg) +static void xfonts_render_msg(void *data, const char *msg, void *parms) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; + font_params_t *params = (font_params_t*)parms; + wchar_t str[PATH_MAX]; + float x, y; + + if (params) + { + x = params->x; + y = params->y; + } + else + { + x = g_settings.video.msg_pos_x; + y = g_settings.video.msg_pos_y; + } d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &pFrontBuffer); - wchar_t str[256]; convert_char_to_wchar(str, msg, sizeof(str)); debug_font->TextOut(pFrontBuffer, str, (unsigned)-1, x, y); pFrontBuffer->Release(); } -static void xfonts_render_msg(void *data, const char *msg) -{ - xfonts_render_msg_place(data, g_settings.video.msg_pos_x, g_settings.video.msg_pos_y, 0, 0, msg); -} - const d3d_font_renderer_t d3d_xdk1_font = { xfonts_init_font, xfonts_deinit_font, xfonts_render_msg, - xfonts_render_msg_place, "XDK1 Xfonts", }; diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp index 4aa2cbcb2f..83f7192d61 100644 --- a/gfx/fonts/xdk360_fonts.cpp +++ b/gfx/fonts/xdk360_fonts.cpp @@ -16,6 +16,7 @@ #include #include "d3d_font.h" +#include "../gfx_common.h" #include "../../general.h" #include "../../xdk/xdk_resources.h" @@ -440,11 +441,24 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font, d3dr->EndVertices(); } -static void xdk_render_msg_place(void *data, float x, float y, float scale, uint32_t color, const char *str_msg) +static void xdk_render_msg(void *driver, const char *msg, void *params) { - (void)data; + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver; xdk360_video_font_t *font = &m_Font; + font_params_t *params = (font_params_t*)parms; wchar_t msg[PATH_MAX]; + float x, y; + + if (params) + { + x = params->x; + y = params->y; + } + else + { + x = (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_HD)) ? 160 : 100; + y = 120; + } convert_char_to_wchar(msg, str_msg, sizeof(msg)); @@ -456,20 +470,9 @@ static void xdk_render_msg_place(void *data, float x, float y, float scale, uint } } -static void xdk_render_msg(void *driver, const char *msg) -{ - xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver; - - float x = (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_HD)) ? 160 : 100; - float y = 120; - - xdk_render_msg_place(d3d, x, y, 0, 0, msg); -} - const d3d_font_renderer_t d3d_xbox360_font = { xdk_init_font, xdk_deinit_font, xdk_render_msg, - xdk_render_msg_place, "Xbox 360 fonts", }; diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index f8f454c8dc..a4f37f41ef 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -40,6 +40,14 @@ void gfx_set_dwm(void); void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned win_height, float aspect_ratio, bool keep_aspect); +typedef struct +{ + float x; + float y; + float scale; + unsigned color; +} font_params_t; + #define MIN_SCALING_FACTOR (1.0f) #if defined(__CELLOS_LV2__) @@ -48,7 +56,6 @@ void gfx_scale_integer(struct rarch_viewport *vp, unsigned win_width, unsigned w #define MAX_SCALING_FACTOR (2.0f) #endif - enum aspect_ratio { ASPECT_RATIO_1_1 = 0, diff --git a/gfx/gl.c b/gfx/gl.c index e3ec9ebf4f..355b1e1554 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1365,15 +1365,23 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei if (lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) { char fps_txt[128]; + font_params_t params = {0}; + gfx_get_fps(fps_txt, sizeof(fps_txt), true); if (gl->font_ctx) - gl->font_ctx->render_msg_place(gl, g_settings.video.msg_pos_x, 0.56f, 1.04f, WHITE, fps_txt); + { + params.x = g_settings.video.msg_pos_x; + params.y = 0.56f; + params.scale = 1.04f; + params.color = WHITE; + gl->font_ctx->render_msg(gl, fps_txt, ¶ms); + } } #endif if (msg && gl->font_ctx) - gl->font_ctx->render_msg(gl, msg); + gl->font_ctx->render_msg(gl, msg, NULL); if (gl->ctx_driver->post_render) context_post_render_func(gl); diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index 9017fce4ed..4f3cea75a9 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -875,22 +875,34 @@ static bool xdk_d3d_frame(void *data, const void *frame, if (lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) { MEMORYSTATUS stat; + char buf[128]; + font_params_t font_parms = {0}; + GlobalMemoryStatus(&stat); - char fps_txt[128]; - char buf[128]; + font_parms.x = mem_width; + font_parms.y = mem_height; + font_parms.scale = 0; + font_parms.color = 0; snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); if (d3d->font_ctx) - d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height, 0, 0, buf); + d3d->font_ctx->render_msg(d3d, buf, &font_parms); - gfx_get_fps(fps_txt, sizeof(fps_txt), true); + gfx_get_fps(buf, sizeof(buf), true); if (d3d->font_ctx) - d3d->font_ctx->render_msg_place(d3d, mem_width, mem_height + 30, 0, 0, fps_txt); + { + font_parms.y = mem_height + 30; + d3d->font_ctx->render_msg(d3d, buf, &font_parms); + } } if (msg) - d3d->font_ctx->render_msg_place(d3d, msg_width, msg_height, 0.0f, 0, msg); + { + font_parms.x = msg_width; + font_parms.y = msg_height; + d3d->font_ctx->render_msg(d3d, msg, &font_parms); + } if (lifecycle_mode_state & (1ULL << MODE_MENU_DRAW)) {