void CCheatMgr::Version() { // Display the version info... std::wstring sBuild; sBuild = MPA2W( g_pVersionMgr->GetBuild()); g_pGameMsgs->AddMessage( sBuild.c_str( ),kMsgCheatConfirm); }
void LTProfileUtils::ReadString(const wchar_t* pszSectionName, const wchar_t* pszKeyName, const wchar_t* pszDefaultValue, wchar_t* pszValueString, uint32 nValueStringBufferSize, const wchar_t* pszFileName) { // get ANSI versions of strings char pszSectionNameANSI[MAX_PATH]; LTStrCpy(pszSectionNameANSI, MPW2A(pszSectionName).c_str(), MAX_PATH); char pszKeyNameANSI[MAX_PATH]; LTStrCpy(pszKeyNameANSI, MPW2A(pszKeyName).c_str(), MAX_PATH); char pszDefaultValueANSI[MAX_PATH]; LTStrCpy(pszDefaultValueANSI, MPW2A(pszDefaultValue).c_str(), MAX_PATH); char pszFileNameANSI[MAX_PATH]; LTStrCpy(pszFileNameANSI, MPW2A(pszFileName).c_str(), MAX_PATH); char* pszValueStringANSI = NULL; LT_MEM_TRACK_ALLOC(pszValueStringANSI = new char[nValueStringBufferSize], LT_MEM_TYPE_MISC); // call ANSI version ReadString(pszSectionNameANSI, pszKeyNameANSI, pszDefaultValueANSI, pszValueStringANSI, nValueStringBufferSize, pszFileNameANSI); // convert output value LTStrCpy(pszValueString, MPA2W(pszValueStringANSI), nValueStringBufferSize); delete [] pszValueStringANSI; }
void CheatFn(int argc, char **argv) { // Track the current execution shell scope for proper SEM behavior CGameClientShell::CClientShellScopeTracker cScopeTracker; if (argc < 1 || !g_pCheatMgr) return; // We need to store converted strings. std::vector< std::wstring > aStrings; aStrings.resize( argc ); CParsedMsgW cMsg; cMsg.Init( argc, NULL ); for( int i = 0; i < argc; i++ ) { aStrings[i] = MPA2W( argv[i] ).c_str( ); CParsedMsgW::CToken token = aStrings[i].c_str( ); cMsg.SetArg( i, token ); } if (g_pCheatMgr->Check( cMsg )) { // g_pClientSoundMgr->PlayInterfaceDBSound("Cheat"); } }
void CScreenHostOptionFile::UpdateName() { CUserProfile* pProfile = g_pProfileMgr->GetCurrentProfile(); wchar_t wszBuffer[MAX_PATH*2]; const wchar_t* wszFriendlyName = CHostOptionsMapMgr::Instance().GetFriendlyNameFromFileName( pProfile->m_sServerOptionsFile.c_str() ); if( wszFriendlyName ) FormatString( "IDS_CURRENT_OPTIONFILE", wszBuffer, LTARRAYSIZE(wszBuffer), wszFriendlyName); else FormatString( "IDS_CURRENT_OPTIONFILE", wszBuffer, LTARRAYSIZE(wszBuffer), MPA2W(pProfile->m_sServerOptionsFile.c_str( )).c_str( )); m_pCurrent->SetString( wszBuffer ); }
void CLoadingScreen::UpdateSessionName( ) { // If connecting to a remote server, set our mission descriptor to // the ip we're connecting to. if( g_pClientConnectionMgr->IsConnectedToRemoteServer( )) { // Make a loading string using the IP to be joined. wchar_t szLoadingString[256]; // LTSNPrintF( szSession, LTARRAYSIZE(szSession), L"%s", g_pClientConnectionMgr->GetStartGameRequest().m_pNetSession->m_sName ); if ( !LTStrEmpty(g_pClientConnectionMgr->GetServerName())) { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s: %s", LoadString("IDS_CONNECTING_TO_SERVER"), g_pClientConnectionMgr->GetServerName() ); } else { LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L"%s", LoadString("IDS_CONNECTING_TO_SERVER")); } m_MissionName.SetFont(g_CurrentLayout.m_sLevelFont); m_MissionName.SetString(szLoadingString); LTSNPrintF( szLoadingString, LTARRAYSIZE(szLoadingString), L" (%S)", g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress ); m_LevelName.SetString(szLoadingString); } // Local game, set the mission descriptor to the level name. else { m_MissionName.SetFont(g_CurrentLayout.m_sTitleFont); if (g_pGameClientShell->IsRunningPerformanceTest()) { m_MissionName.SetString(LoadString( "IDS_TITLE_PERFORMANCE_TEST" )); m_LevelName.SetString(L""); } else { m_MissionName.SetString(LoadString( "IDS_CUSTOM_LEVEL" )); // Split the worldname up into parts so we can get the load string. wchar_t szWorldTitle[MAX_PATH] = L""; _wsplitpath( MPA2W(g_pMissionMgr->GetCurrentWorldName( )).c_str(), NULL, NULL, szWorldTitle, NULL ); m_LevelName.SetString(szWorldTitle); } } }
void CLoadingScreen::FileReceiveCompletedNotification(const std::string& strFilename, uint32 nFileBytesTotal, uint32 nTransferBytesTotal, float fTransferRate) { // No need to update content info if a different screen is being rendered... if( m_pRenderScreen ) return; EnterCriticalSection(&m_MissionUpdate); // update the byte counts and file count m_nCompletedBytes += nFileBytesTotal; m_nCurrentBytes = m_nCompletedBytes; m_nTotalBytes = nTransferBytesTotal; m_nCurrentFiles--; wchar_t szMsg[128]; if (nFileBytesTotal < knKB) { FormatString("CONTENTDL_CURRENT_FILE_B",szMsg,LTARRAYSIZE(szMsg),MPA2W(strFilename.c_str()).c_str(),nFileBytesTotal); } else if (nFileBytesTotal < knMB) { FormatString("CONTENTDL_CURRENT_FILE_KB",szMsg,LTARRAYSIZE(szMsg),MPA2W(strFilename.c_str()).c_str(),nFileBytesTotal/knKB); } else { FormatString("CONTENTDL_CURRENT_FILE_MB",szMsg,LTARRAYSIZE(szMsg),MPA2W(strFilename.c_str()).c_str(),(float)nFileBytesTotal/kfMB ); } m_CurrentFileName.SetString( szMsg ); m_CurrentFileTime.SetString(L""); FormatString("CONTENTDL_FILES",szMsg,LTARRAYSIZE(szMsg),m_nCurrentFiles); m_FilesLeft.SetString(szMsg); UpdateCurrentBar(1.0f); double fElapsed = RealTimeTimer::Instance().GetTimerAccumulatedS() - m_fLastUpdateTime; if (fElapsed > 0.01f) { m_fLastUpdateTime = RealTimeTimer::Instance().GetTimerAccumulatedS(); float fTimeLeft = 999.0f * 60.0f; if (fTransferRate > 0.0f) { fTimeLeft = float(m_nTotalBytes - m_nCurrentBytes) / fTransferRate; } if (fTimeLeft > 90.0f) FormatString("CONTENTDL_TIME_M",szMsg,LTARRAYSIZE(szMsg),uint32(fTimeLeft/60.0f + 0.5f), (fTransferRate / kfKB) ); else FormatString("CONTENTDL_TIME_S",szMsg,LTARRAYSIZE(szMsg),uint32(fTimeLeft), (fTransferRate / kfKB) ); m_TotalTime.SetString(szMsg); } LeaveCriticalSection(&m_MissionUpdate); Update(); }
void CScreenHostLevels::AddMissionToList(int nMissionId, bool bVerifySize, bool bForce) { // Sanity checks... if (!m_pSelMissions) return; if (m_pSelMissions->GetNumControls() == MAX_GAME_LEVELS) return; // Add the level to the list... CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(nSelWidth,nListFontSize); cs.nCommandID = CMD_REMOVE_LEVEL; cs.pCommandHandler = this; HRECORD hMission = g_pMissionDB->GetMission(nMissionId); HRECORD hLevel = g_pMissionDB->GetLevel(hMission,0); if (hMission && hLevel) { if (!g_pMissionDB->CheckMPLevelRequirements(hMission,m_setRequiredMapFeatures)) { return; } if (!bForce) { uint32 nMapMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0); uint32 nMapMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0); uint32 nGameMax = GameModeMgr::Instance( ).m_grnMaxPlayers.GetValue(); if (nMapMax > 0 && nGameMax > nMapMax) { if (bVerifySize) { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = AddCallBack; mb.pData = (void *)nMissionId; mb.pUserData = this; g_pInterfaceMgr->ShowMessageBox("Screen_Host_LevelTooSmall",&mb); } return; } if (nMapMin > 0 && nGameMax < nMapMin) { if (bVerifySize) { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = AddCallBack; mb.pData = (void *)nMissionId; mb.pUserData = this; g_pInterfaceMgr->ShowMessageBox("Screen_Host_LevelTooLarge",&mb); } return; } } const char* szNameId = g_pMissionDB->GetString(hMission,MDB_Name); std::wstring sName; if( szNameId[0] != '\0' ) { sName = LoadString(szNameId); } else { sName = g_pMissionDB->GetWString(hMission,MDB_NameStr); if (!sName.length()) { sName = MPA2W(g_pMissionDB->GetWorldName(hLevel,false)).c_str(); } } wchar_t wszPlayers[64] = L""; uint32 nMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0); uint32 nMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0); if (nMin >= 2 && nMax >= nMin) { FormatString("MP_Players",wszPlayers,LTARRAYSIZE(wszPlayers),nMin,nMax); sName += L" "; sName += wszPlayers; } cs.szHelpID = ""; CLTGUIColumnCtrlEx* pColumnCtrl = debug_new(CLTGUIColumnCtrlEx); pColumnCtrl->Create(cs); pColumnCtrl->SetScale(g_pInterfaceResMgr->GetScreenScale()); pColumnCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); pColumnCtrl->SetParam1( nMissionId ); char const* pszListFont = g_pLayoutDB->GetListFont(m_hLayout,0); const uint32 nListFontSize = g_pLayoutDB->GetListSize(m_hLayout,0); pColumnCtrl->SetFont( CFontInfo(pszListFont, nListFontSize) ); pColumnCtrl->AddTextColumn( sName.c_str(), nSelWidth, true ); m_pSelMissions->AddControl( pColumnCtrl ); } else { ASSERT(!"Invalid mission id"); } }
bool CScreenHostLevels::FillAvailList() { // Sanity checks... if (!m_pAvailMissions) return(false); CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(nAvailWidth,nListFontSize); cs.nCommandID = CMD_ADD_LEVEL; cs.pCommandHandler = this; for (uint32 nMission = 0; nMission < g_pMissionDB->GetNumMissions(); nMission++) { HRECORD hMission = g_pMissionDB->GetMission(nMission); HRECORD hLevel = g_pMissionDB->GetLevel(hMission,0); bool bValidForGameMode = true; if (hMission && hLevel) { if (!g_pMissionDB->CheckMPLevelRequirements(hMission,m_setRequiredMapFeatures)) { continue; } const char* szNameId = g_pMissionDB->GetString(hMission,MDB_Name); std::wstring sName; if( szNameId[0] != '\0' ) { sName = LoadString(szNameId); } else { sName = g_pMissionDB->GetWString(hMission,MDB_NameStr); if (!sName.length()) { sName = MPA2W(g_pMissionDB->GetWorldName(hLevel,false)).c_str(); } } wchar_t wszPlayers[64] = L""; uint32 nMin = g_pMissionDB->GetInt32(hLevel,MDB_MinPlayers,0,0); uint32 nMax = g_pMissionDB->GetInt32(hLevel,MDB_MaxPlayers,0,0); if (nMin >= 2 && nMax >= nMin) { FormatString("MP_Players",wszPlayers,LTARRAYSIZE(wszPlayers),nMin,nMax); sName += L" "; sName += wszPlayers; } char szWorldTitle[MAX_PATH] = ""; LTStrCpy(szWorldTitle,g_pMissionDB->GetWorldName(hLevel,false),LTARRAYSIZE(szWorldTitle)); CLTGUIColumnCtrlEx* pColumnCtrl = debug_new(CLTGUIColumnCtrlEx); pColumnCtrl->Create(cs); pColumnCtrl->SetScale(g_pInterfaceResMgr->GetScreenScale()); pColumnCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); pColumnCtrl->SetParam1(nMission); char const* pszListFont = g_pLayoutDB->GetListFont(m_hLayout,0); const uint32 nListFontSize = g_pLayoutDB->GetListSize(m_hLayout,0); pColumnCtrl->SetFont( CFontInfo(pszListFont, nListFontSize) ); pColumnCtrl->AddTextColumn( sName.c_str(), nAvailWidth, true ); m_pAvailMissions->AddControl( pColumnCtrl ); } } return (true); }
void CScreenHostOptionFile::CreateFileList() { // Empty the list m_pListCtrl->RemoveAll(); m_List.clear(); // Get new stuff LTFINDFILEINFO file; LTFINDFILEHANDLE hFile; // Create directory search string. char szDirectory[MAX_PATH*2]; LTSNPrintF( szDirectory, LTARRAYSIZE( szDirectory ), "%s*.txt", GameModeMgr::Instance( ).GetOptionsFolder( )); // Create the title of the default option file, which we won't show in the list. char szExample[MAX_PATH*2]; LTFileOperations::SplitPath( SERVEROPTIONS_EXAMPLE, NULL, szExample, NULL ); CResExtUtil::StripFileExtension( szExample, LTARRAYSIZE( szExample )); // find first file if( LTFileOperations::FindFirst( szDirectory, hFile, &file )) { do { CResExtUtil::StripFileExtension( file.name, LTARRAYSIZE( file.name )); if( !LTStrIEquals( szExample, file.name )) { const wchar_t* wszFriendlyName = CHostOptionsMapMgr::Instance().GetFriendlyNameFromFileName( file.name ); if( wszFriendlyName ) m_List.insert( wszFriendlyName ); else m_List.insert( MPA2W(file.name).c_str() ); } } while( LTFileOperations::FindNext( hFile, &file )); } LTFileOperations::FindClose( hFile ); CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(kDlgWd - 48,nListFontSz); cs.nCommandID = CMD_OK; // Get the current file title. wchar_t wszCurrentName[MAX_PATH*2]; CUserProfile* pProfile = g_pProfileMgr->GetCurrentProfile(); const wchar_t* wszFriendlyName = CHostOptionsMapMgr::Instance().GetFriendlyNameFromFileName( pProfile->m_sServerOptionsFile.c_str() ); if( wszFriendlyName ) LTStrCpy( wszCurrentName, wszFriendlyName, LTARRAYSIZE( wszCurrentName )); else LTStrCpy( wszCurrentName, MPA2W( pProfile->m_sServerOptionsFile.c_str( )).c_str( ), LTARRAYSIZE( wszCurrentName )); // add files to the list control for (WStringSet::iterator iter = m_List.begin(); iter != m_List.end(); ++iter) { CLTGUITextCtrl* pTextCtrl = NULL; uint16 ndx = 0; pTextCtrl = CreateTextItem(iter->c_str(), cs, false, sListFont.c_str(), nListFontSz); ndx = m_pListCtrl->AddControl(pTextCtrl); pTextCtrl->SetParam1(ndx); if( LTStrEquals( iter->c_str( ), wszCurrentName )) m_pListCtrl->SetSelection(ndx); } }
void CHUDScores::Update() { if( !m_bInitialized ) return; if( !m_bDraw ) return; // uint32 textCol = (m_bScreen ? m_cScreenTextColor : m_cTextColor); // uint32 playerTextCol = (m_bScreen ? m_cScreenPlayerTextColor : m_cPlayerTextColor); //for the screen mode scoreboard, don't update the text once we've drawn it if (m_bScreen && !m_bFirstScreenUpdate) return; m_bFirstScreenUpdate = false; if (GameModeMgr::Instance( ).m_grbUseTeams) { for( uint8 nTeamNum = 0; nTeamNum < kNumTeams; ++nTeamNum ) { uint8 team; if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(nTeamNum)) team = 0; else team = 1; CTeam* pTeam = CTeamMgr::Instance().GetTeam(nTeamNum); if (!pTeam) continue; wchar_t wszTmp[128]; LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d",pTeam->GetName(),pTeam->GetScore()); m_Team[team].SetString(wszTmp); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s : %d", LoadString("IDS_ROUNDS"), pTeam->GetRoundScore( )); m_Rounds[team].SetString(wszTmp); m_Header[team].Show(true); } } else { m_Team[0].SetString(L""); m_Rounds[0].SetString(L""); m_Header[1].Show(false); } m_Server.SetColor(m_cTextColor); if ( !GameModeMgr::Instance( ).m_grwsSessionName.GetValue().empty()) { std::wstring wstr = GameModeMgr::Instance( ).m_grwsSessionName; if ( g_pClientConnectionMgr->IsConnectedToRemoteServer( )) { wstr += L" : "; wstr += MPA2W(g_pClientConnectionMgr->GetStartGameRequest( ).m_TCPAddress).c_str(); } m_Server.SetString(wstr.c_str()); } else { m_Server.SetString(L""); } // Update the round counter. m_RoundInfo.SetColor(m_cTextColor); wchar_t wszRound[32]; uint8 nCurrentRound = g_pClientConnectionMgr ? g_pClientConnectionMgr->GetCurrentRound() : 0; uint8 nNumRounds = GameModeMgr::Instance( ).m_grnNumRounds; FormatString( "HUD_SCORES_ROUNDINFO", wszRound, LTARRAYSIZE( wszRound ), nCurrentRound + 1, nNumRounds ); m_RoundInfo.SetString( wszRound ); CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr(); if (!pCIMgr) return; CLIENT_INFO* pCI = pCIMgr->GetFirstClient(); int nTotal = 0; int count[kNumTeams] = {0,0}; wchar_t wszTmp[64] = L""; uint32 nHeight[kNumTeams]; nHeight[0] = m_Server.GetBaseHeight() + m_Header[0].GetBaseHeight() + m_Team[0].GetBaseHeight() + 24; nHeight[1] = m_Team[1].GetBaseHeight() + m_Header[1].GetBaseHeight() + 16; uint32 nLocalID = 0; g_pLTClient->GetLocalClientID (&nLocalID); while (pCI && (nTotal < kMaxPlayers)) { uint8 nTeam = 0; CCharacterFX* pCharacter = g_pGameClientShell->GetSFXMgr()->GetCharacterFromClientID(pCI->nID); if (GameModeMgr::Instance( ).m_grbUseTeams) { if (g_pInterfaceMgr->GetClientInfoMgr()->IsLocalTeam(pCI->nTeamID)) nTeam = 0; else nTeam = 1; } int ndx = count[nTeam]; if (nTeam < kNumTeams) { LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%s%s",pCI->sName.c_str( ), pCI->bIsAdmin ? L"[*]" : L"" ); m_Columns[nTeam][ndx].SetString( eColumnName, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetScore()); m_Columns[nTeam][ndx].SetString( eColumnScore, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eKill)); m_Columns[nTeam][ndx].SetString( eColumnKill, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eDeath)); m_Columns[nTeam][ndx].SetString( eColumnDeath, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eObjective)); m_Columns[nTeam][ndx].SetString( eColumnObjective, wszTmp ); if (GameModeMgr::Instance( ).m_grbUseTeams) { LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eTeamKill)); m_Columns[nTeam][ndx].SetString( eColumnTK, wszTmp ); m_Columns[nTeam][ndx].ShowColumn(eColumnTK, true); } else { m_Columns[nTeam][ndx].ShowColumn(eColumnTK, false); } LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->sScore.GetEventCount(CPlayerScore::eSuicide)); m_Columns[nTeam][ndx].SetString( eColumnSuicide, wszTmp ); LTSNPrintF(wszTmp,LTARRAYSIZE(wszTmp),L"%d",pCI->nPing); m_Columns[nTeam][ndx].SetString( eColumnPing, wszTmp ); if (nLocalID == pCI->nID) { if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating ) m_Columns[nTeam][ndx].SetColor(m_cPlayerDeadColor); else m_Columns[nTeam][ndx].SetColor(m_cPlayerTextColor); } else { if (!pCharacter || pCharacter->IsPlayerDead() || pCharacter->m_cs.bIsSpectating ) m_Columns[nTeam][ndx].SetColor(m_cDeadColor); else m_Columns[nTeam][ndx].SetColor(m_cTextColor); } m_Columns[nTeam][ndx].Show(true); nHeight[nTeam] += m_Columns[nTeam][ndx].GetBaseHeight(); } pCI = pCI->pNext; ++count[nTeam]; } for (uint8 team = 0; team < kNumTeams; team++) { m_Team[team].SetColor(m_cTextColor); m_Rounds[team].SetColor(m_cTextColor); m_Header[team].SetColor(m_cTextColor); nHeight[team] += 16; m_Frame[team].SetSize(LTVector2n(m_nFrameWidth,nHeight[team])); while (count[team] < kMaxPlayers) { m_Columns[team][count[team]].Show(false); ++count[team]; } LTVector2n pos = m_vBasePos; g_pInterfaceResMgr->ScaleScreenPos(pos); if (GameModeMgr::Instance( ).m_grbUseTeams && team > 0) { pos.y += nHeight[team-1] + 8; } UpdateTeamPos(team,pos); } m_SingleFrame.SetSize(LTVector2n(m_nFrameWidth,nHeight[0]+8)); }