diff options
author | Vladimir Pchelko <pchelko@productengine.com> | 2010-06-09 13:53:43 +0300 |
---|---|---|
committer | Vladimir Pchelko <pchelko@productengine.com> | 2010-06-09 13:53:43 +0300 |
commit | 7bceff4dbc885236296e0c22cd33bfee30a6f5b1 (patch) | |
tree | a0ad4640e42feeb50873689311cd8e3fb63200e3 /indra | |
parent | 18c35a52c5cd157b72403bf3a43123e922c9079b (diff) | |
parent | 0d5da282de9c0891b0af654b2f9b6f0e66204732 (diff) |
merge
--HG--
branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/app_settings/settings.xml | 11 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.cpp | 78 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.h | 21 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_edit_shape.xml | 29 |
4 files changed, 124 insertions, 15 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 52e987dac9..0af77b6a84 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11428,5 +11428,16 @@ <key>Value</key> <integer>180</integer> </map> + <key>HeightUnits</key> + <map> + <key>Comment</key> + <string>Determines which metric units are used: 1(TRUE) for meter and 0(FALSE) for foot.</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> </map> </llsd> diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index a1a9300ec2..1aedfec86f 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -61,6 +61,9 @@ #include "llagentcamera.h" #include "llmorphview.h" +#include "llcommandhandler.h" +#include "lltextutil.h" + // register panel with appropriate XML static LLRegisterPanelClassWrapper<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable"); @@ -608,6 +611,36 @@ LLPanelEditWearable::~LLPanelEditWearable() } +bool LLPanelEditWearable::changeHeightUnits(const LLSD& new_value) +{ + updateMetricLayout( new_value.asBoolean() ); + updateTypeSpecificControls(LLWearableType::WT_SHAPE); + return true; +} + +void LLPanelEditWearable::updateMetricLayout(BOOL new_value) +{ + LLUIString current_metric, replacment_metric; + current_metric = new_value ? mMeters : mFeet; + replacment_metric = new_value ? mFeet : mMeters; + mHeigthValue.setArg( "[METRIC1]", current_metric.getString() ); + mReplacementMetricUrl.setArg( "[URL_METRIC2]", std::string("[secondlife:///app/metricsystem ") + replacment_metric.getString() + std::string("]")); +} + +void LLPanelEditWearable::updateAvatarHeightLabel() +{ + mTxtAvatarHeight->setText(LLStringUtil::null); + LLStyle::Params param; + param.color = mAvatarHeigthLabelColor; + mTxtAvatarHeight->appendText(mHeigth, false, param); + param.color = mAvatarHeigthValueLabelColor; + mTxtAvatarHeight->appendText(mHeigthValue, false, param); + param.color = mAvatarHeigthLabelColor; // using mAvatarHeigthLabelColor for '/' separator + mTxtAvatarHeight->appendText(" / ", false, param); + mTxtAvatarHeight->appendText(this->mReplacementMetricUrl, false, param); +} + + // virtual BOOL LLPanelEditWearable::postBuild() { @@ -700,6 +733,20 @@ BOOL LLPanelEditWearable::postBuild() for_each_picker_ctrl_entry <LLTextureCtrl> (getPanel(type), type, boost::bind(init_texture_ctrl, this, _1, _2)); } + // init all strings + mMeters = mPanelShape->getString("meters"); + mFeet = mPanelShape->getString("feet"); + mHeigth = mPanelShape->getString("height") + " "; + mHeigthValue = "[HEIGHT] [METRIC1]"; + mReplacementMetricUrl = "[URL_METRIC2]"; + + std::string color = mPanelShape->getString("heigth_label_color"); + mAvatarHeigthLabelColor = LLUIColorTable::instance().getColor(color, LLColor4::green); + color = mPanelShape->getString("heigth_value_label_color"); + mAvatarHeigthValueLabelColor = LLUIColorTable::instance().getColor(color, LLColor4::green); + gSavedSettings.getControl("HeightUnits")->getSignal()->connect(boost::bind(&LLPanelEditWearable::changeHeightUnits, this, _2)); + updateMetricLayout(gSavedSettings.getBOOL("HeightUnits")); + return TRUE; } @@ -1107,12 +1154,22 @@ void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type) void LLPanelEditWearable::updateTypeSpecificControls(LLWearableType::EType type) { + const F32 ONE_METER = 1.0; + const F32 ONE_FOOT = 0.3048 * ONE_METER; // in meters // Update controls specific to shape editing panel. if (type == LLWearableType::WT_SHAPE) { // Update avatar height - std::string avatar_height_str = llformat("%.2f", gAgentAvatarp->mBodySize.mV[VZ]); - mTxtAvatarHeight->setTextArg("[HEIGHT]", avatar_height_str); + F32 new_size = gAgentAvatarp->mBodySize.mV[VZ]; + if (gSavedSettings.getBOOL("HeightUnits") == FALSE) + { + // convert meters to feet + new_size = new_size / ONE_FOOT; + } + + std::string avatar_height_str = llformat("%.2f", new_size); + mHeigthValue.setArg("[HEIGHT]", avatar_height_str); + updateAvatarHeightLabel(); } if (LLWearableType::WT_ALPHA == type) @@ -1381,4 +1438,21 @@ void LLPanelEditWearable::initPreviousAlphaTextureEntry(LLVOAvatarDefines::EText } } +// handle secondlife:///app/metricsystem +class LLMetricSystemHandler : public LLCommandHandler +{ +public: + LLMetricSystemHandler() : LLCommandHandler("metricsystem", UNTRUSTED_THROTTLE) { } + + bool handle(const LLSD& params, const LLSD& query_map, LLMediaCtrl* web) + { + // change height units TRUE for meters and FALSE for feet + BOOL new_value = (gSavedSettings.getBOOL("HeightUnits") == FALSE) ? TRUE : FALSE; + gSavedSettings.setBOOL("HeightUnits", new_value); + return true; + } +}; + +LLMetricSystemHandler gMetricSystemHandler; + // EOF diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h index 54f729fa7a..c63671fcc9 100644 --- a/indra/newview/llpaneleditwearable.h +++ b/indra/newview/llpaneleditwearable.h @@ -104,6 +104,15 @@ private: void initPreviousAlphaTextures(); void initPreviousAlphaTextureEntry(LLVOAvatarDefines::ETextureIndex te); + // callback for HeightUnits parameter. + bool changeHeightUnits(const LLSD& new_value); + + // updates current metric and replacemet metric label text + void updateMetricLayout(BOOL new_value); + + // updates avatar height label + void updateAvatarHeightLabel(); + // the pointer to the wearable we're editing. NULL means we're not editing a wearable. LLWearable *mWearablePtr; LLViewerInventoryItem* mWearableItem; @@ -117,6 +126,18 @@ private: LLTextBox *mTxtAvatarHeight; + // localized and parametrized strings that used to build avatar_height_label + std::string mMeters; + std::string mFeet; + std::string mHeigth; + LLUIString mHeigthValue; + LLUIString mReplacementMetricUrl; + + // color for mHeigth string + LLUIColor mAvatarHeigthLabelColor; + // color for mHeigthValue string + LLUIColor mAvatarHeigthValueLabelColor; + // This text editor reference will change each time we edit a new wearable - // it will be grabbed from the currently visible panel LLTextEditor *mTextEditor; diff --git a/indra/newview/skins/default/xui/en/panel_edit_shape.xml b/indra/newview/skins/default/xui/en/panel_edit_shape.xml index cf15fb0455..d295f5fe4a 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_shape.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_shape.xml @@ -8,19 +8,22 @@ name="edit_shape_panel" top_pad="10" width="333" > - <text - follows="top|left|right" - font="SansSerifSmallBold" - halign="right" - height="12" - layout="topleft" - left="0" - name="avatar_height" - text_color="EmphasisColor" - top="0" - width="310"> - [HEIGHT] Meters tall - </text> + <string name="meters">Meters</string> + <string name="feet">Feet</string> + <string name="height">Height:</string> + <string name="heigth_label_color" translate="false">White_50</string> + <string name="heigth_value_label_color" translate="false">White</string> + <text + follows="top|left|right" + font="SansSerifSmallBold" + halign="right" + height="12" + layout="topleft" + left="0" + name="avatar_height" + top="0" + width="310"> + </text> <panel border="false" bg_alpha_color="DkGray2" |