// ***************************************************************************
void CDBGroupListSheetTrade::checkCoords ()
{
	CDBGroupListSheetText::checkCoords();

	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();

	bool	mustUpdateCoords= false;

	// test each child to update each frame, if need to update text id
	for( set< CSheetChildTrade *>::iterator it = VendorNameIdToUpdate.begin(); it != VendorNameIdToUpdate.end(); )
	{
		CSheetChildTrade * cst = (*it);
		// String result
		ucstring result;
		if( pSMC->getString ( cst->LastVendorNameId, result) )
		{
			cst->VendorNameString = CEntityCL::removeShardFromName(result);
			set< CSheetChildTrade *>::iterator itTmp = it;
			++it;
			VendorNameIdToUpdate.erase(itTmp);
			cst->NeedUpdateText= true;
			mustUpdateCoords= true;
		}
		else
		{
			++it;
		}
	}

	// invalidate coords if one of the child need it
	if(mustUpdateCoords)
		invalidateCoords();
}
Esempio n. 2
0
// ***************************************************************************
void CEncyclopediaManager::rebuildAlbumPage(uint32 albumName)
{
	uint32 i;
	CEncyMsgAlbum *pAlbum = NULL;
	// Select the right album
	for (i = 0; i < _Albums.size(); ++i)
	{
		if (_Albums[i].Name == albumName)
		{
			_AlbumNameSelected = _Albums[i].Name;
			pAlbum = &_Albums[i];
			break;
		}
	}

	if (pAlbum == NULL)
		return;

	// Update the right page
	CInterfaceManager *pIM = CInterfaceManager::getInstance();

	// Hide and show good group
	CInterfaceElement *pIE = pIM->getElementFromId(PAGE_ENCY_ALBUM);
	nlassert(pIE != NULL);
	pIE->setActive(true);
	pIE = pIM->getElementFromId(PAGE_ENCY_HELP);
	pIE->setActive(false);
	pIE = pIM->getElementFromId(PAGE_ENCY_THEMA);
	pIE->setActive(false);

	// Setup title
	CViewTextID *pVT = dynamic_cast<CViewTextID*>(pIM->getElementFromId(PAGE_ENCY_ALBUM ":title"));
	nlassert(pVT != NULL);
	pVT->setTextId(pAlbum->Name);

	// Setup brick reward
	pIM->getDbProp("UI:VARIABLES:ENCY:ALBUMBRICK:SHEET")->setValue32(pAlbum->RewardBrick);
	CViewText *pRBVT = dynamic_cast<CViewText*>(pIM->getElementFromId(PAGE_ENCY_ALBUM ":reward:desc"));
	if (pRBVT != NULL)
	{
		STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
		const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pAlbum->RewardBrick)));
		pRBVT->setText(desc);
	}
}
Esempio n. 3
0
// ***************************************************************************
// For the group tree we have to check the incoming phrase because no view id stored
bool CEncyclopediaManager::isStringWaiting()
{
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();

	for (uint32 i = 0; i < _Albums.size(); ++i)
	{
		ucstring res;
		if (!pSMC->getDynString(_Albums[i].Name, res))
			return true;
		for (uint32 j = 0; j < _Albums[i].Themas.size(); ++j)
		{
			if (!pSMC->getDynString(_Albums[i].Themas[j].Name, res))
				return true;
		}
	}

	return false;
}
// ***************************************************************************
static DECLARE_INTERFACE_USER_FCT(getSquadDesc)
{
	if(args.size()!=1)
	{
		nlwarning("<getSquadDesc> requires 1 arg (int=sheet)");
		return false;
	}

	// get arg
	uint32	nSheet = (uint32)args[0].getInteger();
	if (nSheet == 0)
	{
		result.setUCString(string(""));
		return true;
	}

	// get sheet name
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
	const ucstring name(pSMC->getSquadLocalizedDescription(CSheetId(nSheet)));

	result.setUCString(name);

	return true;
}
// ***************************************************************************
static DECLARE_INTERFACE_USER_FCT(getOutpostBuildingDesc)
{
	if(args.size()!=1)
	{
		nlwarning("<getOutpostBuildingDesc> requires 1 arg (int=sheet)");
		return false;
	}

	// get arg
	uint32	nSheet = (uint32)args[0].getInteger();
	if (nSheet == 0)
	{
		result.setUCString(string(""));
		return true;
	}

	// get sheet name
	ucstring name;
	CEntitySheet *pSheet= SheetMngr.get(CSheetId(nSheet));
	COutpostBuildingSheet *pOBS = dynamic_cast<COutpostBuildingSheet*>(pSheet);
	if (pOBS && pOBS->OBType == COutpostBuildingSheet::OB_Empty)
	{
		// Don't display description if the building is an empty slot
		name = "";
	}
	else
	{
		STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
		name = pSMC->getOutpostBuildingLocalizedDescription(CSheetId(nSheet));
	}


	result.setUCString(name);

	return true;
}
// ***************************************************************************
void CDBGroupListSheetTrade::CSheetChildTrade::updateViewText(CDBGroupListSheetText *pFather)
{
	H_AUTO(CDBGroupListSheetTrade_updateViewText);
	ucstring text;
	Ctrl->getContextHelp(text);
	// Append first the type of the sheet to select
	switch ( Ctrl->getSheetCategory() )
	{
		case CDBCtrlSheet::Item:		break;		// none for item. consider useless
		case CDBCtrlSheet::Pact:		text= CI18N::get("uiBotChatPact") + text; break;
		case CDBCtrlSheet::Skill:		text= CI18N::get("uiBotChatSkill") + text; break;
		case CDBCtrlSheet::GuildFlag:	text= CI18N::get("uiBotChatSkill") + text; break;
		case CDBCtrlSheet::Phrase:		text= CI18N::get("uiBotChatPhrase") + text; break;
		default: break;
	}

	// For outpost building get description from string manager
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_OutpostBuilding)
	{
		const COutpostBuildingSheet *pOBS = Ctrl->asOutpostBuildingSheet();
		if (pOBS != NULL)
		{
			STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
			text += string("\n") + pSMC->getOutpostBuildingLocalizedDescription(CSheetId(Ctrl->getSheetId()));
			text += "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pOBS->CostDapper));
			text += CI18N::get("uiBotChatTime") + toString(pOBS->CostTime/60) + CI18N::get("uiBotChatTimeMinute");
			if ((pOBS->CostTime % 60) != 0)
				text += toString(pOBS->CostTime%60) + CI18N::get("uiBotChatTimeSecond");
		}
	}

	// For Phrase, if combat, add Weapon compatibility
	if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase)
	{
		// For combat action, Append weapon restriction
		ucstring	weaponRestriction;
		CSPhraseManager	*pPM= CSPhraseManager::getInstance();
		bool melee,range;
		pPM->getCombatWeaponRestriction(weaponRestriction, Ctrl->getSheetId(),melee,range);
		// don't add also if no combat restriction
		if(!weaponRestriction.empty() && weaponRestriction!=CI18N::get("uiawrSF"))
		{
			weaponRestriction= CI18N::get("uiPhraseWRHeader") + weaponRestriction;
			text+= "\n" + weaponRestriction;
		}
	}

	// Get the Text color
	ucstring colorTag("@{FFFF}");
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
	{
		if(!Ctrl->checkItemRequirement())
			colorTag= CI18N::get("uiItemCannotUseColor");
	}

	// For item, add some information
	if(Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
	{
		const CItemSheet *pIS = Ctrl->asItemSheet();
		if(pIS)
		{
			// Add craft info for MP
			if(pIS->Family==ITEMFAMILY::RAW_MATERIAL)
			{
				ucstring	ipList;
				pIS->getItemPartListAsText(ipList);
				if(ipList.empty())
				{
					if(pIS->isUsedAsCraftRequirement())
						text+= "\n" + CI18N::get("uiItemMpCraftRequirement");
					else
						text+= "\n" + CI18N::get("uiItemMpNoCraft");
				}
				else
					text+= "\n" + CI18N::get("uiItemMpCanCraft") + ipList;
			}
		}
	}

	// get the price
	CDBGroupListSheetTrade *zeFather = safe_cast<CDBGroupListSheetTrade*>(pFather);
	if (zeFather->priceWanted())
	{
		if(Ctrl->getSheetCategory() == CDBCtrlSheet::Phrase)
		{
			if (LastPrice != -1)
				text+= "\n" + CI18N::get("uiBotChatSkillPointCost") + toString(LastPrice);
			else
				text+= "\n" + CI18N::get("uiBotChatSkillPointCostNotReceived");
		}
		else
		{
			bool	guildOption= false;

			// Special case if its a guild option
			if (Ctrl->getType() == CCtrlSheetInfo::SheetType_Item)
			{
				const CItemSheet *pIS = Ctrl->asItemSheet();
				if (pIS && pIS->Family == ITEMFAMILY::GUILD_OPTION)
				{
					text+= "\n" + CI18N::get("uiBotChatSkillPointCost") + toString(pIS->GuildOption.XPCost);
					text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(pIS->GuildOption.MoneyCost));
					guildOption= true;
				}
			}

			// if not a guild option
			if(!guildOption)
			{
				if (LastPrice != -1)
				{
					const CItemSheet *pIS = Ctrl->asItemSheet();

					uint	factor= 1;
					if(zeFather->getMultiplyPriceByQuantityFlag())
						factor= LastQuantity;

					// factor on price
					float priceFactor = 1.0f;

					// Append std price
					bool	displayMulPrice= pIS && pIS->Stackable>1 && zeFather->getMultiplyPriceByQuantityFlag();
					// If seller type wanted, don't mul price if the item comes from a NPC
					if(zeFather->sellerTypeWanted() && LastSellerType==BOTCHATTYPE::NPC)
						displayMulPrice= false;

					// check if we should apply fame factor
					if( zeFather->applyFamePriceFactor() )
					{
						priceFactor = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:TRADING:FAME_PRICE_FACTOR")->getValue16()/10000.0f;
					}

					// display with correct format
					if (LastPrice > 0)
					{
						if(displayMulPrice)
							text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString(sint32(LastPrice * priceFactor))) + " ("
								+ NLMISC::formatThousands(toString( sint32(factor) * sint32(LastPrice * priceFactor) )) + ")";
						else
							text+= "\n" + CI18N::get("uiBotChatPrice") + NLMISC::formatThousands(toString( sint32(factor * LastPrice * priceFactor) ));
					}

					if ((LastFactionPointPrice != 0) && (LastFactionType >= PVP_CLAN::BeginClans) && (LastFactionType <= PVP_CLAN::EndClans))
					{
						if (LastPrice > 0)
							text += ". ";
						else
							text+= "\n";

						text+= CI18N::get("uiBotChatFactionType") + PVP_CLAN::toString((PVP_CLAN::TPVPClan)LastFactionType)
							+  CI18N::get("uiBotChatFactionPointPrice") + NLMISC::formatThousands(toString(LastFactionPointPrice));
					}

					// some additional info for resale
					if(zeFather->sellerTypeWanted())
					{
						// Append retire price if reseller type OK (only if the item belongs to the player)
						if(LastSellerType == BOTCHATTYPE::User || LastSellerType == BOTCHATTYPE::ResaleAndUser ||
							LastSellerType == BOTCHATTYPE::UserRetirable || LastSellerType == BOTCHATTYPE::ResaleAndUserRetirable )
						{
							// append price
							if(pIS && pIS->Stackable>1 && zeFather->getMultiplyPriceByQuantityFlag())
								text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(LastPriceRetire)) + " ("
									+ NLMISC::formatThousands(toString(factor * LastPriceRetire)) + ")";
							else
								text+= CI18N::get("uiBotChatRetirePrice") + NLMISC::formatThousands(toString(factor * LastPriceRetire));
							// set resale time left
							ucstring	fmt= CI18N::get("uiBotChatResaleTimeLeft");
							strFindReplace(fmt, "%d", toString(LastResaleTimeLeft/RYZOM_DAY_IN_HOUR));
							strFindReplace(fmt, "%h", toString(LastResaleTimeLeft%RYZOM_DAY_IN_HOUR));
							text+= "\n" + fmt;
							// force special color (according if retirable or not)
							if(LastSellerType == BOTCHATTYPE::UserRetirable || LastSellerType == BOTCHATTYPE::ResaleAndUserRetirable)
								colorTag= CI18N::get("uiItemUserSellColor");
							else
								colorTag= CI18N::get("uiItemUserSellColorNotRetirable");
						}

						// Append (NPC) tag if NPC item
						if(LastSellerType == BOTCHATTYPE::NPC)
						{
							text+= "\n" + CI18N::get("uiBotChatNPCTag");
						}
						// else display the name of the vendor (not if this is the player himself, to avoid flood)
						else if (LastSellerType == BOTCHATTYPE::Resale)
						{
							text+= "\n" + CI18N::get("uiBotChatVendorTag") + VendorNameString;
						}
					}
				}
				else
				{
					// If comes from User List, -1 means "Already Sold"
					if(zeFather->sellerTypeWanted() &&
						(LastSellerType == BOTCHATTYPE::User || LastSellerType == BOTCHATTYPE::UserRetirable) )
					{
						text+= "\n" + CI18N::get("uiItemSold");
						// force special color
						colorTag= CI18N::get("uiItemSoldColor");
					}
					// error case
					else
					{
						text+= "\n" + CI18N::get("uiPriceNotReceived");
					}
				}
			}
		}
	}

	// setup color and text
	text= colorTag + text;
	Text->setTextFormatTaged(text);
}
Esempio n. 7
0
// ***************************************************************************
void CEncyclopediaManager::rebuildThemaPage(uint32 themaName)
{
	uint32 i;
	CEncyMsgThema *pThema = NULL;
	// Select the right album
	for (i = 0; i < _Albums.size(); ++i)
	{
		pThema = _Albums[i].getThema(themaName);
		if (pThema != NULL)
		{
			_AlbumNameSelected = _Albums[i].Name;
			break;
		}
	}

	if (pThema == NULL)
		return;

	// Update the right page
	CInterfaceManager *pIM = CInterfaceManager::getInstance();

	// Hide and show good group
	CInterfaceElement *pIE = pIM->getElementFromId(PAGE_ENCY_ALBUM);
	nlassert(pIE != NULL);
	pIE->setActive(false);
	pIE = pIM->getElementFromId(PAGE_ENCY_HELP);
	pIE->setActive(false);
	pIE = pIM->getElementFromId(PAGE_ENCY_THEMA);
	pIE->setActive(true);

	// Setup title
	CViewTextID *pVT = dynamic_cast<CViewTextID*>(pIM->getElementFromId(PAGE_ENCY_THEMA ":title"));
	nlassert(pVT != NULL);
	pVT->setTextId(pThema->Name);

	// Setup rewards
	pVT = dynamic_cast<CViewTextID*>(pIM->getElementFromId(PAGE_ENCY_THEMA ":reward_text:desc"));
	nlassert(pVT != NULL);
	pVT->setTextId(pThema->RewardText);

	// Setup brick reward
	pIM->getDbProp("UI:VARIABLES:ENCY:REWARDBRICK:SHEET")->setValue32(pThema->RewardSheet);
	CViewText *pRBVT = dynamic_cast<CViewText*>(pIM->getElementFromId(PAGE_ENCY_THEMA ":reward:desc"));
	nlassert(pRBVT != NULL);
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
	CEntitySheet *pES = SheetMngr.get(CSheetId(pThema->RewardSheet));
	if (pES != NULL)
	{
		if (pES->type() == CEntitySheet::ITEM)
		{
			const ucstring desc(pSMC->getItemLocalizedDescription(CSheetId(pThema->RewardSheet)));
			pRBVT->setText(desc);
		}
		else if (pES->type() == CEntitySheet::SBRICK)
		{
			const ucstring desc(pSMC->getSBrickLocalizedDescription(CSheetId(pThema->RewardSheet)));
			pRBVT->setText(desc);
		}
		else if (pES->type() == CEntitySheet::SPHRASE)
		{
			const ucstring desc(pSMC->getSPhraseLocalizedDescription(CSheetId(pThema->RewardSheet)));
			pRBVT->setText(desc);
		}
	}

	// Setup the total number of steps
	uint32 nNbSteps = pThema->NbTask - 1; // 0th is the rite
	pIM->getDbProp("UI:VARIABLES:ENCY:STEPS")->setValue32(nNbSteps);

	// Count number of tasks done
	uint32 nNbTaskDone = 0;
	for (i = 0; i < pThema->NbTask; ++i)
		if (pThema->getTaskState((uint8)i) == 2) // 2 == finished
			++nNbTaskDone;
	pIM->getDbProp("UI:VARIABLES:ENCY:DONE")->setValue32(nNbTaskDone);

	// setup rite & tasks
	for (i = 0; i < pThema->NbTask; ++i)
	{
		string sTmp;
		if (i == 0)
			sTmp = PAGE_ENCY_THEMA ":todo2:rite";
		else
			sTmp = PAGE_ENCY_THEMA ":todo:task" + toString(i);

		// setup task description
		CViewTextID *pText = dynamic_cast<CViewTextID*>(pIM->getElementFromId(sTmp+":desc"));
		nlassert(pText != NULL);
		pText->setTextId(pThema->TaskName[i]);

		// setup task NPC name
		CStringPostProcessNPCRemoveTitle *pSPPRT = new CStringPostProcessNPCRemoveTitle;
		pIM->addServerID (sTmp+":npc:uc_hardtext", pThema->TaskNPCName[i], pSPPRT);

		// If the task is not known gray it
		if (pThema->getTaskState((uint8)i) == 0)
			pText->setAlpha(80);
		else
			pText->setAlpha(160);

		// If the task is finished toggle it
		CViewBitmap *pBitmap = dynamic_cast<CViewBitmap*>(pIM->getElementFromId(sTmp+":done"));
		nlassert(pBitmap != NULL);
		if (pThema->getTaskState((uint8)i) == 2)
			pBitmap->setActive(true);
		else
			pBitmap->setActive(false);
	}

}
Esempio n. 8
0
// ***************************************************************************
void CEncyclopediaManager::rebuildAlbumList()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();

	CGroupTree *pTree = dynamic_cast<CGroupTree*>(pIM->getElementFromId(LIST_ENCY_ALBUM));
	nlassert(pTree != NULL);

	CGroupTree::SNode *pRoot = new CGroupTree::SNode;
	ucstring res;

	// Add all albums
	for (uint32 i = 0; i < _Albums.size(); ++i)
	{
		CGroupTree::SNode *pAlb = new CGroupTree::SNode;
		pAlb->Id = "a_" + toString(i);
		pAlb->AHName = "ency_click_album";
		pAlb->AHParams = toString(_Albums[i].Name);
		if (_Albums[i].Name == _AlbumNameSelected)
			pAlb->Opened = true;
		if (pSMC->getDynString(_Albums[i].Name, res))
			pAlb->Text = res;
		else
			nlwarning("try to construct album without name");

		// Add all themas
		for (uint32 j = 0; j < _Albums[i].Themas.size(); ++j)
		{
			CGroupTree::SNode *pThm = new CGroupTree::SNode;
			pThm->Id = "t_" + toString(i) + "_" + toString(j);
			pThm->AHName = "ency_click_thema";
			pThm->AHParams = toString(_Albums[i].Themas[j].Name);
			if (pSMC->getDynString(_Albums[i].Themas[j].Name, res))
				pThm->Text = res;
			else
				nlwarning("try to construct thema without name");

			pAlb->addChild(pThm);
		}

		pRoot->addChild(pAlb);
	}

	pTree->setRootNode(pRoot);

	// if previously selected album
	if ((_AlbumNameSelected != 0) && (_ThemaNameSelected == 0))
	{
		for (uint32 i = 0; i < _Albums.size(); ++i)
		{
			if (_Albums[i].Name == _AlbumNameSelected)
			{
				pTree->selectNodeById("a_" + toString(i));
				break;
			}
		}
	}
	// if previously selected thema
	if ((_AlbumNameSelected != 0) && (_ThemaNameSelected != 0))
	{
		for (uint32 i = 0; i < _Albums.size(); ++i)
		{
			if (_Albums[i].Name == _AlbumNameSelected)
			{
				for (uint32 j = 0; j < _Albums[i].Themas.size(); ++j)
				{
					if (_Albums[i].Themas[j].Name == _ThemaNameSelected)
					{
						pTree->selectNodeById("t_" + toString(i) + "_" + toString(j));
						break;
					}
				}
			}
		}
	}
}
Esempio n. 9
0
// ***************************************************************************
void CGuildManager::update()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();

	// *** Need to rebuild the guild data?
	if (_NeedRebuild)
	{
		_NeedUpdate = true;
		_NeedRebuild = false;

		// Rebuild transfert the database to the local structure

		// Guild stuff
		uint32 oldName = _Guild.NameID;
		_Guild.NameID = pIM->getDbProp("SERVER:GUILD:NAME")->getValue32();
		_Guild.Name = "";
		_InGuild = (_Guild.NameID != 0);
		if (!_InGuild)
			closeAllInterfaces();
		_Guild.Icon = pIM->getDbProp("SERVER:GUILD:ICON")->getValue64();
		_Guild.QuitGuildAvailable = true;

		// Guild Members
		if(_NeedRebuildMembers)
		{
			_NeedUpdateMembers = true;
			_NeedRebuildMembers = false;

			_GuildMembers.clear();
			for (uint32 i = 0; i < MAX_GUILD_MEMBER; ++i)
			{
				sint32 name = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":NAME")->getValue32();
				if (name != 0)
				{
					SGuildMember gm;
					gm.NameID = name;
					gm.Index = i;
					gm.Grade = (EGSPD::CGuildGrade::TGuildGrade)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":GRADE")->getValue32());
					gm.Online = (TCharConnectionState)(pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ONLINE")->getValue32());
					gm.EnterDate = pIM->getDbProp("SERVER:GUILD:MEMBERS:"+toString(i)+":ENTER_DATE")->getValue32();
					_GuildMembers.push_back(gm);
				}
			}
		}

		// Does the player are newcomer ?
		// Boris 01/09/2006 : removed : now the guild interface is open if
		// is was active before OR if the EGS ask it to the client

		bool playerNewToTheGuild = _NewToTheGuild &&(oldName != _Guild.NameID) && _InGuild;
		if (playerNewToTheGuild)
		{
			// reset the flag
			_NewToTheGuild = false;
			// Don't pop the guild window in ring mode.
			// NB nico : this test should not be necessary, as the guild infos should be filled during the init of the db
			// However, there are situation where this db info is filled after init (should only happen at guild creation time ...)
			// Maybe an EGS  bug ?
			if (R2::getEditor().getMode() == R2::CEditor::NotInitialized)
			{
				CInterfaceElement *pElt;
				// Open the guild info if we are not in the init phase
				if (!IngameDbMngr.initInProgress())
				{
					pElt = pIM->getElementFromId(WIN_GUILD);
					if (pElt != NULL)
						pElt->setActive(true);
				}
				// Browse the forum
				pElt = pIM->getElementFromId(WIN_GUILD_FORUM":content:html");
				if (pElt != NULL)
				{
					CGroupHTML *html = dynamic_cast<CGroupHTML*>(pElt);
					if (html)
						html->browse("home");
				}
			}
		}
	}

	// *** Need to update Names?
	if (_NeedUpdate)
	{
		bool bAllValid = true;
		// Update wait until all the name of members, name of the guild and description are valid

		if (!pSMC->getString (_Guild.NameID, _Guild.Name)) bAllValid = false;

		for (uint i = 0; i < _GuildMembers.size(); ++i)
		{
			if (!pSMC->getString (_GuildMembers[i].NameID, _GuildMembers[i].Name)) bAllValid = false;
			else _GuildMembers[i].Name = CEntityCL::removeTitleAndShardFromName(_GuildMembers[i].Name);
		}

		// If all is valid no more need update and if guild is opened update the interface
		if (bAllValid)
		{
			// Search for UserEntity to find our own grade
			if ((UserEntity != NULL) && (_GuildMembers.size() > 0))
			{
				uint i;
				_Grade = EGSPD::CGuildGrade::Member;
				string sUserName = strlwr(UserEntity->getEntityName().toString());
				for (i = 0; i < _GuildMembers.size(); ++i)
				{
					if (strlwr(_GuildMembers[i].Name.toString()) == sUserName)
					{
						_Grade = _GuildMembers[i].Grade;
						break;
					}
				}
			}

			// set this value in the database
			pIM->getDbProp("UI:VARIABLES:USER:GUILD_GRADE")->setValue32(_Grade);

			// update the guild display
			CGroupContainer *pGuild = dynamic_cast<CGroupContainer*>(pIM->getElementFromId(WIN_GUILD));
			if (pGuild != NULL)
			{
				// if the guild window is visible
				if (pGuild->isOpen() && pGuild->getActive())
				{
					// Close the modal window if the member list will change
					if(pIM->getModalWindow()!=NULL && _NeedUpdateMembers)
					{
						if (pIM->getModalWindow()->getId() == MENU_GUILD_MEMBER )
							pIM->disableModalWindow();
					}

					// Rebuild interface. Rebuild members only if needed
					pIM->runActionHandler("guild_sheet_open", NULL, toString("update_members=%d", (uint)_NeedUpdateMembers) );
				}
			}

			// guild updated
			_NeedUpdate = false;
			_NeedUpdateMembers= false;
		}
	}

	// *** Join proposal handling
	if (_JoinPropUpdate)
	{
		bool bAllValid = true;
		if (!pSMC->getDynString (_JoinPropPhraseID, _JoinPropPhrase)) bAllValid = false;
		// If all is valid no more need update and update the interface
		if (bAllValid)
		{
			_JoinPropUpdate = false;
			CGroupContainer *pJoinProp = dynamic_cast<CGroupContainer*>(pIM->getElementFromId(WIN_JOIN_PROPOSAL));
			if (pJoinProp != NULL)
			{
				CViewText *pJoinPropPhraseView = dynamic_cast<CViewText*>(pIM->getElementFromId(VIEW_JOIN_PROPOSAL_PHRASE));
				if (pJoinPropPhraseView != NULL)
					pJoinPropPhraseView->setText(_JoinPropPhrase);

				pJoinProp->setActive(true);
				pIM->setTopWindow(pJoinProp);
				pJoinProp->updateCoords();
				pJoinProp->center();
				pJoinProp->enableBlink(2);
			}
		}
	}
}