コード例 #1
0
void KCWindlightInterface::ApplyWindLightPreset(const std::string& preset)
{
	if (rlv_handler_t::isEnabled() && gRlvHandler.hasBehaviour(RLV_BHVR_SETENV))
		return;

	LLWLParamManager* wlprammgr = LLWLParamManager::instance();
	if ( (preset != "Default") && (wlprammgr->mParamList.find(preset) != wlprammgr->mParamList.end()) )
	{
		wlprammgr->mAnimator.mIsRunning = false;
		wlprammgr->mAnimator.mUseLindenTime = false;
		wlprammgr->loadPreset(preset);
		setWL_Status(true);
		mWeChangedIt = true;
	}
	else
	{
		wlprammgr->mAnimator.mIsRunning = true;
		wlprammgr->mAnimator.mUseLindenTime = true;
		wlprammgr->loadPreset("Default", true);
		//KC: reset last to Default
		gSavedPerAccountSettings.setString("PhoenixLastWLsetting", "Default");
		setWL_Status(false);
		mWeChangedIt = false;
	}
}
コード例 #2
0
// Checked: 2009-09-16 (RLVa-1.0.3c) | Modified: RLVa-1.0.3c
ERlvCmdRet RlvExtGetSet::onSetEnv(std::string strSetting, const std::string& strValue)
{
	// HACK: see RlvExtGetSet::onGetEnv
	if (!LLFloaterWindLight::isOpen())
	{
		LLFloaterWindLight::instance()->close();
		LLFloaterWindLight::instance()->syncMenu();
	}

	LLWLParamManager* pWLParams = LLWLParamManager::instance();
	WLFloatControl* pFloat = NULL;
	WLColorControl* pColour = NULL;

	F32 nValue = 0.0f;
	// Sanity check - make sure strValue specifies a number for all settings except "preset"
	if ( (RlvSettings::getNoSetEnv()) || ( (!LLStringUtil::convertToF32(strValue, nValue)) && ("preset" != strSetting) ))
		return RLV_RET_FAILED_OPTION;

	// Not quite correct, but RLV-1.16.0 will halt the default daytime cycle on invalid commands so we need to as well
	pWLParams->mAnimator.mIsRunning = false;
	pWLParams->mAnimator.mUseLindenTime = false;

	// See LLWorldEnvSettings::handleEvent()
	if ("daytime" == strSetting)
	{
		if (0.0f <= nValue)
		{
			pWLParams->mAnimator.setDayTime(llmin(nValue, 1.0f));
			pWLParams->mAnimator.update(pWLParams->mCurParams);
		}
		else
		{
			pWLParams->mAnimator.mIsRunning = true;
			pWLParams->mAnimator.mUseLindenTime = true;	
		}
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onChangePresetName()
	else if ("preset" == strSetting)
	{
		pWLParams->loadPreset(strValue, true);
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onStarAlphaMoved
	else if ("starbrightness" == strSetting)
	{
		pWLParams->mCurParams.setStarBrightness(nValue);
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onGlowRMoved() / LLFloaterWindLight::onGlowBMoved()
	else if ( ("sunglowfocus" == strSetting) || ("sunglowsize" == strSetting) )
	{
		WLColorControl *pColour = &pWLParams->mGlow;
		if ("sunglowfocus" == strSetting) 
			pColour->b = -nValue * 5;
		else
			pColour->r = (2 - nValue) * 20;

		pColour->update(pWLParams->mCurParams);
		pWLParams->propagateParameters();
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onSunMoved()
	else if ( ("eastangle" == strSetting) || ("sunmoonposition" == strSetting) )	
	{
		if ("eastangle" == strSetting)	
			pWLParams->mCurParams.setEastAngle(F_TWO_PI * nValue);
		else
			pWLParams->mCurParams.setSunAngle(F_TWO_PI * nValue);

		// TODO-RLVa: it looks like propagateParameters() will actually take care of this for us, making this redundant?
		WLColorControl* pColour = &pWLParams->mLightnorm;
		pColour->r = -sin(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle());
		pColour->g = sin(pWLParams->mCurParams.getSunAngle());
		pColour->b = cos(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle());
		pColour->i = 1.f;

		pColour->update(pWLParams->mCurParams);
		pWLParams->propagateParameters();
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onCloudScrollXMoved() / LLFloaterWindLight::onCloudScrollYMoved() 
	else if ("cloudscrollx" == strSetting)
	{
		pWLParams->mCurParams.setCloudScrollX(nValue + 10.0f);
		return RLV_RET_SUCCESS;
	}
	else if ("cloudscrolly" == strSetting)
	{
		pWLParams->mCurParams.setCloudScrollY(nValue + 10.0f);
		return RLV_RET_SUCCESS;
	}
	// See LLFloaterWindLight::onFloatControlMoved()
	else if ("cloudcoverage" == strSetting)			pFloat = &pWLParams->mCloudCoverage;
	else if ("cloudscale" == strSetting)			pFloat = &pWLParams->mCloudScale;
	else if ("densitymultiplier" == strSetting)		pFloat = &pWLParams->mDensityMult;
	else if ("distancemultiplier" == strSetting)	pFloat = &pWLParams->mDistanceMult;
	else if ("maxaltitude" == strSetting)			pFloat = &pWLParams->mMaxAlt;
	else if ("scenegamma" == strSetting)			pFloat = &pWLParams->mWLGamma;
	// See LLFloaterWindLight::onColorControlRMoved()
	else if ("hazedensity" == strSetting)	pColour = &pWLParams->mHazeDensity;
	else if ("hazehorizon" == strSetting)	pColour = &pWLParams->mHazeHorizon;

	if (pFloat)
	{
		pFloat->x = nValue / pFloat->mult;
		pFloat->update(pWLParams->mCurParams);
		pWLParams->propagateParameters();
		return RLV_RET_SUCCESS;
	} 
	else if (pColour)
	{
		pColour->r = nValue;
		pColour->update(pWLParams->mCurParams);
		pWLParams->propagateParameters();
		return RLV_RET_SUCCESS;
	}

	// RGBI settings
	char ch = strSetting[strSetting.length() - 1];
	if ('x' == ch)		ch = 'r';
	else if ('y' == ch)	ch = 'g';
	else if ('d' == ch)	ch = 'b';

	if ( ('r' == ch) || ('g' == ch) || ('b' == ch) || ('i' == ch) )
	{
		strSetting.erase(strSetting.length() - 1, 1);
		
		if ("ambient" == strSetting)			pColour = &pWLParams->mAmbient;
		else if ("bluedensity" == strSetting)	pColour = &pWLParams->mBlueDensity;
		else if ("bluehorizon" == strSetting)	pColour = &pWLParams->mBlueHorizon;
		else if ("sunmooncolor" == strSetting)	pColour = &pWLParams->mSunlight;
		else if ("cloudcolor" == strSetting)	pColour = &pWLParams->mCloudColor;
		else if ("cloud" == strSetting)			pColour = &pWLParams->mCloudMain;
		else if ("clouddetail" == strSetting)	pColour = &pWLParams->mCloudDetail;

		if (pColour)
		{
			if (pColour->isBlueHorizonOrDensity)   nValue *= 2.0f;
			else if (pColour->isSunOrAmbientColor) nValue *= 3.0f;

			if ('i' == ch)									// (See: LLFloaterWindLight::onColorControlIMoved)
			{
				if (!pColour->hasSliderName)
					return RLV_RET_FAILED_UNKNOWN;

				F32 curMax = llmax(pColour->r, pColour->g, pColour->b);
				if ( (0.0f == nValue) || (0.0f == curMax) )
					pColour->r = pColour->g = pColour->b = pColour->i = nValue;
				else
				{
					F32 nDelta = (nValue - curMax) / curMax;
					pColour->r *= (1.0f + nDelta);
					pColour->g *= (1.0f + nDelta);
					pColour->b *= (1.0f + nDelta);
					pColour->i = nValue;
				}
			}
			else											// (See: LLFloaterWindLight::onColorControlRMoved)
			{
				F32* pnValue = ('r' == ch) ? &pColour->r : ('g' == ch) ? &pColour->g : ('b' == ch) ? &pColour->b : NULL;
				if (pnValue)
					*pnValue = nValue;
				pColour->i = llmax(pColour->r, pColour->g, pColour->b);
			}

			pColour->update(pWLParams->mCurParams);
			pWLParams->propagateParameters();

			return RLV_RET_SUCCESS;
		}
	}
	return RLV_RET_FAILED_UNKNOWN;
}