From 45400dd87951b79cb2df08eb1c3bcbb7292d073c Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Mon, 5 Aug 2013 20:58:26 +0000 Subject: [PATCH] -updated the file explorer filetype handling, you can now boot ".elf" and ".dol" files and read text files with the extensions ".txt", ".ini", ".cfg", ".nfo", ".conf" and ".xml" --- source/menu/menu.cpp | 3 +++ source/menu/menu.hpp | 6 +++++- source/menu/menu_about.cpp | 22 ++++++++++++++++++++-- source/menu/menu_explorer.cpp | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 1ae3c685..d8117c30 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -127,6 +127,9 @@ CMenu::CMenu() m_use_source = true; m_clearCats = true; m_catStartPage = 1; + /* Explorer stuff */ + m_txt_view = false; + m_txt_path = NULL; } void CMenu::init() diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index f6281688..3f9cff37 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -115,7 +115,11 @@ private: string m_languagesDir; string m_DMLgameDir; string m_helpDir; - + + /* Explorer stuff */ + bool m_txt_view; + const char *m_txt_path; + /* Updates */ char m_app_update_drive[6]; const char* m_app_update_url; diff --git a/source/menu/menu_about.cpp b/source/menu/menu_about.cpp index e42c030a..5f7b216e 100644 --- a/source/menu/menu_about.cpp +++ b/source/menu/menu_about.cpp @@ -81,7 +81,8 @@ void CMenu::_showAbout(void) { _setBg(m_aboutBg, m_aboutBg); m_btnMgr.show(m_aboutLblTitle); - m_btnMgr.show(m_aboutLblIOS); + if(m_txt_view == false) + m_btnMgr.show(m_aboutLblIOS); m_btnMgr.show(m_aboutLblInfo,false); for(u8 i = 0; i < ARRAY_SIZE(m_aboutLblUser); ++i) { @@ -107,7 +108,24 @@ void CMenu::_initAboutMenu() void CMenu::_textAbout(void) { - if(showHelp) + if(m_txt_view) + { + wstringEx txt_file_name; + txt_file_name.fromUTF8(strrchr(m_txt_path, '/') + 1); + m_btnMgr.setText(m_aboutLblTitle, txt_file_name); + wstringEx txt_file_content; + u32 txt_size = 0; + char *txt_mem = (char*)fsop_ReadFile(m_txt_path, &txt_size); + if(txt_mem != NULL) + { + txt_file_content.fromUTF8(txt_mem); + m_btnMgr.setText(m_aboutLblInfo, txt_file_content); + free(txt_mem); + } + txt_mem = NULL; + return; /* no need for ios checks */ + } + else if(showHelp) { m_btnMgr.setText(m_aboutLblTitle, _t("about10", L"Help Guide")); wstringEx help_text; diff --git a/source/menu/menu_explorer.cpp b/source/menu/menu_explorer.cpp index cb772b9e..8e875d28 100644 --- a/source/menu/menu_explorer.cpp +++ b/source/menu/menu_explorer.cpp @@ -228,6 +228,24 @@ void CMenu::_Explorer(void) } _showExplorer(); } + else if(strcasestr(file, ".dol") != NULL || strcasestr(file, ".elf") != NULL) + { + _hideExplorer(); + _launchHomebrew(file, m_homebrewArgs); + _showExplorer(); + } + else if(strcasestr(file, ".txt") != NULL || strcasestr(file, ".nfo") != NULL + || strcasestr(file, ".ini") != NULL || strcasestr(file, ".conf") != NULL + || strcasestr(file, ".cfg") != NULL || strcasestr(file, ".xml") != NULL) + { + _hideExplorer(); + m_txt_view = true; + m_txt_path = file; + _about(false); + m_txt_view = false; + m_txt_path = NULL; + _showExplorer(); + } else if(strcasestr(file, ".wad") != NULL) { _hideExplorer();