From 213bc332385f9a3cdf7d4dc61a2f6c13c1ef4448 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 29 Jul 2012 22:33:10 +0200 Subject: [PATCH] (Xbox 1) refactoring in MenuMain.cpp --- xbox1/frontend/RetroLaunch/MenuMain.cpp | 56 ++++++++++++++----------- xbox1/frontend/RetroLaunch/MenuMain.h | 2 - 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/xbox1/frontend/RetroLaunch/MenuMain.cpp b/xbox1/frontend/RetroLaunch/MenuMain.cpp index 46eeb57ecc..1a1b4543ab 100644 --- a/xbox1/frontend/RetroLaunch/MenuMain.cpp +++ b/xbox1/frontend/RetroLaunch/MenuMain.cpp @@ -34,6 +34,9 @@ extern filebrowser_t browser; +// Rom selector panel with coords +CSurface m_menuMainRomSelectPanel; + uint16_t input_st; uint16_t trigger_state; static uint16_t old_input_st = 0; @@ -85,29 +88,9 @@ bool CMenuMain::Create() return true; } - -void CMenuMain::Render() +static void browser_render(filebrowser_t *b, float current_x, float current_y, float y_spacing) { xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; - - //Render background image - m_menuMainBG.Render(MENU_MAIN_BG_X, MENU_MAIN_BG_Y); - - //Display some text - //Center the text (hardcoded) - int xpos = width == 640 ? 65 : 400; - int ypos = width == 640 ? 430 : 670; - - d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &d3d->pFrontBuffer); - d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer); - d3d->debug_font->TextOut(d3d->pFrontBuffer, L"Libretro core:", (unsigned)-1, xpos, ypos); - d3d->debug_font->TextOut(d3d->pBackBuffer, L"Libretro core:", (unsigned)-1, xpos, ypos); - d3d->debug_font->TextOut(d3d->pFrontBuffer, m_title, (unsigned)-1, xpos + 140, ypos); - d3d->debug_font->TextOut(d3d->pBackBuffer, m_title, (unsigned)-1, xpos + 140, ypos); - d3d->pFrontBuffer->Release(); - d3d->pBackBuffer->Release(); - - filebrowser_t *b = &browser; unsigned file_count = b->current_dir.list->size; int current_index, page_number, page_base, i; float currentX, currentY, ySpacing; @@ -116,9 +99,9 @@ void CMenuMain::Render() page_number = current_index / NUM_ENTRY_PER_PAGE; page_base = page_number * NUM_ENTRY_PER_PAGE; - currentX = m_menuMainRomListPos_x; - currentY = m_menuMainRomListPos_y; - ySpacing = 20; + currentX = current_x; + currentY = current_y; + ySpacing = y_spacing; for (i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i) { @@ -143,6 +126,30 @@ void CMenuMain::Render() } } +void CMenuMain::Render() +{ + xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; + + //Render background image + m_menuMainBG.Render(MENU_MAIN_BG_X, MENU_MAIN_BG_Y); + + //Display some text + //Center the text (hardcoded) + int xpos = width == 640 ? 65 : 400; + int ypos = width == 640 ? 430 : 670; + + d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &d3d->pFrontBuffer); + d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer); + d3d->debug_font->TextOut(d3d->pFrontBuffer, L"Libretro core:", (unsigned)-1, xpos, ypos); + d3d->debug_font->TextOut(d3d->pBackBuffer, L"Libretro core:", (unsigned)-1, xpos, ypos); + d3d->debug_font->TextOut(d3d->pFrontBuffer, m_title, (unsigned)-1, xpos + 140, ypos); + d3d->debug_font->TextOut(d3d->pBackBuffer, m_title, (unsigned)-1, xpos + 140, ypos); + d3d->pFrontBuffer->Release(); + d3d->pBackBuffer->Release(); + + browser_render(&browser, m_menuMainRomListPos_x, m_menuMainRomListPos_y, 20); +} + typedef enum { MENU_ROMSELECT_ACTION_OK, MENU_ROMSELECT_ACTION_GOTO_SETTINGS, @@ -252,4 +259,3 @@ void CMenuMain::ProcessInput() old_input_st = input_st; } - diff --git a/xbox1/frontend/RetroLaunch/MenuMain.h b/xbox1/frontend/RetroLaunch/MenuMain.h index 96d070b02f..32033fc3fa 100644 --- a/xbox1/frontend/RetroLaunch/MenuMain.h +++ b/xbox1/frontend/RetroLaunch/MenuMain.h @@ -40,8 +40,6 @@ _c = color, // Background image with coords CSurface m_menuMainBG; -// Rom selector panel with coords -CSurface m_menuMainRomSelectPanel; // Rom list coords int m_menuMainRomListPos_x;