void LoginCtrl::DoRememberPassword()
{
	GUIString aUserName = mUserNameCombo->GetText();
	GUIString aPassword;
	if(mRememberPasswordCheck->IsChecked())
		aPassword = mPasswordInput->GetText();

	if(aUserName.empty())
		return;

	LobbyPersistentData::AddUserInfo(aUserName, aPassword, true);
}
Exemple #2
0
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));
}
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 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);
	}
}
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;
}
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);
	}
}
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;
}