mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
(360) Filebrowser can now load ROMs from subdir
This commit is contained in:
parent
8e8f56b5e8
commit
471dfcd478
@ -30,6 +30,16 @@ static const char * filebrowser_get_extension(const char * filename)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void filebrowser_clear_current_entries(filebrowser_t * filebrowser)
|
||||||
|
{
|
||||||
|
for(uint32_t i = 0; i < MAX_FILE_LIMIT; i++)
|
||||||
|
{
|
||||||
|
filebrowser->cur[filebrowser->file_count].d_type = 0;
|
||||||
|
filebrowser->cur[filebrowser->file_count].d_namlen = 0;
|
||||||
|
strcpy(filebrowser->cur[filebrowser->file_count].d_name, "\0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char *extensions)
|
void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char *extensions)
|
||||||
{
|
{
|
||||||
int error = FALSE;
|
int error = FALSE;
|
||||||
@ -60,6 +70,7 @@ void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path,
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
strcpy(filebrowser->dir[filebrowser->directory_stack_size], path);
|
||||||
bool found_dir = false;
|
bool found_dir = false;
|
||||||
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
if(!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
{
|
{
|
||||||
@ -100,4 +111,22 @@ error:
|
|||||||
SSNES_ERR("Failed to open directory: \"%s\"\n", path);
|
SSNES_ERR("Failed to open directory: \"%s\"\n", path);
|
||||||
}
|
}
|
||||||
FindClose(hFind);
|
FindClose(hFind);
|
||||||
|
}
|
||||||
|
|
||||||
|
void filebrowser_new(filebrowser_t * filebrowser, const char * start_dir, const char * extensions)
|
||||||
|
{
|
||||||
|
filebrowser_clear_current_entries(filebrowser);
|
||||||
|
filebrowser->directory_stack_size = 0;
|
||||||
|
strcpy(filebrowser->extensions, extensions);
|
||||||
|
|
||||||
|
filebrowser_parse_directory(filebrowser, start_dir, filebrowser->extensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void filebrowser_push_directory(filebrowser_t * filebrowser, const char * path, bool with_extension)
|
||||||
|
{
|
||||||
|
filebrowser->directory_stack_size++;
|
||||||
|
if(with_extension)
|
||||||
|
filebrowser_parse_directory(filebrowser, path, filebrowser->extensions);
|
||||||
|
else
|
||||||
|
filebrowser_parse_directory(filebrowser, path, "empty");
|
||||||
}
|
}
|
@ -16,18 +16,28 @@
|
|||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define FATX_MAX_FILE_LIMIT 4096
|
#define FATX_MAX_FILE_LIMIT 4096
|
||||||
|
#define MAX_FILE_LIMIT FATX_MAX_FILE_LIMIT
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned d_type;
|
unsigned d_type;
|
||||||
|
unsigned d_namlen;
|
||||||
CHAR d_name[MAX_PATH];
|
CHAR d_name[MAX_PATH];
|
||||||
} DirectoryEntry;
|
} DirectoryEntry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned file_count; // amount of files in current directory
|
unsigned file_count; // amount of files in current directory
|
||||||
unsigned currently_selected; // currently selected browser entry
|
unsigned currently_selected; // currently selected browser entry
|
||||||
DirectoryEntry cur[FATX_MAX_FILE_LIMIT]; // current file listing
|
uint32_t directory_stack_size;
|
||||||
|
char dir[128][2048]; /* info on the current directory */
|
||||||
|
DirectoryEntry cur[MAX_FILE_LIMIT]; // current file listing
|
||||||
char extensions[512]; // allowed file extensions
|
char extensions[512]; // allowed file extensions
|
||||||
} filebrowser_t;
|
} filebrowser_t;
|
||||||
|
|
||||||
void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char *extensions);
|
void filebrowser_new(filebrowser_t * filebrowser, const char * start_dir, const char * extensions);
|
||||||
|
void filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char *extensions);
|
||||||
|
void filebrowser_push_directory(filebrowser_t * filebrowser, const char * path, bool with_extension);
|
||||||
|
|
||||||
|
#define FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(filebrowser) (filebrowser.dir[filebrowser.directory_stack_size])
|
13
360/menu.cpp
13
360/menu.cpp
@ -69,7 +69,7 @@ HRESULT CSSNES::UnregisterXuiClasses (void)
|
|||||||
static void filebrowser_fetch_directory_entries(const char *path, CXuiList * romlist,
|
static void filebrowser_fetch_directory_entries(const char *path, CXuiList * romlist,
|
||||||
CXuiTextElement * rompath_title)
|
CXuiTextElement * rompath_title)
|
||||||
{
|
{
|
||||||
filebrowser_parse_directory(&browser, path, ssnes_console_get_rom_ext());
|
filebrowser_push_directory(&browser, path, true);
|
||||||
|
|
||||||
unsigned long dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
unsigned long dwNum_rompath = MultiByteToWideChar(CP_ACP, 0, path, -1, NULL, 0);
|
||||||
wchar_t * rompath_name = new wchar_t[dwNum_rompath];
|
wchar_t * rompath_name = new wchar_t[dwNum_rompath];
|
||||||
@ -232,6 +232,8 @@ HRESULT CSSNESMain::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
|||||||
|
|
||||||
HRESULT CSSNESFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
HRESULT CSSNESFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
||||||
{
|
{
|
||||||
|
char path[MAX_PATH_LENGTH];
|
||||||
|
|
||||||
if(hObjPressed == m_romlist)
|
if(hObjPressed == m_romlist)
|
||||||
{
|
{
|
||||||
int index = m_romlist.GetCurSel();
|
int index = m_romlist.GetCurSel();
|
||||||
@ -240,7 +242,7 @@ HRESULT CSSNESFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
|||||||
memset(strbuffer, 0, sizeof(strbuffer));
|
memset(strbuffer, 0, sizeof(strbuffer));
|
||||||
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
|
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
|
||||||
memset(g_console.rom_path, 0, sizeof(g_console.rom_path));
|
memset(g_console.rom_path, 0, sizeof(g_console.rom_path));
|
||||||
sprintf(g_console.rom_path, "%s%s", g_console.default_rom_startup_dir, strbuffer);
|
sprintf(g_console.rom_path, "%s%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
|
||||||
|
|
||||||
return_to_game();
|
return_to_game();
|
||||||
g_console.initialize_ssnes_enable = 1;
|
g_console.initialize_ssnes_enable = 1;
|
||||||
@ -249,9 +251,8 @@ HRESULT CSSNESFileBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandled )
|
|||||||
{
|
{
|
||||||
memset(strbuffer, 0, sizeof(strbuffer));
|
memset(strbuffer, 0, sizeof(strbuffer));
|
||||||
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
|
wcstombs(strbuffer, (const wchar_t *)m_romlist.GetText(index), sizeof(strbuffer));
|
||||||
char strbuf[512];
|
snprintf(path, sizeof(path), "%s%s\\", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), strbuffer);
|
||||||
snprintf(strbuf, sizeof(strbuf), "%s%s", g_console.default_rom_startup_dir, strbuffer);
|
filebrowser_fetch_directory_entries(path, &m_romlist, &m_rompathtitle);
|
||||||
filebrowser_fetch_directory_entries(strbuf, &m_romlist, &m_rompathtitle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(hObjPressed == m_back)
|
else if(hObjPressed == m_back)
|
||||||
@ -358,6 +359,8 @@ int menu_init (void)
|
|||||||
|
|
||||||
XuiSceneNavigateFirst(app.GetRootObj(), app.hMainScene, XUSER_INDEX_FOCUS);
|
XuiSceneNavigateFirst(app.GetRootObj(), app.hMainScene, XUSER_INDEX_FOCUS);
|
||||||
|
|
||||||
|
filebrowser_new(&browser, g_console.default_rom_startup_dir, ssnes_console_get_rom_ext());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user