From 2c20148c36d004bc875f1457bbe6c3578cc85547 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Fri, 19 Apr 2024 07:26:34 -0400 Subject: [PATCH] Revert "SL-20140 Setting shape hand size to 36 won't save" This reverts commit 810a3d24c2e3671f926091c062b101bdec6a1517. --- indra/newview/character/avatar_lad.xml | 17 +++--- indra/newview/llscrollingpanelparam.cpp | 63 ++++++++++++++------- indra/newview/llscrollingpanelparam.h | 3 + indra/newview/llscrollingpanelparambase.cpp | 29 +++++----- indra/newview/llscrollingpanelparambase.h | 7 +-- 5 files changed, 72 insertions(+), 47 deletions(-) diff --git a/indra/newview/character/avatar_lad.xml b/indra/newview/character/avatar_lad.xml index 18c345291ea..63e32654d4f 100644 --- a/indra/newview/character/avatar_lad.xml +++ b/indra/newview/character/avatar_lad.xml @@ -2021,7 +2021,7 @@ value_min="-1" value_max="1"> - + - - @@ -2041,7 +2042,7 @@ name="mFaceEyeAltRight" scale="0 0 0" offset="-.005 0 0" /> - + - @@ -2061,17 +2062,17 @@ name="mFaceEyeLidUpperLeft" scale="0 0.3 0.7" offset=" 0 0 0" /> - + - + - + diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp index efd84eaa6df..bfa453a0ae1 100644 --- a/indra/newview/llscrollingpanelparam.cpp +++ b/indra/newview/llscrollingpanelparam.cpp @@ -259,15 +259,19 @@ void LLScrollingPanelParam::onHintHeldDown( LLVisualParamHint* hint ) // Make sure we're not taking the slider out of bounds // (this is where some simple UI limits are stored) - F32 new_percent = weightToSlider(new_weight); - if (mSlider->getMinValue() < new_percent - && new_percent < mSlider->getMaxValue()) + F32 new_percent = weightToPercent(new_weight); + LLSliderCtrl* slider = getChild("param slider"); + if (slider) { - mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight); - mWearable->writeToAvatar(gAgentAvatarp); - gAgentAvatarp->updateVisualParams(); + if (slider->getMinValue() < new_percent + && new_percent < slider->getMaxValue()) + { + mWearable->setVisualParamWeight( hint->getVisualParam()->getID(), new_weight); + mWearable->writeToAvatar(gAgentAvatarp); + gAgentAvatarp->updateVisualParams(); - mSlider->setValue( weightToSlider( new_weight ) ); + slider->setValue( weightToPercent( new_weight ) ); + } } } } @@ -288,13 +292,17 @@ void LLScrollingPanelParam::onHintMinMouseUp( void* userdata ) F32 range = self->mHintMax->getVisualParamWeight() - self->mHintMin->getVisualParamWeight(); // step a fraction in the negative directiona F32 new_weight = current_weight - (range / 10.f); - F32 new_percent = self->weightToSlider(new_weight); - if (self->mSlider->getMinValue() < new_percent - && new_percent < self->mSlider->getMaxValue()) + F32 new_percent = self->weightToPercent(new_weight); + LLSliderCtrl* slider = self->getChild("param slider"); + if (slider) { - self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight); - self->mWearable->writeToAvatar(gAgentAvatarp); - self->mSlider->setValue( self->weightToSlider( new_weight ) ); + if (slider->getMinValue() < new_percent + && new_percent < slider->getMaxValue()) + { + self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight); + self->mWearable->writeToAvatar(gAgentAvatarp); + slider->setValue( self->weightToPercent( new_weight ) ); + } } } @@ -318,16 +326,33 @@ void LLScrollingPanelParam::onHintMaxMouseUp( void* userdata ) F32 range = self->mHintMax->getVisualParamWeight() - self->mHintMin->getVisualParamWeight(); // step a fraction in the negative direction F32 new_weight = current_weight + (range / 10.f); - F32 new_percent = self->weightToSlider(new_weight); - if (self->mSlider->getMinValue() < new_percent - && new_percent < self->mSlider->getMaxValue()) + F32 new_percent = self->weightToPercent(new_weight); + LLSliderCtrl* slider = self->getChild("param slider"); + if (slider) { - self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight); - self->mWearable->writeToAvatar(gAgentAvatarp); - self->mSlider->setValue( self->weightToSlider( new_weight ) ); + if (slider->getMinValue() < new_percent + && new_percent < slider->getMaxValue()) + { + self->mWearable->setVisualParamWeight(hint->getVisualParam()->getID(), new_weight); + self->mWearable->writeToAvatar(gAgentAvatarp); + slider->setValue( self->weightToPercent( new_weight ) ); + } } } } LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax ); } + + +F32 LLScrollingPanelParam::weightToPercent( F32 weight ) +{ + LLViewerVisualParam* param = mParam; + return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f; +} + +F32 LLScrollingPanelParam::percentToWeight( F32 percent ) +{ + LLViewerVisualParam* param = mParam; + return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight(); +} diff --git a/indra/newview/llscrollingpanelparam.h b/indra/newview/llscrollingpanelparam.h index dc344486fc6..c7a47d5c7a5 100644 --- a/indra/newview/llscrollingpanelparam.h +++ b/indra/newview/llscrollingpanelparam.h @@ -61,6 +61,9 @@ class LLScrollingPanelParam : public LLScrollingPanelParamBase void onHintMouseDown( LLVisualParamHint* hint ); void onHintHeldDown( LLVisualParamHint* hint ); + F32 weightToPercent( F32 weight ); + F32 percentToWeight( F32 percent ); + public: // Constants for LLPanelVisualParam const static F32 PARAM_STEP_TIME_THRESHOLD; diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp index 2a6c25235df..fe7a3627235 100644 --- a/indra/newview/llscrollingpanelparambase.cpp +++ b/indra/newview/llscrollingpanelparambase.cpp @@ -43,7 +43,6 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints) : LLScrollingPanel( panel_params ), mParam(param), - mSlider(nullptr), mAllowModify(allow_modify), mWearable(wearable) { @@ -51,15 +50,13 @@ LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& pan buildFromFile( "panel_scrolling_param.xml"); else buildFromFile( "panel_scrolling_param_base.xml"); - - mSlider = getChild("param slider"); - mSlider->setMaxValue(100.f * (mParam->getMaxWeight() - mParam->getMinWeight())); - mSlider->setValue(weightToSlider(param->getWeight())); + + getChild("param slider")->setValue(weightToPercent(param->getWeight())); std::string display_name = LLTrans::getString(param->getDisplayName()); - mSlider->setLabelArg("[DESC]", display_name); - mSlider->setEnabled(mAllowModify); - mSlider->setCommitCallback(boost::bind(LLScrollingPanelParamBase::onSliderMoved, mSlider, this)); + getChild("param slider")->setLabelArg("[DESC]", display_name); + getChildView("param slider")->setEnabled(mAllowModify); + childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this); setVisible(FALSE); setBorderVisible( FALSE ); @@ -80,9 +77,9 @@ void LLScrollingPanelParamBase::updatePanel(BOOL allow_modify) } F32 current_weight = mWearable->getVisualParamWeight( param->getID() ); - mSlider->setValue(weightToSlider( current_weight ) ); + getChild("param slider")->setValue(weightToPercent( current_weight ) ); mAllowModify = allow_modify; - mSlider->setEnabled(mAllowModify); + getChildView("param slider")->setEnabled(mAllowModify); } // static @@ -93,7 +90,7 @@ void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata) LLViewerVisualParam* param = self->mParam; F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() ); - F32 new_weight = self->sliderToWeight( (F32)slider->getValue().asReal() ); + F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() ); if (current_weight != new_weight ) { self->mWearable->setVisualParamWeight( param->getID(), new_weight); @@ -102,12 +99,14 @@ void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata) } } -F32 LLScrollingPanelParamBase::weightToSlider(F32 weight) +F32 LLScrollingPanelParamBase::weightToPercent( F32 weight ) { - return (weight - mParam->getMinWeight()) * 100.f; + LLViewerVisualParam* param = mParam; + return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f; } -F32 LLScrollingPanelParamBase::sliderToWeight(F32 slider) +F32 LLScrollingPanelParamBase::percentToWeight( F32 percent ) { - return slider / 100.f + mParam->getMinWeight(); + LLViewerVisualParam* param = mParam; + return percent / 100.f * (param->getMaxWeight() - param->getMinWeight()) + param->getMinWeight(); } diff --git a/indra/newview/llscrollingpanelparambase.h b/indra/newview/llscrollingpanelparambase.h index e7f88a21bd0..95388262514 100644 --- a/indra/newview/llscrollingpanelparambase.h +++ b/indra/newview/llscrollingpanelparambase.h @@ -36,7 +36,6 @@ class LLViewerVisualParam; class LLWearable; class LLVisualParamHint; class LLViewerVisualParam; -class LLSliderCtrl; class LLJoint; class LLScrollingPanelParamBase : public LLScrollingPanel @@ -50,13 +49,11 @@ class LLScrollingPanelParamBase : public LLScrollingPanel static void onSliderMoved(LLUICtrl* ctrl, void* userdata); - F32 weightToSlider(F32 weight); - F32 sliderToWeight(F32 slider); + F32 weightToPercent( F32 weight ); + F32 percentToWeight( F32 percent ); public: LLViewerVisualParam* mParam; - LLSliderCtrl* mSlider; - protected: BOOL mAllowModify; LLWearable *mWearable;