- recoded a little of explorer to make it more memory friendly as Fix94 says. But it still works the same. Also removed theme.selsbtnFontColor and theme.selubtnFontColor which aren't used anymore.

This commit is contained in:
fledge68 2013-08-05 17:23:31 +00:00
parent 76b7ad1d6b
commit c8673083f9
4 changed files with 60 additions and 57 deletions

View File

@ -950,9 +950,6 @@ void CMenu::_buildMenus(void)
theme.txtFont = _font(theme.fontSet, "GENERAL", "text_font", TEXTFONT); theme.txtFont = _font(theme.fontSet, "GENERAL", "text_font", TEXTFONT);
theme.txtFontColor = m_theme.getColor("GENERAL", "text_font_color", 0xFFFFFFFF); theme.txtFontColor = m_theme.getColor("GENERAL", "text_font_color", 0xFFFFFFFF);
theme.selsbtnFontColor = m_theme.getColor("GENERAL", "selsbtn_font_color", 0xFA5882FF);
theme.selubtnFontColor = m_theme.getColor("GENERAL", "selubtn_font_color", 0xD0BFDFFF);
// Default Sounds // Default Sounds
theme.clickSound = _sound(theme.soundSet, "GENERAL", "click_sound", click_wav, click_wav_size, "default_btn_click", false); theme.clickSound = _sound(theme.soundSet, "GENERAL", "click_sound", click_wav, click_wav_size, "default_btn_click", false);
theme.hoverSound = _sound(theme.soundSet, "GENERAL", "hover_sound", hover_wav, hover_wav_size, "default_btn_hover", false); theme.hoverSound = _sound(theme.soundSet, "GENERAL", "hover_sound", hover_wav, hover_wav_size, "default_btn_hover", false);

View File

@ -990,7 +990,7 @@ private:
void _gameSettings(void); void _gameSettings(void);
void _CoverBanner(void); void _CoverBanner(void);
void _Explorer(void); void _Explorer(void);
string _FolderExplorer(void); const char *_FolderExplorer(void);
void _Wad(const char *wad_path = NULL); void _Wad(const char *wad_path = NULL);
void _CheatSettings(); void _CheatSettings();
bool _Source(); bool _Source();

View File

@ -44,10 +44,10 @@ list_element *elements = NULL;
u32 elements_num = 0; u32 elements_num = 0;
char file[MAX_FAT_PATH]; char file[MAX_FAT_PATH];
char dir[MAX_FAT_PATH]; char dir[MAX_FAT_PATH];
char folderPath[MAX_FAT_PATH];
char tmpPath[MAX_FAT_PATH];
u8 explorer_partition = 0; u8 explorer_partition = 0;
bool folderExplorer = false; bool folderExplorer = false;
string folderPath = "";
string path = "";
void CMenu::_hideExplorer(bool instant) void CMenu::_hideExplorer(bool instant)
{ {
@ -120,9 +120,8 @@ void CMenu::_Explorer(void)
} }
else if(m_btnMgr.selected(m_explorerBtnSet)) else if(m_btnMgr.selected(m_explorerBtnSet))
{ {
//only when set is clicked do we set path to dir //only when set is clicked do we set folderPath to dir
if(dir[0] != '\0') strcpy(folderPath, dir);
path = dir;
break; break;
} }
else if(m_btnMgr.selected(m_explorerBtnBack)) else if(m_btnMgr.selected(m_explorerBtnBack))
@ -137,29 +136,31 @@ void CMenu::_Explorer(void)
if(strchr(dir, '/') != NULL) if(strchr(dir, '/') != NULL)
*(strrchr(dir, '/')+1) = '\0'; *(strrchr(dir, '/')+1) = '\0';
} }
folderPath = dir; strcpy(folderPath, dir);
//if dir is just device and : then folderpath empty //if dir is just device and : then clear path completely
if(folderPath.find_last_of("/") == string::npos)
folderPath = "";
else
{
if(folderPath.find_first_of("/") != folderPath.find_last_of("/"))
{
folderPath = folderPath.erase(folderPath.find_last_of("/"));
while(folderPath.length() > 32)
{
if(folderPath.find_first_of("/") == string::npos)
break;
folderPath = folderPath.erase(0, folderPath.find_first_of("/")+1);
}
if(folderPath.find_first_of(":") == string::npos)
folderPath = "/"+folderPath;
folderPath = folderPath+"/";
}
}
//if we removed device then clear path completely
if(strchr(dir, '/') == NULL) if(strchr(dir, '/') == NULL)
{
memset(dir, 0, MAX_FAT_PATH); memset(dir, 0, MAX_FAT_PATH);
memset(folderPath, 0, MAX_FAT_PATH);
}
else if(strchr(folderPath, '/') != strrchr(folderPath, '/'))
{
*strrchr(folderPath, '/') = '\0';
while(strlen(folderPath) > 48)
{
if(strchr(folderPath, '/') == strrchr(folderPath, '/'))
break;
memset(tmpPath, 0, MAX_FAT_PATH);
strncpy(tmpPath, strchr(folderPath, '/') + 1, MAX_FAT_PATH - 1);
strcpy(folderPath, tmpPath);
}
memset(tmpPath, 0, MAX_FAT_PATH);
if(strchr(folderPath, ':') == NULL)
strcpy(tmpPath, "/");
strcat(tmpPath, folderPath);
strcat(tmpPath, "/");
strcpy(folderPath, tmpPath);
}
_refreshExplorer(); _refreshExplorer();
} }
for(u8 i = 1; i < 7; ++i) for(u8 i = 1; i < 7; ++i)
@ -171,26 +172,29 @@ void CMenu::_Explorer(void)
{ {
explorer_partition = i-1; explorer_partition = i-1;
strcpy(dir, fmt("%s:/", DeviceName[i-1])); strcpy(dir, fmt("%s:/", DeviceName[i-1]));
folderPath = dir; strcpy(folderPath, dir);
_refreshExplorer(); _refreshExplorer();
} }
//if it's a folder add folder+/ to path //if it's a folder add folder+/ to path
else if(!fsop_FileExist(fmt("%s%s", dir, elements[start_pos+(i-1)].name))) else if(!fsop_FileExist(fmt("%s%s", dir, elements[start_pos+(i-1)].name)))
{ {
strcat(dir, elements[start_pos+(i-1)].name); strcat(dir, elements[start_pos+(i-1)].name);
folderPath = dir; strcpy(folderPath, dir);
while(folderPath.length() > 48)
{
//this if won't happen the first time
if(folderPath.find_first_of("/") == string::npos)
break;
folderPath = folderPath.erase(0, folderPath.find_first_of("/")+1);
}
if(folderPath.find_first_of(":") == string::npos)
folderPath = "/"+folderPath;
folderPath = folderPath+"/";
/* otherwise it fails */
strcat(dir, "/"); strcat(dir, "/");
while(strlen(folderPath) > 48)
{
if(strchr(folderPath, '/') == strrchr(folderPath, '/'))
break;
memset(tmpPath, 0, MAX_FAT_PATH);
strncpy(tmpPath, strchr(folderPath, '/') + 1, MAX_FAT_PATH - 1);
strcpy(folderPath, tmpPath);
}
memset(tmpPath, 0, MAX_FAT_PATH);
if(strchr(folderPath, ':') == NULL)
strcpy(tmpPath, "/");
strcat(tmpPath, folderPath);
strcat(tmpPath, "/");
strcpy(folderPath, tmpPath);
_refreshExplorer(); _refreshExplorer();
} }
else else
@ -295,7 +299,7 @@ void CMenu::_refreshExplorer(s8 direction)
} }
m_btnMgr.setText(entries[0], L". . ."); m_btnMgr.setText(entries[0], L". . .");
wstringEx path(_t("cfgne36", L"Path =")); wstringEx path(_t("cfgne36", L"Path ="));
path.append(wfmt(L" %.48s", folderPath.c_str())); path.append(wfmt(L" %.48s", folderPath));
m_btnMgr.setText(m_explorerLblSelFolder, path, true); m_btnMgr.setText(m_explorerLblSelFolder, path, true);
if(direction == 0) if(direction == 0)
@ -400,11 +404,11 @@ void CMenu::_refreshExplorer(s8 direction)
m_btnMgr.show(m_explorerBtnPageP); m_btnMgr.show(m_explorerBtnPageP);
} }
string CMenu::_FolderExplorer(void) const char *CMenu::_FolderExplorer(void)
{ {
folderExplorer = true; folderExplorer = true;
path = ""; //path = "";
_Explorer(); _Explorer();
folderExplorer = false; folderExplorer = false;
return path; return folderPath;
} }

View File

@ -374,18 +374,19 @@ int CMenu::_NandEmuCfg(void)
else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnNandFolder))) else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnNandFolder)))
{ {
_hideNandEmu(true); _hideNandEmu(true);
path = _FolderExplorer(); const char *path = _FolderExplorer();
if(!path.empty()) if(strlen(path) > 0)
{ {
if(path.find("sd:/") != string::npos) if(strncmp(path, "sd:/", 4) == 0)
m_cfg.setInt(CHANNEL_DOMAIN, "partition", 0); m_cfg.setInt(CHANNEL_DOMAIN, "partition", 0);
else else
{ {
const char *partval = &path[3]; const char *partval = &path[3];
m_cfg.setInt(CHANNEL_DOMAIN, "partition", atoi(partval)); m_cfg.setInt(CHANNEL_DOMAIN, "partition", atoi(partval));
} }
path = path.erase(0,path.find_first_of("/")); char tmpPath[MAX_FAT_PATH];
m_cfg.setString(CHANNEL_DOMAIN, "path", path); strncpy(tmpPath, strchr(path, '/'), MAX_FAT_PATH-1);
m_cfg.setString(CHANNEL_DOMAIN, "path", tmpPath);
m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true); m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true);
} }
_showNandEmu(); _showNandEmu();
@ -393,18 +394,19 @@ int CMenu::_NandEmuCfg(void)
else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnNandSavesFolder))) else if(BTN_A_PRESSED && (m_btnMgr.selected(m_nandemuBtnNandSavesFolder)))
{ {
_hideNandEmu(true); _hideNandEmu(true);
path = _FolderExplorer(); const char *path = _FolderExplorer();
if(!path.empty()) if(strlen(path) > 0)
{ {
if(path.find("sd:/") != string::npos) if(strncmp(path, "sd:/", 4) == 0)
m_cfg.setInt(WII_DOMAIN, "savepartition", 0); m_cfg.setInt(WII_DOMAIN, "savepartition", 0);
else else
{ {
const char *partval = &path[3]; const char *partval = &path[3];
m_cfg.setInt(WII_DOMAIN, "savepartition", atoi(partval)); m_cfg.setInt(WII_DOMAIN, "savepartition", atoi(partval));
} }
path = path.erase(0,path.find_first_of("/")); char tmpPath[MAX_FAT_PATH];
m_cfg.setString(WII_DOMAIN, "savepath", path); strncpy(tmpPath, strchr(path, '/'), MAX_FAT_PATH-1);
m_cfg.setString(WII_DOMAIN, "savepath", tmpPath);
} }
_showNandEmu(); _showNandEmu();
} }