Esempio n. 1
0
	// ----------------------------------------------------------------------------
	sint64	CDBViewBar::getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp)
	{
		if(dbProp.getNodePtr())
			return dbProp.getSInt64();
		else
			return intProp;
	}
Esempio n. 2
0
	std::string CDBViewBar3::getValProp( const CInterfaceProperty &prop, sint32 intProp ) const
	{
		if( prop.getNodePtr() != NULL )
			return prop.getNodePtr()->getFullName();
		else
			return toString( intProp );
	}
Esempio n. 3
0
//=============================================================================================================
void CChatTargetFilter::setTargetGroup(CChatGroup::TGroupType groupType, uint32 dynamicChannelDbIndex, bool allowUniverseWarning)
{
	_TargetPlayer.resize(0);
	if (_TargetPartyChat)
	{
		_TargetPartyChat->removeObserver(this);
		_TargetPartyChat = NULL;
	}
	_TargetGroup = groupType;
	_TargetDynamicChannelDbIndex = dynamicChannelDbIndex;

	if (_Chat)
	{
		// set the prompt
		const ucstring prompt("");
		_Chat->setPrompt(prompt + (ucchar) '>');

		// set the color
		string entry="UI:SAVE:CHAT:COLORS:";
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		const bool teamActive = pIM->getDbProp("SERVER:GROUP:0:NAME")->getValueBool();
		const bool guildActive = pIM->getDbProp("SERVER:GUILD:NAME")->getValueBool();
		switch(groupType)
		{
			case CChatGroup::dyn_chat: entry+="DYN:" + NLMISC::toString(dynamicChannelDbIndex); break;
			case CChatGroup::say:	entry+="SAY";	break;
			case CChatGroup::shout:	entry+="SHOUT";	break;
			case CChatGroup::team:	if(!teamActive) return; entry+="GROUP";	break;
			case CChatGroup::guild:	entry+="CLADE";	break;
			case CChatGroup::civilization:	entry+="CIVILIZATION";	break;
			case CChatGroup::territory:	entry+="TERRITORY";	break;
			case CChatGroup::universe:
				{
					entry+="UNIVERSE_NEW";
					if(allowUniverseWarning)
						pIM->getDbProp("UI:VARIABLES:UNIVERSE_CHANEL_WARNING_WANTED")->setValue64(1);
				}
				break;
			case CChatGroup::region:	entry+="REGION";	break;
			case CChatGroup::tell:	entry+="TELL";	break;
			case CChatGroup::system: return;	// return with no warning
			default:	nlwarning("unknown CChatGroup type");	return;
		}

		// read DB
		CInterfaceProperty prop;
		prop.readRGBA(entry.c_str()," ");
		_Chat->setPromptColor(prop.getRGBA());
	}
}
Esempio n. 4
0
	void CDBViewBar3::setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp )
	{
		sint32 i;
		if( fromString( value, i ) )
			intProp = i;
		else
			dbProp.link( value.c_str() );
	}
Esempio n. 5
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);
			}
		}
	}
Esempio n. 6
0
	void execute (CCtrlBase *pCaller, const std::string &sParams)
	{
		string receiver = getParam (sParams, "player");
		ucstring message;
		message.fromUtf8(getParam (sParams, "text"));
//		message = getParam (sParams, "text");
		if (receiver.empty() || message.empty())
			return;

		// Get the chat window (if any)
		CChatWindow *cw = NULL;
		CGroupEditBox *eb = pCaller?dynamic_cast<CGroupEditBox *>(pCaller):NULL;
		if (eb)
			cw = getChatWndMgr().getChatWindowFromCaller(eb);

		// Send the message.
		ChatMngr.tell(receiver, message);

		// display in the good window
		CInterfaceProperty prop;
		prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," ");
		ucstring finalMsg;
		CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false);

		ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : "");
		finalMsg += csr + CI18N::get("youTell") + ": ";
		prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
		CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true);
		finalMsg += message;
		// display msg with good color
//		TDataSetIndex dsi; // not used ....
		PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA());

		ucstring s = CI18N::get("youTellPlayer");
		strFindReplace(s, "%name", receiver);
		strFindReplace(finalMsg, CI18N::get("youTell"), s);
		CInterfaceManager::getInstance()->log(finalMsg);
	}
Esempio n. 7
0
	virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
	{
		CInterfaceManager *pIM = CInterfaceManager::getInstance();
		string dbdst = getParam (Params, "dbdst");
		string dbsrc = getParam (Params, "dbsrc");
		CCDBNodeBranch *pNBdst = pIM->getDbBranch(dbdst);
		CCDBNodeBranch *pNBsrc = pIM->getDbBranch(dbsrc);

		// Branch copy

		if ((pNBdst != NULL) && (pNBsrc != NULL))
		{
			//nlinfo("copying from %s to %s",pNBsrc->getName()->c_str(), pNBdst->getName()->c_str());

			// Parse all children of the src branch
			uint nbLeaves = pNBsrc->countLeaves();
			for (uint i = 0; i < nbLeaves; ++i)
			{
				uint count = i;
				CCDBNodeLeaf *pNLsrc = pNBsrc->findLeafAtCount(count);
				// Find its access name
				string sTmp = *pNLsrc->getName();
				CCDBNodeBranch *pParent = pNLsrc->getParent();
				while (pParent != pNBsrc)
				{
					sTmp = *pParent->getName() + ":" + sTmp;
					pParent = pParent->getParent();
				}
				// Find the correspondant node in the dst branch
				CCDBNodeLeaf *pNLdst = dynamic_cast<CCDBNodeLeaf*>(pNBdst->getNode(ICDBNode::CTextId(sTmp)));
				if (pNLdst == NULL)
				{
					nlwarning ("cannot find destination leaf %s",sTmp.c_str());
				}
				else
				{
					pNLdst->setValue64(pNLsrc->getValue64());

					//sint32 nVal = pNLsrc->getValue64();
					//nlinfo("set value %d for node %s", nVal, sTmp.c_str());
				}
			}
			return;
		}

		// Not branch copy so leaf copy

		CInterfaceProperty ipsrc;
		CInterfaceProperty ipdst;
		if (!ipsrc.link (dbsrc.c_str()))
		{
			nlwarning("cannot find leaf %s",dbsrc.c_str());
			return;
		}
		if (!ipdst.link (dbdst.c_str()))
		{
			nlwarning("cannot find leaf %s",dbdst.c_str());
			return;
		}
		// copy
		ipdst.setSInt64 (ipsrc.getSInt64());
	}
Esempio n. 8
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());
		}
	}