2013-06-28 00:16:30 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2013 FIX94
|
|
|
|
*
|
|
|
|
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
2013-08-01 22:18:35 +02:00
|
|
|
#include <algorithm>
|
2013-06-28 00:16:30 +02:00
|
|
|
#include "menu.hpp"
|
2013-07-07 00:35:05 +02:00
|
|
|
#include "channel/nand.hpp"
|
2013-06-28 00:16:30 +02:00
|
|
|
|
|
|
|
TexData m_explorerBg;
|
2013-08-01 22:18:35 +02:00
|
|
|
s16 entries[7];
|
|
|
|
s16 entries_sel[7];
|
2013-11-04 20:46:23 +01:00
|
|
|
s16 m_explorerLblSelFolderBg;
|
2013-08-03 21:40:46 +02:00
|
|
|
s16 m_explorerLblSelFolder;
|
|
|
|
s16 m_explorerBtnSet;
|
|
|
|
s16 m_explorerBtnBack;
|
|
|
|
s16 m_explorerLblPage;
|
|
|
|
s16 m_explorerBtnPageM;
|
|
|
|
s16 m_explorerBtnPageP;
|
|
|
|
s16 m_explorerLblUser[4];
|
2013-07-23 15:14:51 +02:00
|
|
|
|
2013-08-03 08:21:54 +02:00
|
|
|
u32 dirs = 0;
|
|
|
|
u32 files = 0;
|
|
|
|
u32 start_pos = 0;
|
|
|
|
typedef struct {
|
|
|
|
char name[NAME_MAX];
|
|
|
|
} list_element;
|
|
|
|
list_element *elements = NULL;
|
|
|
|
u32 elements_num = 0;
|
2013-07-07 00:35:05 +02:00
|
|
|
char file[MAX_FAT_PATH];
|
2013-06-28 00:16:30 +02:00
|
|
|
char dir[MAX_FAT_PATH];
|
2013-08-05 19:23:31 +02:00
|
|
|
char folderPath[MAX_FAT_PATH];
|
|
|
|
char tmpPath[MAX_FAT_PATH];
|
2013-06-29 16:48:02 +02:00
|
|
|
u8 explorer_partition = 0;
|
2013-07-23 15:14:51 +02:00
|
|
|
bool folderExplorer = false;
|
2016-12-01 01:05:39 +01:00
|
|
|
bool wadsOnly = false;
|
2013-06-29 16:48:02 +02:00
|
|
|
|
2013-06-28 00:16:30 +02:00
|
|
|
void CMenu::_hideExplorer(bool instant)
|
|
|
|
{
|
2013-08-01 14:37:16 +02:00
|
|
|
for(u8 i = 0; i < 7; ++i)
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
|
|
|
m_btnMgr.hide(entries[i], instant);
|
|
|
|
m_btnMgr.hide(entries_sel[i], instant);
|
|
|
|
}
|
2013-11-04 20:46:23 +01:00
|
|
|
m_btnMgr.hide(m_explorerLblSelFolderBg, instant);
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.hide(m_explorerLblSelFolder, instant);
|
|
|
|
m_btnMgr.hide(m_explorerLblPage, instant);
|
|
|
|
m_btnMgr.hide(m_explorerBtnPageM, instant);
|
|
|
|
m_btnMgr.hide(m_explorerBtnPageP, instant);
|
|
|
|
m_btnMgr.hide(m_explorerBtnSet, instant);
|
|
|
|
m_btnMgr.hide(m_explorerBtnBack, instant);
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_explorerLblUser); ++i)
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-03 21:40:46 +02:00
|
|
|
if(m_explorerLblUser[i] != -1)
|
|
|
|
m_btnMgr.hide(m_explorerLblUser[i], instant);
|
2013-07-23 15:14:51 +02:00
|
|
|
}
|
2013-08-03 08:21:54 +02:00
|
|
|
if(elements != NULL)
|
2020-06-26 01:11:58 +02:00
|
|
|
MEM2_free(elements);
|
2013-08-03 08:21:54 +02:00
|
|
|
elements = NULL;
|
|
|
|
elements_num = 0;
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showExplorer(void)
|
|
|
|
{
|
|
|
|
_setBg(m_explorerBg, m_explorerBg);
|
2013-07-23 15:14:51 +02:00
|
|
|
|
2013-11-04 20:46:23 +01:00
|
|
|
m_btnMgr.show(m_explorerLblSelFolderBg);
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.show(m_explorerLblSelFolder);
|
|
|
|
m_btnMgr.show(m_explorerBtnBack);
|
2013-07-23 15:14:51 +02:00
|
|
|
if(folderExplorer)
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.show(m_explorerBtnSet);
|
|
|
|
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_explorerLblUser); ++i)
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-03 21:40:46 +02:00
|
|
|
if(m_explorerLblUser[i] != -1)
|
|
|
|
m_btnMgr.show(m_explorerLblUser[i]);
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
2013-07-23 15:32:54 +02:00
|
|
|
_refreshExplorer();
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_Explorer(void)
|
|
|
|
{
|
2013-08-03 08:21:54 +02:00
|
|
|
CoverFlow.clear();
|
2013-08-18 18:22:54 +02:00
|
|
|
strcpy(folderPath, dir);
|
2013-06-28 00:16:30 +02:00
|
|
|
_showExplorer();
|
|
|
|
while(!m_exit)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
2016-12-01 01:05:39 +01:00
|
|
|
if(BTN_B_PRESSED)
|
2013-08-13 15:12:40 +02:00
|
|
|
{
|
|
|
|
memset(folderPath, 0, MAX_FAT_PATH);
|
2013-06-28 00:16:30 +02:00
|
|
|
break;
|
2013-08-13 15:12:40 +02:00
|
|
|
}
|
2016-12-01 01:05:39 +01:00
|
|
|
else if(BTN_HOME_PRESSED)
|
|
|
|
{
|
|
|
|
memset(dir, 0, MAX_FAT_PATH);
|
|
|
|
memset(folderPath, 0, MAX_FAT_PATH);
|
|
|
|
_refreshExplorer();
|
|
|
|
}
|
2013-08-22 18:52:00 +02:00
|
|
|
else if(BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED)
|
2013-06-29 16:48:02 +02:00
|
|
|
{
|
|
|
|
_refreshExplorer(1);
|
|
|
|
}
|
2013-08-22 18:52:00 +02:00
|
|
|
else if(BTN_MINUS_PRESSED || BTN_LEFT_PRESSED)
|
2013-06-29 16:48:02 +02:00
|
|
|
{
|
|
|
|
_refreshExplorer(-1);
|
|
|
|
}
|
2013-06-28 00:16:30 +02:00
|
|
|
else if(BTN_A_PRESSED)
|
|
|
|
{
|
2013-08-03 21:40:46 +02:00
|
|
|
if(m_btnMgr.selected(m_explorerBtnPageP))
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
|
|
|
_refreshExplorer(1);
|
|
|
|
}
|
2013-08-03 21:40:46 +02:00
|
|
|
else if(m_btnMgr.selected(m_explorerBtnPageM))
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
|
|
|
_refreshExplorer(-1);
|
|
|
|
}
|
2013-08-03 21:40:46 +02:00
|
|
|
else if(m_btnMgr.selected(m_explorerBtnSet))
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
2013-08-13 15:12:40 +02:00
|
|
|
strcpy(folderPath, dir);
|
2013-07-23 15:14:51 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-08-03 21:40:46 +02:00
|
|
|
else if(m_btnMgr.selected(m_explorerBtnBack))
|
2013-08-13 15:12:40 +02:00
|
|
|
{
|
|
|
|
memset(folderPath, 0, MAX_FAT_PATH);
|
2013-07-23 15:14:51 +02:00
|
|
|
break;
|
2013-08-13 15:12:40 +02:00
|
|
|
}
|
2013-07-23 15:14:51 +02:00
|
|
|
//if "..." is selected and path is not empty then go up(back) one folder
|
2013-08-01 14:37:16 +02:00
|
|
|
else if(m_btnMgr.selected(entries_sel[0]) && dir[0] != '\0')
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
|
|
|
//remove last folder or device+partition
|
2013-06-28 00:16:30 +02:00
|
|
|
if(strchr(dir, '/') != NULL)
|
|
|
|
{
|
|
|
|
*strrchr(dir, '/') = '\0';
|
|
|
|
if(strchr(dir, '/') != NULL)
|
|
|
|
*(strrchr(dir, '/')+1) = '\0';
|
|
|
|
}
|
2013-08-05 19:23:31 +02:00
|
|
|
strcpy(folderPath, dir);
|
|
|
|
//if dir is just device and : then clear path completely
|
|
|
|
if(strchr(dir, '/') == NULL)
|
|
|
|
{
|
|
|
|
memset(dir, 0, MAX_FAT_PATH);
|
|
|
|
memset(folderPath, 0, MAX_FAT_PATH);
|
|
|
|
}
|
|
|
|
else if(strchr(folderPath, '/') != strrchr(folderPath, '/'))
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-05 19:23:31 +02:00
|
|
|
*strrchr(folderPath, '/') = '\0';
|
|
|
|
while(strlen(folderPath) > 48)
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-05 19:23:31 +02:00
|
|
|
if(strchr(folderPath, '/') == strrchr(folderPath, '/'))
|
|
|
|
break;
|
|
|
|
memset(tmpPath, 0, MAX_FAT_PATH);
|
|
|
|
strncpy(tmpPath, strchr(folderPath, '/') + 1, MAX_FAT_PATH - 1);
|
|
|
|
strcpy(folderPath, tmpPath);
|
2013-07-23 15:14:51 +02:00
|
|
|
}
|
2013-08-05 19:23:31 +02:00
|
|
|
memset(tmpPath, 0, MAX_FAT_PATH);
|
|
|
|
if(strchr(folderPath, ':') == NULL)
|
|
|
|
strcpy(tmpPath, "/");
|
|
|
|
strcat(tmpPath, folderPath);
|
|
|
|
strcat(tmpPath, "/");
|
|
|
|
strcpy(folderPath, tmpPath);
|
2013-07-23 15:14:51 +02:00
|
|
|
}
|
2013-06-28 00:16:30 +02:00
|
|
|
_refreshExplorer();
|
|
|
|
}
|
2013-08-01 14:37:16 +02:00
|
|
|
for(u8 i = 1; i < 7; ++i)
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
2013-08-01 14:37:16 +02:00
|
|
|
if(m_btnMgr.selected(entries_sel[i]))
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
2013-07-23 15:14:51 +02:00
|
|
|
//if path is empty add device+partition#:/ to start path
|
2013-06-28 00:16:30 +02:00
|
|
|
if(dir[0] == '\0')
|
|
|
|
{
|
2013-06-29 16:48:02 +02:00
|
|
|
explorer_partition = i-1;
|
2013-08-01 14:37:16 +02:00
|
|
|
strcpy(dir, fmt("%s:/", DeviceName[i-1]));
|
2013-08-05 19:23:31 +02:00
|
|
|
strcpy(folderPath, dir);
|
2013-06-28 00:16:30 +02:00
|
|
|
_refreshExplorer();
|
|
|
|
}
|
2013-07-23 15:14:51 +02:00
|
|
|
//if it's a folder add folder+/ to path
|
2013-08-03 08:21:54 +02:00
|
|
|
else if(!fsop_FileExist(fmt("%s%s", dir, elements[start_pos+(i-1)].name)))
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
2013-08-03 08:21:54 +02:00
|
|
|
strcat(dir, elements[start_pos+(i-1)].name);
|
2013-08-05 19:23:31 +02:00
|
|
|
strcpy(folderPath, dir);
|
|
|
|
strcat(dir, "/");
|
|
|
|
while(strlen(folderPath) > 48)
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-05 19:23:31 +02:00
|
|
|
if(strchr(folderPath, '/') == strrchr(folderPath, '/'))
|
2013-08-01 14:37:16 +02:00
|
|
|
break;
|
2013-08-05 19:23:31 +02:00
|
|
|
memset(tmpPath, 0, MAX_FAT_PATH);
|
|
|
|
strncpy(tmpPath, strchr(folderPath, '/') + 1, MAX_FAT_PATH - 1);
|
|
|
|
strcpy(folderPath, tmpPath);
|
2013-07-23 15:14:51 +02:00
|
|
|
}
|
2013-08-05 19:23:31 +02:00
|
|
|
memset(tmpPath, 0, MAX_FAT_PATH);
|
|
|
|
if(strchr(folderPath, ':') == NULL)
|
|
|
|
strcpy(tmpPath, "/");
|
|
|
|
strcat(tmpPath, folderPath);
|
|
|
|
strcat(tmpPath, "/");
|
|
|
|
strcpy(folderPath, tmpPath);
|
2013-06-28 00:16:30 +02:00
|
|
|
_refreshExplorer();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-07 00:35:05 +02:00
|
|
|
memset(file, 0, MAX_FAT_PATH);
|
2018-11-12 21:38:37 +01:00
|
|
|
strncpy(file, fmt("%s%s", dir, elements[start_pos+(i-1)].name), MAX_FAT_PATH - 1);
|
2013-06-29 16:48:02 +02:00
|
|
|
if(strcasestr(file, ".mp3") != NULL || strcasestr(file, ".ogg") != NULL)
|
2013-06-28 00:16:30 +02:00
|
|
|
MusicPlayer.LoadFile(file, false);
|
2013-06-29 16:48:02 +02:00
|
|
|
else if(strcasestr(file, ".iso") != NULL || strcasestr(file, ".wbfs") != NULL)
|
|
|
|
{
|
2013-07-07 00:35:05 +02:00
|
|
|
_hideExplorer();
|
2013-06-29 16:48:02 +02:00
|
|
|
/* create header for id and path */
|
|
|
|
dir_discHdr tmpHdr;
|
|
|
|
memset(&tmpHdr, 0, sizeof(dir_discHdr));
|
|
|
|
memcpy(tmpHdr.path, file, 255);
|
|
|
|
/* check wii or gc */
|
|
|
|
FILE *fp = fopen(file, "rb");
|
|
|
|
fseek(fp, strcasestr(file, ".wbfs") != NULL ? 512 : 0, SEEK_SET);
|
|
|
|
fread((void*)&wii_hdr, 1, sizeof(discHdr), fp);
|
|
|
|
fclose(fp);
|
|
|
|
memcpy(tmpHdr.id, wii_hdr.id, 6);
|
|
|
|
if(wii_hdr.magic == WII_MAGIC)
|
|
|
|
{
|
|
|
|
currentPartition = explorer_partition;
|
2019-05-27 18:04:46 +02:00
|
|
|
_launchWii(&tmpHdr, false);
|
2013-06-29 16:48:02 +02:00
|
|
|
}
|
|
|
|
else if(wii_hdr.gc_magic == GC_MAGIC)
|
|
|
|
{
|
|
|
|
currentPartition = explorer_partition;
|
|
|
|
_launchGC(&tmpHdr, false);
|
|
|
|
}
|
2013-07-07 00:35:05 +02:00
|
|
|
_showExplorer();
|
|
|
|
}
|
2013-08-05 22:58:26 +02:00
|
|
|
else if(strcasestr(file, ".dol") != NULL || strcasestr(file, ".elf") != NULL)
|
|
|
|
{
|
|
|
|
_hideExplorer();
|
2018-06-27 14:47:03 +02:00
|
|
|
vector<string> arguments = _getMetaXML(file);
|
|
|
|
_launchHomebrew(file, arguments);
|
2013-08-05 22:58:26 +02:00
|
|
|
_showExplorer();
|
|
|
|
}
|
|
|
|
else if(strcasestr(file, ".txt") != NULL || strcasestr(file, ".nfo") != NULL
|
|
|
|
|| strcasestr(file, ".ini") != NULL || strcasestr(file, ".conf") != NULL
|
2013-09-03 15:48:30 +02:00
|
|
|
|| strcasestr(file, ".cfg") != NULL || strcasestr(file, ".xml") != NULL
|
|
|
|
|| strcasestr(file, ".log") != NULL)
|
2013-08-05 22:58:26 +02:00
|
|
|
{
|
|
|
|
_hideExplorer();
|
|
|
|
m_txt_view = true;
|
|
|
|
m_txt_path = file;
|
|
|
|
_about(false);
|
|
|
|
m_txt_view = false;
|
|
|
|
m_txt_path = NULL;
|
|
|
|
_showExplorer();
|
|
|
|
}
|
2013-07-07 00:35:05 +02:00
|
|
|
else if(strcasestr(file, ".wad") != NULL)
|
|
|
|
{
|
|
|
|
_hideExplorer();
|
|
|
|
_Wad(file);
|
|
|
|
_showExplorer();
|
2013-06-29 16:48:02 +02:00
|
|
|
}
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideExplorer();
|
2013-08-03 08:21:54 +02:00
|
|
|
_initCF();
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_initExplorer()
|
|
|
|
{
|
|
|
|
memset(dir, 0, MAX_FAT_PATH);
|
|
|
|
TexData blank_btn;
|
2013-11-19 16:27:52 +01:00
|
|
|
TexHandle.fromImageFile(blank_btn, fmt("%s/blank.png", m_imgsDir.c_str()));
|
|
|
|
|
2013-06-28 00:16:30 +02:00
|
|
|
m_explorerBg = _texture("EXPLORER/BG", "texture", theme.bg, false);
|
2013-08-03 21:40:46 +02:00
|
|
|
_addUserLabels(m_explorerLblUser, ARRAY_SIZE(m_explorerLblUser), "EXPLORER");
|
2013-11-04 20:46:23 +01:00
|
|
|
m_explorerLblSelFolderBg = _addLabel("EXPLORER/SELECTED_FOLDER_BG", theme.txtFont, L"", 0, 18, 640, 48, theme.txtFontColor, FTGX_JUSTIFY_LEFT, theme.btnTexC);
|
2018-12-28 01:47:00 +01:00
|
|
|
m_explorerLblSelFolder = _addLabel("EXPLORER/SELECTED_FOLDER", theme.txtFont, L"", 30, 30, 560, 40, theme.txtFontColor, FTGX_JUSTIFY_LEFT);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_explorerBtnSet = _addButton("EXPLORER/SET_BTN", theme.btnFont, L"", 220, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_explorerBtnBack = _addButton("EXPLORER/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
|
|
|
m_explorerBtnPageM = _addPicButton("EXPLORER/PAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 20, 400, 48, 48);
|
|
|
|
m_explorerLblPage = _addLabel("EXPLORER/PAGE_BTN", theme.btnFont, L"", 68, 400, 104, 48, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
|
|
|
|
m_explorerBtnPageP = _addPicButton("EXPLORER/PAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 172, 400, 48, 48);
|
|
|
|
|
|
|
|
_setHideAnim(m_explorerLblSelFolderBg, "EXPLORER/SELECTED_FOLDER_BG", 0, 0, -2.f, 0.f);
|
2013-08-03 21:40:46 +02:00
|
|
|
_setHideAnim(m_explorerLblSelFolder, "EXPLORER/SELECTED_FOLDER", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_explorerBtnSet, "EXPLORER/SET_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_explorerBtnBack, "EXPLORER/BACK_BTN", 0, 0, 1.f, -1.f);
|
2013-08-03 21:40:46 +02:00
|
|
|
_setHideAnim(m_explorerLblPage, "EXPLORER/PAGE_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_explorerBtnPageM, "EXPLORER/PAGE_MINUS", 0, 0, 1.f, -1.f);
|
|
|
|
_setHideAnim(m_explorerBtnPageP, "EXPLORER/PAGE_PLUS", 0, 0, 1.f, -1.f);
|
2013-07-23 15:14:51 +02:00
|
|
|
|
2013-08-01 14:37:16 +02:00
|
|
|
for(u8 i = 0; i < 7; ++i)
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
2013-08-03 21:40:46 +02:00
|
|
|
entries_sel[i] = _addPicButton(fmt("EXPLORER/ENTRY_%i_BTN", i), blank_btn, blank_btn, 40, 75+(i*45), 380, 45);
|
2018-12-28 01:47:00 +01:00
|
|
|
entries[i] = _addLabel(fmt("EXPLORER/ENTRY_%i", i), theme.txtFont, L"", 40, 75+(i*45), 480, 40, theme.txtFontColor, FTGX_JUSTIFY_LEFT);
|
2013-06-28 00:16:30 +02:00
|
|
|
_setHideAnim(entries[i], fmt("EXPLORER/ENTRY_%i", i), 0, 0, 1.f, 0.f);
|
|
|
|
_setHideAnim(entries_sel[i], fmt("EXPLORER/ENTRY_%i_BTN", i), 0, 0, 1.f, 0.f);
|
|
|
|
}
|
|
|
|
_hideExplorer(true);
|
|
|
|
_textExplorer();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textExplorer(void)
|
|
|
|
{
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.setText(m_explorerBtnSet, _t("cfgne34", L"Set"));
|
|
|
|
m_btnMgr.setText(m_explorerBtnBack, _t("cfgne35", L"Back"));
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
|
2013-08-03 08:21:54 +02:00
|
|
|
static bool list_element_cmp(list_element a, list_element b)
|
|
|
|
{
|
|
|
|
const char *first = a.name;
|
|
|
|
const char *second = b.name;
|
|
|
|
return char_cmp(first, second, strlen(first), strlen(second));
|
|
|
|
}
|
|
|
|
|
2013-06-28 00:16:30 +02:00
|
|
|
void CMenu::_refreshExplorer(s8 direction)
|
|
|
|
{
|
2013-08-01 14:37:16 +02:00
|
|
|
for(u8 i = 0; i < 7; ++i)
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
|
|
|
m_btnMgr.hide(entries[i], true);
|
|
|
|
m_btnMgr.hide(entries_sel[i], true);
|
|
|
|
m_btnMgr.setText(entries[i], L" ");
|
|
|
|
}
|
2013-08-01 14:37:16 +02:00
|
|
|
m_btnMgr.setText(entries[0], L". . .");
|
2013-08-03 21:40:46 +02:00
|
|
|
wstringEx path(_t("cfgne36", L"Path ="));
|
2013-08-05 19:23:31 +02:00
|
|
|
path.append(wfmt(L" %.48s", folderPath));
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.setText(m_explorerLblSelFolder, path, true);
|
2013-08-03 08:21:54 +02:00
|
|
|
|
2013-06-28 00:16:30 +02:00
|
|
|
if(direction == 0)
|
2013-08-03 08:21:54 +02:00
|
|
|
start_pos = 0;
|
2013-06-28 00:16:30 +02:00
|
|
|
|
2013-07-23 15:14:51 +02:00
|
|
|
//if path is empty show device+partitions only
|
2013-06-28 00:16:30 +02:00
|
|
|
if(dir[0] == '\0')
|
|
|
|
{
|
2013-08-04 18:21:56 +02:00
|
|
|
elements_num = 0;
|
2013-08-01 14:37:16 +02:00
|
|
|
for(u8 i = 1; i < 7; ++i)
|
2013-06-28 00:16:30 +02:00
|
|
|
{
|
|
|
|
if(DeviceHandle.IsInserted(i-1))
|
2013-07-23 15:14:51 +02:00
|
|
|
{
|
2013-08-01 14:37:16 +02:00
|
|
|
m_btnMgr.setText(entries[i], wfmt(L"%s:/", DeviceName[i-1]));
|
|
|
|
m_btnMgr.show(entries[i]);
|
|
|
|
m_btnMgr.show(entries_sel[i]);
|
2013-07-23 15:14:51 +02:00
|
|
|
}
|
2013-06-28 00:16:30 +02:00
|
|
|
}
|
|
|
|
}
|
2013-07-23 15:14:51 +02:00
|
|
|
//else show folders and files
|
2013-06-28 00:16:30 +02:00
|
|
|
else
|
|
|
|
{
|
2013-08-01 14:37:16 +02:00
|
|
|
m_btnMgr.show(entries[0]);
|
|
|
|
m_btnMgr.show(entries_sel[0]);
|
2013-08-03 08:21:54 +02:00
|
|
|
if(direction == 0)
|
2013-08-01 22:18:35 +02:00
|
|
|
{
|
2013-08-03 08:21:54 +02:00
|
|
|
dirent *pent = NULL;
|
|
|
|
DIR *pdir = NULL;
|
|
|
|
pdir = opendir(dir);
|
|
|
|
/* some sorting */
|
|
|
|
dirs = 0;
|
|
|
|
files = 0;
|
|
|
|
while((pent = readdir(pdir)) != NULL)
|
|
|
|
{
|
|
|
|
if(pent->d_name[0] == '.')
|
|
|
|
continue;
|
|
|
|
if(pent->d_type == DT_DIR)
|
|
|
|
dirs++;
|
|
|
|
else if(pent->d_type == DT_REG)
|
2016-12-01 01:05:39 +01:00
|
|
|
{
|
|
|
|
const char *fileType = strrchr(pent->d_name, '.');
|
|
|
|
if(!wadsOnly || (fileType != NULL && strcasecmp(fileType, ".wad") == 0))
|
|
|
|
files++;
|
|
|
|
}
|
2013-08-03 08:21:54 +02:00
|
|
|
}
|
|
|
|
u32 pos = 0;
|
|
|
|
if(elements != NULL)
|
2020-06-26 01:11:58 +02:00
|
|
|
MEM2_free(elements);
|
2013-08-03 08:21:54 +02:00
|
|
|
elements_num = (folderExplorer ? dirs : dirs+files);
|
|
|
|
elements = (list_element*)MEM2_alloc(elements_num*sizeof(list_element));
|
|
|
|
if(dirs > 0)
|
|
|
|
{
|
|
|
|
rewinddir(pdir);
|
|
|
|
while((pent = readdir(pdir)) != NULL)
|
|
|
|
{
|
|
|
|
if(pent->d_name[0] == '.')
|
|
|
|
continue;
|
|
|
|
if(pent->d_type == DT_DIR)
|
|
|
|
{
|
|
|
|
memcpy(elements[pos].name, pent->d_name, NAME_MAX);
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::sort(elements, elements+pos, list_element_cmp);
|
|
|
|
}
|
|
|
|
if(folderExplorer == false && files > 0)
|
|
|
|
{
|
|
|
|
rewinddir(pdir);
|
|
|
|
while((pent = readdir(pdir)) != NULL)
|
|
|
|
{
|
|
|
|
if(pent->d_name[0] == '.')
|
|
|
|
continue;
|
|
|
|
if(pent->d_type == DT_REG)
|
|
|
|
{
|
2016-12-01 01:05:39 +01:00
|
|
|
// here we will check pent->d_name to make sure it's a wad file and add it if it is
|
|
|
|
const char *fileType = strrchr(pent->d_name, '.');
|
|
|
|
if(!wadsOnly || (fileType != NULL && strcasecmp(fileType, ".wad") == 0))
|
|
|
|
{
|
|
|
|
memcpy(elements[pos].name, pent->d_name, NAME_MAX);
|
|
|
|
pos++;
|
|
|
|
}
|
2013-08-03 08:21:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
std::sort(elements+dirs, elements+pos, list_element_cmp);
|
|
|
|
}
|
|
|
|
closedir(pdir);
|
2013-08-01 22:18:35 +02:00
|
|
|
}
|
2013-08-03 08:21:54 +02:00
|
|
|
if(direction == -1) /* dont question */
|
|
|
|
start_pos = start_pos >= 6 ? start_pos - 6 : (elements_num % 6 ? (elements_num - elements_num % 6) : elements_num - 6);
|
|
|
|
else if(direction == 1)
|
|
|
|
start_pos = start_pos + 6 >= elements_num ? 0 : start_pos + 6;
|
2013-08-04 18:21:56 +02:00
|
|
|
|
2013-08-03 08:21:54 +02:00
|
|
|
for(u8 i = 1; i < 7; i++)
|
2013-08-01 22:18:35 +02:00
|
|
|
{
|
2013-08-03 08:21:54 +02:00
|
|
|
if(start_pos+i > elements_num)
|
2013-08-01 22:18:35 +02:00
|
|
|
break;
|
2013-08-03 08:21:54 +02:00
|
|
|
if(start_pos+i <= dirs)
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.setText(entries[i], wfmt(L"/%.48s", elements[start_pos+i-1].name));
|
2013-08-03 08:21:54 +02:00
|
|
|
else
|
2013-08-03 21:40:46 +02:00
|
|
|
m_btnMgr.setText(entries[i], wfmt(L"%.48s", elements[start_pos+i-1].name));
|
2013-08-03 08:21:54 +02:00
|
|
|
m_btnMgr.show(entries[i]);
|
|
|
|
m_btnMgr.show(entries_sel[i]);
|
2013-08-01 22:18:35 +02:00
|
|
|
}
|
2013-07-10 17:08:40 +02:00
|
|
|
}
|
2013-08-04 18:21:56 +02:00
|
|
|
if(elements_num > 0)
|
|
|
|
m_btnMgr.setText(m_explorerLblPage, wfmt(L"%i / %i", (start_pos/6 + 1), ((elements_num - 1)/6 +1)));
|
|
|
|
else
|
|
|
|
m_btnMgr.setText(m_explorerLblPage, L"1 / 1");
|
|
|
|
m_btnMgr.show(m_explorerLblPage);
|
|
|
|
m_btnMgr.show(m_explorerBtnPageM);
|
|
|
|
m_btnMgr.show(m_explorerBtnPageP);
|
2013-07-10 17:08:40 +02:00
|
|
|
}
|
|
|
|
|
2013-08-19 16:02:03 +02:00
|
|
|
const char *CMenu::_FolderExplorer(const char *startPath)
|
2013-07-10 17:08:40 +02:00
|
|
|
{
|
2013-07-23 15:14:51 +02:00
|
|
|
folderExplorer = true;
|
2013-08-19 16:02:03 +02:00
|
|
|
memset(dir, 0, MAX_FAT_PATH);
|
|
|
|
strcpy(dir, startPath);
|
|
|
|
if(dir[strlen(dir) - 1] != '/')
|
|
|
|
strcat(dir, "/");
|
2013-07-23 15:14:51 +02:00
|
|
|
_Explorer();
|
|
|
|
folderExplorer = false;
|
-updating wiiflow lite to beta 4.3.0
-fixed using categories to hide GC disc 2's. Apparently this has never really worked right for some time or ever.
-fixed deleting the cached cover texture file for plugin games. Delete cover for plugins only deletes the cached texture file (.wfc)
-fixed favorites and adultonly (parental lock) for plugin games. Apparently I may have broke this a few revisions back.
-favorites and adultonly for plugin games now have their own domains in gamecfg1- [FAVORITES_PLUGINS] and [ADULTONLY_PLUGINS]. just makes it more organized.
-only wii, GC, channels are added to [PLAYCOUNT] and [LAST_PLAYED] in gamecfg1.
-now loading gamecfg1 at startup and leaving it loaded till exit. no more loading it and unloading all the time.
-fixed scrolling for game_info synopsis, credits, and help text.
-made source menu buttons wider for wiiflow default. old 80x80, now 100x80. looks better.
-display music info now defaults to off
-screensaver_disabled now defaults to yes
-show GC view button is now on by default no matter what. the only way it is disabled is if you edit wiiflow.ini manually. this is how all the view buttons work.
-removed hiding homebrew button but if wiiflow locked it won't work or in sourceflow it won't show.
-dump_list is now under [GENERAL] instead of each view. Also only works for Wii, GC, and channels.
-sorting only works for Wii, GC, and Channels now. disabled for sourceflow, plugins, homebrew, and combined view.
-now if no games are found a message is shown with the current path so you can see where wiiflow is looking. (except for plugins)
-removed auto create emuNAND for emuNAND view if gamelist is empty. just go to settings>NAND settings if you want to extract or disable it.
-now when no games are found all buttons at bottom are still accessible allowing you to change the view or go to settings and change current partition or path and even extract your NAND to create a EmuNAND. Or go to Home Menu and Install a Wii or GC game.
-removed auto extract NAND to emuNAND when launching a Wii game with EmuNAND save. Now a message is diplayed saying 'emuNAND for saves not found - using real NAND'.
-made the speed at which cover titles fade in/out almost instantly.
-removed update button from Home Menu. online update code is still there but not used and probably won't be used any more as there just isn't a need for it now.
-removed ftp button from Home Menu and all code for the FTP server. I just use WiiXplorer's FTP server. it seems to work better for me.
-disabled keep USB Alive thread for now. i think there's a possibilty it might be the cause of my SD/USB files getting corrupted.
-removed Btn B and - combo to switch partitions. didn't seem useful anymore.
-redid nand emulation settings menu. looks like this now:
pg1
Select EmuNAND
EmuNAND Enulation
Select SaveNAND
SaveNAND Emulation
pg2
Extract Saves All
Missing
Extract NAND
Select Saves Partition
-no longer blocking Select Plugin menu and View icons when using source menu combined view
-now Select Plugins Menu is like switching to plugin view but you get to choose the plugins first
-now [PLUGIN] partition= is the default partition for all plugins. to change individual plugins add 'romPartition=x' to the plugin ini. x is the partition number 0 thru 8 with SD being 0. this is how my usbloadergx plugin mod works.
2016-10-05 01:44:13 +02:00
|
|
|
if(strrchr(folderPath, '/') != NULL)
|
|
|
|
*strrchr(folderPath, '/') = '\0';
|
2013-08-05 19:23:31 +02:00
|
|
|
return folderPath;
|
2013-07-10 17:08:40 +02:00
|
|
|
}
|
2016-12-01 01:05:39 +01:00
|
|
|
|
|
|
|
void CMenu::_wadExplorer(void)
|
|
|
|
{
|
|
|
|
wadsOnly = true;
|
|
|
|
_Explorer();
|
|
|
|
wadsOnly = false;
|
|
|
|
}
|