Ejemplo n.º 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());
		}
	}
Ejemplo n.º 2
0
	// ----------------------------------------------------------------------------
	void CInterfaceTrack::update (double currentTime)
	{
		float currentValue;
		UTrack *pTrack = dynamic_cast<UTrack*>(_TrackKeyFramer);
		if (pTrack == NULL) return;
		pTrack->interpolate((TAnimationTime)currentTime, currentValue);

		// Update the targets
		CInterfaceExprValue expr;
		expr.setDouble(currentValue);
		for (uint i = 0; i < _Targets.size(); ++i)
			_Targets[i].affect(expr);
	}
Ejemplo n.º 3
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);
			}
		}
	}
Ejemplo n.º 4
0
	void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
	{
		CInterfaceManager	*pIM= CInterfaceManager::getInstance();

		// get Squad slot Destination selected
		uint8 nSquadSlot = NLGUI::CDBManager::getInstance()->getDbProp("UI:TEMP:OUTPOST:SQUAD_SLOT_SELECTED")->getValue8();

		// get Squad Id to buy selected
		string sLine = getParam(sParams, "line");
		CInterfaceExprValue ievLine;
		uint8 nLine = 0;
		if (!CInterfaceExpr::eval(sLine, ievLine))
		{
			nlwarning("<COutpostBuy::execute> : Can't evaluate line");
			return;
		}
		if (ievLine.getInteger() >= 0)
			nLine = (uint8)ievLine.getInteger();

		// send msg
		sendMsgToServer("OUTPOST:SET_SQUAD", getOutpostSheet(), nSquadSlot, nLine);
	}
Ejemplo n.º 5
0
	// ----------------------------------------------------------------------------
	void CInterfaceTrack::eval()
	{
		if (!_Dynamic) return;

		if (_TrackKeyFramer != NULL)
			delete _TrackKeyFramer;

		switch(_Type)
		{
			case Track_Linear:
			{
				_TrackKeyFramer = UTrackKeyframer::createLinearFloatTrack();
				for (uint i = 0; i < _DynKeys.size(); ++i)
				{
					SDynKey &rKey = _DynKeys[i];
					UTrackKeyframer::UKeyLinearFloat k;
					CInterfaceExprValue res;
					if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Time to double");
						else
							k.Time = (TAnimationTime)res.getDouble();
					}
					else
					{
						k.Time = 0;
					}

					if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Value to double");
						else
							k.Value = (float)res.getDouble();
					}
					else
					{
						k.Value = 0;
					}

					_TrackKeyFramer->addLinearFloatKey (k);
				}
			}
			break;

			case Track_TCB:
			{
				_TrackKeyFramer = UTrackKeyframer::createTCBFloatTrack();
				for (uint i = 0; i < _DynKeys.size(); ++i)
				{
					SDynKey &rKey = _DynKeys[i];
					UTrackKeyframer::UKeyTCBFloat k;
					CInterfaceExprValue res;
					if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Time to double");
						else
							k.Time = (TAnimationTime)res.getDouble();
					}
					else
					{
						k.Time = 0;
					}

					if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Value to double");
						else
							k.Value = (float)res.getDouble();
					}
					else
					{
						k.Value = 0;
					}

					if (!rKey.Tension.empty() && CInterfaceExpr::eval(rKey.Tension, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Tension to double");
						else
							k.Tension = (float)res.getDouble();
					}
					else
					{
						k.Tension = 0;
					}

					if (!rKey.Continuity.empty() && CInterfaceExpr::eval(rKey.Continuity, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Continuity to double");
						else
							k.Continuity = (float)res.getDouble();
					}
					else
					{
						k.Continuity = 0;
					}

					if (!rKey.Bias.empty() && CInterfaceExpr::eval(rKey.Bias, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Bias to double");
						else
							k.Bias = (float)res.getDouble();
					}
					else
					{
						k.Bias = 0;
					}

					if (!rKey.EaseTo.empty() && CInterfaceExpr::eval(rKey.EaseTo, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert EaseTo to double");
						else
							k.EaseTo = (float)res.getDouble();
					}
					else
					{
						k.EaseTo = 0;
					}

					if (!rKey.EaseFrom.empty() && CInterfaceExpr::eval(rKey.EaseFrom, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert EaseFrom to double");
						else
							k.EaseFrom = (float)res.getDouble();
					}
					else
					{
						k.EaseFrom = 0;
					}

					_TrackKeyFramer->addTCBFloatKey (k);
				}
			}
			break;

			case Track_Bezier:
			{
				_TrackKeyFramer = UTrackKeyframer::createBezierFloatTrack(); break;
				for (uint i = 0; i < _DynKeys.size(); ++i)
				{
					SDynKey &rKey = _DynKeys[i];
					UTrackKeyframer::UKeyBezierFloat k;
					CInterfaceExprValue res;
					if (!rKey.Time.empty() && CInterfaceExpr::eval(rKey.Time, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Time to double");
						else
							k.Time = (TAnimationTime)res.getDouble();
					}
					else
					{
						k.Time = 0;
					}

					if (!rKey.Value.empty() && CInterfaceExpr::eval(rKey.Value, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert Value to double");
						else
							k.Value = (float)res.getDouble();
					}
					else
					{
						k.Value = 0;
					}

					if (!rKey.InTan.empty() && CInterfaceExpr::eval(rKey.InTan, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert TanIn to double");
						else
							k.TanIn = (float)res.getDouble();
					}
					else
					{
						k.TanIn = 0;
					}

					if (!rKey.OutTan.empty() && CInterfaceExpr::eval(rKey.OutTan, res))
					{
						if (!res.toDouble())
							nlwarning ("cannot convert TanOut to double");
						else
							k.TanOut = (float)res.getDouble();
					}
					else
					{
						k.TanOut = 0;
					}

					if (!rKey.Step.empty() && CInterfaceExpr::eval(rKey.Step, res))
					{
						if (!res.toBool())
							nlwarning ("cannot convert Step to bool");
						else
							k.Step = res.getBool();
					}
					else
					{
						k.Step = false;
					}

					_TrackKeyFramer->addBezierFloatKey (k);
				}
			}
			default: nlstop;	break;
		}

	}
Ejemplo n.º 6
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());
		}
	}