2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include "menu.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "types.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
#include "lockMutex.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "channel/nand.hpp"
|
|
|
|
#include "gc/gc.hpp"
|
|
|
|
#include "loader/wbfs.h"
|
|
|
|
#include "loader/wdvd.h"
|
2012-07-06 02:36:45 +02:00
|
|
|
#include "loader/gc_disc_dump.hpp"
|
2012-02-27 17:05:10 +01:00
|
|
|
#include "music/SoundHandler.hpp"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
void CMenu::_hideWBFS(bool instant)
|
|
|
|
{
|
|
|
|
m_btnMgr.hide(m_wbfsLblTitle, instant);
|
|
|
|
m_btnMgr.hide(m_wbfsPBar, instant);
|
|
|
|
m_btnMgr.hide(m_wbfsBtnGo, instant);
|
|
|
|
m_btnMgr.hide(m_wbfsLblDialog);
|
|
|
|
m_btnMgr.hide(m_wbfsLblMessage);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_wbfsLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_wbfsLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.hide(m_wbfsLblUser[i], instant);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_showWBFS(CMenu::WBFS_OP op)
|
|
|
|
{
|
|
|
|
_setBg(m_wbfsBg, m_wbfsBg);
|
|
|
|
switch (op)
|
|
|
|
{
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_ADD_GAME:
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblTitle, _t("wbfsop1", L"Install Game"));
|
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_REMOVE_GAME:
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblTitle, _t("wbfsop2", L"Delete Game"));
|
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_FORMAT:
|
2012-01-21 21:57:41 +01:00
|
|
|
// m_btnMgr.setText(m_wbfsLblTitle, _t("wbfsop3", L"Format"));
|
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_COPY_GAME:
|
2012-02-28 19:44:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblTitle, _t("wbfsop11", L"Copy Game"));
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
};
|
|
|
|
m_btnMgr.show(m_wbfsLblTitle);
|
|
|
|
m_btnMgr.show(m_wbfsBtnGo);
|
|
|
|
m_btnMgr.show(m_wbfsLblDialog);
|
2012-07-05 15:15:23 +02:00
|
|
|
for(u8 i = 0; i < ARRAY_SIZE(m_wbfsLblUser); ++i)
|
2012-09-13 16:54:17 +02:00
|
|
|
if(m_wbfsLblUser[i] != -1)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_wbfsLblUser[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void slotLight(bool state)
|
|
|
|
{
|
|
|
|
if (state)
|
2012-09-13 16:54:17 +02:00
|
|
|
*(u32 *)0xCD0000C0 |= 0x20;
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
2012-09-13 16:54:17 +02:00
|
|
|
*(u32 *)0xCD0000C0 &= ~0x20;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_addDiscProgress(int status, int total, void *user_data)
|
|
|
|
{
|
|
|
|
CMenu &m = *(CMenu *)user_data;
|
2012-03-07 03:05:57 +01:00
|
|
|
m.m_progress = total == 0 ? 0.f : (float)status / (float)total;
|
2012-01-21 21:57:41 +01:00
|
|
|
// Don't synchronize too often
|
2012-03-07 03:05:57 +01:00
|
|
|
if(m.m_progress - m.m_thrdProgress >= 0.01f)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m.m_mutex);
|
2018-06-06 13:32:45 +02:00
|
|
|
m._setThrdMsg(L"...", m.m_progress);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-13 01:03:33 +01:00
|
|
|
void CMenu::_setThrdMsg(const wstringEx &msg, float progress)
|
|
|
|
{
|
|
|
|
if (m_thrdStop) return;
|
|
|
|
if (msg != L"...") m_thrdMessage = msg;
|
|
|
|
m_thrdMessageAdded = true;
|
|
|
|
m_thrdProgress = progress;
|
|
|
|
}
|
|
|
|
|
2016-06-20 23:03:40 +02:00
|
|
|
bool CMenu::_searchGamesByID(const char *gameId)
|
2012-06-16 19:03:23 +02:00
|
|
|
{
|
2016-06-20 23:03:40 +02:00
|
|
|
for(vector<dir_discHdr>::iterator itr = m_gameList.begin(); itr != m_gameList.end(); ++itr)
|
2012-11-01 17:39:42 +01:00
|
|
|
{
|
2016-06-20 23:03:40 +02:00
|
|
|
if(itr->type == TYPE_WII_GAME || itr->type == TYPE_GC_GAME)
|
|
|
|
if(strncmp(itr->id, gameId, 6) == 0)
|
|
|
|
return true;
|
2012-11-01 17:39:42 +01:00
|
|
|
}
|
|
|
|
return false;
|
2012-06-16 19:03:23 +02:00
|
|
|
}
|
|
|
|
|
2013-06-26 23:35:38 +02:00
|
|
|
void CMenu::GC_Messenger(int message, int info, char *cinfo)
|
2012-02-29 01:19:50 +01:00
|
|
|
{
|
|
|
|
if(message == 1)
|
2013-06-26 23:35:38 +02:00
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop23", L"Calculating space needed for %s...\n Please insert disc %d to continue"), cinfo, info);
|
|
|
|
else if(message == 2)
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop15", L"Calculating space needed for %s"), cinfo);
|
|
|
|
else if(message == 3)
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop16", L"Installing %s"), cinfo);
|
|
|
|
else if(message == 4)
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop17", L"Installing %s disc %d/2"), cinfo, info);
|
|
|
|
else if(message == 5)
|
|
|
|
m_thrdMessage = _t("wbfsop18", L"Don't try to trick me with a Wii disc!!");
|
|
|
|
else if(message == 6)
|
|
|
|
m_thrdMessage = _t("wbfsop19", L"This is not a GC disc!!");
|
|
|
|
else if(message == 7)
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop20", L"You inserted disc %d again!!"), info);
|
|
|
|
else if(message == 8)
|
|
|
|
m_thrdMessage = _t("wbfsop21", L"This is a disc of another game!!");
|
|
|
|
else if(message == 9)
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop22", L"Installing %s...\n Please insert disc 2 to continue"), cinfo);
|
|
|
|
else if(message == 10)
|
|
|
|
m_thrdMessage = _t("wbfsop25", L"Disc read error!! Please clean the disc");
|
|
|
|
else if(message == 11)
|
|
|
|
m_thrdMessage = _t("wbfsop26", L"Disc ejected!! Please insert disc again");
|
2013-08-14 21:11:38 +02:00
|
|
|
m_thrdMessageAdded = true;
|
2012-02-29 01:19:50 +01:00
|
|
|
}
|
|
|
|
|
2018-05-29 11:59:57 +02:00
|
|
|
void * CMenu::_gameInstaller(void *obj)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
CMenu &m = *(CMenu *)obj;
|
|
|
|
int ret;
|
|
|
|
|
2012-09-22 15:47:52 +02:00
|
|
|
DeviceHandle.OpenWBFS(currentPartition);
|
2012-09-15 21:59:27 +02:00
|
|
|
if(!WBFS_Mounted())
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
m.m_thrdWorking = false;
|
2018-05-29 11:59:57 +02:00
|
|
|
return NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
u64 comp_size = 0, real_size = 0;
|
|
|
|
f32 free, used;
|
|
|
|
WBFS_DiskSpace(&used, &free);
|
|
|
|
WBFS_DVD_Size(&comp_size, &real_size);
|
2012-03-09 03:47:41 +01:00
|
|
|
if((f32)comp_size + (f32)128*1024 >= free * GB_SIZE)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LWP_MutexLock(m.m_mutex);
|
2012-02-28 19:44:41 +01:00
|
|
|
m._setThrdMsg(wfmt(m._fmt("wbfsop10", L"Not enough space: %lld blocks needed, %i available"), comp_size, free), 0.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
2016-12-01 01:05:39 +01:00
|
|
|
//m.m_thrdWorking = false;
|
2018-05-29 11:59:57 +02:00
|
|
|
//ret = -1;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LWP_MutexLock(m.m_mutex);
|
|
|
|
m._setThrdMsg(L"", 0);
|
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
|
|
|
|
2012-12-21 16:11:24 +01:00
|
|
|
ret = WBFS_AddGame(_addDiscProgress, obj);
|
2012-01-21 21:57:41 +01:00
|
|
|
LWP_MutexLock(m.m_mutex);
|
2018-05-29 11:59:57 +02:00
|
|
|
if(ret == 0)
|
2013-10-17 18:05:48 +02:00
|
|
|
m._setThrdMsg(m._t("wbfsop8", L"Game installed, press B to exit."), 1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
else
|
|
|
|
m._setThrdMsg(m._t("wbfsop9", L"An error has occurred"), 1.f);
|
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
2013-10-17 18:05:48 +02:00
|
|
|
slotLight(false);
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-09-22 15:47:52 +02:00
|
|
|
WBFS_Close();
|
2012-01-21 21:57:41 +01:00
|
|
|
m.m_thrdWorking = false;
|
2018-05-29 11:59:57 +02:00
|
|
|
return NULL;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
|
2013-06-26 23:35:38 +02:00
|
|
|
int CMenu::_GCgameInstaller()
|
2012-02-17 03:35:42 +01:00
|
|
|
{
|
2012-02-21 21:33:38 +01:00
|
|
|
GCDump m_gcdump;
|
2012-04-04 14:22:01 +02:00
|
|
|
|
2013-06-26 23:35:38 +02:00
|
|
|
bool skip = m_cfg.getBool(GC_DOMAIN, "skip_on_error", false);
|
|
|
|
bool comp = m_cfg.getBool(GC_DOMAIN, "compressed_dump", false);
|
2016-12-01 01:05:39 +01:00
|
|
|
bool wexf = m_cfg.getBool(GC_DOMAIN, "write_ex_files", false);
|
2013-06-26 23:35:38 +02:00
|
|
|
bool alig = m_cfg.getBool(GC_DOMAIN, "force_32k_align_files", false);
|
|
|
|
u32 nretry = m_cfg.getUInt(GC_DOMAIN, "num_retries", 5);
|
2012-02-29 15:07:18 +01:00
|
|
|
u32 rsize = 1048576; //1MB
|
2012-04-04 14:22:01 +02:00
|
|
|
|
2012-03-07 03:05:57 +01:00
|
|
|
if(skip)
|
|
|
|
rsize = 8192; // Use small chunks when skip on error is enabled
|
2012-02-28 19:44:41 +01:00
|
|
|
|
2016-04-03 02:31:02 +02:00
|
|
|
m_gcdump.Init(skip, comp, wexf, alig, nretry, rsize, DeviceName[currentPartition], gc_games_dir);
|
2012-02-20 09:26:50 +01:00
|
|
|
|
2013-06-26 23:35:38 +02:00
|
|
|
int ret;
|
|
|
|
m_progress = 0.f;
|
2012-02-17 03:35:42 +01:00
|
|
|
|
2012-11-01 17:39:42 +01:00
|
|
|
if(!DeviceHandle.IsInserted(currentPartition))
|
2012-02-17 03:35:42 +01:00
|
|
|
{
|
2013-06-26 23:35:38 +02:00
|
|
|
m_thrdWorking = false;
|
2012-02-17 03:35:42 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-02-29 15:07:18 +01:00
|
|
|
char partition[6];
|
2012-11-01 17:39:42 +01:00
|
|
|
strncpy(partition, fmt("%s:/", DeviceName[currentPartition]), sizeof(partition));
|
2012-03-02 19:29:55 +01:00
|
|
|
|
2012-02-20 09:26:50 +01:00
|
|
|
u32 needed = 0;
|
2012-02-29 19:11:35 +01:00
|
|
|
|
2012-03-09 03:47:41 +01:00
|
|
|
ret = m_gcdump.CheckSpace(&needed, comp);
|
2012-02-29 01:19:50 +01:00
|
|
|
if(ret != 0)
|
|
|
|
{
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(_t("wbfsop9", L"An error has occurred"), 1.f);
|
|
|
|
m_thrdWorking = false;
|
2012-02-29 01:19:50 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2012-04-04 14:22:01 +02:00
|
|
|
|
2012-03-09 03:47:41 +01:00
|
|
|
if(m_gcdump.GetFreeSpace(partition, BL) <= needed)
|
2012-02-17 03:35:42 +01:00
|
|
|
{
|
2012-03-09 03:47:41 +01:00
|
|
|
gprintf("Free space available: %d Mb (%d blocks)\n", m_gcdump.GetFreeSpace(partition, MB), m_gcdump.GetFreeSpace(partition, BL));
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("wbfsop24", L"Not enough space: %d blocks needed, %d available"), needed, m_gcdump.GetFreeSpace(partition, BL)), 0.f);
|
2012-02-17 03:35:42 +01:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-09 03:47:41 +01:00
|
|
|
gprintf("Free space available: %d Mb (%d blocks)\n", m_gcdump.GetFreeSpace(partition, MB), m_gcdump.GetFreeSpace(partition, BL));
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(L"", 0);
|
2012-04-04 14:22:01 +02:00
|
|
|
|
2012-03-09 03:47:41 +01:00
|
|
|
ret = m_gcdump.DumpGame();
|
2012-02-20 09:26:50 +01:00
|
|
|
if(ret == 0)
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(_t("wbfsop8", L"Game installed"), 1.f);
|
2012-02-20 09:26:50 +01:00
|
|
|
else if( ret >= 0x30200)
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("wbfsop12", L"DVDError(%d)"), ret), 1.f);
|
2012-02-20 09:26:50 +01:00
|
|
|
else if( ret > 0)
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(wfmt(_fmt("wbfsop13", L"Game installed, but disc contains errors (%d)"), ret), 1.f);
|
2012-02-17 03:35:42 +01:00
|
|
|
else
|
2013-06-26 23:35:38 +02:00
|
|
|
_setThrdMsg(_t("wbfsop9", L"An error has occurred"), 1.f);
|
2012-02-17 03:35:42 +01:00
|
|
|
slotLight(true);
|
|
|
|
}
|
2013-06-26 23:35:38 +02:00
|
|
|
m_thrdWorking = false;
|
2012-02-17 03:35:42 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-05-29 11:59:57 +02:00
|
|
|
void * CMenu::_GCcopyGame(void *obj)
|
2012-02-27 17:05:10 +01:00
|
|
|
{
|
|
|
|
CMenu &m = *(CMenu *)obj;
|
2012-08-26 17:20:51 +02:00
|
|
|
|
2012-11-11 19:28:03 +01:00
|
|
|
string GC_Path(CoverFlow.getHdr()->path);
|
2012-08-26 17:20:51 +02:00
|
|
|
if(strcasestr(GC_Path.c_str(), "boot.bin") != NULL)
|
|
|
|
GC_Path.erase(GC_Path.end() - 13, GC_Path.end());
|
|
|
|
else
|
|
|
|
GC_Path.erase(GC_Path.end() - 9, GC_Path.end());
|
2012-11-01 17:39:42 +01:00
|
|
|
|
|
|
|
char source[300];
|
2012-08-26 17:20:51 +02:00
|
|
|
strncpy(source, GC_Path.c_str(), sizeof(source));
|
2012-11-01 17:39:42 +01:00
|
|
|
source[299] = '\0';
|
|
|
|
|
|
|
|
char folder[50];
|
2016-04-03 02:31:02 +02:00
|
|
|
strncpy(folder, fmt(gc_games_dir, DeviceName[SD]), sizeof(folder));
|
2012-11-01 17:39:42 +01:00
|
|
|
folder[49] = '\0';
|
|
|
|
|
|
|
|
char target[300];
|
|
|
|
strncpy(target, fmt("%s/%s", folder, strrchr(source, '/') + 1), sizeof(target));
|
|
|
|
target[299] = '\0';
|
2012-04-03 17:49:52 +02:00
|
|
|
|
|
|
|
LWP_MutexLock(m.m_mutex);
|
|
|
|
m._setThrdMsg(L"", 0);
|
2012-08-26 17:20:51 +02:00
|
|
|
gprintf("Copying from:\n%s\nto:\n%s\n", source, target);
|
2012-04-03 17:49:52 +02:00
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
2013-07-07 03:50:26 +02:00
|
|
|
fsop_MakeFolder(folder);
|
2012-12-21 16:11:24 +01:00
|
|
|
fsop_CopyFolder(source, target, _addDiscProgress, obj);
|
2012-04-03 17:49:52 +02:00
|
|
|
LWP_MutexLock(m.m_mutex);
|
|
|
|
m._setThrdMsg(m._t("wbfsop14", L"Game copied, press Back to boot the game."), 1.f);
|
|
|
|
gprintf("Game copied.\n");
|
|
|
|
LWP_MutexUnlock(m.m_mutex);
|
|
|
|
slotLight(true);
|
|
|
|
|
2012-02-27 17:05:10 +01:00
|
|
|
m.m_thrdWorking = false;
|
2012-04-03 17:49:52 +02:00
|
|
|
return 0;
|
2012-02-27 17:05:10 +01:00
|
|
|
}
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
|
|
|
{
|
2018-08-06 16:58:26 +02:00
|
|
|
if(op == WO_ADD_GAME)
|
|
|
|
{
|
|
|
|
error(_t("wbfsoperr6", L"Install game is broken,\nplease use cleanrip."));
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
lwp_t thread = 0;
|
2012-11-01 17:39:42 +01:00
|
|
|
char GameID[7];
|
|
|
|
GameID[6] = '\0';
|
2012-11-18 14:40:26 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
bool done = false;
|
2016-04-03 02:31:02 +02:00
|
|
|
bool upd_wii = false;
|
|
|
|
bool upd_gc = false;
|
|
|
|
bool upd_plgin = false;
|
2013-09-08 20:29:54 +02:00
|
|
|
bool upd_chan = false;
|
2012-01-21 21:57:41 +01:00
|
|
|
bool out = false;
|
2016-12-01 01:05:39 +01:00
|
|
|
u8 game_type = TYPE_WII_GAME;
|
2013-01-21 00:30:28 +01:00
|
|
|
const dir_discHdr *CF_Hdr = CoverFlow.getHdr();
|
2012-12-27 21:22:40 +01:00
|
|
|
char cfPos[7];
|
|
|
|
cfPos[6] = '\0';
|
|
|
|
strncpy(cfPos, CoverFlow.getNextId(), 6);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
SetupInput();
|
|
|
|
_showWBFS(op);
|
|
|
|
switch (op)
|
|
|
|
{
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_ADD_GAME:
|
2012-02-28 19:44:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("wbfsadddlg", L"Please insert the disc you want to copy, then click on Go."));
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_REMOVE_GAME:
|
2012-11-14 17:58:14 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsremdlg", L"To permanently remove the game: %s, click on Go."), CoverFlow.getTitle().toUTF8().c_str()));
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_FORMAT:
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_COPY_GAME:
|
2012-02-28 19:44:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, _t("wbfscpydlg", L"If you are sure you want to copy this game to SD, click on Go."));
|
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
m_thrdStop = false;
|
|
|
|
m_thrdMessageAdded = false;
|
2012-09-09 20:35:15 +02:00
|
|
|
while(!m_exit)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-09 20:35:15 +02:00
|
|
|
_mainLoopCommon();
|
2012-09-01 11:34:18 +02:00
|
|
|
if((BTN_HOME_PRESSED || BTN_B_PRESSED) && !m_thrdWorking)
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-09-01 11:34:18 +02:00
|
|
|
else if(BTN_UP_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.up();
|
2012-09-01 11:34:18 +02:00
|
|
|
else if(BTN_DOWN_PRESSED)
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.down();
|
2016-12-14 19:47:13 +01:00
|
|
|
else if(BTN_A_PRESSED && !m_thrdWorking)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-12-21 16:11:24 +01:00
|
|
|
if(m_btnMgr.selected(m_wbfsBtnGo))
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-09-01 11:34:18 +02:00
|
|
|
switch(op)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_ADD_GAME:
|
2016-12-01 01:05:39 +01:00
|
|
|
TempLoadIOS();// switch to cios if using ios 58
|
|
|
|
m_btnMgr.hide(m_wbfsBtnGo, true);
|
2013-06-26 23:35:38 +02:00
|
|
|
m_btnMgr.show(m_wbfsPBar, true);
|
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
|
|
|
m_btnMgr.show(m_wbfsLblMessage, true);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, L"");
|
|
|
|
if (Disc_Wait() < 0)
|
|
|
|
{
|
|
|
|
error(_t("wbfsoperr1", L"Disc_Wait failed"));
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
2012-08-17 17:48:11 +02:00
|
|
|
if (Disc_Open(false) < 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
error(_t("wbfsoperr2", L"Disc_Open failed"));
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
2012-02-17 03:35:42 +01:00
|
|
|
if (Disc_IsWii() == 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-08-06 16:58:26 +02:00
|
|
|
//error(_t("wbfsoperr6", L"Install game is broken, please use cleanrip."));
|
|
|
|
//out = true;
|
|
|
|
//break;
|
2016-12-01 01:05:39 +01:00
|
|
|
|
2012-11-18 14:40:26 +01:00
|
|
|
Disc_ReadHeader(&wii_hdr);
|
|
|
|
memcpy(GameID, wii_hdr.id, 6);
|
2012-11-01 17:39:42 +01:00
|
|
|
if(_searchGamesByID(GameID))
|
2012-02-17 03:35:42 +01:00
|
|
|
{
|
|
|
|
error(_t("wbfsoperr4", L"Game already installed"));
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
2016-12-01 01:05:39 +01:00
|
|
|
game_type = TYPE_WII_GAME;
|
2013-10-17 18:05:48 +02:00
|
|
|
CoverFlow.clear();
|
2012-12-27 21:22:40 +01:00
|
|
|
strncpy(cfPos, GameID, 6);
|
2012-11-18 14:40:26 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, wii_hdr.title));
|
2016-12-01 01:05:39 +01:00
|
|
|
currentPartition = m_cfg.getInt(WII_DOMAIN, "partition", 0);
|
2012-02-17 03:35:42 +01:00
|
|
|
done = true;
|
2016-04-03 02:31:02 +02:00
|
|
|
upd_wii = true;
|
2012-02-17 03:35:42 +01:00
|
|
|
m_thrdWorking = true;
|
|
|
|
m_thrdProgress = 0.f;
|
|
|
|
m_thrdMessageAdded = false;
|
2018-05-29 11:59:57 +02:00
|
|
|
LWP_CreateThread(&thread, _gameInstaller, this, 0, 8 * 1024, 64);
|
2012-02-17 03:35:42 +01:00
|
|
|
}
|
|
|
|
else if(Disc_IsGC() == 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2018-08-06 16:58:26 +02:00
|
|
|
//error(_t("wbfsoperr6", L"Install game is broken, please use cleanrip."));
|
|
|
|
//out = true;
|
|
|
|
//break;
|
2018-07-09 16:53:35 +02:00
|
|
|
|
2012-11-18 14:40:26 +01:00
|
|
|
Disc_ReadGCHeader(&gc_hdr);
|
|
|
|
memcpy(GameID, gc_hdr.id, 6);
|
2012-11-01 17:39:42 +01:00
|
|
|
if(_searchGamesByID(GameID))
|
2012-02-20 09:26:50 +01:00
|
|
|
{
|
|
|
|
error(_t("wbfsoperr4", L"Game already installed"));
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
2016-12-01 01:05:39 +01:00
|
|
|
game_type = TYPE_GC_GAME;
|
|
|
|
CoverFlow.clear();
|
2012-12-27 21:22:40 +01:00
|
|
|
strncpy(cfPos, GameID, 6);
|
2016-12-01 01:05:39 +01:00
|
|
|
currentPartition = m_cfg.getInt(GC_DOMAIN, "partition", 0);
|
2012-02-17 03:35:42 +01:00
|
|
|
done = true;
|
2016-04-03 02:31:02 +02:00
|
|
|
upd_gc = true;
|
2012-02-17 03:35:42 +01:00
|
|
|
m_thrdWorking = true;
|
|
|
|
m_thrdProgress = 0.f;
|
2013-06-26 23:35:38 +02:00
|
|
|
//LWP_CreateThread(&thread, (void *(*)(void *))_GCgameInstaller, (void *)this, 0, 8 * 1024, 64);
|
2013-08-14 21:11:38 +02:00
|
|
|
_start_pThread();
|
|
|
|
m_thrdMessage = wfmt(_fmt("wbfsop6", L"Installing [%s] %s..."), GameID, gc_hdr.title);
|
|
|
|
m_thrdMessageAdded = true;
|
2013-06-26 23:35:38 +02:00
|
|
|
_GCgameInstaller();
|
2013-08-14 21:11:38 +02:00
|
|
|
_stop_pThread();
|
2016-12-01 01:05:39 +01:00
|
|
|
/* restart inputs to resolve an issue */
|
|
|
|
Close_Inputs();
|
|
|
|
Open_Inputs();
|
|
|
|
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
|
|
|
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
|
2012-02-17 03:35:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error(_t("wbfsoperr3", L"This is not a Wii or GC disc!"));
|
2012-01-21 21:57:41 +01:00
|
|
|
out = true;
|
2012-02-25 23:34:52 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_REMOVE_GAME:
|
2016-12-01 01:05:39 +01:00
|
|
|
done = true;
|
2012-11-14 17:58:14 +01:00
|
|
|
if(CF_Hdr->type == TYPE_GC_GAME)
|
2012-03-02 19:29:55 +01:00
|
|
|
{
|
2012-11-16 23:00:20 +01:00
|
|
|
char GC_Path[1024];
|
|
|
|
GC_Path[1023] = '\0';
|
2012-11-14 17:58:14 +01:00
|
|
|
if(strcasestr(CF_Hdr->path, "boot.bin") != NULL)
|
2012-11-01 17:39:42 +01:00
|
|
|
{
|
2012-11-16 23:00:20 +01:00
|
|
|
strncpy(GC_Path, CF_Hdr->path, 1023);
|
2018-07-09 16:53:35 +02:00
|
|
|
*strrchr(GC_Path, '/') = '\0'; // remove /boot.bin from path
|
|
|
|
*strrchr(GC_Path, '/') = '\0'; // remove /sys folder from path
|
2012-11-16 23:00:20 +01:00
|
|
|
fsop_deleteFolder(GC_Path);
|
2012-11-01 17:39:42 +01:00
|
|
|
}
|
2012-08-20 21:15:52 +02:00
|
|
|
else
|
2012-11-16 23:00:20 +01:00
|
|
|
{
|
|
|
|
strncpy(GC_Path, CF_Hdr->path, 1023);
|
2018-07-09 16:53:35 +02:00
|
|
|
*strrchr(GC_Path, '/') = '\0'; // remove /game.iso from path
|
2016-04-03 02:31:02 +02:00
|
|
|
const char *cmp = fmt(gc_games_dir, DeviceName[currentPartition]);
|
2012-11-16 23:00:20 +01:00
|
|
|
if(strcasecmp(GC_Path, cmp) == 0)
|
|
|
|
fsop_deleteFile(CF_Hdr->path);
|
|
|
|
else
|
|
|
|
fsop_deleteFolder(GC_Path);
|
|
|
|
}
|
2016-04-03 02:31:02 +02:00
|
|
|
upd_gc = true;
|
2012-03-02 19:29:55 +01:00
|
|
|
}
|
2012-11-14 17:58:14 +01:00
|
|
|
else if(CF_Hdr->type == TYPE_PLUGIN)
|
2012-05-24 20:48:26 +02:00
|
|
|
{
|
2012-11-14 17:58:14 +01:00
|
|
|
fsop_deleteFile(CF_Hdr->path);
|
2016-04-03 02:31:02 +02:00
|
|
|
upd_plgin = true;
|
2012-05-24 20:48:26 +02:00
|
|
|
}
|
2012-11-14 17:58:14 +01:00
|
|
|
else if(CF_Hdr->type == TYPE_WII_GAME)
|
2012-05-24 20:48:26 +02:00
|
|
|
{
|
2012-11-14 17:58:14 +01:00
|
|
|
DeviceHandle.OpenWBFS(currentPartition);
|
2013-01-21 00:30:28 +01:00
|
|
|
WBFS_RemoveGame((u8*)&CF_Hdr->id, (char*)&CF_Hdr->path);
|
2012-11-14 17:58:14 +01:00
|
|
|
WBFS_Close();
|
2016-04-03 02:31:02 +02:00
|
|
|
upd_wii = true;
|
2012-05-24 20:48:26 +02:00
|
|
|
}
|
2016-06-20 23:03:40 +02:00
|
|
|
else if(CF_Hdr->type == TYPE_EMUCHANNEL)
|
2013-09-08 20:29:54 +02:00
|
|
|
{
|
|
|
|
if(CF_Hdr->settings[0] != 0x00010001)
|
|
|
|
{
|
|
|
|
error(_t("wbfsoperr5", L"Deleting this Channel is not allowed!"));
|
|
|
|
done = true;
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const char *nand_base = NandHandle.GetPath();
|
|
|
|
fsop_deleteFolder(fmt("%s/title/%08x/%08x", nand_base, CF_Hdr->settings[0], CF_Hdr->settings[1]));
|
|
|
|
fsop_deleteFile(fmt("%s/ticket/%08x/%08x.tik", nand_base, CF_Hdr->settings[0], CF_Hdr->settings[1]));
|
|
|
|
upd_chan = true;
|
|
|
|
}
|
|
|
|
else /*who knows how but just block it*/
|
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
out = true;
|
|
|
|
break;
|
|
|
|
}
|
2012-11-01 17:39:42 +01:00
|
|
|
if(m_cfg.getBool("GENERAL", "delete_cover_and_game", false))
|
2012-11-14 17:58:14 +01:00
|
|
|
RemoveCover(CF_Hdr->id);
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.show(m_wbfsPBar);
|
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 0.f, true);
|
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, 1.f);
|
|
|
|
m_btnMgr.hide(m_wbfsLblDialog);
|
|
|
|
m_btnMgr.hide(m_wbfsBtnGo);
|
|
|
|
m_btnMgr.show(m_wbfsLblMessage);
|
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, _t("wbfsop7", L"Game deleted"));
|
|
|
|
done = true;
|
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_FORMAT:
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:11:24 +01:00
|
|
|
case WO_COPY_GAME:
|
2012-02-28 19:44:41 +01:00
|
|
|
break;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-09-01 11:34:18 +02:00
|
|
|
if(out)
|
2012-12-21 16:20:11 +01:00
|
|
|
{
|
2016-12-01 01:05:39 +01:00
|
|
|
TempLoadIOS(IOS_TYPE_NORMAL_IOS);//restore to IOS 58 if not using cios
|
2012-01-21 21:57:41 +01:00
|
|
|
break;
|
2012-12-21 16:20:11 +01:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
2012-09-01 11:34:18 +02:00
|
|
|
if(m_thrdMessageAdded)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
LockMutex lock(m_mutex);
|
|
|
|
m_thrdMessageAdded = false;
|
2016-12-01 01:05:39 +01:00
|
|
|
if(!m_thrdMessage.empty())
|
2012-01-21 21:57:41 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage);
|
|
|
|
m_btnMgr.setProgress(m_wbfsPBar, m_thrdProgress);
|
2012-11-01 17:39:42 +01:00
|
|
|
m_btnMgr.setText(m_wbfsLblMessage, wfmt(L"%i%%", (int)(m_thrdProgress * 100.f)));
|
2012-12-21 16:11:24 +01:00
|
|
|
if(!m_thrdWorking && op == WO_ADD_GAME)
|
2012-05-04 10:04:23 +02:00
|
|
|
{
|
2012-12-21 16:11:24 +01:00
|
|
|
WDVD_StopMotor();
|
2016-12-01 01:05:39 +01:00
|
|
|
TempLoadIOS(IOS_TYPE_NORMAL_IOS);//restore to IOS 58 if not using cios
|
|
|
|
/* restart inputs to resolve an issue */
|
|
|
|
Close_Inputs();
|
|
|
|
Open_Inputs();
|
|
|
|
for(int chan = WPAD_MAX_WIIMOTES-1; chan >= 0; chan--)
|
|
|
|
WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height());
|
2012-05-04 10:04:23 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_hideWBFS();
|
2016-06-20 23:03:40 +02:00
|
|
|
if(done)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2016-06-20 23:03:40 +02:00
|
|
|
if(op == WO_ADD_GAME)
|
|
|
|
{
|
2016-12-01 01:05:39 +01:00
|
|
|
if(game_type == TYPE_WII_GAME)
|
2016-06-20 23:03:40 +02:00
|
|
|
m_cfg.setString(WII_DOMAIN, "current_item", cfPos);
|
|
|
|
else
|
|
|
|
m_cfg.setString(GC_DOMAIN, "current_item", cfPos);
|
|
|
|
}
|
2016-04-03 02:31:02 +02:00
|
|
|
if(upd_gc)
|
2016-11-07 16:06:00 +01:00
|
|
|
m_cfg.setBool(GC_DOMAIN, "update_cache", true);
|
2016-04-03 02:31:02 +02:00
|
|
|
if(upd_wii)
|
2016-11-07 16:06:00 +01:00
|
|
|
m_cfg.setBool(WII_DOMAIN, "update_cache", true);
|
2016-04-03 02:31:02 +02:00
|
|
|
if(upd_plgin)
|
2016-11-07 16:06:00 +01:00
|
|
|
m_cfg.setBool(PLUGIN_DOMAIN, "update_cache", true);
|
2013-09-08 20:29:54 +02:00
|
|
|
if(upd_chan)
|
2016-11-07 16:06:00 +01:00
|
|
|
m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true);
|
|
|
|
m_refreshGameList = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
return done;
|
|
|
|
}
|
|
|
|
|
2012-11-03 20:16:03 +01:00
|
|
|
void CMenu::_initWBFSMenu()
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-11-03 20:16:03 +01:00
|
|
|
_addUserLabels(m_wbfsLblUser, ARRAY_SIZE(m_wbfsLblUser), "WBFS");
|
|
|
|
m_wbfsBg = _texture("WBFS/BG", "texture", theme.bg, false);
|
2018-12-28 01:47:00 +01:00
|
|
|
m_wbfsLblTitle = _addLabel("WBFS/TITLE", theme.titleFont, L"", 0, 10, 640, 60, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE);
|
2016-12-01 01:05:39 +01:00
|
|
|
m_wbfsLblDialog = _addLabel("WBFS/DIALOG", theme.lblFont, L"", 40, 75, 600, 200, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
|
|
|
|
m_wbfsLblMessage = _addLabel("WBFS/MESSAGE", theme.lblFont, L"", 40, 300, 600, 100, theme.lblFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_TOP);
|
2013-11-04 20:46:23 +01:00
|
|
|
m_wbfsPBar = _addProgressBar("WBFS/PROGRESS_BAR", 40, 200, 560, 20);
|
|
|
|
m_wbfsBtnGo = _addButton("WBFS/GO_BTN", theme.btnFont, L"", 420, 400, 200, 48, theme.btnFontColor);
|
2012-02-28 19:44:41 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
_setHideAnim(m_wbfsLblTitle, "WBFS/TITLE", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_wbfsLblDialog, "WBFS/DIALOG", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_wbfsLblMessage, "WBFS/MESSAGE", 0, 0, -2.f, 0.f);
|
|
|
|
_setHideAnim(m_wbfsPBar, "WBFS/PROGRESS_BAR", 0, 0, -2.f, 0.f);
|
2013-11-04 20:46:23 +01:00
|
|
|
_setHideAnim(m_wbfsBtnGo, "WBFS/GO_BTN", 0, 0, 1.f, -1.f);
|
2012-01-21 21:57:41 +01:00
|
|
|
_hideWBFS(true);
|
|
|
|
_textWBFS();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenu::_textWBFS(void)
|
|
|
|
{
|
|
|
|
m_btnMgr.setText(m_wbfsBtnGo, _t("wbfsop5", L"Go"));
|
|
|
|
}
|