Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
					}
				}
			}
		}
	}
}
Exemplo n.º 3
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);
			}
		}
	}
}