summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2011-03-29 20:57:17 -0400
committerLoren Shih <seraph@lindenlab.com>2011-03-29 20:57:17 -0400
commit3208104e2e51124fb6ee90133fee328f59e1fddc (patch)
treeb3b8d9e46bf63c88d465da8f1cd9dac551d05626 /indra
parent45a43256ae71ec7936fc73e3b9c41470a23dd229 (diff)
A bit of rearchitecture so that we can have edit wearables that don't have associated snapshots. Needed to support physics wearables, which don't use a snapshot.
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/CMakeLists.txt2
-rw-r--r--indra/newview/llpaneleditwearable.cpp11
-rw-r--r--indra/newview/llphysicsmotion.cpp14
-rw-r--r--indra/newview/llscrollingpanelparam.cpp61
-rw-r--r--indra/newview/llscrollingpanelparam.h11
-rw-r--r--indra/newview/llscrollingpanelparambase.cpp112
-rw-r--r--indra/newview/llscrollingpanelparambase.h62
-rw-r--r--indra/newview/skins/default/xui/en/panel_scrolling_param_base.xml23
8 files changed, 236 insertions, 60 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index b7ed4fc0a4..04f2ec0cb2 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -401,6 +401,7 @@ set(viewer_SOURCE_FILES
llscreenchannel.cpp
llscriptfloater.cpp
llscrollingpanelparam.cpp
+ llscrollingpanelparambase.cpp
llsearchcombobox.cpp
llsearchhistory.cpp
llsecapi.cpp
@@ -938,6 +939,7 @@ set(viewer_HEADER_FILES
llscreenchannel.h
llscriptfloater.h
llscrollingpanelparam.h
+ llscrollingpanelparambase.h
llsearchcombobox.h
llsearchhistory.h
llsecapi.h
diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 7058839e8c..a7d20acbbc 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1415,7 +1415,16 @@ void LLPanelEditWearable::buildParamList(LLScrollingPanelList *panel_list, value
{
LLPanel::Params p;
p.name("LLScrollingPanelParam");
- LLScrollingPanelParam* panel_param = new LLScrollingPanelParam( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
+ LLWearable *wearable = this->getWearable();
+ LLScrollingPanelParamBase *panel_param = NULL;
+ if (wearable && wearable->getType() == LLWearableType::WT_PHYSICS) // Hack to show a different panel for physics. Should generalize this later.
+ {
+ panel_param = new LLScrollingPanelParamBase( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
+ }
+ else
+ {
+ panel_param = new LLScrollingPanelParam( p, NULL, (*it).second, TRUE, this->getWearable(), jointp);
+ }
height = panel_list->addPanel( panel_param );
}
}
diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 48e632280e..4048c66262 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -448,8 +448,16 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
const F32 behavior_spring = getParamValue("Spring");
const F32 behavior_gain = getParamValue("Gain");
const F32 behavior_damping = getParamValue("Damping");
- const F32 behavior_maxspeed = getParamValue("MaxSpeed");
const F32 behavior_drag = getParamValue("Drag");
+ const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest");
+
+ F32 behavior_maxspeed = getParamValue("MaxSpeed");
+ if (physics_test)
+ behavior_maxspeed = 100.0f;
+ /*
+ if (behavior_maxspeed == 0)
+ return FALSE;
+ */
F32 position_current_local = mPosition_local; // Normalized [0,1] range
@@ -526,9 +534,9 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
-behavior_maxspeed, behavior_maxspeed);
// Temporary debugging setting to cause all avatars to move, for profiling purposes.
- if (gSavedSettings.getBOOL("AvatarPhysicsTest"))
+ if (physics_test)
{
- velocity_new_local = sin(time*4.0)*5.0;
+ velocity_new_local = sin(time*4.0);
}
// Calculate the new parameters, or remain unchanged if max speed is 0.
const F32 position_new_local = (behavior_maxspeed != 0) ?
diff --git a/indra/newview/llscrollingpanelparam.cpp b/indra/newview/llscrollingpanelparam.cpp
index f8c20dada0..5310ababba 100644
--- a/indra/newview/llscrollingpanelparam.cpp
+++ b/indra/newview/llscrollingpanelparam.cpp
@@ -50,14 +50,9 @@ const S32 LLScrollingPanelParam::PARAM_HINT_HEIGHT = 128;
S32 LLScrollingPanelParam::sUpdateDelayFrames = 0;
LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_params,
- LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp )
- : LLScrollingPanel( panel_params ),
- mParam(param),
- mAllowModify(allow_modify),
- mWearable(wearable)
+ LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints )
+ : LLScrollingPanelParamBase( panel_params, mesh, param, allow_modify, wearable, jointp, use_hints)
{
- buildFromFile( "panel_scrolling_param.xml");
-
// *HACK To avoid hard coding texture position, lets use border's position for texture.
LLViewBorder* left_border = getChild<LLViewBorder>("left_border");
@@ -73,17 +68,6 @@ LLScrollingPanelParam::LLScrollingPanelParam( const LLPanel::Params& panel_param
mHintMin->setAllowsUpdates( FALSE );
mHintMax->setAllowsUpdates( FALSE );
- getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
-
- std::string display_name = LLTrans::getString(param->getDisplayName());
- getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
- getChildView("param slider")->setEnabled(mAllowModify);
- childSetCommitCallback("param slider", LLScrollingPanelParam::onSliderMoved, this);
-
- std::string min_name = LLTrans::getString(param->getMinDisplayName());
- std::string max_name = LLTrans::getString(param->getMaxDisplayName());
- getChild<LLUICtrl>("min param text")->setValue(min_name);
- getChild<LLUICtrl>("max param text")->setValue(max_name);
LLButton* less = getChild<LLButton>("less");
if (less)
@@ -112,20 +96,15 @@ LLScrollingPanelParam::~LLScrollingPanelParam()
}
void LLScrollingPanelParam::updatePanel(BOOL allow_modify)
{
- LLViewerVisualParam* param = mHintMin->getVisualParam();
-
if (!mWearable)
{
// not editing a wearable just now, no update necessary
return;
}
- F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
- getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
+ LLScrollingPanelParamBase::updatePanel(allow_modify);
+
mHintMin->requestUpdate( sUpdateDelayFrames++ );
mHintMax->requestUpdate( sUpdateDelayFrames++ );
-
- mAllowModify = allow_modify;
- getChildView("param slider")->setEnabled(mAllowModify);
getChildView("less")->setEnabled(mAllowModify);
getChildView("more")->setEnabled(mAllowModify);
}
@@ -135,13 +114,17 @@ void LLScrollingPanelParam::setVisible( BOOL visible )
if( getVisible() != visible )
{
LLPanel::setVisible( visible );
- mHintMin->setAllowsUpdates( visible );
- mHintMax->setAllowsUpdates( visible );
+ if (mHintMin)
+ mHintMin->setAllowsUpdates( visible );
+ if (mHintMax)
+ mHintMax->setAllowsUpdates( visible );
if( visible )
{
- mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ );
- mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ );
+ if (mHintMin)
+ mHintMin->setUpdateDelayFrames( sUpdateDelayFrames++ );
+ if (mHintMax)
+ mHintMax->setUpdateDelayFrames( sUpdateDelayFrames++ );
}
}
}
@@ -164,7 +147,7 @@ void LLScrollingPanelParam::draw()
getChildView("min param text")->setVisible( FALSE );
getChildView("max param text")->setVisible( FALSE );
LLPanel::draw();
-
+
// If we're in a focused floater, don't apply the floater's alpha to visual param hint,
// making its behavior similar to texture controls'.
F32 alpha = getTransparencyType() == TT_ACTIVE ? 1.0f : getCurrentTransparency();
@@ -196,23 +179,6 @@ void LLScrollingPanelParam::draw()
}
// static
-void LLScrollingPanelParam::onSliderMoved(LLUICtrl* ctrl, void* userdata)
-{
- LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
- LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata;
- LLViewerVisualParam* param = self->mParam;
-
- F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() );
- F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() );
- if (current_weight != new_weight )
- {
- self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
- self->mWearable->writeToAvatar();
- gAgentAvatarp->updateVisualParams();
- }
-}
-
-// static
void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata)
{
}
@@ -221,7 +187,6 @@ void LLScrollingPanelParam::onSliderMouseDown(LLUICtrl* ctrl, void* userdata)
void LLScrollingPanelParam::onSliderMouseUp(LLUICtrl* ctrl, void* userdata)
{
LLScrollingPanelParam* self = (LLScrollingPanelParam*) userdata;
-
LLVisualParamHint::requestHintUpdates( self->mHintMin, self->mHintMax );
}
diff --git a/indra/newview/llscrollingpanelparam.h b/indra/newview/llscrollingpanelparam.h
index 1cbc64f45a..c7a47d5c7a 100644
--- a/indra/newview/llscrollingpanelparam.h
+++ b/indra/newview/llscrollingpanelparam.h
@@ -28,8 +28,7 @@
#ifndef LL_SCROLLINGPANELPARAM_H
#define LL_SCROLLINGPANELPARAM_H
-#include "llpanel.h"
-#include "llscrollingpanellist.h"
+#include "llscrollingpanelparambase.h"
class LLViewerJointMesh;
class LLViewerVisualParam;
@@ -38,11 +37,11 @@ class LLVisualParamHint;
class LLViewerVisualParam;
class LLJoint;
-class LLScrollingPanelParam : public LLScrollingPanel
+class LLScrollingPanelParam : public LLScrollingPanelParamBase
{
public:
LLScrollingPanelParam( const LLPanel::Params& panel_params,
- LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp );
+ LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints = TRUE );
virtual ~LLScrollingPanelParam();
virtual void draw();
@@ -50,7 +49,6 @@ public:
virtual void updatePanel(BOOL allow_modify);
static void onSliderMouseDown(LLUICtrl* ctrl, void* userdata);
- static void onSliderMoved(LLUICtrl* ctrl, void* userdata);
static void onSliderMouseUp(LLUICtrl* ctrl, void* userdata);
static void onHintMinMouseDown(void* userdata);
@@ -74,7 +72,6 @@ public:
const static S32 PARAM_HINT_HEIGHT;
public:
- LLViewerVisualParam* mParam;
LLPointer<LLVisualParamHint> mHintMin;
LLPointer<LLVisualParamHint> mHintMax;
static S32 sUpdateDelayFrames;
@@ -82,9 +79,7 @@ public:
protected:
LLTimer mMouseDownTimer; // timer for how long mouse has been held down on a hint.
F32 mLastHeldTime;
-
BOOL mAllowModify;
- LLWearable *mWearable;
};
#endif
diff --git a/indra/newview/llscrollingpanelparambase.cpp b/indra/newview/llscrollingpanelparambase.cpp
new file mode 100644
index 0000000000..62e3039d2f
--- /dev/null
+++ b/indra/newview/llscrollingpanelparambase.cpp
@@ -0,0 +1,112 @@
+/**
+ * @file llscrollingpanelparam.cpp
+ * @brief UI panel for a list of visual param panels
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llscrollingpanelparambase.h"
+#include "llviewerjointmesh.h"
+#include "llviewervisualparam.h"
+#include "llwearable.h"
+#include "llviewervisualparam.h"
+#include "lltoolmorph.h"
+#include "lltrans.h"
+#include "llbutton.h"
+#include "llsliderctrl.h"
+#include "llagent.h"
+#include "llviewborder.h"
+#include "llvoavatarself.h"
+
+LLScrollingPanelParamBase::LLScrollingPanelParamBase( const LLPanel::Params& panel_params,
+ LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints)
+ : LLScrollingPanel( panel_params ),
+ mParam(param),
+ mAllowModify(allow_modify),
+ mWearable(wearable)
+{
+ if (use_hints)
+ buildFromFile( "panel_scrolling_param.xml");
+ else
+ buildFromFile( "panel_scrolling_param_base.xml");
+
+ getChild<LLUICtrl>("param slider")->setValue(weightToPercent(param->getWeight()));
+
+ std::string display_name = LLTrans::getString(param->getDisplayName());
+ getChild<LLUICtrl>("param slider")->setLabelArg("[DESC]", display_name);
+ getChildView("param slider")->setEnabled(mAllowModify);
+ childSetCommitCallback("param slider", LLScrollingPanelParamBase::onSliderMoved, this);
+
+ setVisible(FALSE);
+ setBorderVisible( FALSE );
+}
+
+LLScrollingPanelParamBase::~LLScrollingPanelParamBase()
+{
+}
+
+void LLScrollingPanelParamBase::updatePanel(BOOL allow_modify)
+{
+ LLViewerVisualParam* param = mParam;
+
+ if (!mWearable)
+ {
+ // not editing a wearable just now, no update necessary
+ return;
+ }
+
+ F32 current_weight = mWearable->getVisualParamWeight( param->getID() );
+ getChild<LLUICtrl>("param slider")->setValue(weightToPercent( current_weight ) );
+ mAllowModify = allow_modify;
+ getChildView("param slider")->setEnabled(mAllowModify);
+}
+
+// static
+void LLScrollingPanelParamBase::onSliderMoved(LLUICtrl* ctrl, void* userdata)
+{
+ LLSliderCtrl* slider = (LLSliderCtrl*) ctrl;
+ LLScrollingPanelParamBase* self = (LLScrollingPanelParamBase*) userdata;
+ LLViewerVisualParam* param = self->mParam;
+
+ F32 current_weight = self->mWearable->getVisualParamWeight( param->getID() );
+ F32 new_weight = self->percentToWeight( (F32)slider->getValue().asReal() );
+ if (current_weight != new_weight )
+ {
+ self->mWearable->setVisualParamWeight( param->getID(), new_weight, FALSE );
+ self->mWearable->writeToAvatar();
+ gAgentAvatarp->updateVisualParams();
+ }
+}
+
+F32 LLScrollingPanelParamBase::weightToPercent( F32 weight )
+{
+ LLViewerVisualParam* param = mParam;
+ return (weight - param->getMinWeight()) / (param->getMaxWeight() - param->getMinWeight()) * 100.f;
+}
+
+F32 LLScrollingPanelParamBase::percentToWeight( F32 percent )
+{
+ 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
new file mode 100644
index 0000000000..9538826251
--- /dev/null
+++ b/indra/newview/llscrollingpanelparambase.h
@@ -0,0 +1,62 @@
+/**
+ * @file llscrollingpanelparam.h
+ * @brief the scrolling panel containing a list of visual param
+ * panels
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_SCROLLINGPANELPARAMBASE_H
+#define LL_SCROLLINGPANELPARAMBASE_H
+
+#include "llpanel.h"
+#include "llscrollingpanellist.h"
+
+class LLViewerJointMesh;
+class LLViewerVisualParam;
+class LLWearable;
+class LLVisualParamHint;
+class LLViewerVisualParam;
+class LLJoint;
+
+class LLScrollingPanelParamBase : public LLScrollingPanel
+{
+public:
+ LLScrollingPanelParamBase( const LLPanel::Params& panel_params,
+ LLViewerJointMesh* mesh, LLViewerVisualParam* param, BOOL allow_modify, LLWearable* wearable, LLJoint* jointp, BOOL use_hints = FALSE );
+ virtual ~LLScrollingPanelParamBase();
+
+ virtual void updatePanel(BOOL allow_modify);
+
+ static void onSliderMoved(LLUICtrl* ctrl, void* userdata);
+
+ F32 weightToPercent( F32 weight );
+ F32 percentToWeight( F32 percent );
+
+public:
+ LLViewerVisualParam* mParam;
+protected:
+ BOOL mAllowModify;
+ LLWearable *mWearable;
+};
+
+#endif
diff --git a/indra/newview/skins/default/xui/en/panel_scrolling_param_base.xml b/indra/newview/skins/default/xui/en/panel_scrolling_param_base.xml
new file mode 100644
index 0000000000..177a2fe9f0
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/panel_scrolling_param_base.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ layout="topleft"
+ left="0"
+ name="LLScrollingPanelParamBase"
+ height="20"
+ width="290">
+ <slider
+ can_edit_text="true"
+ decimal_digits="0"
+ enabled="false"
+ height="16"
+ increment="1"
+ initial_value="0"
+ label="[DESC]"
+ layout="bottom|left"
+ left="6"
+ max_val="100"
+ name="param slider"
+ bottom="1"
+ width="274"
+ slider_label.font.style="BOLD" />
+</panel>