Пример #1
0
void CMenu::error(const wstringEx &msg)
{
	s32 padsState;
	WPADData *wd;

	WPAD_Rumble(WPAD_CHAN_0, 0);
	_hideAbout();
	_hideCode();
	_hideConfig();
	_hideConfig2();
	_hideConfigAdv();
	_hideDownload();
	_hideGame();
	_hideMain();
	_hideWBFS();
	_hideGameSettings();
	m_btnMgr.setText(m_errorLblMessage, msg, true);
	_showError();
	do
	{
		WPAD_ScanPads();
		padsState = WPAD_ButtonsDown(0);
		wd = WPAD_Data(0);
		_mainLoopCommon(wd);
	} while ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_A | WPAD_BUTTON_B)) == 0);
	WPAD_Rumble(WPAD_CHAN_0, 0);
	_hideError(false);
}
Пример #2
0
bool CMenu::_ExitTo(void)
{
	SetupInput();
	_showExitTo();

	while(!m_exit)
	{
		_mainLoopCommon();
		if(BTN_A_PRESSED)
		{
			if(m_btnMgr.selected(m_homeBtnExitToHBC))
			{
				exitHandler(EXIT_TO_HBC);
				break;
			}
			else if(m_btnMgr.selected(m_homeBtnExitToMenu))
			{
				exitHandler(EXIT_TO_MENU);
				break;
			}
			else if(m_btnMgr.selected(m_homeBtnExitToPriiloader))
			{
				exitHandler(EXIT_TO_PRIILOADER);
				break;
			}
			else if(m_btnMgr.selected(m_homeBtnExitToBootmii))
			{
				exitHandler(EXIT_TO_BOOTMII);
				break;
			}
			else if(m_btnMgr.selected(m_homeBtnExitToNeek))
			{
				if(!Load_Neek2o_Kernel())
				{
					error(_fmt("errneek1", L"Cannot launch neek2o. Verify your neek2o setup"));
					exitHandler(PRIILOADER_DEF);
				}
				else
				{
					bool nkWiiflow = m_cfg.getBool("NEEK2O", "launchwiiflow", true);
					if(nkWiiflow)
						exitHandler(EXIT_TO_WFNK2O);
					else
						exitHandler(EXIT_TO_SMNK2O);
				}
				break;
			}
		}
		else if(BTN_HOME_PRESSED)
		{
			exitHandler(WIIFLOW_DEF);
			break;
		}
		else if(BTN_B_PRESSED)
			break;
	}
	_hideExitTo();
	return m_exit;
}
Пример #3
0
bool CMenu::_Home(void)
{
	SetupInput();
	_showHome();

	string prevTheme = m_cfg.getString("GENERAL", "theme", "default");
	while(!m_exit)
	{
		/* battery gets refreshed in here... */
		_mainLoopCommon();
		/* and it always changes so... */
		m_btnMgr.setText(m_homeLblBattery, wfmt(PLAYER_BATTERY_LABEL, min((float)wd[0]->battery_level, 100.f), 
			min((float)wd[1]->battery_level, 100.f), min((float)wd[2]->battery_level, 100.f), min((float)wd[3]->battery_level, 100.f)));
		if(BTN_A_PRESSED)
		{
			if(m_btnMgr.selected(m_homeBtnSettings))
			{
				_hideHome();
				_config(1);
				if(prevTheme != m_cfg.getString("GENERAL", "theme") || m_reload == true)
				{
					m_exit = true;
					m_reload = true;
					break;
				}
				_showHome();
			}
			else if(m_btnMgr.selected(m_homeBtnReloadCache))
			{
				//m_gameList.SetLanguage(m_loc.getString(m_curLanguage, "gametdb_code", "EN").c_str());
				UpdateCache(m_current_view);
				LoadView();
				break;
			}
			else if(m_btnMgr.selected(m_homeBtnUpdate) && !m_locked)
			{
				CoverFlow.stopCoverLoader(true);
				_hideHome();
				_system();
				remove(m_ver.c_str());
				if(m_exit)
					_launchHomebrew(m_dol.c_str(), m_homebrewArgs);
				else
				{
					_showHome();
					CoverFlow.startCoverLoader();
				}
			}
			else if(m_btnMgr.selected(m_homeBtnInstall))
			{
				_hideHome();
				_wbfsOp(WO_ADD_GAME);
				_showHome();
			}
			else if(m_btnMgr.selected(m_homeBtnAbout))
			{
				_hideHome();
				_about();
				_showHome();
			}
			else if(m_btnMgr.selected(m_homeBtnExitTo))
			{
				_hideHome();
				if(m_locked)
					exitHandler(WIIFLOW_DEF);
				else 
					_ExitTo();
				_showHome();
			}
			else if(m_btnMgr.selected(m_homeBtnExplorer))
			{
				_hideHome();
				_Explorer();
				_showHome();
			}
			else if(m_btnMgr.selected(m_homeBtnFTP))
			{
				_hideHome();
				_FTP();
				_showHome();
			}
		}
		else if(BTN_HOME_PRESSED)
		{
			exitHandler(WIIFLOW_DEF);
			break;
		}
		else if(BTN_B_PRESSED)
			break;
	}

	_hideHome();
	return m_exit;
}
void CMenu::_system()
{
	int msg = 0, newVer = SVN_REV_NUM;
	lwp_t thread = LWP_THREAD_NULL;
	wstringEx prevMsg;

	int amount_of_skips = 0;
	int update_x = 0, update_y = 0;
	u32 update_w = 0, update_h = 0;
	bool first = true;

	m_btnMgr.reset(m_systemLblInfo, true);

	SetupInput();
	m_btnMgr.setText(m_systemBtnBack, _t("dl1", L"Cancel"));
	m_thrdStop = false;
	m_thrdMessageAdded = false;
	m_showtimer = -1;
	while(!m_exit)
	{
		_mainLoopCommon();
		if(amount_of_skips == 0) // Check dimensions in the loop, because the animation can have an effect
			m_btnMgr.getDimensions(m_systemLblInfo, update_x, update_y, update_w, update_h); // Get original dimensions
		if(first)
		{
			m_btnMgr.moveBy(m_systemLblInfo, 0, -(pixels_to_skip * 10));
			amount_of_skips++;
			first = false;
		}

		if (m_showtimer == -1)
		{
			m_showtimer = 120;
			m_btnMgr.show(m_downloadPBar);
			m_btnMgr.setProgress(m_downloadPBar, 0.f);
			m_thrdStop = false;
			m_thrdWorking = true;
			LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionTxtDownloaderInit, 
								(void *)this, downloadStack, downloadStackSize, 40);
		}
		if (m_showtimer > 0 && !m_thrdWorking)
		{
			if (thread != LWP_THREAD_NULL)
			{
				LWP_JoinThread(thread, NULL);
				thread = LWP_THREAD_NULL;
			}
			if (--m_showtimer == 0)
			{
				m_btnMgr.hide(m_downloadPBar);
				m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -2.f, 0.f);
				m_btnMgr.hide(m_downloadLblMessage[1], 0, 0, -2.f, 0.f);
				CMenu::_version[1] = m_version.getInt("GENERAL", "version", SVN_REV_NUM);
				num_versions = m_version.getInt("GENERAL", "num_versions", 1);
				for (i = 2; i < num_versions; i++)
				{
					CMenu::_version[i] = m_version.getInt(fmt("VERSION%i", i-1u), "version", SVN_REV_NUM);
					//add the changelog info here
				}
				if (num_versions > 1 && version_num == 0) version_num = 1;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				newVer = CMenu::_version[i];
				_showSystem();
			}
		}
		if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop))
		{
			if (update_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (35 + update_y)))
			{
				m_btnMgr.moveBy(m_systemLblInfo, 0, -pixels_to_skip);
				amount_of_skips++;
			}
		}
		else if ((BTN_UP_PRESSED || BTN_UP_HELD) && !(m_thrdWorking && m_thrdStop))
		{
			if (amount_of_skips > 1)
			{
				m_btnMgr.moveBy(m_systemLblInfo, 0, pixels_to_skip);
				amount_of_skips--;
			}
		}
		else if ((BTN_HOME_PRESSED || BTN_B_PRESSED || m_exit) && !m_thrdWorking)
			break;
		else if ((BTN_A_PRESSED) && !(m_thrdWorking && m_thrdStop))
		{
			if ((m_btnMgr.selected(m_systemBtnDownload)) && !m_thrdWorking)
			{
				// Download selected version
				_hideSystem();
				m_btnMgr.show(m_downloadPBar);
				m_btnMgr.setProgress(m_downloadPBar, 0.f);
				m_thrdStop = false;
				m_thrdWorking = true;
				gprintf("\nVersion to DL: %i\n", newVer);

				if(m_version.getInt("GENERAL", "version", 0) == newVer)
					m_app_update_size = m_version.getInt("GENERAL", "app_zip_size", 0);
				m_data_update_size = m_version.getInt("GENERAL", "data_zip_size", 0);

				m_app_update_url = fmt("%s/Wiiflow_Mod_svn_r%i.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer);
				m_data_update_url = fmt("%s/r%i/data.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer);

				m_showtimer = 120;
				LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionDownloaderInit, 
									(void *)this, downloadStack, downloadStackSize, 40);
				if (m_exit && !m_thrdWorking) 
				{
					m_thrdStop = true;
					break;
				}
			}
			else if (m_btnMgr.selected(m_systemBtnBack))
			{
				LockMutex lock(m_mutex);
				m_thrdStop = true;
				m_thrdMessageAdded = true;
				m_thrdMessage = _t("dlmsg6", L"Canceling...");
			}
			else if (m_btnMgr.selected(m_systemBtnVerSelectM))
			{
				if (version_num > 1)
					--version_num;
				else
					version_num = num_versions;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				{
					m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i])));
					newVer = CMenu::_version[i];
					m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0);
					if (i > 1 && i != num_versions)
						m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false);
					else 
						if (i == num_versions)
							m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false);
						else
							m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false);
				}
			}
			else if (m_btnMgr.selected(m_systemBtnVerSelectP))
			{
				if (version_num < num_versions)
					++version_num;
				else
					version_num = 1;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				{
					m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i])));
					newVer = CMenu::_version[i];
					m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0);
					if (i > 1 && i != num_versions)
						m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false);
					else 
						if (i == num_versions)
							m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false);
						else
							m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false);
				}
			}
		}
		if (Sys_Exiting())
		{
			LockMutex lock(m_mutex);
			m_thrdStop = true;
			m_thrdMessageAdded = true;
			m_thrdMessage = _t("dlmsg6", L"Canceling...");
		}
		// 
		if (m_thrdMessageAdded)
		{
			LockMutex lock(m_mutex);
			m_thrdMessageAdded = false;
			m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress);
			if (m_thrdProgress == 1.f)
				m_btnMgr.setText(m_systemBtnBack, _t("dl2", L"Back"));
			if (prevMsg != m_thrdMessage)
			{
				prevMsg = m_thrdMessage;
				m_btnMgr.setText(m_downloadLblMessage[msg], m_thrdMessage, false);
				m_btnMgr.hide(m_downloadLblMessage[msg], -200, 0, 1.f, 0.5f, true);
				m_btnMgr.show(m_downloadLblMessage[msg]);
				msg ^= 1;
				m_btnMgr.hide(m_downloadLblMessage[msg], +400, 0, 1.f, 1.f);
			}
		}
		if (m_thrdStop && !m_thrdWorking)
			break;
	}
	if (thread != LWP_THREAD_NULL)
	{
		LWP_JoinThread(thread, NULL);
		thread = LWP_THREAD_NULL;
	}
	_hideSystem();
}
Пример #5
0
void CMenu::_gameinfo(void)
{
	bool first = true;
	SetupInput();
	_showGameInfo();

	u8 page = 0;

	int amount_of_skips = 0;

	int synopsis_x = 0, synopsis_y = 0;
	u32 synopsis_w = 0, synopsis_h = 0;

	do
	{
		_mainLoopCommon();

		if (amount_of_skips == 0)
		{
			// Check dimensions in the loop, because the animation can have an effect
			m_btnMgr.getDimensions(m_gameinfoLblSynopsis, synopsis_x, synopsis_y, synopsis_w, synopsis_h); // Get original dimensions
		}
		if(first)
		{
			m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -1);
			amount_of_skips++;
			first = false;
		}
		if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop) && page == 1)
		{
			if (synopsis_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (35 + synopsis_y)))
			  {
				m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, -pixels_to_skip);
				amount_of_skips++;
			}
		}
		else if ((BTN_UP_PRESSED || BTN_UP_HELD) && !(m_thrdWorking && m_thrdStop) && page == 1)
		{
			if (amount_of_skips > 1)
			{
				m_btnMgr.moveBy(m_gameinfoLblSynopsis, 0, pixels_to_skip);
				amount_of_skips--;
			}
		}
		else if (BTN_RIGHT_PRESSED && !(m_thrdWorking && m_thrdStop) && page == 0 && gameinfo.Synopsis.size() > 0)
		{
			page = 1;
			amount_of_skips = 0;
			first = true;
			m_btnMgr.reset(m_gameinfoLblSynopsis);
			m_btnMgr.setText(m_gameinfoLblSynopsis, wfmt(L"%s", gameinfo.Synopsis.c_str()));

			m_btnMgr.hide(m_gameinfoLblDev, true);
			m_btnMgr.hide(m_gameinfoLblRegion, true);
			m_btnMgr.hide(m_gameinfoLblPublisher, true);
			m_btnMgr.hide(m_gameinfoLblRlsdate, true);
			m_btnMgr.hide(m_gameinfoLblGenre, true);
			m_btnMgr.hide(m_gameinfoLblRating, true);
			m_btnMgr.hide(m_gameinfoLblWifiplayers, true);

			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControlsReq); ++i)
				if (m_gameinfoLblControlsReq[i] != -1u)
					m_btnMgr.hide(m_gameinfoLblControlsReq[i], true);

			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControls); ++i)
				if (m_gameinfoLblControls[i] != -1u)
					m_btnMgr.hide(m_gameinfoLblControls[i], true);

			// When showing synopsis, only show user labels 2 and 3
			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblUser); ++i)
				if (i < ARRAY_SIZE(m_gameinfoLblUser) / 2)
					m_btnMgr.hide(m_gameinfoLblUser[i], true);
				else
					m_btnMgr.show(m_gameinfoLblUser[i]);

			m_btnMgr.show(m_gameinfoLblID);
			m_btnMgr.show(m_gameinfoLblSynopsis);
		}
		else if (BTN_LEFT_PRESSED && !(m_thrdWorking && m_thrdStop))
		{
			page = 0;
			m_btnMgr.show(m_gameinfoLblID);
			m_btnMgr.show(m_gameinfoLblDev);
			m_btnMgr.show(m_gameinfoLblRegion);
			m_btnMgr.show(m_gameinfoLblPublisher);
			m_btnMgr.show(m_gameinfoLblRlsdate);
			m_btnMgr.show(m_gameinfoLblGenre);
			m_btnMgr.show(m_gameinfoLblRating);
			m_btnMgr.show(m_gameinfoLblWifiplayers);

			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControlsReq); ++i)
				if (m_gameinfoLblControlsReq[i] != -1u && i < cnt_controlsreq)
					m_btnMgr.show(m_gameinfoLblControlsReq[i]);

			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblControls); ++i)
				if (m_gameinfoLblControls[i] != -1u && i < cnt_controls)
					m_btnMgr.show(m_gameinfoLblControls[i]);

			// When showing synopsis, only show user labels 2 and 3
			for (u8 i = 0; i < ARRAY_SIZE(m_gameinfoLblUser); ++i)
				if (i < ARRAY_SIZE(m_gameinfoLblUser) / 2)
					m_btnMgr.show(m_gameinfoLblUser[i]);
				else
					m_btnMgr.hide(m_gameinfoLblUser[i], true);

			m_btnMgr.hide(m_gameinfoLblSynopsis,true);
		}

	} while (!BTN_HOME_PRESSED && !BTN_B_PRESSED);

	_hideGameInfo(false);
}
Пример #6
0
void CMenu::_CheatSettings() {
	s32 padsState;
	WPADData *wd;
	u32 btn;
	WPAD_Rumble(WPAD_CHAN_0, 0);

	// try to load cheat file
	int txtavailable=0;
	m_cheatSettingsPage = 1; // init page
	
	txtavailable = m_cheatfile.openTxtfile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); 
	
	_showCheatSettings();
	_textCheatSettings();
	
	if (txtavailable)
		m_btnMgr.setText(m_cheatLblTitle,wfmt(L"%s",m_cheatfile.getGameName().c_str()));
	else 
		m_btnMgr.setText(m_cheatLblTitle,L"");
	
	while (true)
	{
		WPAD_ScanPads();
		padsState = WPAD_ButtonsDown(0);
		wd = WPAD_Data(0);
		btn = _btnRepeat(wd->btns_h);
		if ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_B)) != 0)
			break;
		if (wd->ir.valid)
			m_btnMgr.mouse(wd->ir.x - m_cur.width() / 2, wd->ir.y - m_cur.height() / 2);
		else if ((padsState & WPAD_BUTTON_UP) != 0)
			m_btnMgr.up();
		else if ((padsState & WPAD_BUTTON_DOWN) != 0)
			m_btnMgr.down();
		if ((padsState & WPAD_BUTTON_MINUS) != 0)
		{
			if (m_cheatSettingsPage > 1)
				--m_cheatSettingsPage;
			_hideCheatSettings();
			_showCheatSettings();
			m_btnMgr.click(m_cheatBtnPageM);
		}
		else if ((padsState & WPAD_BUTTON_PLUS) != 0)
		{
			_hideCheatSettings();
			if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE)
				++m_cheatSettingsPage;
			_showCheatSettings();
			m_btnMgr.click(m_cheatBtnPageP);
		}		
		if ((padsState & WPAD_BUTTON_A) != 0)
		{
			m_btnMgr.click();
			if (m_btnMgr.selected() == m_cheatBtnBack)
				break;
			else if (m_btnMgr.selected() == m_cheatBtnPageM)
			{
				_hideCheatSettings();
				if (m_cheatSettingsPage > 1)
					--m_cheatSettingsPage;
				_showCheatSettings();
			}
			else if (m_btnMgr.selected() == m_cheatBtnPageP)
			{
				_hideCheatSettings();
				if (m_cheatSettingsPage < (m_cheatfile.getCnt()+CHEATSPERPAGE-1)/CHEATSPERPAGE)
					++m_cheatSettingsPage;
				_showCheatSettings();
			}
				
			for (int i = 0; i < CHEATSPERPAGE; ++i)
				if (m_btnMgr.selected() == m_cheatBtnItem[i]) {
					// handling code for clicked cheat
					m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i] = !m_cheatfile.sCheatSelected[(m_cheatSettingsPage-1)*CHEATSPERPAGE + i];
					_showCheatSettings();
				}
			
			if (m_btnMgr.selected() == m_cheatBtnApply)
			{
				int operation_ok,check = 0;
				//checks if at least one cheat is selected
				for (unsigned int i=0; i < m_cheatfile.getCnt(); ++i) {
					if (m_cheatfile.sCheatSelected[i] == true) 
						{
						check = 1;
						break;
						}
					
					}
					
				if (check)
				{
					operation_ok = m_cheatfile.createGCT(fmt("%s/%s.gct", m_cheatDir.c_str(), m_cf.getId().c_str())); 
					operation_ok = m_cheatfile.createTXT(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str())); 
					
				}
					
				m_cfg.setOptBool(m_cf.getId(), "cheat",1);
				if (operation_ok)
					break;
			}

			if (m_btnMgr.selected() == m_cheatBtnDownload)
			{
				// Download cheat code
				m_btnMgr.hide(m_cheatLblTitle);
				
				u32 bufferSize = 0x100000;	// Maximum download size 1 MB
				SmartBuf buffer;
				block cheatfile;
				FILE *file;
				char ip[16];
				
				if (!m_networkInit && _initNetwork(ip) < 0) {
					m_btnMgr.hide(m_cheatLblTitle);
					break;
				}
				m_networkInit = true;

				buffer = smartCoverAlloc(bufferSize);
				cheatfile = downloadfile(buffer.get(), bufferSize, sfmt(GECKOURL, m_cf.getId().c_str()).c_str(),CMenu::_downloadProgress, this);

				if (cheatfile.data != NULL && cheatfile.size > 65 && cheatfile.data[0] != '<') {
					// cheat file was downloaded and presumably no 404
					file = fopen(fmt("%s/%s.txt", m_txtCheatDir.c_str(), m_cf.getId().c_str()), "wb");
							
					if (file != NULL)
					{
						fwrite(cheatfile.data, 1, cheatfile.size, file);
						fclose(file);
						break;
					}
				}
				else
				{
					// cheat code not found, show result
					m_btnMgr.setText(m_cheatLblItem[0], _t("cheat4", L"Download not found."));
					m_btnMgr.setText(m_cheatLblItem[1], wfmt(L"http://www.geckocodes.org/codes/R/%s.txt",m_cf.getId().c_str()));
					m_btnMgr.show(m_cheatLblItem[1]);
				}
			}
		}
		_mainLoopCommon(wd);
	}
	_hideCheatSettings();
}
Пример #7
0
void CMenu::_code(void)
{
	char code[4];
	_hideConfig();

	u32 n = 0;
	wchar_t codeLbl[] = L"_ _ _ _";

	SetupInput();
	memset(code, 0, sizeof code);
	m_btnMgr.setText(m_codeLblTitle, codeLbl);
	_showCode();
	bool ageLockMode = false;
	bool modeChanged = false;
	bool goBack = false;
	if (!m_locked)
	{
		m_btnMgr.show(m_codeBtnAge);
		m_btnMgr.show(m_codeBtnErase);
	}
	while(!m_exit)
	{
		int c = -1;
		_mainLoopCommon();
		if (BTN_HOME_PRESSED)
			goBack = true;
		if (WPadIR_ANY())
		{
			if (BTN_B_PRESSED)
				goBack = true;
			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_codeBtnBack))
					goBack = true;
				else if (m_btnMgr.selected(m_codeBtnErase))
				{
					goBack = true;
					_cfNeedsUpdate();
					if (ageLockMode)
						m_cfg.remove("GENERAL", "age_lock");
					else
					{
						m_cfg.remove("GENERAL", "parent_code");
						m_locked = false;
					}
				}
				else if (m_btnMgr.selected(m_codeBtnAge))
					modeChanged = true;
				else
					for (int i = 0; i < 10; ++i)
						if (m_btnMgr.selected(m_codeBtnKey[i]))
						{
							c = i;
							break;
						}
			}
		}
		else if (!ageLockMode)
		{
			// Map buttons to numbers
			c = -1;
			if (BTN_UP_PRESSED) c = 0;
			else if (BTN_LEFT_PRESSED) c = 1;
			else if (BTN_RIGHT_PRESSED) c = 2;
			else if (BTN_DOWN_PRESSED) c = 3;
			else if (BTN_MINUS_PRESSED) c = 4;
			else if (BTN_PLUS_PRESSED) c = 5;
			else if (BTN_A_PRESSED) c = 6;
			else if (BTN_B_PRESSED) c = 7;
			else if (BTN_1_PRESSED) c = 8;
			else if (BTN_2_PRESSED) c = 9;
		}

		if  (goBack)
		{
			if (!ageLockMode)
				break;
			modeChanged = true;
			goBack = false;
		}
		// ageLockMode allows entry of numbers 2 - 19
		// a first digit of 0 is ignored
		// a first digit of 2 - 9 is taken to mean a single digit number
		// a first digit of 1 will be the start of a 2 digit number
		else if (c != -1 && !(ageLockMode && (n == 0 && c == 0)))
		{
			codeLbl[n * 2] = ageLockMode ? '0' + c : 'X';
			code[n++] = '0' + c;
			m_btnMgr.setText(m_codeLblTitle, codeLbl);
		}
		
		if (modeChanged)
		{
			modeChanged = false;
			memset(code, 0, sizeof code);
			n = 0;
			ageLockMode = !ageLockMode;
			
			if (ageLockMode)
			{
				int ageLockM = m_cfg.getInt("GENERAL", "age_lock");
				if (ageLockM < 2 || ageLockM > 19)
					ageLockM = 19;
				m_btnMgr.hide(m_codeBtnAge, true);
				wchar_t ageLbl[40];
				wcsncpy(ageLbl, (_t("cd3", L"Age Lock")).c_str(), 35);
				ageLbl[35] = 0;
				swprintf(ageLbl, 40, L"%ls: %d", ageLbl, ageLockM);
				m_btnMgr.setText(m_codeLblAge, ageLbl);
				m_btnMgr.show(m_codeLblAge);
			}
			else if (!m_locked)
			{
				m_btnMgr.show(m_codeBtnAge);
				m_btnMgr.hide(m_codeLblAge, true);
			}

			for (u32 i = 0; i < sizeof code; i++)
				codeLbl[i*2] = (ageLockMode && i > 1) ? ' ' : '_';
			m_btnMgr.setText(m_codeLblTitle, codeLbl);
		}
		else
		{
			if (ageLockMode)
			{
				if ((n >= 2) || (n == 1 && c > 1))
				{
					modeChanged = true;
					m_cfg.setString("GENERAL", "age_lock", string(code, 2).c_str());
					_cfNeedsUpdate();				}
			}
			else if (n >= sizeof code)
			{
				if (m_locked)
				{
					if (memcmp(code, m_cfg.getString("GENERAL", "parent_code").c_str(), 4) == 0)
					{
						m_locked = false;
						_cfNeedsUpdate();
					}
					else
						error(_t("cfgg25", L"Password incorrect."));
				}
				else
				{
					m_cfg.setString("GENERAL", "parent_code", string(code, 4).c_str());
					m_locked = true;
					_cfNeedsUpdate();
				}
				break;
			}
		}
	}
	_hideCode();
	_showConfig();
}
Пример #8
0
bool CMenu::_Boot(void)
{
	boot_curPage = 1;
	SetupInput();
	set_port = currentPort;
	bool prev_load = cur_load;
	u8 prev_ios = cur_ios;
	showBoot();
	_refreshBoot();

	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_MINUS_PRESSED || BTN_LEFT_PRESSED) || (BTN_A_PRESSED && m_btnMgr.selected(m_bootBtnPageM)))
		{
			boot_curPage--;
			if(boot_curPage == 0) boot_curPage = boot_Pages;
			if(BTN_LEFT_PRESSED || BTN_MINUS_PRESSED)
				m_btnMgr.click(m_bootBtnPageM);
			_refreshBoot();
		}
		else if(((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED)) || (BTN_A_PRESSED && m_btnMgr.selected(m_bootBtnPageP)))
		{
			boot_curPage++;
			if(boot_curPage > boot_Pages) boot_curPage = 1;
			if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED)
				m_btnMgr.click(m_bootBtnPageP);
			_refreshBoot();
		}
		else if(BTN_A_PRESSED)
		{
			if(m_btnMgr.selected(m_bootBtnBack))
				break;
			else if(m_btnMgr.selected(m_bootBtnLoadCIOS))
			{
				cur_load = !cur_load;
				m_btnMgr.setText(m_bootBtnLoadCIOS, _optBoolToString(cur_load));
			}
			else if(m_btnMgr.selected(m_bootLblCIOSrevM) || m_btnMgr.selected(m_bootLblCIOSrevP))
			{
				bool increase = m_btnMgr.selected(m_bootLblCIOSrevP);
				CIOSItr itr = _installed_cios.find(cur_ios);
				if(increase)
				{
					itr++;
					if(itr == _installed_cios.end())
						itr = _installed_cios.begin();
				}
				else
				{
					if(itr == _installed_cios.begin())
						itr = _installed_cios.end();
					itr--;
				}
				cur_ios = itr->first;
				if(cur_ios > 0)
					m_btnMgr.setText(m_bootLblCurCIOSrev, wfmt(L"%i", cur_ios));
				else
					m_btnMgr.setText(m_bootLblCurCIOSrev, L"AUTO");
			}
			else if(m_btnMgr.selected(m_bootBtnUSBPort))
			{
				set_port = !set_port;
				m_btnMgr.setText(m_bootBtnUSBPort, wfmt(L"%i", set_port));
			}
			else if (m_btnMgr.selected(m_bootBtnManageSM))
			{
				hideBoot(true, true);
				_CfgSrc();
				showBoot();
				_refreshBoot();
			}
			else if (m_btnMgr.selected(m_bootBtnAsyncNet))
			{
				m_cfg.setBool("GENERAL", "async_network", !m_cfg.getBool("GENERAL", "async_network", false));
				m_btnMgr.setText(m_bootBtnAsyncNet, m_cfg.getBool("GENERAL", "async_network", false) ? _t("on", L"On") : _t("off", L"Off"));
			}
			else if (m_btnMgr.selected(m_bootBtnCategoryOnBoot))
			{
				m_cfg.setBool("GENERAL", "category_on_start", !m_cfg.getBool("GENERAL", "category_on_start", false));
				m_btnMgr.setText(m_bootBtnCategoryOnBoot, m_cfg.getBool("GENERAL", "category_on_start") ? _t("on", L"On") : _t("off", L"Off"));
			}
			else if (m_btnMgr.selected(m_bootBtnFtpOnBoot))
			{
				m_cfg.setBool(FTP_DOMAIN, "auto_start", !m_cfg.getBool(FTP_DOMAIN, "auto_start", false));
				m_btnMgr.setText(m_bootBtnFtpOnBoot, m_cfg.getBool(FTP_DOMAIN, "auto_start") ? _t("on", L"On") : _t("off", L"Off"));
			}
		}
	}
	if(prev_load != cur_load || prev_ios != cur_ios)
		InternalSave.SaveIOS();
	if(set_port != currentPort)
		InternalSave.SavePort(set_port);
	hideBoot(false, true);

	if(prev_load != cur_load || prev_ios != cur_ios || set_port != currentPort)
	{
		m_exit = true;
		m_reload = true;
		return 1;
	}
	return 0;
}
Пример #9
0
void CMenu::_PluginSettings()
{
	u8 i = 0;
	while(m_plugin.PluginExist(i)) i++;
	Plugin_Pages = static_cast<int>(ceil(static_cast<float>(i)/static_cast<float>(10)));
	m_max_plugins = i;
	//gprintf("Plugins found: %i, Pages: %i\n", m_max_plugins, Plugin_Pages);
	if(Plugin_Pages == 0)
		return;
	/* Only use Plugin Settings if Plugins are found */
	SetupInput();
	Plugin_curPage = 1;
	_showPluginSettings();
	_updatePluginText();
	while(!m_exit)
	{
		_mainLoopCommon();
		if(BTN_HOME_PRESSED || BTN_B_PRESSED)
		{
			m_cfg.save();
			break;
		}
		else if(BTN_UP_PRESSED)
			m_btnMgr.up();
		else if(BTN_DOWN_PRESSED)
			m_btnMgr.down();
		if((BTN_MINUS_PRESSED || BTN_LEFT_PRESSED) || (BTN_A_PRESSED && m_btnMgr.selected(m_pluginBtnPageM)))
		{
			Plugin_curPage--;
			if(Plugin_curPage == 0) Plugin_curPage = Plugin_Pages;
			if(BTN_LEFT_PRESSED || BTN_MINUS_PRESSED)
				m_btnMgr.click(m_pluginBtnPageM);
			_updatePluginCheckboxes();
			_updatePluginText();
		}
		else if(((BTN_PLUS_PRESSED || BTN_RIGHT_PRESSED)) || (BTN_A_PRESSED && m_btnMgr.selected(m_pluginBtnPageP)))
		{
			Plugin_curPage++;
			if(Plugin_curPage > Plugin_Pages) Plugin_curPage = 1;
			if(BTN_RIGHT_PRESSED || BTN_PLUS_PRESSED)
				m_btnMgr.click(m_pluginBtnPageP);
			_updatePluginCheckboxes();
			_updatePluginText();
		}
		if(BTN_A_PRESSED)
		{
			if(m_btnMgr.selected(m_pluginBtnBack))
			{
				m_cfg.save();
				break;
			}
			u32 IteratorHelp = (Plugin_curPage - 1) * 10;
			for(u8 i = 0; i < min(IteratorHelp+10, (u32)m_max_plugins)-IteratorHelp+1; ++i)
			{
				if(m_btnMgr.selected(m_pluginBtn[i]))
				{
					if(i == 0)
					{
						m_plugin.GetEnabledPlugins(m_cfg, &enabledPluginsCount);
						for(u8 j = 0; m_plugin.PluginExist(j); j++)
							m_plugin.SetEnablePlugin(m_cfg, j, (enabledPluginsCount == 0) ? 2 : 1);
					}
					else
						m_plugin.SetEnablePlugin(m_cfg, i+IteratorHelp-1);
					_updatePluginCheckboxes();
					break;
				}
			}
		}
	}
	_hidePluginSettings();
	_loadList();
}
Пример #10
0
bool CMenu::_LangSettings(void)
{
	_refreshLangSettings();
	bool lang_changed = false;

	while(!m_exit)
	{
		_mainLoopCommon();
		if(BTN_HOME_PRESSED || BTN_B_PRESSED)
			break;
		else if(BTN_A_PRESSED)
		{
			if(m_btnMgr.selected(m_LangSettingsBtnBack))
				break;
			else if(m_btnMgr.selected(m_LangSettingsBtnCurLanguageP) || m_btnMgr.selected(m_LangSettingsBtnCurLanguageM))
			{
				s8 direction = m_btnMgr.selected(m_LangSettingsBtnCurLanguageP) ? 1 : -1;
				available_pos = loopNum(available_pos + direction, languages_available.size());
				m_curLanguage = languages_available[available_pos];
				if(!m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str())))
				{
					m_curLanguage = "Default";
					m_cfg.setString("GENERAL", "language", m_curLanguage.c_str());
					m_loc.unload();
				}
				else
					m_cfg.setString("GENERAL", "language", m_curLanguage.c_str());
				lang_changed = true;
				_updateText();
				_showLangSettings();
			}
			else if(m_btnMgr.selected(m_LangSettingsBtnGetLanguages))
			{
				/* reset our variables doh */
				_hideLangSettings();
				language_cnt = 0;
				mem_pos = 0;
				u8 *file = NULL;
				u32 filesize = 0;
				_downloadUrl(fmt("%s/Languages/", SVN_URL), &file, &filesize);
				if(m_buffer != NULL)
				{
					const char *search_char = "<li><a";
					/* getting count */
					char *start = (strstr((char*)file, search_char)); /* skipping the .. */
					start = strstr(start, "\n") + 1; /* skipping the line */
					char *tmp = start;

					while((tmp = strstr(tmp, search_char)) != NULL)
					{
						language_cnt++;
						tmp = strstr(tmp, "\n") + 1; /* next line */
					}
					gprintf("Found %u languages\n", language_cnt);
					/* creating list */
					tmp = start;
					lang_list_mem = (language_list*)MEM2_alloc(language_cnt*sizeof(language_list));
					memset(lang_list_mem, 0, language_cnt*sizeof(language_list));
					for(u32 i = 0; i < language_cnt; ++i)
					{
						tmp = strstr(tmp, search_char);
						char *lang_chr = strchr(tmp, 0x22) + 1; /* the " is the beginning for the name */
						memcpy(lang_list_mem[i].lang, lang_chr, std::min(31u, (u32)(strchr(lang_chr, '.') - lang_chr)));
						//gprintf("%s added\n", lang_list_mem[i].lang);
						tmp = strstr(tmp, "\n") + 1; /* next line */
					}
					//gprintf("Finished creating the list\n");
					free(m_buffer);
					m_buffer = NULL;
				}
				_showLangSettings();
			}
			else if(m_btnMgr.selected(m_LangSettingsBtnCurDlLangP) || m_btnMgr.selected(m_LangSettingsBtnCurDlLangM))
			{
				s8 direction = m_btnMgr.selected(m_LangSettingsBtnCurDlLangP) ? 1 : -1;
				mem_pos = loopNum(mem_pos + direction, language_cnt);
				_showLangSettings();
			}
			else if(m_btnMgr.selected(m_LangSettingsBtnDownload))
			{
				_hideLangSettings();
				m_loc.unload();
				/* Get main ini */
				u8 *file = NULL;
				u32 filesize = 0;
				_downloadUrl(fmt("%s/Languages/%s.ini", SVN_URL, lang_list_mem[mem_pos].lang), &file, &filesize);
				if(m_buffer != NULL)
				{
					if(filesize > 0)
					{
						const char *language_ini = fmt("%s/%s.ini", m_languagesDir.c_str(), lang_list_mem[mem_pos].lang);
						fsop_deleteFile(language_ini);
						fsop_WriteFile(language_ini, file, filesize);
						gprintf("Wrote %s with the size %u\n", language_ini, filesize);
					}
					free(m_buffer);
					m_buffer = NULL;
				}
				/* Get help file */
				file = NULL;
				filesize = 0;
				_downloadUrl(fmt("%s/help/%s.txt", SVN_URL, lang_list_mem[mem_pos].lang), &file, &filesize);
				if(m_buffer != NULL)
				{
					if(filesize > 0)
					{
						const char *language_help = fmt("%s/%s.txt", m_helpDir.c_str(), lang_list_mem[mem_pos].lang);
						fsop_deleteFile(language_help);
						fsop_WriteFile(language_help, file, filesize);
						gprintf("Wrote %s with the size %u\n", language_help, filesize);
					}
					free(m_buffer);
					m_buffer = NULL;
				}
				/* reload */
				m_loc.load(fmt("%s/%s.ini", m_languagesDir.c_str(), m_curLanguage.c_str()));
				_updateText();
				_refreshLangSettings();
			}
		}
	}
	_hideLangSettings();
	if(lang_changed)
		_cfNeedsUpdate();

	if(lang_list_mem != NULL)
		free(lang_list_mem);
	lang_list_mem = NULL;
	return lang_changed;
}