RLVa impl updated to that used in v3. Hooked RLVa restrictions back into wearables. New RLVa floater: 'Locks...' Also updated 'Restrictions...' floater.
This commit is contained in:
@@ -17,14 +17,363 @@
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
#include "llagent.h"
|
||||
#include "llagentcamera.h"
|
||||
#include "llfloaterwindlight.h"
|
||||
#include "lldaycyclemanager.h"
|
||||
#include "llviewercontrol.h"
|
||||
#include "llviewerwindow.h"
|
||||
#include "llvoavatar.h"
|
||||
#include "llvoavatarself.h"
|
||||
#include "llwlparammanager.h"
|
||||
|
||||
#include "rlvextensions.h"
|
||||
#include "rlvhandler.h"
|
||||
#include "rlvhelper.h"
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class RlvWindLightControl
|
||||
{
|
||||
public:
|
||||
enum EType { TYPE_COLOR, TYPE_COLOR_R, TYPE_FLOAT, TYPE_UNKNOWN };
|
||||
enum EColorComponent { COMPONENT_R, COMPONENT_G, COMPONENT_B, COMPONENT_I, COMPONENT_NONE };
|
||||
public:
|
||||
RlvWindLightControl(WLColorControl* pCtrl, bool fColorR) : m_eType((!fColorR) ? TYPE_COLOR: TYPE_COLOR_R), m_pColourCtrl(pCtrl), m_pFloatCtrl(NULL) {}
|
||||
RlvWindLightControl(WLFloatControl* pCtrl) : m_eType(TYPE_FLOAT), m_pColourCtrl(NULL), m_pFloatCtrl(pCtrl) {}
|
||||
|
||||
EType getControlType() const { return m_eType; }
|
||||
bool isColorType() const { return (TYPE_COLOR == m_eType) || (TYPE_COLOR_R == m_eType); }
|
||||
bool isFloatType() const { return (TYPE_FLOAT == m_eType); }
|
||||
// TYPE_COLOR and TYPE_COLOR_R
|
||||
F32 getColorComponent(EColorComponent eComponent, bool& fError) const;
|
||||
LLVector4 getColorVector(bool& fError) const;
|
||||
bool setColorComponent(EColorComponent eComponent, F32 nValue);
|
||||
// TYPE_FLOAT
|
||||
F32 getFloat(bool& fError) const;
|
||||
bool setFloat(F32 nValue);
|
||||
|
||||
static EColorComponent getComponentFromCharacter(char ch);
|
||||
protected:
|
||||
EType m_eType; // Type of the WindLight control
|
||||
WLColorControl* m_pColourCtrl;
|
||||
WLFloatControl* m_pFloatCtrl;
|
||||
};
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
static F32 get_intensity_from_color(const LLVector4& v)
|
||||
{
|
||||
return llmax(v.mV[0], v.mV[1], v.mV[2]);
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
F32 RlvWindLightControl::getColorComponent(EColorComponent eComponent, bool& fError) const
|
||||
{
|
||||
switch (eComponent)
|
||||
{
|
||||
case COMPONENT_R: return getColorVector(fError).mV[0];
|
||||
case COMPONENT_G: return getColorVector(fError).mV[1];
|
||||
case COMPONENT_B: return getColorVector(fError).mV[2];
|
||||
case COMPONENT_I: return get_intensity_from_color(getColorVector(fError)); // SL-2.8: Always seems to be 1.0 so get it manually
|
||||
default : RLV_ASSERT(false); fError = true; return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
RlvWindLightControl::EColorComponent RlvWindLightControl::getComponentFromCharacter(char ch)
|
||||
{
|
||||
if (('r' == ch) || ('x' == ch))
|
||||
return COMPONENT_R;
|
||||
else if (('g' == ch) || ('y' == ch))
|
||||
return COMPONENT_G;
|
||||
else if (('b' == ch) || ('d' == ch))
|
||||
return COMPONENT_B;
|
||||
else if ('i' == ch)
|
||||
return COMPONENT_I;
|
||||
return COMPONENT_NONE;
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
LLVector4 RlvWindLightControl::getColorVector(bool& fError) const
|
||||
{
|
||||
if ((fError = !isColorType()))
|
||||
return LLVector4(0, 0, 0, 0);
|
||||
F32 nMult = (m_pColourCtrl->isSunOrAmbientColor) ? 3.0f : ((m_pColourCtrl->isBlueHorizonOrDensity) ? 2.0f : 1.0f);
|
||||
return LLWLParamManager::getInstance()->mCurParams.getVector(m_pColourCtrl->mName, fError) / nMult;
|
||||
}
|
||||
|
||||
// Checked: 2011-08-28 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
bool RlvWindLightControl::setColorComponent(EColorComponent eComponent, F32 nValue)
|
||||
{
|
||||
if (isColorType())
|
||||
{
|
||||
nValue *= (m_pColourCtrl->isSunOrAmbientColor) ? 3.0f : ((m_pColourCtrl->isBlueHorizonOrDensity) ? 2.0f : 1.0f);
|
||||
if (COMPONENT_I == eComponent) // (See: LLFloaterWindLight::onColorControlIMoved)
|
||||
{
|
||||
if (m_pColourCtrl->hasSliderName)
|
||||
{
|
||||
F32 curMax = llmax(m_pColourCtrl->r, m_pColourCtrl->g, m_pColourCtrl->b);
|
||||
if ( (0.0f == nValue) || (0.0f == curMax) )
|
||||
{
|
||||
m_pColourCtrl->r = m_pColourCtrl->g = m_pColourCtrl->b = m_pColourCtrl->i = nValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
F32 nDelta = (nValue - curMax) / curMax;
|
||||
m_pColourCtrl->r *= (1.0f + nDelta);
|
||||
m_pColourCtrl->g *= (1.0f + nDelta);
|
||||
m_pColourCtrl->b *= (1.0f + nDelta);
|
||||
m_pColourCtrl->i = nValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // (See: LLFloaterWindLight::onColorControlRMoved)
|
||||
{
|
||||
F32* pnValue = (COMPONENT_R == eComponent) ? &m_pColourCtrl->r : (COMPONENT_G == eComponent) ? &m_pColourCtrl->g : (COMPONENT_B == eComponent) ? &m_pColourCtrl->b : NULL;
|
||||
if (pnValue)
|
||||
*pnValue = nValue;
|
||||
if (m_pColourCtrl->hasSliderName)
|
||||
m_pColourCtrl->i = llmax(m_pColourCtrl->r, m_pColourCtrl->g, m_pColourCtrl->b);
|
||||
}
|
||||
m_pColourCtrl->update(LLWLParamManager::getInstance()->mCurParams);
|
||||
LLWLParamManager::getInstance()->propagateParameters();
|
||||
}
|
||||
return isColorType();
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
F32 RlvWindLightControl::getFloat(bool& fError) const
|
||||
{
|
||||
return (!(fError = (TYPE_FLOAT != m_eType))) ? LLWLParamManager::getInstance()->mCurParams.getVector(m_pFloatCtrl->mName, fError).mV[0] * m_pFloatCtrl->mult : 0.0;
|
||||
}
|
||||
|
||||
// Checked: 2011-08-28 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
bool RlvWindLightControl::setFloat(F32 nValue)
|
||||
{
|
||||
if (TYPE_FLOAT == m_eType)
|
||||
{
|
||||
m_pFloatCtrl->x = nValue / m_pFloatCtrl->mult;
|
||||
m_pFloatCtrl->update(LLWLParamManager::getInstance()->mCurParams);
|
||||
LLWLParamManager::getInstance()->propagateParameters();
|
||||
}
|
||||
return (TYPE_FLOAT == m_eType);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
class RlvWindLight : public LLSingleton<RlvWindLight>
|
||||
{
|
||||
friend class LLSingleton<RlvWindLight>;
|
||||
public:
|
||||
RlvWindLight();
|
||||
|
||||
std::string getValue(const std::string& strSetting, bool& fError);
|
||||
bool setValue(const std::string& strRlvName, const std::string& strValue);
|
||||
|
||||
protected:
|
||||
std::map<std::string, RlvWindLightControl> m_ControlLookupMap;
|
||||
};
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
RlvWindLight::RlvWindLight()
|
||||
{
|
||||
LLWLParamManager* pWLParamMgr = LLWLParamManager::getInstance();
|
||||
|
||||
// TYPE_FLOAT
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudcoverage", RlvWindLightControl(&pWLParamMgr->mCloudCoverage)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudscale", RlvWindLightControl(&pWLParamMgr->mCloudScale)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("densitymultiplier", RlvWindLightControl(&pWLParamMgr->mDensityMult)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("distancemultiplier", RlvWindLightControl(&pWLParamMgr->mDistanceMult)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("maxaltitude", RlvWindLightControl(&pWLParamMgr->mMaxAlt)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("scenegamma", RlvWindLightControl(&pWLParamMgr->mWLGamma)));
|
||||
// TYPE_COLOR_R
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("hazedensity", RlvWindLightControl(&pWLParamMgr->mHazeDensity)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("hazehorizon", RlvWindLightControl(&pWLParamMgr->mHazeHorizon)));
|
||||
// TYPE_COLOR
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("ambient", RlvWindLightControl(&pWLParamMgr->mAmbient, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("bluedensity", RlvWindLightControl(&pWLParamMgr->mBlueDensity, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("bluehorizon", RlvWindLightControl(&pWLParamMgr->mBlueHorizon, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloud", RlvWindLightControl(&pWLParamMgr->mCloudMain, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("cloudcolor", RlvWindLightControl(&pWLParamMgr->mCloudColor, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("clouddetail", RlvWindLightControl(&pWLParamMgr->mCloudDetail, false)));
|
||||
m_ControlLookupMap.insert(std::pair<std::string, RlvWindLightControl>("sunmooncolor", RlvWindLightControl(&pWLParamMgr->mSunlight, false)));
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
std::string RlvWindLight::getValue(const std::string& strSetting, bool& fError)
|
||||
{
|
||||
LLWLParamManager* pWLParams = LLWLParamManager::getInstance();
|
||||
LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance();
|
||||
|
||||
fError = false; // Assume we won't fail
|
||||
if ("preset" == strSetting)
|
||||
return (pEnvMgr->getUseFixedSky()) ? pEnvMgr->getSkyPresetName() : std::string();
|
||||
else if ("daycycle" == strSetting)
|
||||
return (pEnvMgr->getUseDayCycle()) ? pEnvMgr->getDayCycleName() : std::string();
|
||||
|
||||
F32 nValue = 0.0f;
|
||||
if ("daytime" == strSetting)
|
||||
{
|
||||
nValue = (pEnvMgr->getUseFixedSky()) ? pWLParams->mCurParams.getFloat("sun_angle", fError) / F_TWO_PI : -1.0f;
|
||||
}
|
||||
else if (("sunglowfocus" == strSetting) || ("sunglowsize" == strSetting))
|
||||
{
|
||||
pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError);
|
||||
RLV_ASSERT_DBG(!fError);
|
||||
|
||||
if ("sunglowfocus" == strSetting)
|
||||
nValue = -pWLParams->mGlow.b / 5.0f;
|
||||
else
|
||||
nValue = 2 - pWLParams->mGlow.r / 20.0f;
|
||||
}
|
||||
else if ("starbrightness" == strSetting) nValue = pWLParams->mCurParams.getStarBrightness();
|
||||
else if ("eastangle" == strSetting) nValue = pWLParams->mCurParams.getEastAngle() / F_TWO_PI;
|
||||
else if ("sunmoonposition" == strSetting) nValue = pWLParams->mCurParams.getSunAngle() / F_TWO_PI;
|
||||
else if ("cloudscrollx" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollX() - 10.0f;
|
||||
else if ("cloudscrolly" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollY() - 10.0f;
|
||||
else
|
||||
{
|
||||
std::map<std::string, RlvWindLightControl>::const_iterator itControl = m_ControlLookupMap.find(strSetting);
|
||||
if (m_ControlLookupMap.end() != itControl)
|
||||
{
|
||||
switch (itControl->second.getControlType())
|
||||
{
|
||||
case RlvWindLightControl::TYPE_FLOAT:
|
||||
nValue = itControl->second.getFloat(fError);
|
||||
break;
|
||||
case RlvWindLightControl::TYPE_COLOR_R:
|
||||
nValue = itControl->second.getColorComponent(RlvWindLightControl::COMPONENT_R, fError);
|
||||
break;
|
||||
default:
|
||||
fError = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Couldn't find the exact name, check for a color control name
|
||||
RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strSetting[strSetting.length() - 1]);
|
||||
if (RlvWindLightControl::COMPONENT_NONE != eComponent)
|
||||
itControl = m_ControlLookupMap.find(strSetting.substr(0, strSetting.length() - 1));
|
||||
if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) )
|
||||
nValue = itControl->second.getColorComponent(eComponent, fError);
|
||||
else
|
||||
fError = true;
|
||||
}
|
||||
}
|
||||
return llformat("%f", nValue);
|
||||
}
|
||||
|
||||
// Checked: 2011-08-29 (RLVa-1.4.1a) | Added: RLVa-1.4.1a
|
||||
bool RlvWindLight::setValue(const std::string& strRlvName, const std::string& strValue)
|
||||
{
|
||||
F32 nValue = 0.0f;
|
||||
// Sanity check - make sure strValue specifies a number for all settings except "preset" and "daycycle"
|
||||
if ( (RlvSettings::getNoSetEnv()) ||
|
||||
( (!LLStringUtil::convertToF32(strValue, nValue)) && (("preset" != strRlvName) && ("daycycle" != strRlvName)) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
LLWLParamManager* pWLParams = LLWLParamManager::getInstance();
|
||||
LLEnvManagerNew* pEnvMgr = LLEnvManagerNew::getInstance();
|
||||
|
||||
if ("daytime" == strRlvName)
|
||||
{
|
||||
if (0.0f <= nValue)
|
||||
{
|
||||
pWLParams->mAnimator.deactivate();
|
||||
pWLParams->mAnimator.setDayTime(nValue);
|
||||
pWLParams->mAnimator.update(pWLParams->mCurParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
pEnvMgr->useRegionSettings();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ("preset" == strRlvName)
|
||||
{
|
||||
std::string strPresetName = pWLParams->findPreset(strValue, LLEnvKey::SCOPE_LOCAL);
|
||||
if (!strPresetName.empty())
|
||||
pEnvMgr->useSkyPreset(strPresetName);
|
||||
return !strPresetName.empty();
|
||||
}
|
||||
else if ("daycycle" == strRlvName)
|
||||
{
|
||||
std::string strPresetName = LLDayCycleManager::instance().findPreset(strValue);
|
||||
if (!strPresetName.empty())
|
||||
pEnvMgr->useDayCycle(strValue, LLEnvKey::SCOPE_LOCAL);
|
||||
return !strPresetName.empty();
|
||||
}
|
||||
|
||||
bool fError = false;
|
||||
pWLParams->mAnimator.deactivate();
|
||||
if (("sunglowfocus" == strRlvName) || ("sunglowsize" == strRlvName))
|
||||
{
|
||||
pWLParams->mGlow = pWLParams->mCurParams.getVector(pWLParams->mGlow.mName, fError);
|
||||
RLV_ASSERT_DBG(!fError);
|
||||
|
||||
if ("sunglowfocus" == strRlvName)
|
||||
pWLParams->mGlow.b = -nValue * 5;
|
||||
else
|
||||
pWLParams->mGlow.r = (2 - nValue) * 20;
|
||||
|
||||
pWLParams->mGlow.update(pWLParams->mCurParams);
|
||||
pWLParams->propagateParameters();
|
||||
return true;
|
||||
}
|
||||
else if ("starbrightness" == strRlvName)
|
||||
{
|
||||
pWLParams->mCurParams.setStarBrightness(nValue);
|
||||
return true;
|
||||
}
|
||||
else if (("eastangle" == strRlvName) || ("sunmoonposition" == strRlvName))
|
||||
{
|
||||
if ("eastangle" == strRlvName)
|
||||
pWLParams->mCurParams.setEastAngle(F_TWO_PI * nValue);
|
||||
else
|
||||
pWLParams->mCurParams.setSunAngle(F_TWO_PI * nValue);
|
||||
|
||||
// Set the sun vector
|
||||
pWLParams->mLightnorm.r = -sin(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle());
|
||||
pWLParams->mLightnorm.g = sin(pWLParams->mCurParams.getSunAngle());
|
||||
pWLParams->mLightnorm.b = cos(pWLParams->mCurParams.getEastAngle()) * cos(pWLParams->mCurParams.getSunAngle());
|
||||
pWLParams->mLightnorm.i = 1.f;
|
||||
|
||||
pWLParams->propagateParameters();
|
||||
return true;
|
||||
}
|
||||
else if ("cloudscrollx" == strRlvName)
|
||||
{
|
||||
pWLParams->mCurParams.setCloudScrollX(nValue + 10.0f);
|
||||
return true;
|
||||
}
|
||||
else if ("cloudscrolly" == strRlvName)
|
||||
{
|
||||
pWLParams->mCurParams.setCloudScrollY(nValue + 10.0f);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<std::string, RlvWindLightControl>::iterator itControl = m_ControlLookupMap.find(strRlvName);
|
||||
if (m_ControlLookupMap.end() != itControl)
|
||||
{
|
||||
switch (itControl->second.getControlType())
|
||||
{
|
||||
case RlvWindLightControl::TYPE_FLOAT:
|
||||
return itControl->second.setFloat(nValue);
|
||||
case RlvWindLightControl::TYPE_COLOR_R:
|
||||
return itControl->second.setColorComponent(RlvWindLightControl::COMPONENT_R, nValue);
|
||||
default:
|
||||
RLV_ASSERT(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Couldn't find the exact name, check for a color control name
|
||||
RlvWindLightControl::EColorComponent eComponent = RlvWindLightControl::getComponentFromCharacter(strRlvName[strRlvName.length() - 1]);
|
||||
if (RlvWindLightControl::COMPONENT_NONE != eComponent)
|
||||
itControl = m_ControlLookupMap.find(strRlvName.substr(0, strRlvName.length() - 1));
|
||||
if ( (m_ControlLookupMap.end() != itControl) && (itControl->second.isColorType()) )
|
||||
return itControl->second.setColorComponent(eComponent, nValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -98,16 +447,17 @@ bool RlvExtGetSet::processCommand(const RlvCommand& rlvCmd, ERlvCmdRet& eRet)
|
||||
}
|
||||
else if ("env" == strBehaviour)
|
||||
{
|
||||
bool fError = false;
|
||||
if ( ("get" == strGetSet) && (RLV_TYPE_REPLY == rlvCmd.getParamType()) )
|
||||
{
|
||||
RlvUtil::sendChatReply(rlvCmd.getParam(), onGetEnv(strSetting));
|
||||
eRet = RLV_RET_SUCCESS;
|
||||
RlvUtil::sendChatReply(rlvCmd.getParam(), RlvWindLight::instance().getValue(strSetting, fError));
|
||||
eRet = (!fError) ? RLV_RET_SUCCESS : RLV_RET_FAILED_UNKNOWN;
|
||||
return true;
|
||||
}
|
||||
else if ( ("set" == strGetSet) && (RLV_TYPE_FORCE == rlvCmd.getParamType()) )
|
||||
{
|
||||
if (!gRlvHandler.hasBehaviourExcept(RLV_BHVR_SETENV, rlvCmd.getObjectID()))
|
||||
eRet = onSetEnv(strSetting, rlvCmd.getOption());
|
||||
eRet = (RlvWindLight::instance().setValue(strSetting, rlvCmd.getOption())) ? RLV_RET_SUCCESS : RLV_RET_FAILED_UNKNOWN;
|
||||
else
|
||||
eRet = RLV_RET_FAILED_LOCK;
|
||||
return true;
|
||||
@@ -218,7 +568,7 @@ std::string RlvExtGetSet::onGetPseudoDebug(const std::string& strSetting)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gAgentAvatarp)
|
||||
if (isAgentAvatarValid())
|
||||
return llformat("%d", (gAgentAvatarp->getSex() == SEX_MALE)); // [See LLFloaterCustomize::LLFloaterCustomize()]
|
||||
}
|
||||
}
|
||||
@@ -295,256 +645,4 @@ ERlvCmdRet RlvExtGetSet::onSetPseudoDebug(const std::string& strSetting, const s
|
||||
return eRet;
|
||||
}
|
||||
|
||||
// Checked: 2009-09-16 (RLVa-1.0.3c) | Modified: RLVa-1.0.3c
|
||||
std::string RlvExtGetSet::onGetEnv(std::string strSetting)
|
||||
{
|
||||
// HACK: - create a LLFloaterWindLight instance if there isn't one already
|
||||
// - isOpen() is actually instanceExists()
|
||||
// - creating an instance results in showing the floater which is why we need to ->close() it
|
||||
if (!LLFloaterWindLight::isOpen())
|
||||
{
|
||||
LLFloaterWindLight::instance()->close();
|
||||
LLFloaterWindLight::instance()->syncMenu();
|
||||
}
|
||||
|
||||
LLWLParamManager* pWLParams = LLWLParamManager::getInstance();
|
||||
|
||||
F32 nValue = 0.0f;
|
||||
if ("daytime" == strSetting)
|
||||
{
|
||||
nValue = (pWLParams->mAnimator.getIsRunning() && pWLParams->mAnimator.getUseLindenTime()) ? -1.0f : pWLParams->mAnimator.getDayTime();
|
||||
}
|
||||
else if ("preset" == strSetting)
|
||||
{
|
||||
return (pWLParams->mAnimator.getIsRunning() && pWLParams->mAnimator.getUseLindenTime()) ? std::string() : pWLParams->mCurParams.mName;
|
||||
}
|
||||
else if ("cloudcoverage" == strSetting) nValue = pWLParams->mCloudCoverage;
|
||||
else if ("cloudscale" == strSetting) nValue = pWLParams->mCloudScale;
|
||||
else if ("cloudscrollx" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollX() - 10.0f;
|
||||
else if ("cloudscrolly" == strSetting) nValue = pWLParams->mCurParams.getCloudScrollY() - 10.0f;
|
||||
else if ("densitymultiplier" == strSetting) nValue = pWLParams->mDensityMult.x * pWLParams->mDensityMult.mult;
|
||||
else if ("distancemultiplier" == strSetting) nValue = pWLParams->mDistanceMult;
|
||||
else if ("eastangle" == strSetting) nValue = pWLParams->mCurParams.getEastAngle() / F_TWO_PI;
|
||||
else if ("hazedensity" == strSetting) nValue = pWLParams->mHazeDensity;
|
||||
else if ("hazehorizon" == strSetting) nValue = pWLParams->mHazeHorizon;
|
||||
else if ("maxaltitude" == strSetting) nValue = pWLParams->mMaxAlt;
|
||||
else if ("scenegamma" == strSetting) nValue = pWLParams->mWLGamma;
|
||||
else if ("starbrightness" == strSetting) nValue = pWLParams->mCurParams.getStarBrightness();
|
||||
else if ("sunglowfocus" == strSetting) nValue = -pWLParams->mGlow.b / 5.0f;
|
||||
else if ("sunglowsize" == strSetting) nValue = 2 - pWLParams->mGlow.r / 20.0f;
|
||||
else if ("sunmoonposition" == strSetting) nValue = pWLParams->mCurParams.getSunAngle() / F_TWO_PI;
|
||||
else
|
||||
{
|
||||
char ch = strSetting[strSetting.length() - 1];
|
||||
// HACK-RLVa: not entirely proper (creates new synonyms)
|
||||
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) )
|
||||
{
|
||||
WLColorControl* pColour = NULL;
|
||||
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 ('r' == ch) nValue = pColour->r;
|
||||
else if ('g' == ch) nValue = pColour->g;
|
||||
else if ('b' == ch) nValue = pColour->b;
|
||||
else if (('i' == ch) && (pColour->hasSliderName)) nValue = llmax(pColour->r, pColour->g, pColour->b);
|
||||
|
||||
if (pColour->isBlueHorizonOrDensity) nValue /= 2.0f;
|
||||
else if (pColour->isSunOrAmbientColor) nValue /= 3.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return llformat("%f", nValue);
|
||||
}
|
||||
|
||||
// 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::getInstance();
|
||||
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.deactivate();
|
||||
//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.activate(LLWLAnimator::TIME_LINDEN);
|
||||
}
|
||||
return RLV_RET_SUCCESS;
|
||||
}
|
||||
// See LLFloaterWindLight::onChangePresetName()
|
||||
else if ("preset" == strSetting)
|
||||
{
|
||||
// LLEnvManagerNew manages using presets now -KC
|
||||
//pWLParams->loadPreset(strValue, true);
|
||||
LLEnvManagerNew::instance().useSkyPreset(strValue);
|
||||
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) pFloat = &pWLParams->mHazeDensity;
|
||||
else if ("hazehorizon" == strSetting) pFloat = &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;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user