From 629dfe4a153f673ec6c4ffa8e0fb38fcd23c3c46 Mon Sep 17 00:00:00 2001 From: twinaphex <autechre1024@hotmail.com> Date: Sun, 29 Jul 2012 22:07:40 +0200 Subject: [PATCH] (Xbox 1) Uses filebrowser code now - now lists subdirs as well --- console/fileio/file_browser.c | 5 +- console/griffin/griffin.c | 2 - console/rarch_console_settings.c | 4 +- msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj | 10 +- xbox1/frontend/RetroLaunch/MenuMain.cpp | 196 ++++++++++++-------- xbox1/frontend/RetroLaunch/Rom.cpp | 41 ---- xbox1/frontend/RetroLaunch/Rom.h | 30 --- xbox1/frontend/RetroLaunch/RomList.cpp | 160 ---------------- xbox1/frontend/RetroLaunch/RomList.h | 54 ------ xbox1/frontend/menu.cpp | 16 +- 10 files changed, 140 insertions(+), 378 deletions(-) delete mode 100644 xbox1/frontend/RetroLaunch/Rom.cpp delete mode 100644 xbox1/frontend/RetroLaunch/Rom.h delete mode 100644 xbox1/frontend/RetroLaunch/RomList.cpp delete mode 100644 xbox1/frontend/RetroLaunch/RomList.h diff --git a/console/fileio/file_browser.c b/console/fileio/file_browser.c index 00cc91ff69..2d509c4db9 100644 --- a/console/fileio/file_browser.c +++ b/console/fileio/file_browser.c @@ -149,10 +149,11 @@ void filebrowser_iterate(filebrowser_t *filebrowser, filebrowser_action_t action case FILEBROWSER_ACTION_SCROLL_DOWN_SMOOTH: filebrowser->current_dir.ptr = (min(filebrowser->current_dir.ptr + 50, filebrowser->current_dir.list->size-1)); - if(!filebrowser->current_dir.ptr) filebrowser->current_dir.ptr = 0; + if(!filebrowser->current_dir.ptr) + filebrowser->current_dir.ptr = 0; break; case FILEBROWSER_ACTION_OK: - filebrowser_push_directory(filebrowser, filebrowser_get_current_path(filebrowser), true); + filebrowser_push_directory(filebrowser, filebrowser_get_current_path(filebrowser), true); break; case FILEBROWSER_ACTION_CANCEL: filebrowser_pop_directory(filebrowser); diff --git a/console/griffin/griffin.c b/console/griffin/griffin.c index 8a72f43d9a..73c5df75e4 100644 --- a/console/griffin/griffin.c +++ b/console/griffin/griffin.c @@ -288,8 +288,6 @@ MENU #include "../../xbox1/frontend/RetroLaunch/IoSupport.cpp" #include "../../xbox1/frontend/RetroLaunch/MenuMain.cpp" #include "../../xbox1/frontend/RetroLaunch/MenuManager.cpp" -#include "../../xbox1/frontend/RetroLaunch/Rom.cpp" -#include "../../xbox1/frontend/RetroLaunch/RomList.cpp" #include "../../xbox1/frontend/RetroLaunch/Surface.cpp" #elif defined(GEKKO) #include "../../wii/frontend/rgui.c" diff --git a/console/rarch_console_settings.c b/console/rarch_console_settings.c index 5631da08a4..b5319252e1 100644 --- a/console/rarch_console_settings.c +++ b/console/rarch_console_settings.c @@ -358,9 +358,11 @@ void rarch_settings_set_default (const input_driver_t *input) g_console.mode_switch = MODE_MENU; g_console.screen_orientation = ORIENTATION_NORMAL; g_console.current_resolution_id = 0; -#ifdef _XBOX360 +#if defined(_XBOX360) //Ugly but necessary hack strlcpy(g_console.default_rom_startup_dir, "game:", sizeof(g_console.default_rom_startup_dir)); +#elif defined(_XBOX1) + strlcpy(g_console.default_rom_startup_dir, "D:", sizeof(g_console.default_rom_startup_dir)); #else strlcpy(g_console.default_rom_startup_dir, default_paths.filesystem_root_dir, sizeof(g_console.default_rom_startup_dir)); #endif diff --git a/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj b/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj index 8d947bc6c6..9134b8e136 100644 --- a/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj +++ b/msvc/RetroArch-Xbox1/RetroArch-Xbox1.vcproj @@ -22,7 +22,7 @@ Optimization="3" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="_DEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8" + PreprocessorDefinitions="_DEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER" MinimalRebuild="TRUE" BasicRuntimeChecks="0" RuntimeLibrary="1" @@ -72,7 +72,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -126,7 +126,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;FASTCAP;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;PROFILE;FASTCAP;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -187,7 +187,7 @@ EnableFiberSafeOptimizations="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;inline=_inline;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;HAVE_GRIFFIN;inline=_inline;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" @@ -240,7 +240,7 @@ OmitFramePointers="TRUE" OptimizeForProcessor="2" AdditionalIncludeDirectories=""$(SolutionDir)\msvc-stdint";"$(SolutionDir)\msvc-71"" - PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;LTCG;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8" + PreprocessorDefinitions="NDEBUG;_XBOX;_XBOX1;RARCH_CONSOLE;HAVE_XINPUT_XBOX1;PACKAGE_VERSION=\"0.9.6\";__STDC_CONSTANT_MACROS;HAVE_ZLIB;LTCG;HAVE_GRIFFIN;HAVE_RARCH_MAIN_WRAP;HAVE_LIBRETRO_MANAGEMENT;HAVE_RARCH_EXEC;HAVE_DEFAULT_RETROPAD_INPUT;HAVE_CONFIGFILE;HAVE_VID_CONTEXT;HAVE_DSOUND;HAVE_D3D8;HAVE_FILEBROWSER" StringPooling="TRUE" RuntimeLibrary="0" BufferSecurityCheck="TRUE" diff --git a/xbox1/frontend/RetroLaunch/MenuMain.cpp b/xbox1/frontend/RetroLaunch/MenuMain.cpp index ab5f36363b..0318b5d575 100644 --- a/xbox1/frontend/RetroLaunch/MenuMain.cpp +++ b/xbox1/frontend/RetroLaunch/MenuMain.cpp @@ -14,11 +14,20 @@ */ #include "MenuMain.h" -#include "RomList.h" #include "../../console/rarch_console.h" #include "../../general.h" +#include "../../console/fileio/file_browser.h" + +#define NUM_ENTRY_PER_PAGE 17 + +extern filebrowser_t browser; + +uint16_t input_st; +uint16_t trigger_state; +static uint16_t old_input_st = 0; + CMenuMain g_menuMain; CMenuMain::CMenuMain() @@ -40,7 +49,7 @@ CMenuMain::~CMenuMain() bool CMenuMain::Create() { - RARCH_LOG("CMenuMain::Create()."); + RARCH_LOG("CMenuMain::Create().\n"); xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data; @@ -94,9 +103,6 @@ bool CMenuMain::Create() //The offset in the romlist m_romListOffset = 0; - if(m_romListEndRender > g_romList.GetRomListSize() - 1) - m_romListEndRender = g_romList.GetRomListSize() - 1; - return true; } @@ -124,28 +130,79 @@ void CMenuMain::Render() //Begin with the rom selector panel //FIXME: Width/Height needs to be current Rom texture width/height (or should we just leave it at a fixed size?) - m_menuMainRomSelectPanel.Render(m_menuMainRomSelectPanel_x, m_menuMainRomSelectPanel_y, m_menuMainRomSelectPanel_w, m_menuMainRomSelectPanel_h); - int32_t dwSpacing = 0; - for (int i = m_romListBeginRender; i <= m_romListEndRender; i++) + filebrowser_t *b = &browser; + unsigned file_count = b->current_dir.list->size; + int current_index, page_number, page_base, i; + float currentX, currentY, ySpacing; + + current_index = b->current_dir.ptr; + 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 = m_menuMainRomListSpacing; + + for (i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i) { - const wchar_t *rom_basename = g_romList.GetRomAt(i + m_romListOffset)->GetFileName(); + char fname_tmp[256]; + fill_pathname_base(fname_tmp, b->current_dir.list->elems[i].data, sizeof(fname_tmp)); + currentY = currentY + ySpacing; + const char *rom_basename = fname_tmp; + wchar_t rom_basename_w[256]; + + //check if this is the currently selected file + const char *current_pathname = filebrowser_get_current_path(b); + if(strcmp(current_pathname, b->current_dir.list->elems[i].data) == 0) + { + m_menuMainRomSelectPanel.Render(currentX, currentY, m_menuMainRomSelectPanel_w, m_menuMainRomSelectPanel_h); + } + + convert_char_to_wchar(rom_basename_w, rom_basename, sizeof(rom_basename_w)); 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, rom_basename, (unsigned)-1, m_menuMainRomListPos_x, m_menuMainRomListPos_y + dwSpacing); - d3d->debug_font->TextOut(d3d->pBackBuffer, rom_basename, (unsigned)-1, m_menuMainRomListPos_x, m_menuMainRomListPos_y + dwSpacing); + d3d->debug_font->TextOut(d3d->pFrontBuffer, rom_basename_w, (unsigned)-1, currentX, currentY); + d3d->debug_font->TextOut(d3d->pBackBuffer, rom_basename_w, (unsigned)-1, currentX, currentY); d3d->pFrontBuffer->Release(); d3d->pBackBuffer->Release(); - dwSpacing += m_menuMainRomListSpacing; } } -static uint16_t old_input_state = 0; +typedef enum { + MENU_ROMSELECT_ACTION_OK, + MENU_ROMSELECT_ACTION_GOTO_SETTINGS, + MENU_ROMSELECT_ACTION_NOOP, +} menu_romselect_action_t; -void CMenuMain::ProcessInput() +static void menu_romselect_iterate(filebrowser_t *filebrowser, menu_romselect_action_t action) { - uint16_t input_state = 0; + switch(action) + { + case MENU_ROMSELECT_ACTION_OK: + if(filebrowser_get_current_path_isdir(filebrowser)) + { + /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path */ + //hacky - need to fix this + //if(browser.current_dir.ptr == 0) + // filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_CANCEL); + //else + filebrowser_iterate(filebrowser, FILEBROWSER_ACTION_OK); + } + else + rarch_console_load_game_wrap(filebrowser_get_current_path(filebrowser), g_console.zip_extract_mode, S_DELAY_45); + break; + case MENU_ROMSELECT_ACTION_GOTO_SETTINGS: + break; + default: + break; + } +} + +static void control_update_wrap(void) +{ + input_st = 0; input_xinput.poll(NULL); static const struct retro_keybind *binds[MAX_PLAYERS] = { @@ -161,82 +218,65 @@ void CMenuMain::ProcessInput() for (unsigned i = 0; i < RARCH_FIRST_META_KEY; i++) { - input_state |= input_xinput.input_state(NULL, binds, false, + input_st |= input_xinput.input_state(NULL, binds, false, RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0; } +} - uint16_t trigger_state = input_state & ~old_input_state; +static void browser_update(filebrowser_t * b, const char *extensions) +{ + filebrowser_action_t action = FILEBROWSER_ACTION_NOOP; - if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN)) + if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_DOWN)) + action = FILEBROWSER_ACTION_DOWN; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP)) + action = FILEBROWSER_ACTION_UP; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT)) + action = FILEBROWSER_ACTION_RIGHT; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_LEFT)) + action = FILEBROWSER_ACTION_LEFT; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R)) + action = FILEBROWSER_ACTION_SCROLL_DOWN; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R2)) + action = FILEBROWSER_ACTION_SCROLL_DOWN_SMOOTH; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_L2)) + action = FILEBROWSER_ACTION_SCROLL_UP_SMOOTH; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_L)) + action = FILEBROWSER_ACTION_SCROLL_UP; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_A)) + action = FILEBROWSER_ACTION_CANCEL; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START)) { - if(m_romListSelectedRom < g_romList.GetRomListSize()) - { - if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * m_romListEndRender))) - { - m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing; - m_romListSelectedRom++; - RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom); - } - - if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y + (m_menuMainRomListSpacing * (m_romListEndRender)))) - { - m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing; - m_romListSelectedRom++; - if(m_romListSelectedRom > g_romList.GetRomListSize() - 1) - m_romListSelectedRom = g_romList.GetRomListSize() - 1; - - RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom); - - if(m_romListSelectedRom < g_romList.GetRomListSize() - 1 && m_romListOffset < g_romList.GetRomListSize() - 1 - m_romListEndRender - 1) - { - m_romListOffset++; - RARCH_LOG("OFFSET: %d.\n", m_romListOffset); - } - } - } + action = FILEBROWSER_ACTION_RESET; + filebrowser_set_root(b, "/"); + strlcpy(b->extensions, extensions, sizeof(b->extensions)); } - if(trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_UP)) - { - if(m_romListSelectedRom > -1) - { - if(m_menuMainRomSelectPanel_y > (m_menuMainRomListPos_y - m_menuMainRomListSpacing)) - { - m_menuMainRomSelectPanel_y -= m_menuMainRomListSpacing; - m_romListSelectedRom--; - RARCH_LOG("SELECTED ROM: %d.\n", m_romListSelectedRom); - } + if(action != FILEBROWSER_ACTION_NOOP) + filebrowser_iterate(b, action); +} - if(m_menuMainRomSelectPanel_y < (m_menuMainRomListPos_y - m_menuMainRomListSpacing)) - { - m_menuMainRomSelectPanel_y += m_menuMainRomListSpacing; - m_romListSelectedRom--; - if(m_romListSelectedRom < 0) - m_romListSelectedRom = 0; +void CMenuMain::ProcessInput() +{ + control_update_wrap(); - RARCH_LOG("SELECTED ROM AFTER CORRECTION: %d.\n", m_romListSelectedRom); + trigger_state = input_st & ~old_input_st; - if(m_romListSelectedRom > 0 && m_romListOffset > 0) - { - m_romListOffset--; - RARCH_LOG("OFFSET: %d.\n", m_romListOffset); - } - } - } - } - - // Press A to launch - if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B) || trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_START)) - { - char rom_filename[PATH_MAX]; - convert_wchar_to_char(rom_filename, g_romList.GetRomAt(m_romListSelectedRom)->GetFileName(), sizeof(rom_filename)); - rarch_console_load_game_wrap(rom_filename, g_console.zip_extract_mode, S_DELAY_1); - } - - if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R3)) + browser_update(&browser, rarch_console_get_rom_ext()); + + menu_romselect_action_t action = MENU_ROMSELECT_ACTION_NOOP; + + if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_B)) + action = MENU_ROMSELECT_ACTION_OK; + else if (trigger_state & (1 << RETRO_DEVICE_ID_JOYPAD_R3)) { LD_LAUNCH_DASHBOARD LaunchData = { XLD_LAUNCH_DASHBOARD_MAIN_MENU }; XLaunchNewImage( NULL, (LAUNCH_DATA*)&LaunchData ); } + + if (action != MENU_ROMSELECT_ACTION_NOOP) + menu_romselect_iterate(&browser, action); + + old_input_st = input_st; } diff --git a/xbox1/frontend/RetroLaunch/Rom.cpp b/xbox1/frontend/RetroLaunch/Rom.cpp deleted file mode 100644 index 10509e1760..0000000000 --- a/xbox1/frontend/RetroLaunch/Rom.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Surreal 64 Launcher (C) 2003 - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the - * authors: email: buttza@hotmail.com, lantus@lantus-x.com - */ - -#include "Rom.h" - -Rom::Rom() -{ - m_bLoaded = false; -} - -Rom::~Rom(void) -{ -} - -bool Rom::Load(const char *szFilename) -{ - if (m_bLoaded) - return true; - - convert_char_to_wchar(m_szFilename, szFilename, sizeof(m_szFilename)); - m_bLoaded = true; - - return true; -} - -const wchar_t *Rom::GetFileName() -{ - return m_szFilename; -} \ No newline at end of file diff --git a/xbox1/frontend/RetroLaunch/Rom.h b/xbox1/frontend/RetroLaunch/Rom.h deleted file mode 100644 index 0fb56ee8b6..0000000000 --- a/xbox1/frontend/RetroLaunch/Rom.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Surreal 64 Launcher (C) 2003 - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the - * authors: email: buttza@hotmail.com, lantus@lantus-x.com - */ - -#pragma once - -class Rom -{ -public: - Rom(); - ~Rom(); - - bool Load(const char *szFilename); - - const wchar_t *GetFileName(); -private: - wchar_t m_szFilename[256]; - bool m_bLoaded; -}; diff --git a/xbox1/frontend/RetroLaunch/RomList.cpp b/xbox1/frontend/RetroLaunch/RomList.cpp deleted file mode 100644 index f8f684b225..0000000000 --- a/xbox1/frontend/RetroLaunch/RomList.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/** - * RetroLaunch 2012 - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the - * authors: Surreal64 CE Team (http://www.emuxtras.net) - */ -#include <algorithm> -#include "RomList.h" - -RomList g_romList; - -bool RLessThan(Rom *elem1, Rom *elem2) -{ - return (elem1->GetFileName() < elem2->GetFileName()); -} - -RomList::RomList(void) -{ - m_iBaseIndex = 0; - m_bLoaded = false; - m_szRomPath = "D:\\"; -} - -RomList::~RomList(void) -{ - Destroy(); -} - -void RomList::Refresh() -{ - Destroy(); -} - -bool RomList::IsLoaded() -{ - return m_bLoaded; -} - -void RomList::AddRomToList(Rom *rom, int mode) -{ - std::vector<Rom *> *pList; - - pList = &m_romList; - - // look to see if the rom is already in the list, we dont want duplicates - for (int i = 0; i < static_cast<int>(pList->size()); i++) - { - if (rom == (*pList)[i]) - return; - } - - pList->push_back(rom); - std::sort(pList->begin(), pList->end(), RLessThan); -} - -void RomList::RemoveRomFromList(Rom *rom, int mode) -{ - std::vector<Rom *> *pList; - std::vector<Rom *>::iterator i; - - pList = &m_romList; - - // look to see if the rom is already in the list, we dont want duplicates - for (i = pList->begin(); i != pList->end(); i++) - { - if (rom == *i) - { - pList->erase(i); - return; - } - } -} - -int RomList::GetBaseIndex() -{ - if (m_iBaseIndex > GetRomListSize() - 1) - m_iBaseIndex = GetRomListSize() - 1; - if (m_iBaseIndex < 0) - m_iBaseIndex = 0; - - return m_iBaseIndex; -} - -void RomList::SetBaseIndex(int index) -{ - if (index > GetRomListSize() - 1) - index = GetRomListSize() - 1; - if (index < 0) - index = 0; - - m_iBaseIndex = index; -} - -int RomList::GetRomListSize() -{ - return m_romList.size(); -} - -Rom *RomList::GetRomAt(int index) -{ - return m_romList[index]; -} - -void RomList::Build() -{ - WIN32_FIND_DATA fd; - - HANDLE hFF = FindFirstFile((m_szRomPath + "*.*").c_str(), &fd); - - do - { - char ext[_MAX_EXT]; - - // get the filename extension - _splitpath((m_szRomPath + fd.cFileName).c_str(), - NULL, NULL, NULL, ext); - - if ( - stricmp(ext, ".bin") == 0 - || stricmp(ext, ".cue") == 0 - || stricmp(ext, ".iso") == 0 - || stricmp(ext, ".mdf") == 0 - || stricmp(ext, ".gba") == 0 - ) - { - Rom *rom = new Rom(); - bool bSuccess = rom->Load((m_szRomPath + fd.cFileName).c_str()); - - if (bSuccess) - m_romList.push_back(rom); - else - delete rom; - } - } while (FindNextFile(hFF, &fd)); - - sort(m_romList.begin(), m_romList.end(), RLessThan); - - m_bLoaded = true; -} - -void RomList::Destroy() -{ - m_bLoaded = false; - m_iBaseIndex = 0; - - std::vector<Rom *>::iterator i; - - for (i = m_romList.begin(); i != m_romList.end(); i++) - delete *i; - - m_romList.clear(); -} diff --git a/xbox1/frontend/RetroLaunch/RomList.h b/xbox1/frontend/RetroLaunch/RomList.h deleted file mode 100644 index eac7fac294..0000000000 --- a/xbox1/frontend/RetroLaunch/RomList.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * RetroLaunch 2012 - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. To contact the - * authors: Surreal64 CE Team (http://www.emuxtras.net) - */ - -#pragma once - -#include <vector> -#include "Rom.h" - -class RomList -{ -public: - RomList(void); - ~RomList(void); - - void Refresh(); - void Build(); - - bool IsLoaded(); - - void AddRomToList(Rom *rom, int mode); - void RemoveRomFromList(Rom *rom, int mode); - - int GetBaseIndex(); - void SetBaseIndex(int index); - - int GetRomListSize(); - - Rom *GetRomAt(int index); - - int m_iBaseIndex; - - std::vector<Rom *> m_romList; - -private: - void Destroy(); - -private: - bool m_bLoaded; - std::string m_szRomPath; -}; - -extern RomList g_romList; \ No newline at end of file diff --git a/xbox1/frontend/menu.cpp b/xbox1/frontend/menu.cpp index 9af964e4ee..a7c811188c 100644 --- a/xbox1/frontend/menu.cpp +++ b/xbox1/frontend/menu.cpp @@ -16,7 +16,10 @@ #include "RetroLaunch/IoSupport.h" #include "RetroLaunch/MenuManager.h" -#include "RetroLaunch/RomList.h" + +#include "../../console/fileio/file_browser.h" + +filebrowser_t browser; int menu_init(void) { @@ -32,9 +35,9 @@ int menu_init(void) g_IOSupport.Mount("F:", "Harddisk0\\Partition6"); g_IOSupport.Mount("G:", "Harddisk0\\Partition7"); - // Load the rom list if it isn't already loaded - if (!g_romList.IsLoaded()) - g_romList.Build(); + strlcpy(browser.extensions, rarch_console_get_rom_ext(), sizeof(browser.extensions)); + filebrowser_set_root(&browser, g_console.default_rom_startup_dir); + filebrowser_iterate(&browser, FILEBROWSER_ACTION_RESET); // Build menu here (Menu state -> Main Menu) g_menuManager.Create(); @@ -44,7 +47,10 @@ int menu_init(void) return 0; } -void menu_free(void) {} +void menu_free(void) +{ + filebrowser_free(&browser); +} void menu_loop(void) {