summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorYuri Chebotarev <ychebotarev@productengine.com>2010-06-09 13:56:42 +0300
committerYuri Chebotarev <ychebotarev@productengine.com>2010-06-09 13:56:42 +0300
commitd34ce302591616637a9a025c8016bfbe2a9ff174 (patch)
tree617ab1e5d5d0be28e915e6e3d56128a9febbe524 /indra/newview
parent2959a6413fe853bce000422f591e3f231fd9d188 (diff)
parent7bceff4dbc885236296e0c22cd33bfee30a6f5b1 (diff)
merge
--HG-- branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/llpaneleditwearable.cpp78
-rw-r--r--indra/newview/llpaneleditwearable.h21
-rw-r--r--indra/newview/skins/default/xui/en/panel_edit_shape.xml29
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"