Exemplo n.º 1
0
void PerformanceTest::_addArmature()
{
    const auto armature = _factory.buildArmature(_dragonBonesData->getArmatureNames()[1]);
    const auto armatureDisplay = static_cast<dragonBones::CCArmatureDisplayContainer*>(armature->getDisplay());

    armatureDisplay->setScale(0.3f);
    this->addChild(armatureDisplay);

    armature->setCacheFrameRate(24);
    armature->getAnimation().play(armature->getAnimation().getAnimationNames()[0], 0);
    dragonBones::WorldClock::clock.add(armature);

    _armatures.push_back(armature);
    _updateText();
}
Exemplo n.º 2
0
void PerformanceTest::_removeArmature()
{
    if (_armatures.empty())
    {
        return;
    }

    const auto armature = _armatures.back();
    const auto armatureDisplay = static_cast<dragonBones::CCArmatureDisplayContainer*>(armature->getDisplay());
    this->removeChild(armatureDisplay);
    dragonBones::WorldClock::clock.remove(armature);
    armature->dispose();

    _armatures.pop_back();
    _updateText();
}
Exemplo n.º 3
0
 void textBox::_updateTextAndCaret()
 {
     _updateText();
     _updateCaret();
 }
Exemplo n.º 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;
}