From 7a6ee6a3008cbbd1f63423b719efe4a4b1d9a1a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 2 Oct 2014 21:57:01 +0200 Subject: [PATCH] Get rid of MODE_MENU_HD too -g_extern.lifecycle_state can now be used for 'injecting' button presses (i.e. libretro button presses and/or meta button presses) --- frontend/menu/disp/rmenu_xui.cpp | 12 +++++------- general.h | 6 ------ gfx/context/d3d_ctx.cpp | 13 +++++++------ gfx/d3d/d3d.cpp | 2 +- gfx/d3d/d3d.hpp | 2 ++ gfx/fonts/xdk360_fonts.cpp | 14 +++++++------- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/frontend/menu/disp/rmenu_xui.cpp b/frontend/menu/disp/rmenu_xui.cpp index 51e7fa3f0f..3ffdd75f5d 100644 --- a/frontend/menu/disp/rmenu_xui.cpp +++ b/frontend/menu/disp/rmenu_xui.cpp @@ -165,9 +165,7 @@ static void* rmenu_xui_init(void) d3d_video_t *d3d= (d3d_video_t*)driver.video_data; - bool hdmenus_allowed = (g_extern.lifecycle_state & (1ULL << MODE_MENU_HD)); - - if (hdmenus_allowed) + if (d3d->resolution_hd_enable) RARCH_LOG("HD menus enabled.\n"); D3DPRESENT_PARAMETERS d3dpp; @@ -210,7 +208,7 @@ static void* rmenu_xui_init(void) goto error; } - hr = XuiSceneCreate(hdmenus_allowed ? + hr = XuiSceneCreate(d3d->resolution_hd_enable ? L"file://game:/media/hd/" : L"file://game:/media/sd/", L"rarch_main.xur", NULL, &root_menu); if (FAILED(hr)) @@ -257,7 +255,8 @@ static void xui_render_message(const char *msg) size_t i, j; struct string_list *list = string_split(msg, "\n"); - if (!list) + d3d_video_t *d3d = (d3d_video_t*)driver.video_data; + if (!list || !d3d) return; if (list->elems == 0) @@ -281,8 +280,7 @@ static void xui_render_message(const char *msg) msglen = RMENU_TERM_WIDTH; } #endif - float msg_width = (g_extern.lifecycle_state & - (1ULL << MODE_MENU_HD)) ? 160 : 100; + float msg_width = d3d->resolution_hd_enable ? 160 : 100; float msg_height = 120; float msg_offset = 32; diff --git a/general.h b/general.h index a232f5876b..ba16a96c43 100644 --- a/general.h +++ b/general.h @@ -141,12 +141,6 @@ enum action_state RARCH_ACTION_STATE_FORCE_QUIT, }; -enum menu_enums -{ - MODE_NONE = 0, - MODE_MENU_HD, -}; - enum sound_mode_enums { SOUND_MODE_NORMAL = 0, diff --git a/gfx/context/d3d_ctx.cpp b/gfx/context/d3d_ctx.cpp index b900d83545..980816ffa6 100644 --- a/gfx/context/d3d_ctx.cpp +++ b/gfx/context/d3d_ctx.cpp @@ -334,7 +334,7 @@ static void gfx_ctx_d3d_input_driver(void *data, const input_driver_t **input, v static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *height) { - (void)data; + d3d_video_t *d3d = (d3d_video_t*)driver.video_data; #ifdef _XBOX (void)width; (void)height; @@ -345,17 +345,18 @@ static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *he *width = video_mode.dwDisplayWidth; *height = video_mode.dwDisplayHeight; + driver.resolution_hd_enable = false; + if(video_mode.fIsHiDef) { *width = 1280; *height = 720; - g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD); + driver.resolution_hd_enable = true; } else { *width = 640; *height = 480; - g_extern.lifecycle_state &= ~(1ULL << MODE_MENU_HD); } widescreen_mode = video_mode.fIsWideScreen; @@ -402,21 +403,21 @@ static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *he *width = 640; *height = 480; widescreen_mode = false; - g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD); + driver.resolution_hd_enable = true; } else if(video_mode & XC_VIDEO_FLAGS_HDTV_720p) { *width = 1280; *height = 720; widescreen_mode = true; - g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD); + driver.resolution_hd_enable = true; } else if(video_mode & XC_VIDEO_FLAGS_HDTV_1080i) { *width = 1920; *height = 1080; widescreen_mode = true; - g_extern.lifecycle_state |= (1ULL << MODE_MENU_HD); + driver.resolution_hd_enable = true; } } #endif diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 774ff272a9..20a7a99343 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1570,7 +1570,7 @@ static bool d3d_frame(void *data, const void *frame, float msg_width = 60; float msg_height = 365; #elif defined(_XBOX360) - float msg_width = (g_extern.lifecycle_state & (1ULL << MODE_MENU_HD)) ? 160 : 100; + float msg_width = d3d->resolution_dh_enable ? 160 : 100; float msg_height = 120; #endif font_parms.x = msg_width; diff --git a/gfx/d3d/d3d.hpp b/gfx/d3d/d3d.hpp index 9895563e10..e8fc9d4803 100644 --- a/gfx/d3d/d3d.hpp +++ b/gfx/d3d/d3d.hpp @@ -171,6 +171,8 @@ typedef struct d3d_video unsigned tex_w; unsigned tex_h; #endif + /* TODO - refactor this away properly. */ + bool resolution_hd_enable; } d3d_video_t; #ifndef _XBOX diff --git a/gfx/fonts/xdk360_fonts.cpp b/gfx/fonts/xdk360_fonts.cpp index 5337a8998e..444caa3250 100644 --- a/gfx/fonts/xdk360_fonts.cpp +++ b/gfx/fonts/xdk360_fonts.cpp @@ -21,7 +21,7 @@ #include "../../general.h" #include "../../xdk/xdk_resources.h" -#define FONT_SCALE ((g_extern.lifecycle_state & (1ULL << MODE_MENU_HD)) ? 2 : 1) +#define FONT_SCALE(d3d) ((d3d->resolution_hd_enable) ? 2 : 1) typedef struct GLYPH_ATTR { @@ -363,7 +363,7 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font, void *video_data { // Handle the newline character m_fCursorX = x; - m_fCursorY += font->m_fFontYAdvance * FONT_SCALE; + m_fCursorY += font->m_fFontYAdvance * FONT_SCALE(d3d); continue; } @@ -375,10 +375,10 @@ static void xdk_video_font_draw_text(xdk360_video_font_t *font, void *video_data else pGlyph = &font->m_Glyphs[0]; - float fOffset = FONT_SCALE * (float)pGlyph->wOffset; - float fAdvance = FONT_SCALE * (float)pGlyph->wAdvance; - float fWidth = FONT_SCALE * (float)pGlyph->wWidth; - float fHeight = FONT_SCALE * font->m_fFontHeight; + float fOffset = FONT_SCALE(d3d) * (float)pGlyph->wOffset; + float fAdvance = FONT_SCALE(d3d) * (float)pGlyph->wAdvance; + float fWidth = FONT_SCALE(d3d) * (float)pGlyph->wWidth; + float fHeight = FONT_SCALE(d3d) * font->m_fFontHeight; m_fCursorX += fOffset; @@ -454,7 +454,7 @@ static void xdk_render_msg(void *data, const char *str_msg, } else { - x = (g_extern.lifecycle_state & (1ULL << MODE_MENU_HD)) ? 160 : 100; + x = d3d->resolution_hd_enable ? 160 : 100; y = 120; }