void TextImage::GetSelText(TextArea *theTextArea, GUIString &theStr) { if(theTextArea->mSelStartChar<=mAbsStartChar && theTextArea->mSelEndChar>=mAbsEndChar) { theStr.append(mText); if(mLineBreak && theTextArea->mSelEndChar>mAbsEndChar) theStr.append("\r\n"); } }
static GUIString Unencrypt(char* sEncryptedString) { GUIString sString; for (int i = 0; i < strlen(sEncryptedString); i++) sString.append((char)(((int)sEncryptedString[i]) - 0x70)); return sString; }
void TextSegment::GetSelText(TextArea *theTextArea, GUIString &theStr) { int aSelStartChar = theTextArea->mSelStartChar; int aSelEndChar = theTextArea->mSelEndChar; if(mAbsStartChar > aSelStartChar) aSelStartChar = mAbsStartChar; if(mAbsEndChar < aSelEndChar) aSelEndChar = mAbsEndChar; if(aSelStartChar >= aSelEndChar) return; aSelStartChar -= mAbsStartChar; aSelEndChar -= mAbsStartChar; theStr.append(mText, aSelStartChar, aSelEndChar-aSelStartChar); if(mLineBreak && theTextArea->mSelEndChar>mAbsEndChar) theStr.append("\r\n"); }
//---------------------------------------------------------------------------------- // UpdateInfoText: Update the contents of the info text box. //---------------------------------------------------------------------------------- void SelectHostCtrl::UpdateInfoText(void) { // Some of the text changes dynamically based on patch selection, update it. ResourceManager* pResMgr = GetCustomInfo()->GetResourceManager(); GUIString sInfo = pResMgr->BuildInfoString(SelectHost_WaitInfo1_String_Id); if (GetCustomInfo()->GetPatchList()->size()) { sInfo = pResMgr->BuildInfoString(SelectHost_Info1_String_Id); if (m_bMixedPatches) { sInfo.append("\n\n"); sInfo.append(pResMgr->GetFinishedString(SelectHost_InfoManual_String)); } } m_pInfoText->Clear(); m_pInfoText->AddFormatedText(sInfo); m_pInfoText->SetVertOffset(0); // Scroll to the top. }
//---------------------------------------------------------------------------------- // InitComponent: Initialize all of the sub-controls. //---------------------------------------------------------------------------------- void AboutDlg::InitComponent(ComponentInit &theInit) { Dialog::InitComponent(theInit); if(theInit.mType==ComponentInitType_ComponentConfig) { ComponentConfigInit &anInit = (ComponentConfigInit&)theInit; ComponentConfig *aConfig = anInit.mConfig; SafeGetRequiredComponent(aConfig,m_pVersionLabel,"VersionLabel"); SafeGetRequiredComponent(aConfig,m_pCopyrightLabel,"CopyrightLabel"); SafeGetRequiredComponent(aConfig,m_pCloseButton,"CloseButton"); GUIString sVersion = m_pVersionLabel->GetText(); sVersion.append(m_sVersion); m_pVersionLabel->SetText(sVersion); SetEndOnEscape(1); } }
GUIString ChatCommandParser::GetWord(const GUIString &s1, int &thePos, bool doToUpper, bool checkQuotes) { SkipWhitespace(s1,thePos); if(thePos>=s1.length()) return ""; GUIString aWord; if(checkQuotes && s1.at(thePos)=='"') { int anEndQuotePos = s1.find('"',thePos+1); if(anEndQuotePos>=0) { aWord = s1.substr(thePos+1,anEndQuotePos-thePos-1); thePos = anEndQuotePos+1; if(doToUpper) aWord.toUpperCase(); return aWord; } } while(thePos<s1.length()) { wchar_t aChar = s1.at(thePos); if(doToUpper) aChar = towupper(aChar); if(aChar==' ') return aWord; aWord.append(aChar); thePos++; } return aWord; }
void InitLogic::GetTitanServersCompletion(AsyncOp *theOp) { ServerContext *anAccountServers = LobbyMisc::GetAccountServers(); ServerContext *anAuthServers = LobbyMisc::GetAuthServers(); ServerContext *aFirewallServers = LobbyMisc::GetFirewallDetectServers(); ServerContext *aPatchServers = LobbyMisc::GetPatchServers(); ServerContext *aDirServers = LobbyMisc::GetDirServers(); LobbyConfig *aConfig = LobbyConfig::GetLobbyConfig(); if(aConfig==NULL || anAccountServers==NULL || anAuthServers==NULL || aFirewallServers==NULL || aDirServers==NULL) return; GetMultiDirOp *anOp = (GetMultiDirOp*)theOp; if(anOp->Succeeded() || anOp->GetStatus()==WS_DirServ_MultiGetPartialFailure) { const GetEntityRequestList &aList = anOp->GetRequestList(); GetEntityRequestList::const_iterator anItr = aList.begin(); int aCount = 0; while(anItr!=aList.end()) { GetEntityRequest *aRequest = *anItr; if(aRequest->GetStatus()==WS_Success) { ServerContext *aContext = NULL; switch(aCount) { case 0: if(aConfig->mAuthServers.empty()) aContext = anAuthServers; break; case 1: aContext = anAccountServers; break; case 2: aContext = aFirewallServers; break; case 3: aContext = aPatchServers; break; } if(aContext!=NULL) aContext->AddAddressesFromDir(aRequest->GetDirEntityList()); } ++aCount; ++anItr; } if(anAuthServers->IsEmpty() || anAccountServers->IsEmpty() || aPatchServers->IsEmpty()) { aDirServers->NotifyFailed(anOp->GetCurAddr()); GUIString aList; int anInitErrorFlags = 0; if(anAuthServers->IsEmpty()) { aList.append(LobbyContainer_AuthServers_String); anInitErrorFlags |= InitErrorFlag_NoAuthServers; } if(anAccountServers->IsEmpty()) { if(!aList.empty()) aList.append(", "); aList.append(LobbyContainer_AccountServers_String); anInitErrorFlags |= InitErrorFlag_NoAccountServers; } if(aPatchServers->IsEmpty()) { if(!aList.empty()) aList.append(", "); aList.append(LobbyContainer_VersionServers_String); anInitErrorFlags |= InitErrorFlag_NoVersionServers; } GUIString aString = LobbyContainer_NoServers_String; aString.append(aList); if(SetLastInitError(anInitErrorFlags, aString)) return; } RunVersionOp(); RunDetectFirewallOp(); } else { GUIString aString = StringLocalize::GetStr(LobbyContainer_DirLookupFailure_String,FriendlyWONStatusToString(anOp->GetStatus())); SetLastInitError(InitErrorFlag_DirLookupFailed,aString); } }
//---------------------------------------------------------------------------------- // StartDownloads: Start the threads that will download the files. //---------------------------------------------------------------------------------- void DownloadCtrl::StartDownloads(void) { CustomInfo* pCustInfo = GetCustomInfo(); CPatchData* pPatch = pCustInfo->GetSelectedPatch(); if (pPatch) { #ifdef _DEBUG if (GetKeyState(VK_MENU) & GetKeyState(VK_CONTROL) & GetKeyState(VK_SHIFT) & 0x8000) pPatch->DebugBox(GetWindow()); #endif GUIString sPatchFile = pPatch->GetPatchUrl(); int nPos = sPatchFile.rFind('/'); if (nPos == -1) nPos = sPatchFile.rFind('\\'); if (nPos != -1) sPatchFile.erase(0, nPos + 1); else sPatchFile = TEXT("Update.exe"); std::string aHostGraphic = pPatch->GetHostBmp(); int aPos = aHostGraphic.find_last_of('.'); std::string aHostGraphicExtension; if(aPos != std::string::npos && aHostGraphic.length() > aPos + 1) aHostGraphicExtension = aHostGraphic.substr(aPos+1); else aHostGraphicExtension = "bmp"; m_sHostBitmapFile = GenerateTempFileName("FS", aHostGraphicExtension); CreateDirectoryRecursive(pCustInfo->GetPatchFolder()); GUIString sPatchExe = pCustInfo->GetPatchFolder(); sPatchExe.append(sPatchFile); pCustInfo->SetPatchFile(sPatchExe); mStartTime = time(NULL); mNumberCallbacks = 0; if (IsFtpAddress(pPatch->GetHostBmp())) { // Don't attempt to handle resumed downloads of bitmaps - not worth it. DeleteFile(std::string(m_sHostBitmapFile).c_str()); m_pFtpGetBitmap = new FTPGetOp(pPatch->GetHostBmp(), true); m_pFtpGetBitmap->SetLocalPath(m_sHostBitmapFile); m_pFtpGetBitmap->SetCompletion(new DownloadCompletion(FtpBitmapDoneCallback)); m_pFtpGetBitmap->RunAsync(static_cast<ULONG>(OP_TIMEOUT_INFINITE)); } else { m_pHttpGetBitmap = new HTTPGetOp(pPatch->GetHostBmp()); m_pHttpGetBitmap->SetLocalPath(m_sHostBitmapFile); m_pHttpGetBitmap->SetCompletion(new DownloadCompletion(HttpBitmapDoneCallback)); m_pHttpGetBitmap->RunAsync(static_cast<ULONG>(OP_TIMEOUT_INFINITE)); } // m_tDownloadStarted = GetTickCount(); m_nPrevDownloadedFtpBytes = 0; if (IsFtpAddress(pPatch->GetPatchUrl())) { // If the previous patch profile does not match this patch profile, nuke the file. if (! pCustInfo->MatchFtpDownloadTag(sPatchExe, pCustInfo->GetNewVersion(), pPatch->GetPatchSize(), pPatch->GetChecksum())) DeleteFile(std::string(sPatchExe).c_str()); else m_nPrevDownloadedFtpBytes = GetFileSize(sPatchExe); // Tag the patch's profile (so we can 'resume or not as appropriate later). pCustInfo->TagFtpDownload(sPatchExe, pCustInfo->GetNewVersion(), pPatch->GetPatchSize(), pPatch->GetChecksum()); m_pFtpGetPatch = new FTPGetOp(pPatch->GetPatchUrl(), true); m_pFtpGetPatch->SetDoResume(true); // Allow resuming of downloads. m_pFtpGetPatch->SetLocalPath(sPatchExe); m_pFtpGetPatch->SetRecvChunkCompletion(new DownloadCompletion(PatchProgressCallback), CHUNCK_SIZE); m_pFtpGetPatch->SetCompletion(new DownloadCompletion(FtpPatchDoneCallback)); m_pFtpGetPatch->RunAsync(static_cast<ULONG>(OP_TIMEOUT_INFINITE)); } else { m_pHttpGetPatch = new HTTPGetOp(pPatch->GetPatchUrl()); m_pHttpGetPatch->SetLocalPath(sPatchExe); m_pHttpGetPatch->SetRecvChunkCompletion(new DownloadCompletion(PatchProgressCallback), CHUNCK_SIZE); m_pHttpGetPatch->SetCompletion(new DownloadCompletion(HttpPatchDoneCallback)); m_pHttpGetPatch->RunAsync(static_cast<ULONG>(OP_TIMEOUT_INFINITE)); } m_bDownloadStarted = true; } }
void TextSegmentBase::GetSelText(TextArea *theTextArea, GUIString &theStr) { if(mLineBreak && theTextArea->mSelStartChar<=mAbsStartChar && theTextArea->mSelEndChar>mAbsEndChar) theStr.append("\r\n"); }
/////////////////////////////////////////////////////////////////////////////// // GetHelpText: Return a block of text that sums up the chat commands. /////////////////////////////////////////////////////////////////////////////// GUIString ChatCommandParser::GetHelpText(unsigned short myClientId) { bool isAdmin = false; bool isModerator = false; bool isCaptain = false; bool isGameCaptain = false; bool isLan = mRoomSpecFlags&LobbyRoomSpecFlag_Lan?true:false; if(mClientList.get()!=NULL) { LobbyClient *aClient = mClientList->GetClient(myClientId); if(aClient!=NULL) { isModerator = aClient->IsModerator(); isCaptain = aClient->IsCaptain(mRoomSpecFlags&LobbyRoomSpecFlag_Game?true:false); isGameCaptain = aClient->IsCaptain(true); isAdmin = aClient->IsAdmin(); } } GUIString aHelp = ChatCommandLogic_HelpHeader_String; aHelp.append("<n>"); AddCommandToHelpText(LobbyChatCommand_Help, ChatCommandLogic_HelpHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Whisper, ChatCommandLogic_WhisperHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Reply, ChatCommandLogic_ReplyHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Emote, ChatCommandLogic_EmoteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Ignore, ChatCommandLogic_IgnoreHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Clear, ChatCommandLogic_ClearHelp_String, aHelp); if(mRoomSpecFlags&LobbyRoomSpecFlag_Game) AddCommandToHelpText(LobbyChatCommand_ShowTeam, ChatCommandLogic_ShowTeamHelp_String, aHelp); if(!isLan) { AddCommandToHelpText(LobbyChatCommand_Block, ChatCommandLogic_BlockHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Away, ChatCommandLogic_AwayHelp_String, aHelp); if(isGameCaptain) { AddCommandToHelpText(LobbyChatCommand_Invite, ChatCommandLogic_InviteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Uninvite, ChatCommandLogic_UninviteHelp_String, aHelp); } if(isCaptain || isModerator) { AddCommandToHelpText(LobbyChatCommand_Mute, ChatCommandLogic_MuteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Unmute, ChatCommandLogic_UnmuteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Ban, ChatCommandLogic_BanHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Unban, ChatCommandLogic_UnbanHelp_String, aHelp); } if(isModerator) { AddCommandToHelpText(LobbyChatCommand_BecomeModerator, ChatCommandLogic_ModeratorHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_ServerMute, ChatCommandLogic_ServerMuteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_ServerUnmute, ChatCommandLogic_ServerUnmuteHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_ServerBan, ChatCommandLogic_ServerBanHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_ServerUnban, ChatCommandLogic_ServerUnbanHelp_String, aHelp); AddCommandToHelpText(LobbyChatCommand_Warn, ChatCommandLogic_WarnHelp_String, aHelp); } if(isAdmin) AddCommandToHelpText(LobbyChatCommand_Alert, ChatCommandLogic_AlertHelp_String, aHelp); } return aHelp; }
void ChatCommandParser::AddCommandToHelpText(LobbyChatCommand theCommand, const GUIString &theDescription, GUIString &theHelpText) { theHelpText.append(theDescription); theHelpText.append("<n>"); }