示例#1
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		string sValue = getParam(Params,"value");
		string sTarget = getParam(Params,"target");

		if (sTarget.empty()) return;

		if (sTarget.rfind(':') == string::npos)
		{
			if (pCaller == NULL) return;
			sTarget = pCaller->getId() + ":" + sTarget;
		}
		else
		{
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			string elt = sTarget.substr(0,sTarget.rfind(':'));
			CInterfaceElement *pIE;
			if (pCaller != NULL)
				pIE = pIM->getElementFromId(pCaller->getId(), elt);
			else
				pIE = pIM->getElementFromId(elt);
			if (pIE == NULL) return;
			sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size());
		}

		CInterfaceExprValue evValue;
		if (CInterfaceExpr::eval(sValue, evValue, NULL))
		{
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			if (evValue.toInteger())
				pIM->addServerString (sTarget, (uint32)evValue.getInteger());
		}
	}
示例#2
0
	void CInterfaceElement::getSizeParent( std::string &id ) const
	{
		CInterfaceElement *p = getParentSize();

		// If there's no parent set then the size parent is the parent
		if( p == NULL )
		{
			id = "parent";
			return;
		}

		// If the size parent is the same as the group parent, then the size parent is the parent ofc
		if( p == getParent() )
		{
			id = "parent";
			return;
		}

		// If the size parent is in the parent group, use the short Id
		if( p->isInGroup( getParent() ) )
		{
			id = p->getShortId();
			return;
		}

		// Otherwise use the full Id
		id = p->getId();
	}
示例#3
0
// ***************************************************************************
void CEncyclopediaManager::updateThema(uint32 nAlbumName, const CEncyMsgThema &t)
{
	CEncyMsgAlbum *pA = getAlbum(nAlbumName);
	nlassert(pA != NULL);
	CEncyMsgThema *pT = pA->getThema(t.Name);
	// Thema not found add it !
	if (pT == NULL)
	{
		uint32 nBack = (uint32)pA->Themas.size();
		pA->Themas.push_back(CEncyMsgThema());
		pT = &pA->Themas[nBack];

		// If we are not initializing so we must open the encyclopedia on the new thema
		if ( ! _Initializing )
		{
			_AlbumNameSelected = nAlbumName;
			_ThemaNameSelected = t.Name;
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			CInterfaceElement *pContainer = dynamic_cast<CInterfaceElement*>(pIM->getElementFromId(CONT_ENCY));
			if (pContainer != NULL)
				pContainer->setActive(true);
		}
	}
	nlassert(pT != NULL);
	*pT = t;
}
示例#4
0
	void CInterfaceElement::getPosParent( std::string &id ) const
	{

		// If there's no pos parent set, then the parent group is the pos parent
		if( getParentPos() == NULL )
		{
			id = "parent";
			return;
		}

		// If pos parent and parent are the same then ofc the parent group is the pos parent...
		CInterfaceElement *p = getParent();
		if( getParentPos() == p )
		{
			id = "parent";
			return;
		}

		// If parent is in the same group, use the short id
		p = getParentPos();
		if( p->isInGroup( getParent() ) )
		{
			id = p->getShortId();
			return;
		}

		// Otherwise use the full id
		id = p->getId();
	}
示例#5
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();

		string elt = getParam (Params, "elt");

		sint32 value;
		fromString(getParam(Params, "value"), value);

		sint32 limit;
		fromString(getParam(Params, "limit"), limit);

		CInterfaceElement *pIE = pIM->getElementFromId (pCaller->getId(), elt);
		if (pIE == NULL) return;

		sint32 newW = pIE->getW();
		newW += value;
		if (value < 0)
		{
			if (newW < limit)
				newW = limit;
		}
		else
		{
			if (newW > limit)
				newW = limit;
		}
		pIE->setW (newW);
		pIE->invalidateCoords();
	}
示例#6
0
	// ***************************************************************************
	void CInterfaceElement::invalidateContent()
	{
		CInterfaceElement *elm = this;
		while (elm)
		{
			// Call back
			elm->onInvalidateContent();

			// Get the parent
			elm = elm->getParent();
		}
	}
示例#7
0
	// ------------------------------------------------------------------------------------------------
	CInterfaceGroup* CInterfaceElement::getParentContainer()
	{
		CInterfaceElement *parent = this;
		while (parent)
		{
			CInterfaceGroup *gc = dynamic_cast< CInterfaceGroup* >( parent );
			if( ( gc != NULL ) && gc->isGroupContainer() )
				return gc;

			parent = parent->getParent();
		}
		return NULL;
	}
示例#8
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		string sValue = getParam(Params,"value");
		string sTarget = getParam(Params,"target");
		string sRemoveTitle = getParam(Params,"remove_title");

		if (sTarget.empty()) return;

		if (sTarget.rfind(':') == string::npos)
		{
			if (pCaller == NULL) return;
			sTarget = pCaller->getId() + ":" + sTarget;
		}
		else
		{
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			string elt = sTarget.substr(0,sTarget.rfind(':'));
			CInterfaceElement *pIE;
			if (pCaller != NULL)
				pIE = pIM->getElementFromId(pCaller->getId(), elt);
			else
				pIE = pIM->getElementFromId(elt);
			if (pIE == NULL) return;
			sTarget = pIE->getId() + ":" + sTarget.substr(sTarget.rfind(':')+1,sTarget.size());
		}

		CInterfaceExprValue evValue;
		if (CInterfaceExpr::eval(sValue, evValue, NULL))
		{
			bool bRemoveTitle = false;
			if (!sRemoveTitle.empty())
				fromString(sRemoveTitle, bRemoveTitle);

			CInterfaceManager *pIM = CInterfaceManager::getInstance();

			if (bRemoveTitle)
			{
				CStringPostProcessRemoveTitle *pSPPRT = new CStringPostProcessRemoveTitle;

				if (evValue.toInteger())
					pIM->addServerID (sTarget, (uint32)evValue.getInteger(), pSPPRT);
			}
			else
			{
				if (evValue.toInteger())
					pIM->addServerID (sTarget, (uint32)evValue.getInteger(), NULL);
			}
		}
	}
示例#9
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);
	}
}
示例#10
0
	void CPropBrowserCtrl::onPropertyChanged( QtProperty *prop )
	{
		QString propName = prop->propertyName();
		QString propValue = prop->valueText();

		// for some reason booleans cannot be extracted from a QtProperty :(
		if( propValue.isEmpty() )
		{
			QtVariantProperty *p = propertyMgr->variantProperty( prop );
			if( p != NULL )
				propValue = p->value().toString();
		}

		CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( currentElement );
		if( e == NULL )
			return;
		e->setProperty( propName.toUtf8().constData(), propValue.toUtf8().constData() );
	}
示例#11
0
	void CInterfaceElement::parseSizeParent( const std::string &id )
	{
		CInterfaceElement *p = getParent();

		if( ( id == "parent" ) || ( id.empty() ) )
		{
			setParentSize( p );
			return;
		}

		std::string spId;

		if( p != NULL )
			spId = p->getId() + ":" + id;
		else
			spId = std::string( "ui:" ) + id;

		CWidgetManager::getInstance()->getParser()->addParentSizeAssociation( this, spId );
	}
示例#12
0
	// ------------------------------------------------------------------------------------------------
	void CInterfaceElement::relativeSInt32Read (CInterfaceProperty &rIP, const string &prop, const char *val,
														   const string &defVal)
	{
		if (val == NULL)
		{
			rIP.readSInt32 (defVal.c_str(), _Id+":"+prop);
		}
		else
		{
			if ( isdigit(*val) || *val=='-')
			{
				rIP.readSInt32 (val, _Id+":"+prop);
				return;
			}

			sint32 decal = 0;
			if (val[0] == ':')
				decal = 1;
			if (NLGUI::CDBManager::getInstance()->getDbProp(val+decal, false) != NULL)
			{
				rIP.readSInt32 (val+decal, _Id+":"+prop);
				return;
			}
			else
			{
				string sTmp;
				CInterfaceElement *pIEL = this;

				while (pIEL != NULL)
				{
					sTmp = pIEL->getId()+":"+string(val+decal);
					if (NLGUI::CDBManager::getInstance()->getDbProp(sTmp, false) != NULL)
					{
						rIP.readSInt32 (sTmp.c_str(), _Id+":"+prop);
						return;
					}
					pIEL = pIEL->getParent();
				}

				rIP.readSInt32 (val+decal, _Id+":"+prop);
			}
		}
	}
示例#13
0
	void CPropBrowserCtrl::onSelectionChanged( std::string &id )
	{
		if( browser == NULL )
			return;

		disconnect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
			this, SLOT( onPropertyChanged( QtProperty* ) ) );

		browser->clear();

		CInterfaceElement *e = CWidgetManager::getInstance()->getElementFromId( id );
		if( e == NULL )
			return;

		currentElement = id;

        std::string n = e->getClassName();

        setupProperties( n, e );
		connect( propertyMgr, SIGNAL( propertyChanged( QtProperty* ) ),
			this, SLOT( onPropertyChanged( QtProperty* ) ) );
	}
示例#14
0
// ****************************************************************************
void CHugeListObs::updateUIItemPage(uint index)
{
	nlassert((uint) _Category < ListTypeCount); // must call setListType
	CInterfaceManager *im = CInterfaceManager::getInstance();
	//
	std::string					 dbPath; // db path for the current item list
	TItemVect					 *items = &_ItemsPages;
	CDBCtrlSheet::TSheetCategory *itemCategory = &_ItemCategory;
	CDBGroupListSheetText		 *listSheet;
	CCDBNodeLeaf				 *itemListCategoryLeaf = NULL;
	switch (_Category)
	{
		case Trading:
		{
			if (BotChatPageAll->Trade->getBuyOnly())
			{
				dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":";
				listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY_BUY_ONLY));
			}
			else
			{
				dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MONEY ":";
				listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MONEY));
			}
			if (!listSheet) return;
			itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_TO_BUY", false);
		}
		break;
		case ItemForMissions:
		{
			dbPath = DB_LOCAL_BRANCH_FOR_ITEM_FOR_MISSION ":";
			listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_MISSION));
			if (!listSheet) return;
			itemListCategoryLeaf = im->getDbProp("UI:TEMP:TYPE_OF_ITEMS_FOR_MISSION", false);
			if (!itemListCategoryLeaf) return;
			// display the group for mission items
			CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_MISSION);
			if (elm) elm->setActive(true);
		}
		break;
		case Ascensor:
		{
			dbPath = DB_LOCAL_BRANCH_FOR_ASCENSOR ":";
			listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_ITEMS_FOR_ASCENSOR));
			if (!listSheet) return;
			// display the group for mission items
			CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_ITEMS_FOR_ASCENSOR);
			if (elm) elm->setActive(true);
		}
		break;
		case Missions:
		{
			dbPath = DB_LOCAL_BRANCH_FOR_MISSIONS ":";
			listSheet = dynamic_cast<CDBGroupListSheetText *>(im->getElementFromId(UI_LIST_OF_MISSIONS));
			if (!listSheet) return;
			// display the group for mission items
			CInterfaceElement *elm = im->getElementFromId(UI_GROUP_OF_MISSIONS);
			if (elm) elm->setActive(true);
		}
		break;
		default:
			nlassert(0); // Provide code for initializing
		break;
	}
	// Copy item into the big local db
	for(uint k = 0; k < TRADE_PAGE_NUM_ITEMS; ++k)
	{
		CCDBNodeLeaf *leaf;
		const CItem &currItem = (*items)[index].Items[k];
		// get branch for the item
		switch(_Category)
		{
			case Trading:
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false);
				if (leaf) leaf->setValue32(currItem.Quality);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false);
				if (leaf) leaf->setValue32(currItem.SlotType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false);
				if (leaf) leaf->setValue32(currItem.SheetIDOrSkill);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false);
				if (leaf) leaf->setValue32(currItem.Price);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false);
				if (leaf) leaf->setValue32(currItem.Weight);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false);
				if (leaf) leaf->setValue32(currItem.NameId);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false);
				if (leaf) leaf->setValue32(currItem.UserColor);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false);
				if (leaf) leaf->setValue32(currItem.Enchant);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS_TYPE", false);
				if (leaf) leaf->setValue32(currItem.RMClassType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false);
				if (leaf) leaf->setValue32(currItem.RMFaberStatType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQUISIT_VALID", false);
				if (leaf) leaf->setValue32(currItem.PrerequisitValid);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false);
				if (leaf) leaf->setValue32(currItem.InfoVersion);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUANTITY", false);
				if (leaf) leaf->setValue32(currItem.Quantity);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE_RETIRE", false);
				if (leaf) leaf->setValue32(currItem.PriceRetire);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RESALE_TIME_LEFT", false);
				if (leaf) leaf->setValue32(currItem.ResaleTimeLeft);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SELLER_TYPE", false);
				if (leaf) leaf->setValue32(currItem.SellerType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":VENDOR_NAMEID", false);
				if (leaf) leaf->setValue32(currItem.VendorNameId);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":FACTION_TYPE", false);
				if (leaf) leaf->setValue32(currItem.FactionType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PRICE", false);
				if (leaf) leaf->setValue32(currItem.FactionPointPrice);

			break;
			case ItemForMissions:
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":QUALITY", false);
				if (leaf) leaf->setValue32(currItem.Quality);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SLOT_TYPE", false);
				if (leaf) leaf->setValue32(currItem.SlotType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":SHEET", false);
				if (leaf) leaf->setValue32(currItem.SheetIDOrSkill);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":LOGIC_TEXT_ID", false);
				if (leaf) leaf->setValue32(currItem.LogicTextID);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DESC_TEXT_ID", false);
				if (leaf) leaf->setValue32(currItem.DescTextID);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":WEIGHT", false);
				if (leaf) leaf->setValue32(currItem.Weight);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAMEID", false);
				if (leaf) leaf->setValue32(currItem.NameId);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":USER_COLOR", false);
				if (leaf) leaf->setValue32(currItem.UserColor);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ENCHANT", false);
				if (leaf) leaf->setValue32(currItem.Enchant);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_CLASS", false);
				if (leaf) leaf->setValue32(currItem.RMClassType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":RM_FABER_STAT_TYPE", false);
				if (leaf) leaf->setValue32(currItem.RMFaberStatType);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":INFO_VERSION", false);
				if (leaf) leaf->setValue32(currItem.InfoVersion);
			break;
			case Ascensor:
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false);
				if (leaf) leaf->setValue64(currItem.GuildIcon);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":NAME", false);
				if (leaf) leaf->setValue32(currItem.GuildName);
			break;
			case Missions:
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":TEXT", false);
				if (leaf) leaf->setValue64(currItem.MissionText);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":DETAIL_TEXT", false);
				if (leaf) leaf->setValue64(currItem.MissionDetailText);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":ICON", false);
				if (leaf) leaf->setValue32(currItem.MissionIcon);
				leaf = im->getDbProp(dbPath + toString(k + index * TRADE_PAGE_NUM_ITEMS) + ":PREREQ_STATE", false);
				if (leaf) leaf->setValue32(currItem.MissionPreReqState);
				break;
			default:
				nlassert(0); // Implement the temp -> local stuff
			break;
		}

		CDBCtrlSheet *sheet = listSheet->getSheet(k + index * TRADE_PAGE_NUM_ITEMS);
		if (sheet)
		{
			CDBCtrlSheet::TSheetCategory newItemCategory = sheet->getSheetCategory();
			if (k == 0 && index == 0)
			{
				*itemCategory = newItemCategory;
			}
			else
			{
				if (*itemCategory != newItemCategory)
				{
					*itemCategory = CDBCtrlSheet::DontKnow;
				}
			}
			if (_Category == Trading)
			{
				// If price of current selected item has changed, repercute it
				if (sheet == CDBCtrlSheet::getCurrSelection())
				{
					string ls = im->getDefine("item_price_1");
					string ms = im->getDefine("item_price_2");
					string bs = im->getDefine("item_price_3");
					string vbs = im->getDefine("item_price_4");
					setPriceInDB(currItem.Price, ls, ms, bs, vbs);
				}
			}
		}
	}
	// set db entry to give the type of the items
	if (itemListCategoryLeaf) itemListCategoryLeaf->setValue64((sint64) *itemCategory);

	// max page set
	_FirstPageNotUpdated= max(_FirstPageNotUpdated, uint32(index+1));

	// For Phrase BotChat, update the DB prices
	if(_Category==Trading && _PhrasePriceUpdateAndMaybeClientFill)
	{
		CSPhraseManager		*pPM= CSPhraseManager::getInstance();
		pPM->updateBotChatPhrasePrice(index * TRADE_PAGE_NUM_ITEMS, (index+1) * TRADE_PAGE_NUM_ITEMS);
	}
}
示例#15
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);
	}

}
示例#16
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);
			}
		}
	}
}
示例#17
0
	virtual void execute (CCtrlBase *pCaller, const string &Params)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		string dblink   = getParam (Params, "dblink");
		string property = getParam (Params, "target_property");
		string propertyToEval = getParam (Params, "target");
		string expr = getParam (Params, "value");
		//nlinfo("set %s %s %s %s", dblink.c_str(), property.c_str(), propertyToEval.c_str(), expr.c_str());
		CInterfaceExprValue value;
		if (CInterfaceExpr::eval(expr, value, NULL))
		{
			if (!dblink.empty())
			{
				// Do not allow Write on SERVER: or LOCAL:
				static const std::string	dbServer= "SERVER:";
				static const std::string	dbLocal= "LOCAL:";
				static const std::string	dbLocalR2= "LOCAL:R2";
				if( (0==dblink.compare(0,    dbServer.size(),    dbServer)) ||
					(0==dblink.compare(0,    dbLocal.size(),    dbLocal))
					)
				{
					if (0!=dblink.compare(0,    dbLocalR2.size(),    dbLocalR2))
					{
						//nlwarning("You are not allowed to write on 'SERVER:...' or 'LOCAL:...' database");
						nlstop;
						return;
					}
				}

				string dblinkeval;
				CInterfaceExpr::unpackDBentry(dblink.c_str(), NULL, dblinkeval);
				if (!value.toInteger())
				{
					nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
				}
				CInterfaceProperty ip;

				if (!value.toInteger())
				{
					nlwarning("<CAHSet:execute> expression doesn't evaluate to a numerical value");
				}
				if (ip.link (dblinkeval.c_str()))
				{
					ip.setSInt64(value.getInteger());
				}
			}

			if (!propertyToEval.empty())
			{
				CInterfaceExprValue res;
				if (!CInterfaceExpr::eval(propertyToEval, res, NULL)) return;
				res.toString();
				property = res.getString();
			}


			if (!property.empty())
			{
				std::vector<CInterfaceLink::CTargetInfo> targets;
				// find first enclosing group
				CCtrlBase *currCtrl = pCaller;
				CInterfaceGroup *ig = NULL;
				while (currCtrl)
				{
					ig = dynamic_cast<CInterfaceGroup *>(currCtrl);
					if (ig != NULL) break;
					currCtrl = currCtrl->getParent();
				}
				if (ig == NULL)
				{
					string elt = property.substr(0,property.rfind(':'));
					CInterfaceElement *pIE = pIM->getElementFromId(elt);
					ig = dynamic_cast<CInterfaceGroup*>(pIE);
					if (ig == NULL && pIE != NULL)
						ig = pIE->getParent();
				}

				if (ig != NULL)
				{
					CInterfaceParser::splitLinkTargets(property, ig, targets);
					for(uint k = 0; k < targets.size(); ++k)
					{
						if (targets[k].Elem) targets[k].affect(value);
					}
				}
			}
		}
		else
		{
			nlwarning("<CAHSet::execute> Couldn't evaluate expression to affect, expr = %s", expr.c_str());
		}
	}
// ***************************************************************************
void CInterfaceConfig::CDesktopImage::toCurrentDesktop()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	COnLoadConfigVisitor onLoadVisitor;
	pIM->visit(&onLoadVisitor); // send 'onLoad' msg to every element
//	uint32 nCount = 0;

	for(uint k = 0; k < GCImages.size(); ++k)
	{
		CGroupContainer *pGC = dynamic_cast<CGroupContainer*>(pIM->getElementFromId(GCImages[k].Id));
		if (pGC != NULL)
			GCImages[k].setTo(pGC);
	}
	// serial extra data from the stream
	NLMISC::CMemStream &f = ExtraDatas;
	if (!f.isReading())
	{
		f.invert();
	}
	f.resetPtrTable();
	f.seek(0, NLMISC::IStream::begin);
	f.seek(0, NLMISC::IStream::end);
	if (f.getPos() == 0) return;
	f.seek(0, NLMISC::IStream::begin);
	// Load TopWindow config
	if(Version>=1)
	{
		string	topWindowName;
		f.serial(topWindowName);
		if(!topWindowName.empty())
		{
			CInterfaceGroup	*window= dynamic_cast<CInterfaceGroup*>(pIM->getElementFromId(topWindowName));
			if(window && window->getActive())
				pIM->setTopWindow(window);
		}
	}
	uint32 numElemWithConfig;
	f.serial(numElemWithConfig);
	for(uint k = 0; k < numElemWithConfig; ++k)
	{
		std::string elemID;
		f.serial(elemID);
		uint32 chunkSize;
		f.serial(chunkSize);
		uint startPos = f.getPos();
		CInterfaceManager *im = CInterfaceManager::getInstance();
		CInterfaceElement *elem = im->getElementFromId(elemID);
		if (!elem)
		{
			nlwarning("Element %s not found while loading config, skipping datas", elemID.c_str());
			f.seek(chunkSize, NLMISC::IStream::current);
		}
		else
		{
			try
			{
				elem->serialConfig(f);
			}
			catch (const NLMISC::ENewerStream &)
			{
				nlwarning("Element %s config in stream are too recent to be read by the application,  config ignored", elemID.c_str());
				f.seek(startPos + chunkSize, NLMISC::IStream::begin);
			}
		}
	}
}