Exemplo n.º 1
0
void CScreenProfile::CreateProfileList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();

	// Get new stuff
	m_ProfileList.clear();
	g_pProfileMgr->GetProfileList(m_ProfileList);

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	// Profiles to the list
	for (StringSet::iterator iter = m_ProfileList.begin(); iter != m_ProfileList.end(); ++iter)
	{
		char *pStr = (char *)iter->c_str();
		CLTGUITextCtrl* pTextCtrl = CreateTextItem(pStr, CMD_OK, LTNULL);
		pTextCtrl->SetFont(pFont,nListFontSz);
		uint16 ndx = m_pListCtrl->AddControl(pTextCtrl);
		pTextCtrl->SetParam1(ndx);

		if (stricmp(iter->c_str(),m_pProfile->m_sName.c_str()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}
Exemplo n.º 2
0
	int LMDBEngine::FlushWriteBatch(BatchHolder& holder)
	{
		if (NULL != holder.txn)
		{
			StringSet::iterator it = holder.dels.begin();
			while (it != holder.dels.end())
			{
				MDB_val k;
				k.mv_data = (void*) (it->c_str());
				k.mv_size = it->size();
				mdb_del(holder.txn, m_dbi, &k, NULL);
				it++;
			}
			std::map<std::string, std::string>::iterator sit =
			        holder.inserts.begin();
			while (sit != holder.inserts.end())
			{
				MDB_val k, v;
				k.mv_data = (void*) (sit->first.c_str());
				k.mv_size = sit->first.size();
				v.mv_data = (void*) (sit->second.c_str());
				v.mv_size = sit->second.size();
				mdb_put(holder.txn, m_dbi, &k, &v, 0);
				sit++;
			}
			mdb_txn_commit(holder.txn);
			holder.txn = NULL;
			holder.Clear();
		}
		return 0;
	}
void emitShinglesWithDocSizes(const StringSet& shingleSet,
    const std::string& docId) {
  assert(shingleSet.size() <= dedup::SKETCH_SIZE);

  std::string docIdWithSize = docId + dedup::DOC_SIZE_SEP +
      dedup::numToStr(shingleSet.size());
  for (StringSet::iterator it = shingleSet.begin();
      it != shingleSet.end(); ++it) {
    printf("%s\t%s\n", it->c_str(), docIdWithSize.c_str());
  }
}
Exemplo n.º 4
0
void GLESRenderSpec::report(LogChannel* ch)
{
	LOG_SCOPE(ch, "++ * GLESRenderSpec Report\n");

	LOG(ch, "++ - GL_VENDOR: %s\n", _vendor.c_str());
	LOG(ch, "++ - GL_RENDERER: %s\n", _renderer.c_str());
	LOG(ch, "++ - GL_VERSION: %s\n", _version.c_str());
	LOG(ch, "++ + GL_EXTENSIONS:\n");

	for (StringSet::iterator itr = _extensions.begin(), end = _extensions.end(); itr != end; ++itr)
	{
		LOG(ch, "++   - %s\n", itr->c_str());
	}

	RenderSpec::report(ch);
}
Exemplo n.º 5
0
// Build the list of Custom Levels
void CScreenSingle::BuildCustomLevelsList(int nWidth)
{
	m_Filenames.clear();
	m_pCustom->RemoveAll();

	// Get a list of world names and sort them alphabetically

    uint8 nNumPaths = g_pClientButeMgr->GetNumSingleWorldPaths();

    char pathBuf[128];
	FileEntry** pFilesArray = debug_newa(FileEntry*, nNumPaths);

	if (pFilesArray)
	{
		for (int i=0; i < nNumPaths; ++i)
		{
			pathBuf[0] = '\0';
			g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

			if (pathBuf[0])
			{
                pFilesArray[i] = g_pLTClient->GetFileList(pathBuf);
			}
			else
			{
                pFilesArray[i] = LTNULL;
			}
		}
	}



	char Buf[255];

	for (int i=0; i < nNumPaths; ++i)
	{
		pathBuf[0] = '\0';
		g_pClientButeMgr->GetWorldPath(i, pathBuf, ARRAY_LEN(pathBuf));

		if (pathBuf[0] && pFilesArray[i])
		{
			sprintf(Buf, "%s\\", pathBuf);
			AddFilesToFilenames(pFilesArray[i], Buf);
            g_pLTClient->FreeFileList(pFilesArray[i]);
		}
	}

	debug_deletea(pFilesArray);

	CLTGUITextCtrl* pItem;

	uint8 nListFontSize = (uint8)g_pLayoutMgr->GetScreenCustomInt((eScreenID)m_nScreenID,"ListFontSize");
	int index = 0;
	StringSet::iterator iter = m_Filenames.begin();
	while (iter != m_Filenames.end())
	{
		pItem = CreateTextItem((char *)iter->c_str(), CMD_CUSTOM+index, IDS_HELP_CUSTOMLEVEL);
		pItem->SetFont(LTNULL, nListFontSize);
		pItem->SetFixedWidth(nWidth,LTTRUE);

		m_pCustom->AddControl(pItem);
		++index;
		iter++;
	}

}
Exemplo n.º 6
0
uint32 CScreenSingle::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2)
{
	if (dwCommand >= CMD_CUSTOM)
	{

		int index = dwCommand - CMD_CUSTOM;

		//is custom level
		if (index < 1000)
		{
			StringSet::iterator iter = m_Filenames.begin();
			while (iter != m_Filenames.end() && index > 0)
			{
				iter++;
				--index;
			}
			if (iter != m_Filenames.end())
			{
				g_pMissionMgr->StartGameFromLevel(iter->c_str());
			}
			
		}
		else
		{
			index -= 1000;
			if (index < g_pMissionButeMgr->GetNumMissions())
			{
				const MISSION* pMission = g_pMissionButeMgr->GetMission(index);
				const LEVEL* pLevel = &pMission->aLevels[0];
				g_pMissionMgr->StartGameFromLevel(pLevel->szLevel);

			}
			return 1;
		}
	}

	switch(dwCommand)
	{

	case CMD_BACK:
		{


#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustom->SetSelection(kNoSelection);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS


			m_pDiff->Show(LTFALSE);
			m_pDiff->SetSelection(kNoSelection);
			m_pDiffFrame->Show(LTFALSE);

			m_pChapter->Show(LTFALSE);
			m_pChapter->SetSelection(kNoSelection);
			m_pChapterFrame->Show(LTFALSE);


			m_pScreenMgr->EscapeCurrentScreen();
			break;
		}
	case CMD_NEW_GAME:
		{

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS

			m_pDiff->Show(LTTRUE);
			m_pDiffFrame->Show(LTTRUE);

			m_pChapter->Show(LTFALSE);
			m_pChapterFrame->Show(LTFALSE);


			SetSelection(GetIndex(m_pDiff));
			m_pDiff->SetSelection(g_pGameClientShell->GetDifficulty());
			UpdateHelpText();

			break;
		}

	case CMD_CHAPTER:
		{

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTFALSE);
			m_pCustomFrame->Show(LTFALSE);
#endif // _REMOVE_CUSTOM_LEVELS

			m_pDiff->Show(LTFALSE);
			m_pDiffFrame->Show(LTFALSE);

			m_pChapter->Show(LTTRUE);
			m_pChapterFrame->Show(LTTRUE);


			SetSelection(GetIndex(m_pChapter));
//			m_pDiff->SetSelection(g_pGameClientShell->GetDifficulty());

			break;
		}

	case CMD_EASY:
		{
			g_pGameClientShell->SetDifficulty(GD_EASY);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_MEDIUM:
		{
			g_pGameClientShell->SetDifficulty(GD_NORMAL);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_HARD:
		{
			g_pGameClientShell->SetDifficulty(GD_HARD);
			g_pMissionMgr->StartGameNew( );
			break;
		}
	case CMD_INSANE:
		{
			g_pGameClientShell->SetDifficulty(GD_VERYHARD);
			g_pMissionMgr->StartGameNew( );
			break;
		}

	case CMD_LOAD_GAME:
		{
			g_pInterfaceMgr->SwitchToScreen(SCREEN_ID_LOAD);
			break;
		}
	case CMD_CUSTOM_LEVEL:
		{
			m_pDiff->Show(LTFALSE);
			m_pDiffFrame->Show(LTFALSE);
			m_pChapter->Show(LTFALSE);
			m_pChapterFrame->Show(LTFALSE);

#ifndef _REMOVE_CUSTOM_LEVELS
			m_pCustom->Show(LTTRUE);
			m_pCustomFrame->Show(LTTRUE);
			SetSelection(GetIndex(m_pCustom));
#endif // _REMOVE_CUSTOM_LEVELS

			break;
		}
	default:
		return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2);
	}
	return 1;
};
Exemplo n.º 7
0
void CScreenHostMission::CreateCampaignList()
{
	// Empty the list
	m_pListCtrl->RemoveAll();
	m_CampaignList.clear();

	CUIFont *pFont = g_pInterfaceResMgr->GetFont(nListFont);

	m_CampaignList.insert(DEFAULT_CAMPAIGN);

	// Get new stuff
	struct _finddata_t file;
	intptr_t hFile;

	CUserProfile* pUserProfile = g_pProfileMgr->GetCurrentProfile( );
	std::string directory = GetCampaignDir( g_pProfileMgr->GetCurrentProfileName( ), 
		pUserProfile->m_ServerGameOptions.m_eGameType );
	directory += "*.txt"; 

	// find first file
	if((hFile = _findfirst(directory.c_str(), &file)) != -1L)
	{
		do
		{
			if (_stricmp(file.name,DEFAULT_CAMPAIGN_FILE) != 0)
			{
				char *pName = strtok(file.name,".");
				m_CampaignList.insert(pName);
			}

		}
		while(_findnext(hFile, &file) == 0);
	}
	_findclose(hFile);

	// add campaigns to the list control
	for (StringSet::iterator iter = m_CampaignList.begin(); iter != m_CampaignList.end(); ++iter)
	{
		CLTGUITextCtrl* pTextCtrl = NULL;
		uint16 ndx = 0;
		if (iter->compare(DEFAULT_CAMPAIGN) == 0)
		{
			m_pDefaultTextCtrl = CreateTextItem(IDS_HOST_CAMPAIGN_DEFAULT, CMD_OK, LTNULL);
			ndx = m_pListCtrl->AddControl(m_pDefaultTextCtrl);
			m_nDefaultCampaign = ndx;
			m_pDefaultTextCtrl->Show(LTFALSE);
			m_pDefaultTextCtrl->SetParam1(ndx);
			m_pDefaultTextCtrl->SetFont(pFont,nListFontSz);
		}
		else
		{
			pTextCtrl = CreateTextItem((char *)iter->c_str(), CMD_OK, LTNULL);
			pTextCtrl->SetFont(pFont,nListFontSz);
			ndx = m_pListCtrl->AddControl(pTextCtrl);
			pTextCtrl->SetParam1(ndx);
		}

		
		

		if (iter->compare(m_pProfile->m_ServerGameOptions.GetCampaignName()) == 0)
			m_pListCtrl->SetSelection(ndx);
	}

}