From a97485fa60f1b1f29d8109b79450ab993880529c Mon Sep 17 00:00:00 2001 From: Andrew Dyukov Date: Thu, 15 Jul 2010 21:07:16 +0300 Subject: EXT-8385 FIXED Fixed simultaneous availability to click "Sit here" and "Stand Up" on object. Made only one of them enabled in the same time, didn't make disabled one invisible because it was decided so in EXT-8094. - This bug is the result of EXT-8094 fix. Corrected logic of enabling "Sit here" and "Stand up" both in xml and code. - Removed class LLObjectEnableSitOrStand because it's not needed anymore, and it's handleEvent() method duplicates is_object_sittable() function. - Renamed Object.EnableSit to Object.EnableGearSit because its name is now used for enabling object menu sit, and this "simple" version is used only from object inspector's gear menu. Reviewed by Mike Antipov at https://codereview.productengine.com/secondlife/r/761 --HG-- branch : product-engine --- indra/newview/llviewermenu.cpp | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) (limited to 'indra/newview/llviewermenu.cpp') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 635cc361f3..7cca118392 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -3627,7 +3627,7 @@ class LLEnableEditShape : public view_listener_t } }; -bool enable_sit_object() +bool is_object_sittable() { LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); @@ -5513,17 +5513,17 @@ bool enable_pay_object() return false; } -bool visible_object_stand_up() +bool enable_object_stand_up() { - // 'Object Stand Up' menu item is visible when agent is sitting on selection + // 'Object Stand Up' menu item is enabled when agent is sitting on selection return sitting_on_selection(); } -bool visible_object_sit() +bool enable_object_sit() { - // 'Object Sit' menu item is visible when agent is not sitting on selection - bool is_sit_visible = !sitting_on_selection(); - if (is_sit_visible) + // '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("Object Sit"); // Init default 'Object Sit' menu item label @@ -5541,28 +5541,9 @@ bool visible_object_sit() } sit_menu_item->setLabel(label); } - return is_sit_visible; + return !sitting_on_sel && is_object_sittable(); } -class LLObjectEnableSitOrStand : public view_listener_t -{ - bool handleEvent(const LLSD& userdata) - { - bool new_value = false; - LLViewerObject* dest_object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); - - if(dest_object) - { - if(dest_object->getPCode() == LL_PCODE_VOLUME) - { - new_value = true; - } - } - - return new_value; - } -}; - void dump_select_mgr(void*) { LLSelectMgr::getInstance()->dump(); @@ -8067,7 +8048,7 @@ 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.EnableSit", boost::bind(&enable_sit_object)); + 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"); @@ -8084,12 +8065,11 @@ void initialize_menus() 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"); - view_listener_t::addMenu(new LLObjectEnableSitOrStand(), "Object.EnableSitOrStand"); enable.add("Object.EnableDelete", boost::bind(&enable_object_delete)); enable.add("Object.EnableWear", boost::bind(&object_selected_and_point_valid)); - enable.add("Object.StandUpVisible", boost::bind(&visible_object_stand_up)); - enable.add("Object.SitVisible", boost::bind(&visible_object_sit)); + enable.add("Object.EnableStandUp", boost::bind(&enable_object_stand_up)); + enable.add("Object.EnableSit", boost::bind(&enable_object_sit)); view_listener_t::addMenu(new LLObjectEnableReturn(), "Object.EnableReturn"); view_listener_t::addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse"); -- cgit v1.2.3 From a8632670db7366d7b1be362fa2300c6896cc0f61 Mon Sep 17 00:00:00 2001 From: Alexei Arabadji Date: Fri, 23 Jul 2010 17:06:27 +0300 Subject: EXT-6739 FIXED Provided updating of object inspector gear menu 'Touch' and 'Sit' entries. Details: 1 Provided using Object.EnableSit and Object.EnableTouch callbacks for both object menu and inspector gear menu. Now default menu item label stores in hash map and since callback receives triggered control no need to hardcode updating menu item labels from callback. 2 Removed redundant attribute 'parameter' from menu xml's since now handler callbacks receives triggered menu item as function parameter. 3 Replaced LLObjectEnableTouch class with enable_object_touch function, since there no need on triggering callback on menu commit event. 4 Added symmetric method LLMenuItemGL::getValue(). 5 Removed unused "Object.EnableGearSit" callback. reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/774/ --HG-- branch : product-engine --- indra/newview/llviewermenu.cpp | 84 +++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 30 deletions(-) (limited to 'indra/newview/llviewermenu.cpp') diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 7cca118392..df8e127b1f 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 sDefaultItemLabels; + BOOL enable_land_build(void*); BOOL enable_object_build(void*); @@ -2403,31 +2406,53 @@ 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::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 + LLStringExplicit default_label = gMenuHolder->childGetValue(item_name).asString(); + if (!default_label.empty()) { - touch_text = userdata.asString(); + sDefaultItemLabels.insert(std::pair(item_name, default_label)); } - gMenuHolder->childSetText("Object Touch", touch_text); - gMenuHolder->childSetText("Attachment Object Touch", touch_text); + } +} - return new_value; +static LLStringExplicit get_default_item_label(const std::string& item_name) +{ + LLStringExplicit res(""); + boost::unordered_map::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 +5544,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("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(); } @@ -8048,7 +8073,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"); @@ -8064,12 +8088,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"); -- cgit v1.2.3