2016-12-14 19:47:13 +01:00
|
|
|
|
|
|
|
#include "menu.hpp"
|
|
|
|
|
|
|
|
s16 m_partitionsLblTitle;
|
|
|
|
s16 m_partitionsBtnBack;
|
|
|
|
s16 m_partitionsLblUser[4];
|
|
|
|
|
|
|
|
TexData m_partitionsBg;
|
|
|
|
|
2022-12-10 22:10:29 +01:00
|
|
|
static inline int loopNum(int i, int s)
|
|
|
|
{
|
|
|
|
return (i + s) % s;
|
|
|
|
}
|
|
|
|
|
2016-12-14 19:47:13 +01:00
|
|
|
void CMenu::_hidePartitionsCfg(bool instant)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_partitionsLblTitle, instant);
|
|
|
|
m_btnMgr.hide(m_partitionsBtnBack, instant);
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_partitionsLblUser); ++i)
|
|
|
|
if(m_partitionsLblUser[i] != -1)
|
|
|
|
m_btnMgr.hide(m_partitionsLblUser[i], instant);
|
2022-07-14 23:48:12 +02:00
|
|
|
|
|
|
|
_hideConfigButtons(instant);
|
2016-12-14 19:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showPartitionsCfg(void)
|
|
|
|
{
|
2022-07-08 00:12:42 +02:00
|
|
|
_setBg(m_partitionsBg, m_partitionsBg);
|
2016-12-14 19:47:13 +01:00
|
|
|
m_btnMgr.show(m_partitionsLblTitle);
|
|
|
|
m_btnMgr.show(m_partitionsBtnBack);
|
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_partitionsLblUser); ++i)
|
|
|
|
if(m_partitionsLblUser[i] != -1)
|
|
|
|
m_btnMgr.show(m_partitionsLblUser[i]);
|
|
|
|
|
2022-07-08 00:12:42 +02:00
|
|
|
m_btnMgr.setText(m_configLbl1, _t("part1", L"Wii Partition"));
|
|
|
|
m_btnMgr.setText(m_configLbl2, _t("part2", L"GameCube Partition"));
|
|
|
|
m_btnMgr.setText(m_configLbl3, _t("part3", L"Emu NANDS Partition"));
|
|
|
|
m_btnMgr.setText(m_configLbl4, _t("part4", L"Plugins Default Partition"));
|
|
|
|
|
2022-12-10 22:10:29 +01:00
|
|
|
currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", USB1);
|
|
|
|
m_btnMgr.setText(m_configLbl1Val, currentPartition == 8 ? "SD/USB" : upperCase(DeviceName[currentPartition]));
|
2022-07-08 00:12:42 +02:00
|
|
|
|
2022-12-10 22:10:29 +01:00
|
|
|
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", USB1);
|
|
|
|
m_btnMgr.setText(m_configLbl2Val, currentPartition == 8 ? "SD/USB" : upperCase(DeviceName[currentPartition]));
|
2022-07-08 00:12:42 +02:00
|
|
|
|
2022-12-10 22:10:29 +01:00
|
|
|
currentPartition = m_cfg.getInt(CHANNEL_DOMAIN, "partition", USB1);
|
|
|
|
m_btnMgr.setText(m_configLbl3Val, upperCase(DeviceName[currentPartition]));
|
2022-07-08 00:12:42 +02:00
|
|
|
|
2022-12-10 22:10:29 +01:00
|
|
|
currentPartition = m_cfg.getInt(PLUGIN_DOMAIN, "partition", SD);
|
|
|
|
m_btnMgr.setText(m_configLbl4Val, upperCase(DeviceName[currentPartition]));
|
2022-07-08 00:12:42 +02:00
|
|
|
|
|
|
|
m_btnMgr.show(m_configLbl1);
|
|
|
|
m_btnMgr.show(m_configLbl1Val);
|
|
|
|
m_btnMgr.show(m_configBtn1P);
|
|
|
|
m_btnMgr.show(m_configBtn1M);
|
|
|
|
m_btnMgr.show(m_configLbl2);
|
|
|
|
m_btnMgr.show(m_configLbl2Val);
|
|
|
|
m_btnMgr.show(m_configBtn2P);
|
|
|
|
m_btnMgr.show(m_configBtn2M);
|
|
|
|
m_btnMgr.show(m_configLbl3);
|
|
|
|
m_btnMgr.show(m_configLbl3Val);
|
|
|
|
m_btnMgr.show(m_configBtn3P);
|
|
|
|
m_btnMgr.show(m_configBtn3M);
|
|
|
|
m_btnMgr.show(m_configLbl4);
|
|
|
|
m_btnMgr.show(m_configLbl4Val);
|
|
|
|
m_btnMgr.show(m_configBtn4P);
|
|
|
|
m_btnMgr.show(m_configBtn4M);
|
2016-12-14 19:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_partitionsCfg(void)
|
|
|
|
{
|
|
|
|
SetupInput();
|
|
|
|
_showPartitionsCfg();
|
|
|
|
while(!m_exit)
|
|
|
|
{
|
|
|
|
_mainLoopCommon();
|
|
|
|
if(BTN_HOME_PRESSED || BTN_B_PRESSED)
|
|
|
|
break;
|
|
|
|
else if(BTN_UP_PRESSED)
|
|
|
|
m_btnMgr.up();
|
|
|
|
else if(BTN_DOWN_PRESSED)
|
|
|
|
m_btnMgr.down();
|
|
|
|
else if(BTN_A_PRESSED)
|
|
|
|
{
|
|
|
|
if(m_btnMgr.selected(m_partitionsBtnBack))
|
|
|
|
break;
|
2022-07-08 00:12:42 +02:00
|
|
|
else if(m_btnMgr.selected(m_configBtn1P) || m_btnMgr.selected(m_configBtn1M))
|
2016-12-14 19:47:13 +01:00
|
|
|
{
|
2022-07-08 00:12:42 +02:00
|
|
|
s8 direction = m_btnMgr.selected(m_configBtn1P) ? 1 : -1;
|
2022-11-29 22:39:12 +01:00
|
|
|
_setPartition(direction, m_cfg.getInt(WII_DOMAIN, "partition"), COVERFLOW_WII);
|
2022-12-10 22:10:29 +01:00
|
|
|
m_cfg.setInt(WII_DOMAIN, "partition", currentPartition);
|
2016-12-14 19:47:13 +01:00
|
|
|
_showPartitionsCfg();
|
2022-12-10 22:10:29 +01:00
|
|
|
if(m_current_view & COVERFLOW_WII || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(WII_PMAGIC)))
|
2016-12-14 19:47:13 +01:00
|
|
|
m_refreshGameList = true;
|
|
|
|
}
|
2022-07-08 00:12:42 +02:00
|
|
|
else if(m_btnMgr.selected(m_configBtn2P) || m_btnMgr.selected(m_configBtn2M))
|
2016-12-14 19:47:13 +01:00
|
|
|
{
|
2022-07-08 00:12:42 +02:00
|
|
|
s8 direction = m_btnMgr.selected(m_configBtn2P) ? 1 : -1;
|
2022-11-29 22:39:12 +01:00
|
|
|
_setPartition(direction, m_cfg.getInt(GC_DOMAIN, "partition"), COVERFLOW_GAMECUBE);
|
2022-12-10 22:10:29 +01:00
|
|
|
m_cfg.setInt(GC_DOMAIN, "partition", currentPartition);
|
2016-12-14 19:47:13 +01:00
|
|
|
_showPartitionsCfg();
|
2022-12-10 22:10:29 +01:00
|
|
|
if(m_current_view & COVERFLOW_GAMECUBE || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(GC_PMAGIC)))
|
2016-12-14 19:47:13 +01:00
|
|
|
m_refreshGameList = true;
|
|
|
|
}
|
2022-07-08 00:12:42 +02:00
|
|
|
else if(m_btnMgr.selected(m_configBtn3P) || m_btnMgr.selected(m_configBtn3M))
|
2016-12-14 19:47:13 +01:00
|
|
|
{
|
2022-07-08 00:12:42 +02:00
|
|
|
s8 direction = m_btnMgr.selected(m_configBtn3P) ? 1 : -1;
|
2022-11-29 22:39:12 +01:00
|
|
|
_setPartition(direction, m_cfg.getInt(CHANNEL_DOMAIN, "partition"), COVERFLOW_CHANNEL);
|
2022-12-10 22:10:29 +01:00
|
|
|
m_cfg.setInt(CHANNEL_DOMAIN, "partition", currentPartition);
|
2016-12-14 19:47:13 +01:00
|
|
|
_showPartitionsCfg();
|
2022-11-29 22:39:12 +01:00
|
|
|
// partition only for emu nands
|
2022-12-10 22:10:29 +01:00
|
|
|
if(m_current_view & COVERFLOW_CHANNEL || (m_current_view & COVERFLOW_PLUGIN && m_plugin.GetEnabledStatus(ENAND_PMAGIC)))
|
2016-12-14 19:47:13 +01:00
|
|
|
m_refreshGameList = true;
|
|
|
|
}
|
2022-07-08 00:12:42 +02:00
|
|
|
else if(m_btnMgr.selected(m_configBtn4P) || m_btnMgr.selected(m_configBtn4M))
|
2016-12-14 19:47:13 +01:00
|
|
|
{
|
2022-07-08 00:12:42 +02:00
|
|
|
s8 direction = m_btnMgr.selected(m_configBtn4P) ? 1 : -1;
|
2022-11-29 22:39:12 +01:00
|
|
|
_setPartition(direction, m_cfg.getInt(PLUGIN_DOMAIN, "partition"), COVERFLOW_PLUGIN);
|
2022-12-10 22:10:29 +01:00
|
|
|
m_cfg.setInt(PLUGIN_DOMAIN, "partition", currentPartition);
|
2016-12-14 19:47:13 +01:00
|
|
|
_showPartitionsCfg();
|
2022-11-29 22:39:12 +01:00
|
|
|
if(m_current_view & COVERFLOW_PLUGIN)
|
2016-12-14 19:47:13 +01:00
|
|
|
m_refreshGameList = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_hidePartitionsCfg();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_initPartitionsCfgMenu()
|
|
|
|
{
|
|
|
|
m_partitionsBg = _texture("PARTCFG/BG", "texture", theme.bg, false);
|
2022-07-08 00:12:42 +02:00
|
|
|
|
2016-12-14 19:47:13 +01:00
|
|
|
_addUserLabels(m_partitionsLblUser, ARRAY_SIZE(m_partitionsLblUser), "PARTCFG");
|
2018-12-28 01:47:00 +01:00
|
|
|
m_partitionsLblTitle = _addLabel("PARTCFG/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2016-12-14 19:47:13 +01:00
|
|
|
m_partitionsBtnBack = _addButton("PARTCFG/BACK_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
|
|
|
|
|
|
|
_setHideAnim(m_partitionsLblTitle, "PARTCFG/TITLE", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_partitionsBtnBack, "PARTCFG/BACK_BTN", 0, 0, 1.f, -1.f);
|
|
|
|
|
|
|
|
_hidePartitionsCfg(true);
|
|
|
|
_textPartitionsCfg();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textPartitionsCfg(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_partitionsLblTitle, _t("part5", L"Partition Settings"));
|
|
|
|
m_btnMgr.setText(m_partitionsBtnBack, _t("cfg10", L"Back"));
|
|
|
|
}
|
2022-12-10 22:10:29 +01:00
|
|
|
|
|
|
|
void CMenu::_setPartition(s8 direction, u8 partition, u8 coverflow)// COVERFLOW_NONE is for emu saves nand
|
|
|
|
{
|
|
|
|
currentPartition = partition;
|
|
|
|
u8 prev_view = m_current_view;// save and restore later
|
|
|
|
m_current_view = coverflow;
|
|
|
|
int FS_Type = 0;
|
|
|
|
bool NeedFAT = m_current_view == COVERFLOW_CHANNEL || m_current_view == COVERFLOW_GAMECUBE || m_current_view == COVERFLOW_NONE;
|
|
|
|
u8 limiter = 0;
|
|
|
|
|
|
|
|
if(direction != 0)// change partition if direction is not zero
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
currentPartition = loopNum(currentPartition + direction, 9);
|
|
|
|
if(currentPartition == 8 && (m_current_view == COVERFLOW_WII || m_current_view == COVERFLOW_GAMECUBE))
|
|
|
|
break;
|
|
|
|
FS_Type = DeviceHandle.GetFSType(currentPartition);
|
|
|
|
limiter++;
|
|
|
|
}
|
|
|
|
while(limiter < 9 && (!DeviceHandle.IsInserted(currentPartition) ||
|
|
|
|
(m_current_view != COVERFLOW_WII && FS_Type == PART_FS_WBFS) ||
|
|
|
|
(NeedFAT && FS_Type != PART_FS_FAT)));
|
|
|
|
}
|
|
|
|
m_current_view = prev_view;
|
|
|
|
}
|