summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r--indra/newview/llviewermenu.cpp102
1 files changed, 64 insertions, 38 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 82143f656d..a83980dc23 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -108,9 +108,12 @@
#include "llappearancemgr.h"
#include "lltrans.h"
#include "lleconomy.h"
+#include "boost/unordered_map.hpp"
using namespace LLVOAvatarDefines;
+static boost::unordered_map<std::string, LLStringExplicit> sDefaultItemLabels;
+
BOOL enable_land_build(void*);
BOOL enable_object_build(void*);
@@ -327,11 +330,11 @@ LLMenuParcelObserver::~LLMenuParcelObserver()
void LLMenuParcelObserver::changed()
{
- gMenuHolder->getChildView("Land Buy Pass")->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL));
+ gMenuHolder->childSetEnabled("Land Buy Pass", LLPanelLandGeneral::enableBuyPass(NULL));
BOOL buyable = enable_buy_land(NULL);
- gMenuHolder->getChildView("Land Buy")->setEnabled(buyable);
- gMenuHolder->getChildView("Buy Land...")->setEnabled(buyable);
+ gMenuHolder->childSetEnabled("Land Buy", buyable);
+ gMenuHolder->childSetEnabled("Buy Land...", buyable);
}
@@ -451,10 +454,10 @@ void init_menus()
// Assume L$10 for now, the server will tell us the real cost at login
// *TODO:Also fix cost in llfolderview.cpp for Inventory menus
const std::string upload_cost("10");
- gMenuHolder->getChild<LLUICtrl>("Upload Image")->setLabelArg("[COST]", upload_cost);
- gMenuHolder->getChild<LLUICtrl>("Upload Sound")->setLabelArg("[COST]", upload_cost);
- gMenuHolder->getChild<LLUICtrl>("Upload Animation")->setLabelArg("[COST]", upload_cost);
- gMenuHolder->getChild<LLUICtrl>("Bulk Upload")->setLabelArg("[COST]", upload_cost);
+ gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost);
+ gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
+ gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
+ gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
gAFKMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Away", TRUE);
gBusyMenu = gMenuBarView->getChild<LLMenuItemCallGL>("Set Busy", TRUE);
@@ -2403,31 +2406,55 @@ void handle_object_touch()
msg->sendMessage(object->getRegion()->getHost());
}
-// One object must have touch sensor
-class LLObjectEnableTouch : public view_listener_t
+static void init_default_item_label(const std::string& item_name)
{
- bool handleEvent(const LLSD& userdata)
+ boost::unordered_map<std::string, LLStringExplicit>::iterator it = sDefaultItemLabels.find(item_name);
+ if (it == sDefaultItemLabels.end())
{
- LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
-
- bool new_value = obj && obj->flagHandleTouch();
-
- // Update label based on the node touch name if available.
- std::string touch_text;
- LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
- if (node && node->mValid && !node->mTouchName.empty())
- {
- touch_text = node->mTouchName;
- }
- else
+ // *NOTE: This will not work for items of type LLMenuItemCheckGL because they return boolean value
+ // (doesn't seem to matter much ATM).
+ LLStringExplicit default_label = gMenuHolder->childGetValue(item_name).asString();
+ if (!default_label.empty())
{
- touch_text = userdata.asString();
+ sDefaultItemLabels.insert(std::pair<std::string, LLStringExplicit>(item_name, default_label));
}
- gMenuHolder->getChild<LLUICtrl>("Object Touch")->setValue(touch_text);
- gMenuHolder->getChild<LLUICtrl>("Attachment Object Touch")->setValue(touch_text);
+ }
+}
- return new_value;
+static LLStringExplicit get_default_item_label(const std::string& item_name)
+{
+ LLStringExplicit res("");
+ boost::unordered_map<std::string, LLStringExplicit>::iterator it = sDefaultItemLabels.find(item_name);
+ if (it != sDefaultItemLabels.end())
+ {
+ res = it->second;
+ }
+
+ return res;
+}
+
+
+bool enable_object_touch(LLUICtrl* ctrl)
+{
+ LLViewerObject* obj = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject();
+
+ bool new_value = obj && obj->flagHandleTouch();
+
+ std::string item_name = ctrl->getName();
+ init_default_item_label(item_name);
+
+ // Update label based on the node touch name if available.
+ LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
+ if (node && node->mValid && !node->mTouchName.empty())
+ {
+ gMenuHolder->childSetText(item_name, node->mTouchName);
+ }
+ else
+ {
+ gMenuHolder->childSetText(item_name, get_default_item_label(item_name));
}
+
+ return new_value;
};
//void label_touch(std::string& label, void*)
@@ -5519,27 +5546,27 @@ bool enable_object_stand_up()
return sitting_on_selection();
}
-bool enable_object_sit()
+bool enable_object_sit(LLUICtrl* ctrl)
{
// 'Object Sit' menu item is enabled when agent is not sitting on selection
bool sitting_on_sel = sitting_on_selection();
if (!sitting_on_sel)
{
- LLMenuItemGL* sit_menu_item = gMenuHolder->getChild<LLMenuItemGL>("Object Sit");
- // Init default 'Object Sit' menu item label
- static const LLStringExplicit sit_text(sit_menu_item->getLabel());
+ std::string item_name = ctrl->getName();
+
+ // init default labels
+ init_default_item_label(item_name);
+
// Update label
- std::string label;
LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode();
if (node && node->mValid && !node->mSitName.empty())
{
- label.assign(node->mSitName);
+ gMenuHolder->childSetText(item_name, node->mSitName);
}
else
{
- label = sit_text;
+ gMenuHolder->childSetText(item_name, get_default_item_label(item_name));
}
- sit_menu_item->setLabel(label);
}
return !sitting_on_sel && is_object_sittable();
}
@@ -7668,7 +7695,7 @@ class LLUploadCostCalculator : public view_listener_t
bool handleEvent(const LLSD& userdata)
{
std::string menu_name = userdata.asString();
- gMenuHolder->getChildView(menu_name)->setLabelArg("[COST]", mCostStr);
+ gMenuHolder->childSetLabelArg(menu_name, "[COST]", mCostStr);
return true;
}
@@ -8087,7 +8114,6 @@ void initialize_menus()
view_listener_t::addMenu(new LLObjectBuild(), "Object.Build");
commit.add("Object.Touch", boost::bind(&handle_object_touch));
commit.add("Object.SitOrStand", boost::bind(&handle_object_sit_or_stand));
- enable.add("Object.EnableGearSit", boost::bind(&is_object_sittable));
commit.add("Object.Delete", boost::bind(&handle_object_delete));
view_listener_t::addMenu(new LLObjectAttachToAvatar(), "Object.AttachToAvatar");
view_listener_t::addMenu(new LLObjectReturn(), "Object.Return");
@@ -8103,12 +8129,12 @@ void initialize_menus()
commit.add("Object.Open", boost::bind(&handle_object_open));
commit.add("Object.Take", boost::bind(&handle_take));
enable.add("Object.EnableOpen", boost::bind(&enable_object_open));
- view_listener_t::addMenu(new LLObjectEnableTouch(), "Object.EnableTouch");
+ enable.add("Object.EnableTouch", boost::bind(&enable_object_touch, _1));
enable.add("Object.EnableDelete", boost::bind(&enable_object_delete));
enable.add("Object.EnableWear", boost::bind(&object_selected_and_point_valid));
enable.add("Object.EnableStandUp", boost::bind(&enable_object_stand_up));
- enable.add("Object.EnableSit", boost::bind(&enable_object_sit));
+ enable.add("Object.EnableSit", boost::bind(&enable_object_sit, _1));
view_listener_t::addMenu(new LLObjectEnableReturn(), "Object.EnableReturn");
view_listener_t::addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse");