MAINT-9026: Adding scale for sun and moon. Also don't allow the user to directly set the radio buttons for inventory and custom.

master
Rider Linden 2018-08-21 15:59:18 -07:00
parent 477c66c890
commit 4859db1ada
8 changed files with 160 additions and 47 deletions

View File

@ -306,7 +306,7 @@ bool LLSettingsBase::validate()
LLSD LLSettingsBase::settingValidation(LLSD &settings, validation_list_t &validations)
{
static Validator validateName(SETTING_NAME, false, LLSD::TypeString);
static Validator validateName(SETTING_NAME, false, LLSD::TypeString, boost::bind(&Validator::verifyStringLength, _1, 32));
static Validator validateId(SETTING_ID, false, LLSD::TypeUUID);
static Validator validateHash(SETTING_HASH, false, LLSD::TypeInteger);
static Validator validateType(SETTING_TYPE, false, LLSD::TypeString);
@ -564,6 +564,18 @@ bool LLSettingsBase::Validator::verifyIntegerRange(LLSD &value, LLSD range)
return true;
}
bool LLSettingsBase::Validator::verifyStringLength(LLSD &value, S32 length)
{
std::string sval = value.asString();
if (!sval.empty())
{
sval = sval.substr(0, length);
value = LLSD::String(sval);
}
return true;
}
//=========================================================================
void LLSettingsBlender::update(const LLSettingsBase::BlendFactor& blendf)
{

View File

@ -230,6 +230,7 @@ public:
static bool verifyQuaternionNormal(LLSD &value);
static bool verifyFloatRange(LLSD &value, LLSD range);
static bool verifyIntegerRange(LLSD &value, LLSD range);
static bool verifyStringLength(LLSD &value, S32 length);
private:
std::string mName;

View File

@ -93,10 +93,12 @@ const std::string LLSettingsSky::SETTING_GLOW("glow");
const std::string LLSettingsSky::SETTING_LIGHT_NORMAL("lightnorm");
const std::string LLSettingsSky::SETTING_MAX_Y("max_y");
const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation");
const std::string LLSettingsSky::SETTING_MOON_SCALE("moon_scale");
const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id");
const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness");
const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color");
const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation");
const std::string LLSettingsSky::SETTING_SUN_SCALE("sun_scale");
const std::string LLSettingsSky::SETTING_SUN_TEXTUREID("sun_id");
const std::string LLSettingsSky::SETTING_LEGACY_EAST_ANGLE("east_angle");
@ -524,6 +526,8 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
validation.push_back(Validator(SETTING_MAX_Y, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(4000.0f)))));
validation.push_back(Validator(SETTING_MOON_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal));
validation.push_back(Validator(SETTING_MOON_SCALE, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.25f)(20.0f))), LLSD::Real(1.0)));
validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(2.0f)))));
@ -532,7 +536,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList()
LLSD(LLSDArray(0.0f)(0.0f)(0.0f)("*")),
LLSD(LLSDArray(3.0f)(3.0f)(3.0f)("*")))));
validation.push_back(Validator(SETTING_SUN_ROTATION, true, LLSD::TypeArray, &Validator::verifyQuaternionNormal));
validation.push_back(Validator(SETTING_SUN_TEXTUREID, false, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_SUN_SCALE, false, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.25f)(20.0f))), LLSD::Real(1.0)));
validation.push_back(Validator(SETTING_SUN_TEXTUREID, false, LLSD::TypeUUID));
validation.push_back(Validator(SETTING_PLANET_RADIUS, true, LLSD::TypeReal,
boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(1000.0f)(32768.0f)))));
@ -1310,6 +1316,16 @@ void LLSettingsSky::setMoonRotation(const LLQuaternion &val)
setValue(SETTING_MOON_ROTATION, val);
}
F32 LLSettingsSky::getMoonScale() const
{
return mSettings[SETTING_MOON_SCALE].asReal();
}
void LLSettingsSky::setMoonScale(F32 val)
{
setValue(SETTING_MOON_SCALE, val);
}
LLUUID LLSettingsSky::getMoonTextureId() const
{
return mSettings[SETTING_MOON_TEXTUREID].asUUID();
@ -1350,6 +1366,17 @@ void LLSettingsSky::setSunRotation(const LLQuaternion &val)
setValue(SETTING_SUN_ROTATION, val);
}
F32 LLSettingsSky::getSunScale() const
{
return mSettings[SETTING_SUN_SCALE].asReal();
}
void LLSettingsSky::setSunScale(F32 val)
{
setValue(SETTING_SUN_SCALE, val);
}
LLUUID LLSettingsSky::getSunTextureId() const
{
return mSettings[SETTING_SUN_TEXTUREID].asUUID();

View File

@ -62,10 +62,12 @@ public:
static const std::string SETTING_LIGHT_NORMAL;
static const std::string SETTING_MAX_Y;
static const std::string SETTING_MOON_ROTATION;
static const std::string SETTING_MOON_SCALE;
static const std::string SETTING_MOON_TEXTUREID;
static const std::string SETTING_STAR_BRIGHTNESS;
static const std::string SETTING_SUNLIGHT_COLOR;
static const std::string SETTING_SUN_ROTATION;
static const std::string SETTING_SUN_SCALE;
static const std::string SETTING_SUN_TEXTUREID;
static const std::string SETTING_PLANET_RADIUS;
@ -165,6 +167,9 @@ public:
LLQuaternion getMoonRotation() const;
void setMoonRotation(const LLQuaternion &val);
F32 getMoonScale() const;
void setMoonScale(F32 val);
LLUUID getMoonTextureId() const;
void setMoonTextureId(LLUUID id);
@ -177,6 +182,9 @@ public:
LLQuaternion getSunRotation() const;
void setSunRotation(const LLQuaternion &val) ;
F32 getSunScale() const;
void setSunScale(F32 val);
LLUUID getSunTextureId() const;
void setSunTextureId(LLUUID id);

View File

@ -65,8 +65,10 @@ namespace
const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness");
const std::string FIELD_SKY_SUN_ROTATION("sun_rotation");
const std::string FIELD_SKY_SUN_IMAGE("sun_image");
const std::string FIELD_SKY_SUN_SCALE("sun_scale");
const std::string FIELD_SKY_MOON_ROTATION("moon_rotation");
const std::string FIELD_SKY_MOON_IMAGE("moon_image");
const std::string FIELD_SKY_MOON_SCALE("moon_scale");
const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f);
const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f);
@ -334,6 +336,7 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild()
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); });
getChild<LLUICtrl>(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); });
getChild<LLUICtrl>(FIELD_SKY_SUN_IMAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunImageChanged(); });
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); });
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId());
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setDefaultImageAssetID(LLSettingsSky::GetBlankSunTextureId());
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setAllowNoTexture(TRUE);
@ -344,7 +347,7 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild()
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setBlankImageAssetID(LLSettingsSky::GetBlankSunTextureId());
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE);
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowLocalTexture(FALSE);
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); });
refresh();
@ -381,8 +384,10 @@ void LLPanelSettingsSkySunMoonTab::refresh()
getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mSkySettings->getStarBrightness());
getChild<LLVirtualTrackball>(FIELD_SKY_SUN_ROTATION)->setRotation(mSkySettings->getSunRotation());
getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->setValue(mSkySettings->getSunTextureId());
getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setValue(mSkySettings->getSunScale());
getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation());
getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId());
getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale());
}
//-------------------------------------------------------------------------
@ -418,6 +423,12 @@ void LLPanelSettingsSkySunMoonTab::onSunRotationChanged()
mSkySettings->update();
}
void LLPanelSettingsSkySunMoonTab::onSunScaleChanged()
{
mSkySettings->setSunScale((getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->getValue().asReal()));
mSkySettings->update();
}
void LLPanelSettingsSkySunMoonTab::onSunImageChanged()
{
mSkySettings->setSunTextureId(getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->getValue().asUUID());
@ -435,3 +446,9 @@ void LLPanelSettingsSkySunMoonTab::onMoonImageChanged()
mSkySettings->setMoonTextureId(getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->getValue().asUUID());
mSkySettings->update();
}
void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged()
{
mSkySettings->setMoonScale((getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->getValue().asReal()));
mSkySettings->update();
}

View File

@ -120,8 +120,10 @@ private:
void onGlowChanged();
void onStarBrightnessChanged();
void onSunRotationChanged();
void onSunScaleChanged();
void onSunImageChanged();
void onMoonRotationChanged();
void onMoonScaleChanged();
void onMoonImageChanged();
};
#endif // LLPANEL_EDIT_SKY_H

View File

@ -243,8 +243,8 @@ void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled)
getChild<LLUICtrl>(RDG_ENVIRONMENT_SELECT)->setEnabled(enabled);
getChild<LLUICtrl>(RDO_USEDEFAULT)->setEnabled(enabled && !is_legacy);
getChild<LLUICtrl>(RDO_USEINV)->setEnabled(enabled && !is_legacy);
getChild<LLUICtrl>(RDO_USECUSTOM)->setEnabled(enabled);
getChild<LLUICtrl>(RDO_USEINV)->setEnabled(false); // these two are selected automatically based on
getChild<LLUICtrl>(RDO_USECUSTOM)->setEnabled(false);
getChild<LLUICtrl>(EDT_INVNAME)->setEnabled(FALSE);
getChild<LLUICtrl>(BTN_SELECTINV)->setEnabled(enabled && !is_legacy);
getChild<LLUICtrl>(BTN_EDIT)->setEnabled(enabled);

View File

@ -32,39 +32,39 @@
width="120">
Sun &amp; Stars
</text>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="10"
top_delta="30"
width="100">
Position:
</text>
<sun_moon_trackball
name="sun_rotation"
follows="left|top"
left_delta="0"
top_delta="20"
height="150"
width="150"
thumb_mode="sun" />
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="160"
top_delta="-20"
width="200">
Image:
</text>
<texture_picker
height="123"
layout="topleft"
left_delta="5"
name="sun_image"
top_pad="10"
width="100"/>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="10"
top_delta="30"
width="100">
Position:
</text>
<sun_moon_trackball
name="sun_rotation"
follows="left|top"
left_delta="0"
top_delta="20"
height="150"
width="150"
thumb_mode="sun" />
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="160"
top_delta="-20"
width="200">
Image:
</text>
<texture_picker
height="123"
layout="topleft"
left_delta="5"
name="sun_image"
top_pad="10"
width="100"/>
<text
follows="left|top"
height="10"
@ -72,6 +72,29 @@
left_delta="-5"
top_delta="110"
width="80">
Scale:
</text>
<slider
decimal_digits="2"
follows="left|top"
height="16"
increment="0.25"
initial_value="0"
layout="topleft"
left_delta="5"
min_val="0.25"
max_val="20"
name="sun_scale"
top_delta="15"
width="130"
can_edit_text="true"/>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="-5"
top_delta="20"
width="80">
Color:
</text>
<color_swatch
@ -89,7 +112,7 @@
height="10"
layout="topleft"
left_delta="-160"
top_delta="47"
top_delta="27"
width="200">
Glow Focus:
</text>
@ -135,7 +158,7 @@
height="10"
layout="topleft"
left_delta="-5"
top_delta="30"
top_delta="22"
width="200">
Star Brightness:
</text>
@ -195,13 +218,13 @@
Position:
</text>
<sun_moon_trackball
name="moon_rotation"
follows="left|top"
left_delta="0"
top_delta="20"
height="150"
width="150"
thumb_mode="moon" />
name="moon_rotation"
follows="left|top"
left_delta="0"
top_delta="20"
height="150"
width="150"
thumb_mode="moon" />
<text
follows="left|top"
height="10"
@ -218,6 +241,29 @@
name="moon_image"
top_pad="10"
width="100"/>
<text
follows="left|top"
height="10"
layout="topleft"
left_delta="-5"
top_delta="110"
width="80">
Scale:
</text>
<slider
decimal_digits="2"
follows="left|top"
height="16"
increment="0.25"
initial_value="0"
layout="topleft"
left_delta="5"
min_val="0.25"
max_val="20"
name="sun_scale"
top_delta="15"
width="130"
can_edit_text="true"/>
</layout_panel>
</layout_stack>
</layout_panel>