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 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"); } }
void LoginCtrl::DoRememberPassword() { GUIString aUserName = mUserNameCombo->GetText(); GUIString aPassword; if(mRememberPasswordCheck->IsChecked()) aPassword = mPasswordInput->GetText(); if(aUserName.empty()) return; LobbyPersistentData::AddUserInfo(aUserName, aPassword, true); }
bool ChatCommandParser::HandleInput(const GUIString &theInput) { mLastInputError = InputError_None; mLastTargetClient = NULL; mLastMatchName.erase(); if(mClientList.get()==NULL) { mLastInputError = InputError_NotLoggedIn; return false; } if(theInput.at(0)==mCommandChar) return HandleCommand(theInput); if(mDoColonEmote && theInput.at(0)==L':') { mLastChatCommand = LobbyChatCommand_Emote; mLastChat = theInput.substr(1); int aPos = 0; SkipWhitespace(mLastChat,aPos); if(aPos==mLastChat.length()) { mLastInputError = InputError_NoChat; return false; } // mServer->mConnection->SendChat(aChat,RoutingChatFlag_IsEmote,theGroupIdContext); return true; } mLastChatCommand = LobbyChatCommand_Broadcast; int aPos = 0; SkipWhitespace(theInput,aPos); if(aPos==theInput.length()) { mLastInputError = InputError_NoChat; return false; } mLastChat = theInput; // mServer->mConnection->SendChat(theInput,0,theGroupIdContext); return true; }
GUIString ChatCommandParser::GetRestOfLine(const GUIString &s1, int thePos) { SkipWhitespace(s1,thePos); if(thePos>=s1.length()) return ""; GUIString aWord; if(s1.at(thePos)=='"') { int anEndQuotePos = s1.find('"',thePos+1); if(anEndQuotePos>=0) { aWord = s1.substr(thePos+1,anEndQuotePos-thePos-1); return aWord; } } int aPos = s1.length()-1; while(aPos>thePos) { if(s1.at(aPos)!=' ') break; aPos--; } if(aPos>thePos) return s1.substr(thePos,aPos-thePos+1); else return ""; }
void LoginCtrl::CheckFillPassword() { LobbyConfig *aConfig = LobbyConfig::GetLobbyConfig(); if(aConfig!=NULL && aConfig->mIsPublic) // public computer -> (don't remember password) { mPasswordInput->Clear(); mRememberPasswordCheck->SetVisible(false); mRememberPasswordCheck->SetCheck(false); } else { GUIString aPassword = LobbyPersistentData::GetPassword(mUserNameCombo->GetText()); mPasswordInput->SetText(aPassword); mPasswordInput->SetSel(); mRememberPasswordCheck->SetCheck(!aPassword.empty()); mRememberPasswordCheck->SetVisible(true); } }
//---------------------------------------------------------------------------------- // 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); } }
bool ChatCommandParser::Compare(const GUIString &s1, const GUIString &s2, bool &partialMatch) { partialMatch = false; int i1 = 0, i2 = 0; int len1 = s1.length(), len2 = s2.length(); while(i1<len1 && i2<len2) { if (towupper(s1.at(i1)) != towupper(s2.at(i2))) return false; i1++; i2++; } if(len1<=len2) partialMatch = true; return len1==len2; }
void ChatCommandParser::AddCommandString(const GUIString &theStr, LobbyChatCommand theCommand) { if(theStr.empty()) return; GUIString aStr = theStr; mCommandStringMap[aStr] = theCommand; PreferredCommandStringMap::const_iterator anItr = mPreferredCommandStringMap.find(theCommand); if (anItr == mPreferredCommandStringMap.end()) mPreferredCommandStringMap.insert(PreferredCommandStringMap::value_type(theCommand,theStr)); }
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"); }
bool BrowserComponentConfig::HandleInstruction(const std::string& theInstruction) { if(theInstruction=="TRANSPARENT") { bool transparent = ReadBool(); mBrowserComponent->GetHTMLView()->SetComponentFlags(ComponentFlag_GrabBG,transparent); if(transparent) mBrowserComponent->SetBackground(COLOR_INVALID); else mBrowserComponent->RemoveBackground(); } else if(theInstruction=="BACKGROUND") mBrowserComponent->SetBackground(ReadBackground()); else if(theInstruction=="SCROLLER") mBrowserComponent->SetScroller(SafeConfigGetComponent<Scroller*>(ReadComponent(),"Scroller")); else if(theInstruction=="FONTSIZE") { HTMLFontSize aSize; GUIString aSizeStr = ReadString(); if(aSizeStr.compareNoCase("Smallest")==0) aSize = HTMLFontSize_Smallest; else if(aSizeStr.compareNoCase("Small")==0) aSize = HTMLFontSize_Small; else if(aSizeStr.compareNoCase("Medium")==0) aSize = HTMLFontSize_Medium; else if(aSizeStr.compareNoCase("Large")==0) aSize = HTMLFontSize_Large; else if(aSizeStr.compareNoCase("Largest")==0) aSize = HTMLFontSize_Largest; else throw ConfigObjectException("Invalid font size: " + (std::string)aSizeStr); mBrowserComponent->SetFontSize(aSize); } else return ContainerConfig::HandleInstruction(theInstruction); return true; }
//---------------------------------------------------------------------------------- // 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. }
GUIString LobbyGame::GetStatusString(short theStatus) { switch(theStatus) { case LobbyGameStatus_Success: return LobbyGameStatus_Success_String; case LobbyGameStatus_GameFull: return LobbyGameStatus_GameFull_String; case LobbyGameStatus_GameInProgress: return LobbyGameStatus_GameInProgress_String; case LobbyGameStatus_UnpackFailure: return LobbyGameStatus_UnpackFailure_String; case LobbyGameStatus_NotInvited: return LobbyGameStatus_NotInvited_String; case LobbyGameStatus_CaptainRejectedYou: return LobbyGameStatus_CaptainRejectedYou_String; case LobbyGameStatus_InvalidPassword: return LobbyGameStatus_InvalidPassword_String; case LobbyGameStatus_DuplicateName: return LobbyGameStatus_DuplicateName_String; } GUIString aString = GetStatusStringHook(theStatus); if(!aString.empty()) return aString; char aBuf[50]; sprintf(aBuf,"%d",theStatus); return aBuf; }
bool ContainerConfig::HandleNoOverlapLayout() { Component *target = ReadComponent(); EnsureComma(); int instructions = 0; while(true) { GUIString aStr = ReadString(true); if(aStr.empty()) break; if(aStr.compareNoCase("Above")==0) instructions |= CLI_Above; else if(aStr.compareNoCase("Below")==0) instructions |= CLI_Below; else if(aStr.compareNoCase("Right")==0) instructions |= CLI_Right; else if(aStr.compareNoCase("Left")==0) instructions |= CLI_Left; else throw ConfigObjectException("Unknown no overlap instruction: " + (std::string)aStr); } EnsureComma(); Component *ref = ReadComponent(); EnsureComma(); int horzPad, vertPad; horzPad = ReadInt(); EnsureComma(); vertPad = ReadInt(); NoOverlapLayoutPtr aLayout = new NoOverlapLayout(target,instructions,ref,horzPad,vertPad); while(!EndOfString()) { EnsureComma(); Component *aComponent = ReadComponent(); aLayout->Add(aComponent); } mContainer->AddChildLayout(aLayout); return true; }
Splitter::QuadrantPosition SplitterConfig::ReadQuadrant() { GUIString aStr = ReadString(); if(aStr.compareNoCase("Left")==0) return Splitter::Position_Left; else if(aStr.compareNoCase("Right")==0) return Splitter::Position_Right; else if(aStr.compareNoCase("Top")==0) return Splitter::Position_Top; else if(aStr.compareNoCase("Bottom")==0) return Splitter::Position_Bottom; else if(aStr.compareNoCase("TopLeft")==0) return Splitter::Position_TopLeft; else if(aStr.compareNoCase("TopRight")==0) return Splitter::Position_TopRight; else if(aStr.compareNoCase("BottomLeft")==0) return Splitter::Position_BottomLeft; else if(aStr.compareNoCase("BottomRight")==0) return Splitter::Position_BottomRight; else throw ConfigObjectException("Invalid quadrant: " + (std::string)aStr); }
Splitter::SplitterType SplitterConfig::ReadSplitterType() { GUIString aStr = ReadString(); if(aStr.compareNoCase("LeftRight")==0) return Splitter::Splitter_LeftRight; else if(aStr.compareNoCase("UpDown")==0) return Splitter::Splitter_UpDown; else if(aStr.compareNoCase("LeftRight_Top")==0) return Splitter::Splitter_LeftRight_Top; else if(aStr.compareNoCase("LeftRight_Bottom")==0) return Splitter::Splitter_LeftRight_Bottom; else if(aStr.compareNoCase("UpDown_Left")==0) return Splitter::Splitter_UpDown_Left; else if(aStr.compareNoCase("UpDown_Right")==0) return Splitter::Splitter_UpDown_Right; else if(aStr.compareNoCase("Center")==0) return Splitter::Splitter_Center; else throw ConfigObjectException("Invalid splitter type: " + (std::string)aStr); }
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; }
bool FontConfig::HandleInstruction(const std::string &theInstruction) { if(theInstruction=="SRC") SetFont(ReadFont()); else if(theInstruction=="SIZE") { mNeedRecalcFont = true; mDescriptor.mSize = ReadInt(); } else if(theInstruction=="STYLE") { while(true) { mNeedRecalcFont = true; bool add = true; GUIString aStr = ReadFlag(&add); if(aStr.empty()) break; int aStyle = 0; if(aStr.compareNoCase("Bold")==0) aStyle = FontStyle_Bold; else if(aStr.compareNoCase("Italic")==0) aStyle = FontStyle_Italic; else if(aStr.compareNoCase("Plain")==0) aStyle = FontStyle_Plain; else if(aStr.compareNoCase("Underline")==0) aStyle = FontStyle_Underline; else throw ConfigObjectException("Unknown font style: " + (std::string)aStr); if(add) mDescriptor.mStyle |= aStyle; else mDescriptor.mStyle &= ~aStyle; } } else if(theInstruction=="SETDEFAULTFONT") WindowManager::GetDefaultWindowManager()->SetDefaultFont(ReadFont()); else if(theInstruction=="SETNAMEDFONT") { GUIString aName = ReadString(); EnsureComma(); FontPtr aFont = ReadFont(); WindowManager::GetDefaultWindowManager()->SetNamedFont(aName,aFont); } else return false; return true; }
void TextArea::AddFormatedText(const GUIString &theText, bool lineBreak) { int aStartPos = 0; int anEndPos = 0; int aNextStartPos = 0; while(aStartPos < theText.length()) { int anEndPos = aStartPos; while(anEndPos < theText.length()) // find "\r", "\r\n", or "\n" { int aChar = theText.at(anEndPos); if(aChar=='\r') { if(anEndPos+1 < theText.length() && theText.at(anEndPos+1)=='\n') aNextStartPos = anEndPos + 2; else aNextStartPos = anEndPos + 1; break; } else if(aChar=='\n') { aNextStartPos = anEndPos + 1; break; } anEndPos++; } bool foundReturn = true; if(anEndPos>=theText.length()) { aNextStartPos = theText.length(); // Force it to exit next pass. foundReturn = lineBreak; } AddSegment(theText.substr(aStartPos,anEndPos-aStartPos),foundReturn); aStartPos = aNextStartPos; } }
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); } }
void UpdateResource_UnloadResources() { Global_Yes_String.erase(); Global_No_String.erase(); Global_Ok_String.erase(); Global_Cancel_String.erase(); Global_Close_String.erase(); Global_BadHelpExe_String.erase(); Global_WrongSize_String.erase(); Global_InvalidChecksum_String.erase(); Global_InvalidPatch_String.erase(); Global_Validation_String.erase(); Global_Validating_String.erase(); Global_DownloadFailures_String.erase(); Global_DownloadAborts_String.erase(); Global_NoStringRes_String.erase(); Global_MenuAbout_String.erase(); Global_ParamErrTitle_String.erase(); Global_CfgFileTooBig_String.erase(); Global_NoReadCfgFile_String.erase(); Global_NoOpenCfgFile_String.erase(); Global_PatcherDispName_String.erase(); Global_BadHelpFile_String.erase(); Global_BadResFile_String.erase(); Global_UnknownParam_String.erase(); Global_PrUnknown_String.erase(); Global_PrUpToDate_String.erase(); Global_PrPatchFound_String.erase(); Global_PrPatchFetched_String.erase(); Global_PrUserAbort_String.erase(); Global_PrNoServerConnection_String.erase(); Global_PrNoHostList_String.erase(); Global_PrNoDownload_String.erase(); Global_NoMonitor_String.erase(); Global_PsUndetermined_String.erase(); Global_NoFindPatch_String.erase(); Global_NoRunPatch_String.erase(); Global_PatchFailed_String.erase(); Global_PrepPatcher_String.erase(); Global_CheckingForThePatch_String.erase(); Global_VerCheckFailed_String.erase(); Global_PatchFound_String.erase(); Global_NoRetrievePatch_String.erase(); Global_Applying_String.erase(); Global_AnotherPatch_String.erase(); Global_PatchApplied_String.erase(); Global_LaunchingExe_String.erase(); Global_CheckingMotd_String.erase(); Global_CheckingForMotd_String.erase(); Global_UpToDate_String.erase(); Global_PatcherInfoTitle_String.erase(); Global_VersionFileCheckFailed_String.erase(); Global_PatchReturnedError_String.erase(); Global_CheckConnection_String.erase(); Global_TimeOut_String.erase(); Global_SkipMotd_String.erase(); Global_Warning_String.erase(); Global_IncompletePatch_String.erase(); Global_SelfUpToDate_String.erase(); Global_CheckingSelfForPatch_String.erase(); Global_CloseForSelfPatch_String.erase(); Global_SelfNoHostList_String.erase(); Global_NoFindRestarter_String.erase(); Global_NoRunRestarter_String.erase(); Global_RestarterFailed_String.erase(); Global_SierraUpdate_String.erase(); Global_SelfUpdateLang_String.erase(); Global_NoWritePsapi_String.erase(); Global_NoWriteRestarter_String.erase(); Global_Error_String.erase(); Global_Host_String.erase(); Global_Bytes_String.erase(); Global_KiloBytes_String.erase(); Global_MegaBytes_String.erase(); Global_PrOptionalPatch_String.erase(); Global_PrManualDownload_String.erase(); Global_OptionalPatchFound_String.erase(); Global_PossiblePatch_String.erase(); Global_CheckForPossiblePatch_String.erase(); Global_NoPatchUrl_String.erase(); Global_LocalPatchDoesNotMatch_String.erase(); Global_CheckConection_String.erase(); Global_CheckConectionTitle_String.erase(); Global_Success_String.erase(); Global_MotdSkipped_String.erase(); Global_MotdNotFound_String.erase(); Global_GameMotdNotFound_String.erase(); Global_MotdError_String.erase(); Global_NoNewMotd_String.erase(); Global_PatchRequired_String.erase(); Global_OptionalPatch_String.erase(); Global_PartialDirServerFailure_String.erase(); Global_DirServerFailure_String.erase(); Global_BadVersionNoUpdate_String.erase(); Global_SierraUpBadVersionNoUpdate_String.erase(); Global_PatchServerError_String.erase(); Global_UpdateServerTimedOut_String.erase(); Global_NoConfigFile_String.erase(); Global_GameLogo_Image = NULL; Global_MpsLogo_Image = NULL; SelectHost_Title_String.erase(); SelectHost_Info1_String.erase(); SelectHost_Info2_String.erase(); SelectHost_Info3_String.erase(); SelectHost_Info4_String.erase(); SelectHost_Info5_String.erase(); SelectHost_Info6_String.erase(); SelectHost_ConfigProxy_String.erase(); SelectHost_Help_String.erase(); SelectHost_Next_String.erase(); SelectHost_HavePatch_String.erase(); SelectHost_PatchFilter_String.erase(); SelectHost_InfoManual_String.erase(); SelectHost_Back_String.erase(); SelectHost_FileOpenDlgTitle_String.erase(); SelectHost_HostTitle_String.erase(); SelectHost_Results_String.erase(); SelectHost_WaitInfo1_String.erase(); SelectHost_WaitInfo2_String.erase(); SelectHost_WaitInfo3_String.erase(); SelectHost_WaitInfo4_String.erase(); SelectHost_WaitInfo5_String.erase(); SelectHost_WaitInfo6_String.erase(); ConfigProxy_Title_String.erase(); ConfigProxy_Info1_String.erase(); ConfigProxy_Info2_String.erase(); ConfigProxy_Info3_String.erase(); ConfigProxy_Info4_String.erase(); ConfigProxy_Info5_String.erase(); ConfigProxy_Info6_String.erase(); ConfigProxy_UseProxy_String.erase(); ConfigProxy_Host_String.erase(); ConfigProxy_Port_String.erase(); ConfigProxy_Help_String.erase(); Download_Title_String.erase(); Download_Info1_String.erase(); Download_Info2_String.erase(); Download_Info3_String.erase(); Download_Info4_String.erase(); Download_Info5_String.erase(); Download_Info6_String.erase(); Download_Host_String.erase(); Download_Progress_String.erase(); Download_Preparing_String.erase(); Download_Estimating_String.erase(); Download_Help_String.erase(); Download_Back_String.erase(); Download_VisitHost_String.erase(); Download_HostedBy_String.erase(); Download_BytesTransferred_String.erase(); Download_ConnectionRefused_String.erase(); Download_InvalidHttpHeader_String.erase(); Download_InvalidHttpRedirect_String.erase(); Download_TooManyHttpRedirects_String.erase(); Download_DownloadError_String.erase(); Download_UnknownHttpError_String.erase(); Download_HttpError_String.erase(); Download_Http404Error_String.erase(); Download_Confirm_String.erase(); Download_AbandonDownload_String.erase(); Download_AbortPatch_String.erase(); Download_UnknownFtpError_String.erase(); Download_FtpError_String.erase(); Download_InvalidFtpResp_String.erase(); Download_InvalidFtpPasvResp_String.erase(); Download_NoData_String.erase(); Download_InvalidFtpFile_String.erase(); Download_InvalidFtpUser_String.erase(); Download_InvalidFtpPassword_String.erase(); Download_TimeHoursMinutes_String.erase(); Download_TimeHourMinutes_String.erase(); Download_TimeMinutesSeconds_String.erase(); Download_TimeMinuteSeconds_String.erase(); Download_TimeSeconds_String.erase(); Download_Http421Error_String.erase(); Download_Next_String.erase(); Download_UnableToFindHost_String.erase(); Download_NoHostUrl_String.erase(); Dialog_AbortDlgAbort_String.erase(); Dialog_BaseBackground_Background = Background(); Welcome_Continue_String.erase(); Welcome_Cancel_String.erase(); Welcome_ConfigProxy_String.erase(); Welcome_Help_String.erase(); Welcome_Info1_String.erase(); Welcome_Info2_String.erase(); Welcome_Info3_String.erase(); Welcome_Info4_String.erase(); Welcome_Info5_String.erase(); Welcome_Info6_String.erase(); Welcome_Title_String.erase(); About_Version_String.erase(); About_Copyright_String.erase(); About_Title_String.erase(); Motd_SystemTitle_String.erase(); Motd_ProductTitle_String.erase(); Motd_Info1_String.erase(); Motd_Info2_String.erase(); Motd_Info3_String.erase(); Motd_Info4_String.erase(); Motd_Info5_String.erase(); Motd_Info6_String.erase(); Motd_Help_String.erase(); Motd_Back_String.erase(); Motd_Next_String.erase(); Motd_Skip_String.erase(); Motd_Title_String.erase(); VisitHost_Title_String.erase(); VisitHost_Info1_String.erase(); VisitHost_Info2_String.erase(); VisitHost_Info3_String.erase(); VisitHost_Info4_String.erase(); VisitHost_Info5_String.erase(); VisitHost_Info6_String.erase(); VisitHost_Help_String.erase(); VisitHost_Back_String.erase(); VisitHost_Next_String.erase(); OptionalPatch_Title_String.erase(); OptionalPatch_Info1_String.erase(); OptionalPatch_Info2_String.erase(); OptionalPatch_Info3_String.erase(); OptionalPatch_Info4_String.erase(); OptionalPatch_Info5_String.erase(); OptionalPatch_Info6_String.erase(); OptionalPatch_ViewDetails_String.erase(); OptionalPatch_Help_String.erase(); OptionalPatch_Next_String.erase(); OptionalPatch_BadDescExe_String.erase(); OptionalPatch_DescTitle_String.erase(); OptionalPatch_FetchingDesc_String.erase(); OptionalPatch_TimedOut_String.erase(); OptionalPatch_DownloadFailed_String.erase(); OptionalPatch_Back_String.erase(); PatchDetails_Title_String.erase(); PatchDetails_Info1_String.erase(); PatchDetails_Info2_String.erase(); PatchDetails_Info3_String.erase(); PatchDetails_Info4_String.erase(); PatchDetails_Info5_String.erase(); PatchDetails_Info6_String.erase(); PatchDetails_Help_String.erase(); PatchDetails_Back_String.erase(); PatchDetails_Next_String.erase(); PatchDetails_FileTooBig_String.erase(); PatchDetails_FileTooBigTtl_String.erase(); VersionCheck_Title_String.erase(); VersionCheck_Info1_String.erase(); VersionCheck_Info2_String.erase(); VersionCheck_Info3_String.erase(); VersionCheck_Info4_String.erase(); VersionCheck_Info5_String.erase(); VersionCheck_Info6_String.erase(); VersionCheck_Help_String.erase(); VersionCheck_Next_String.erase(); VersionCheck_Back_String.erase(); VersionCheck_OkToGoBack_String.erase(); VersionCheck_StatusPleaseWait_String.erase(); VersionCheck_StatusErrorFound_String.erase(); VersionCheck_StatusFinished_String.erase(); VersionCheck_DNSTestStarted_String.erase(); VersionCheck_MotdLookupStarted_String.erase(); VersionCheck_ServerLookupStarted_String.erase(); VersionCheck_SelfVersionCheckStarted_String.erase(); VersionCheck_GameVersionCheckStarted_String.erase(); VersionCheck_UpToDate_String.erase(); VersionCheck_Finish_String.erase(); VersionCheck_CheckingForPatch_String.erase(); VersionCheck_AbortTitle_String.erase(); VersionCheck_Visit_String.erase(); Login_Title_String.erase(); Login_Info_String.erase(); Login_Name_String.erase(); Login_Password_String.erase(); Login_Ok_String.erase(); }
bool ContainerConfig::HandleLayout(bool chain, bool repeat) { Component *target = ReadComponent(); int instructions = 0; Component *ref; if(!chain && !repeat) { EnsureComma(); while(true) { GUIString aStr = ReadString(true); if(aStr.empty()) break; if(aStr.compareNoCase("SameWidth")==0) instructions |= CLI_SameWidth; else if(aStr.compareNoCase("SameHeight")==0) instructions |= CLI_SameHeight; else if(aStr.compareNoCase("Above")==0) instructions |= CLI_Above; else if(aStr.compareNoCase("Below")==0) instructions |= CLI_Below; else if(aStr.compareNoCase("Right")==0) instructions |= CLI_Right; else if(aStr.compareNoCase("Left")==0) instructions |= CLI_Left; else if(aStr.compareNoCase("SameLeft")==0) instructions |= CLI_SameLeft; else if(aStr.compareNoCase("SameRight")==0) instructions |= CLI_SameRight; else if(aStr.compareNoCase("SameTop")==0) instructions |= CLI_SameTop; else if(aStr.compareNoCase("SameBottom")==0) instructions |= CLI_SameBottom; else if(aStr.compareNoCase("GrowToRight")==0) instructions |= CLI_GrowToRight; else if(aStr.compareNoCase("GrowToLeft")==0) instructions |= CLI_GrowToLeft; else if(aStr.compareNoCase("GrowToTop")==0) instructions |= CLI_GrowToTop; else if(aStr.compareNoCase("GrowToBottom")==0) instructions |= CLI_GrowToBottom; else if(aStr.compareNoCase("SameSize")==0) instructions |= CLI_SameSize; else throw ConfigObjectException("Unknown layout instruction: " + (std::string)aStr); } } else instructions = mLayoutInstruction; if(chain || (repeat && EndOfString())) { if(mLayoutRef==NULL) throw ConfigObjectException("Invalid LayoutChain"); ref = mLayoutRef; } else { EnsureComma(); ref = ReadComponent(); } if(!EndOfString()) EnsureComma(); for(int i=0; i<4; i++) { if(EndOfString()) break; mLayoutParams[i] = ReadInt(); if(!EndOfString()) EnsureComma(); } if((!chain && !repeat) || i!=0) { for(; i<4; i++) mLayoutParams[i] = 0; } mContainer->AddChildLayout(target,instructions,ref,mLayoutParams[0],mLayoutParams[1], mLayoutParams[2],mLayoutParams[3],mCurLayoutId); if(repeat) mLayoutRef = ref; else mLayoutRef = target; mLayoutInstruction = instructions; return true; }
void HTMLDocumentGen::printf(const GUIString &theText) { int aStartPos = 0; while(true) { int anEndPos = theText.find('%',aStartPos); if(anEndPos<0) break; if(theText.at(anEndPos+1)=='%') { anEndPos++; AddDoc(theText.substr(aStartPos,anEndPos-aStartPos),HTMLDocGenFlag_IsHTML); aStartPos = anEndPos+1; continue; } AddDoc(theText.substr(aStartPos,anEndPos-aStartPos),HTMLDocGenFlag_IsHTML); anEndPos++; aStartPos = anEndPos; while(anEndPos<theText.length() && theText.at(anEndPos)!='%') anEndPos++; GUIString aNumber = theText.substr(aStartPos,anEndPos-aStartPos); int aParamNum = aNumber.atoi()-1; if(aParamNum>=0 && aParamNum<mDocumentVector.size()) mDocument->AddDocument(mDocumentVector[aParamNum]); aStartPos = anEndPos+1; if(aStartPos>=theText.length()) break; } if(aStartPos<theText.length()) AddDoc(theText.substr(aStartPos),HTMLDocGenFlag_IsHTML); }
void ChatCommandParser::SkipWhitespace(const GUIString &s1, int &thePos) { while(thePos<s1.length() && iswspace(s1.at(thePos))) thePos++; }
//---------------------------------------------------------------------------------- // 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"); }
bool ChatCommandParser::HandleCommand(const GUIString &theInput) { int aPos = 1; GUIString aCommand = GetWord(theInput,aPos,true,false); CommandStringMap::iterator anItr = mCommandStringMap.find(aCommand); if(anItr==mCommandStringMap.end()) { mLastChatCommand = LobbyChatCommand_None; mLastInputError = InputError_InvalidCommand; return false; } mLastChatCommand = anItr->second; // Extract name if needed bool needName = false; switch(mLastChatCommand) { case LobbyChatCommand_Reply: mLastMatchName = mLastWhisperClientName; needName = true; break; case LobbyChatCommand_Ignore: mLastMatchName = GetRestOfLine(theInput,aPos); needName = (! mLastMatchName.empty()); break; case LobbyChatCommand_Block: mLastMatchName = GetRestOfLine(theInput,aPos); needName = true; break; case LobbyChatCommand_Unmute: case LobbyChatCommand_ServerUnmute: mLastMatchName = GetRestOfLine(theInput,aPos); if(!mLastMatchName.empty()) needName = true; break; case LobbyChatCommand_Warn: case LobbyChatCommand_Whisper: case LobbyChatCommand_Mute: case LobbyChatCommand_ServerMute: case LobbyChatCommand_Ban: case LobbyChatCommand_ServerBan: case LobbyChatCommand_Invite: case LobbyChatCommand_Uninvite: mLastMatchName = GetWord(theInput,aPos,false,true); needName = true; break; } // Find corresponding client/member if(needName) { if(mLastMatchName.empty()) { mLastInputError = InputError_RequireName; return false; } MatchResult aResult; mLastTargetClient = GetClientByName(mLastMatchName, &aResult); if(aResult < mMatchTolerance) { if(aResult==MatchResult_Ambiguous) mLastInputError = InputError_ClientAmbiguous; else mLastInputError = InputError_ClientNotFound; return false; } } SkipWhitespace(theInput,aPos); switch(mLastChatCommand) { /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_Warn: case LobbyChatCommand_Whisper: case LobbyChatCommand_Alert: case LobbyChatCommand_Emote: { if(aPos>=theInput.length()) { mLastInputError = InputError_NoChat; return false; } mLastChat = theInput.substr(aPos); return true; } /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_Reply: { mLastChat = theInput.substr(aPos); if(!mLastChat.empty()) mLastChatCommand = LobbyChatCommand_Whisper; return true; } /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_BecomeModerator: case LobbyChatCommand_Help: case LobbyChatCommand_Ignore: case LobbyChatCommand_Away: case LobbyChatCommand_AbortShutdown: return true; /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_Invite: case LobbyChatCommand_Uninvite: { mLastChat = theInput.substr(aPos); mLastBool = mLastChatCommand==LobbyChatCommand_Invite; return true; } /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_Mute: case LobbyChatCommand_ServerMute: case LobbyChatCommand_Ban: case LobbyChatCommand_ServerBan: case LobbyChatCommand_StartShutdown: { DWORD aSeconds = 3600; // 1 hour std::string aTimeStr = GetWord(theInput,aPos,true,false); if(aTimeStr=="INFINITE") aSeconds = 0; else if(aTimeStr.length()>0) { char aUnitChar = aTimeStr[aTimeStr.length()-1]; if(isalpha(aUnitChar)) aTimeStr = aTimeStr.substr(0,aTimeStr.length()-1); aSeconds = atoi(aTimeStr.c_str()); switch(aUnitChar) { case 'D': aSeconds*=24; case 'H': aSeconds*=60; case 'M': aSeconds*=60; case 'S': break; default: mLastInputError = InputError_BadTime; return false; } if(aSeconds==0) { mLastInputError = InputError_BadTime; return false; } } mLastInputDuration = aSeconds; mLastChat = GetRestOfLine(theInput,aPos); return true; } /////////////////////////////////////////// /////////////////////////////////////////// case LobbyChatCommand_Unmute: case LobbyChatCommand_ServerUnmute: { mLastChat = GetRestOfLine(theInput,aPos); return true; } } return true; }
//---------------------------------------------------------------------------------- // UpdatePatchList: Update the list of patches (and results). //---------------------------------------------------------------------------------- void SelectHostCtrl::UpdatePatchList(void) { CustomInfo* pCustInfo = GetCustomInfo(); ResourceManager* pResMgr = pCustInfo->GetResourceManager(); GUIString sError; int nManualPatches = 0; int nAutoPatches = 0; // Clear the list box of old refuse. m_pHostList->Clear(); m_pHostList->BeginMultiChange(); GUIString sDefault = pCustInfo->LoadDefaultSelection(); sDefault.toLowerCase(); CPatchDataList* pPatches = pCustInfo->GetPatchList(); // Go through the list and decide if we have to mark manual downloads. CPatchDataList::iterator Itr = pPatches->begin(); while (Itr != pPatches->end()) { CPatchData* pData = *Itr; if (pData) { if (pData->GetMustVisitHost()) nManualPatches++; else nAutoPatches++; } ++Itr; } m_bMixedPatches = nManualPatches != 0 && nAutoPatches != 0; // Now go through the list and add all of the items to the list box. Itr = pPatches->begin(); int nIndex = 0; int nSelectIndex = -1; while (Itr != pPatches->end()) { CPatchData* pData = *Itr; //pData->MessageBox(GetWindow()); // Debugging Aide. if (pData) { // Start with the Patch Name (we will display this). std::string sLine = pData->GetPatchName(); // Add the Manual flag (if needed). if (pData->GetMustVisitHost() && m_bMixedPatches) sLine += " *"; // Now add the results of previous download atempts. int nFailures = pData->GetDownloadFailures(); int nAborts = pData->GetDownloadAborts(); if (nFailures) { sError = pResMgr->GetFinishedString(Global_DownloadFailures_String); ReplaceSubInt(sError, "%NUM_FAILURES%", nFailures); } else if (nAborts) { sError = pResMgr->GetFinishedString(Global_DownloadAborts_String); ReplaceSubInt(sError, "%NUM_ABORTS%", nAborts); } else sError = ""; PatchDataItem* pItem = static_cast<PatchDataItem*>(m_pHostList->InsertItem(new PatchDataItem)); m_pHostList->SetString(nIndex, 0, sLine); m_pHostList->SetString(nIndex, 1, sError); pItem->m_pPatchData = pData; // Check to see if this was the last 'successful download site', if so, select it. GUIString sHost = pData->GetHostName(); sHost.toLowerCase(); if (sDefault == sHost) nSelectIndex = nIndex; ++nIndex; } ++Itr; } // If no site was selected, choose one at random. if (nSelectIndex == -1 && nIndex > 0) { srand(GetTickCount()); nSelectIndex = rand() % nIndex; } // Actually make the selection. if (nSelectIndex != -1) m_pHostList->SetSelItem(nSelectIndex); m_pHostList->EndMultiChange(); // Changing the patch list can change the Info Text, so update it. UpdateInfoText(); EnableControls(); }
void ChatCommandParser::AddCommandToHelpText(LobbyChatCommand theCommand, const GUIString &theDescription, GUIString &theHelpText) { theHelpText.append(theDescription); theHelpText.append("<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; }