コード例 #1
0
int CMenu::_config4(void)
{
	int change = CONFIG_PAGE_NO_CHANGE;

	_showConfig4();
	while(!m_exit)
	{
		change = _configCommon();
		if (change != CONFIG_PAGE_NO_CHANGE)
			break;
		if (BTN_A_PRESSED)
		{
			if (m_btnMgr.selected(m_config4BtnHome))
			{
				int exit_to = (int)loopNum((u32)m_cfg.getInt("GENERAL", "exit_to", 0) + 1, ARRAY_SIZE(CMenu::_exitTo));
				m_cfg.setInt("GENERAL", "exit_to", exit_to);
				Sys_ExitTo(exit_to);
				_showConfig4();
			}
			else if (m_btnMgr.selected(m_config4BtnSaveFavMode))
			{
				m_cfg.setBool("GENERAL", "save_favorites_mode", !m_cfg.getBool("GENERAL", "save_favorites_mode"));
				_showConfig4();
			}
			else if (m_btnMgr.selected(m_config4BtnPathManager))
			{
				_hideConfig4();
				_Paths();
				_showConfig4();
				break;
			}
			else if (m_btnMgr.selected(m_config4BtnReturnToP))
			{
				currentChannelIndex = (currentChannelIndex >= amountOfChannels - 1) ? -1 : currentChannelIndex + 1;
				if (currentChannelIndex == -1)
					m_cfg.remove("GENERAL", "returnto");
				else
					m_cfg.setString("GENERAL", "returnto", ChannelHandle.GetId(currentChannelIndex));
				_showConfig4();
			}
			else if (m_btnMgr.selected(m_config4BtnReturnToM))
			{
				if (currentChannelIndex == -1) currentChannelIndex = amountOfChannels;
				currentChannelIndex--;
				if (currentChannelIndex == -1)
					m_cfg.remove("GENERAL", "returnto");
				else
					m_cfg.setString("GENERAL", "returnto", ChannelHandle.GetId(currentChannelIndex));
				_showConfig4();
			}
		}
	}
	_hideConfig4();
	return change;
}
コード例 #2
0
    /*!
     * \brief Set the next scanning curve.
     *
     * Next in the sense of the number of reversals
     * from imbibition to drainage or vince versa. If this
     * curve already has a list of next curves, it is
     * deleted and thus forgotten.
     */
    void setNext(Scalar SwReversal,
                 Scalar pcnwReversal,
                 Scalar SwMiCurve,
                 Scalar SwMdCurve)
    {
        // if next_ is NULL, delete does nothing, so
        // this is valid!!
        delete next_;

        next_ = new PLScanningCurve(this, // prev
                                    NULL, // next
                                    loopNum() + 1,
                                    SwReversal,
                                    pcnwReversal,
                                    SwMiCurve,
                                    SwMdCurve);
    }
コード例 #3
0
 /*!
  * \brief Returns true iff the scanning curve is a
  *        imbibition curve.
  */
 bool isImbib()
 { return loopNum()%2 == 1; }
コード例 #4
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;
}