diff options
author | Dessie Linden <dessie@lindenlab.com> | 2010-06-11 11:51:14 -0700 |
---|---|---|
committer | Dessie Linden <dessie@lindenlab.com> | 2010-06-11 11:51:14 -0700 |
commit | 6b7470480692fc614d625212f9c17afd688e42de (patch) | |
tree | f510e51c81fb930ed42ef22de47cd7071a7c3b43 /indra/newview/llviewermenu.cpp | |
parent | 61d6669ffd766208abfa6240edc52723d8d141de (diff) | |
parent | b228915d1f45dc6d2c88a9381957b904410428f8 (diff) |
Merge
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r-- | indra/newview/llviewermenu.cpp | 268 |
1 files changed, 147 insertions, 121 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 476e761c28..caa868dca8 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -2,25 +2,31 @@ * @file llviewermenu.cpp * @brief Builds menus out of items. * - * $LicenseInfo:firstyear=2002&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * $LicenseInfo:firstyear=2002&license=viewergpl$ + * + * Copyright (c) 2002-2009, 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. + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * - * 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. + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * - * 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 + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ @@ -102,12 +108,9 @@ #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*); @@ -2048,9 +2051,9 @@ class LLAdvancedEnableRenderDeferred: public view_listener_t }; ///////////////////////////////////// -// Enable Global Illumination /// +// Enable Deferred Rendering sub-options ///////////////////////////////////// -class LLAdvancedEnableRenderDeferredGI: public view_listener_t +class LLAdvancedEnableRenderDeferredOptions: public view_listener_t { bool handleEvent(const LLSD& userdata) { @@ -2400,55 +2403,31 @@ void handle_object_touch() msg->sendMessage(object->getRegion()->getHost()); } -static void init_default_item_label(const std::string& item_name) +// One object must have touch sensor +class LLObjectEnableTouch : public view_listener_t { - boost::unordered_map<std::string, LLStringExplicit>::iterator it = sDefaultItemLabels.find(item_name); - if (it == sDefaultItemLabels.end()) + bool handleEvent(const LLSD& userdata) { - // *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()) + 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()) { - sDefaultItemLabels.insert(std::pair<std::string, LLStringExplicit>(item_name, default_label)); + touch_text = node->mTouchName; } - } -} - -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); + else + { + touch_text = userdata.asString(); + } + gMenuHolder->childSetText("Object Touch", touch_text); + gMenuHolder->childSetText("Attachment Object Touch", touch_text); - // 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; } - - return new_value; }; //void label_touch(std::string& label, void*) @@ -3299,6 +3278,16 @@ void handle_buy_object(LLSaleInfo sale_info) return; } + S32 price = sale_info.getSalePrice(); + + if (price > 0 && price > gStatusBar->getBalance()) + { + LLStringUtil::format_map_t args; + args["AMOUNT"] = llformat("%d", price); + LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("this_object_costs", args), price ); + return; + } + LLFloaterBuy::show(sale_info); } @@ -3648,7 +3637,7 @@ class LLEnableEditShape : public view_listener_t } }; -bool is_object_sittable() +bool enable_sit_object() { LLViewerObject* object = LLSelectMgr::getInstance()->getSelection()->getPrimaryObject(); @@ -3799,6 +3788,17 @@ class LLViewMouselook : public view_listener_t } }; +class LLViewFullscreen : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + // we no longer permit full screen mode EXT-6775 + // gViewerWindow->toggleFullscreen(TRUE); + llwarns << "full screen mode no longer supported" << llendl; + return true; + } +}; + class LLViewDefaultUISize : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -4554,16 +4554,6 @@ void handle_buy() BOOL valid = LLSelectMgr::getInstance()->selectGetSaleInfo(sale_info); if (!valid) return; - S32 price = sale_info.getSalePrice(); - - if (price > 0 && price > gStatusBar->getBalance()) - { - LLStringUtil::format_map_t args; - args["AMOUNT"] = llformat("%d", price); - LLBuyCurrencyHTML::openCurrencyFloater( LLTrans::getString("this_object_costs", args), price ); - return; - } - if (sale_info.getSaleType() == LLSaleInfo::FS_CONTENTS) { handle_buy_contents(sale_info); @@ -5534,37 +5524,56 @@ bool enable_pay_object() return false; } -bool enable_object_stand_up() +bool visible_object_stand_up() { - // 'Object Stand Up' menu item is enabled when agent is sitting on selection + // 'Object Stand Up' menu item is visible when agent is sitting on selection return sitting_on_selection(); } -bool enable_object_sit(LLUICtrl* ctrl) +bool visible_object_sit() { - // 'Object Sit' menu item is enabled when agent is not sitting on selection - bool sitting_on_sel = sitting_on_selection(); - if (!sitting_on_sel) + // 'Object Sit' menu item is visible when agent is not sitting on selection + bool is_sit_visible = !sitting_on_selection(); + if (is_sit_visible) { - std::string item_name = ctrl->getName(); - - // init default labels - init_default_item_label(item_name); - + 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()); // Update label + std::string label; LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstRootNode(); if (node && node->mValid && !node->mSitName.empty()) { - gMenuHolder->childSetText(item_name, node->mSitName); + label.assign(node->mSitName); } else { - gMenuHolder->childSetText(item_name, get_default_item_label(item_name)); + label = sit_text; } + sit_menu_item->setLabel(label); } - return !sitting_on_sel && is_object_sittable(); + return is_sit_visible; } +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(); @@ -6528,7 +6537,7 @@ void handle_dump_attachments(void*) } -// these are used in the gl menus to set control values. +// these are used in the gl menus to set control values, generically. class LLToggleControl : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -6547,8 +6556,44 @@ class LLCheckControl : public view_listener_t std::string callback_data = userdata.asString(); bool new_value = gSavedSettings.getBOOL(callback_data); return new_value; -} + } +}; +// not so generic + +class LLAdvancedCheckRenderShadowOption: public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + std::string control_name = userdata.asString(); + S32 current_shadow_level = gSavedSettings.getS32(control_name); + if (current_shadow_level == 0) // is off + { + return false; + } + else // is on + { + return true; + } + } +}; + +class LLAdvancedClickRenderShadowOption: public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + std::string control_name = userdata.asString(); + S32 current_shadow_level = gSavedSettings.getS32(control_name); + if (current_shadow_level == 0) // upgrade to level 2 + { + gSavedSettings.setS32(control_name, 2); + } + else // downgrade to level 0 + { + gSavedSettings.setS32(control_name, 0); + } + return true; + } }; void menu_toggle_attached_lights(void* user_data) @@ -7200,7 +7245,7 @@ void handle_web_browser_test(const LLSD& param) { url = "about:blank"; } - LLWeb::loadURLInternal(url); + LLWeb::loadURL(url); } void handle_buy_currency_test(void*) @@ -7695,31 +7740,6 @@ void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y) LLMenuGL::showPopup(ctrl, show_navbar_context_menu, x, y); } -void show_topinfobar_context_menu(LLView* ctrl, S32 x, S32 y) -{ - static LLMenuGL* show_topbarinfo_context_menu = LLUICtrlFactory::getInstance()->createFromFile<LLMenuGL>("menu_topinfobar.xml", - gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); - - LLMenuItemGL* landmark_item = show_topbarinfo_context_menu->getChild<LLMenuItemGL>("Landmark"); - if (!LLLandmarkActions::landmarkAlreadyExists()) - { - landmark_item->setLabel(LLTrans::getString("AddLandmarkNavBarMenu")); - } - else - { - landmark_item->setLabel(LLTrans::getString("EditLandmarkNavBarMenu")); - } - - if(gMenuHolder->hasVisibleMenu()) - { - gMenuHolder->hideMenus(); - } - - show_topbarinfo_context_menu->buildDrawLabels(); - show_topbarinfo_context_menu->updateParent(LLMenuGL::sMenuContainer); - LLMenuGL::showPopup(ctrl, show_topbarinfo_context_menu, x, y); -} - void initialize_edit_menu() { view_listener_t::addMenu(new LLEditUndo(), "Edit.Undo"); @@ -7799,6 +7819,7 @@ void initialize_menus() view_listener_t::addMenu(new LLZoomer(1.2f), "View.ZoomOut"); view_listener_t::addMenu(new LLZoomer(1/1.2f), "View.ZoomIn"); view_listener_t::addMenu(new LLZoomer(DEFAULT_FIELD_OF_VIEW, false), "View.ZoomDefault"); + view_listener_t::addMenu(new LLViewFullscreen(), "View.Fullscreen"); view_listener_t::addMenu(new LLViewDefaultUISize(), "View.DefaultUISize"); view_listener_t::addMenu(new LLViewEnableMouselook(), "View.EnableMouselook"); @@ -7873,7 +7894,7 @@ void initialize_menus() // Help menu // most items use the ShowFloater method - // Advance menu + // Advanced menu view_listener_t::addMenu(new LLAdvancedToggleConsole(), "Advanced.ToggleConsole"); view_listener_t::addMenu(new LLAdvancedCheckConsole(), "Advanced.CheckConsole"); view_listener_t::addMenu(new LLAdvancedDumpInfoToConsole(), "Advanced.DumpInfoToConsole"); @@ -7900,12 +7921,13 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedSelectedTextureInfo(), "Advanced.SelectedTextureInfo"); view_listener_t::addMenu(new LLAdvancedToggleWireframe(), "Advanced.ToggleWireframe"); view_listener_t::addMenu(new LLAdvancedCheckWireframe(), "Advanced.CheckWireframe"); + // Develop > Render view_listener_t::addMenu(new LLAdvancedToggleTextureAtlas(), "Advanced.ToggleTextureAtlas"); view_listener_t::addMenu(new LLAdvancedCheckTextureAtlas(), "Advanced.CheckTextureAtlas"); view_listener_t::addMenu(new LLAdvancedEnableObjectObjectOcclusion(), "Advanced.EnableObjectObjectOcclusion"); view_listener_t::addMenu(new LLAdvancedEnableRenderFBO(), "Advanced.EnableRenderFBO"); view_listener_t::addMenu(new LLAdvancedEnableRenderDeferred(), "Advanced.EnableRenderDeferred"); - view_listener_t::addMenu(new LLAdvancedEnableRenderDeferredGI(), "Advanced.EnableRenderDeferredGI"); + view_listener_t::addMenu(new LLAdvancedEnableRenderDeferredOptions(), "Advanced.EnableRenderDeferredOptions"); view_listener_t::addMenu(new LLAdvancedToggleRandomizeFramerate(), "Advanced.ToggleRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedCheckRandomizeFramerate(), "Advanced.CheckRandomizeFramerate"); view_listener_t::addMenu(new LLAdvancedTogglePeriodicSlowFrame(), "Advanced.TogglePeriodicSlowFrame"); @@ -7914,6 +7936,8 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedToggleFrameTest(), "Advanced.ToggleFrameTest"); view_listener_t::addMenu(new LLAdvancedCheckFrameTest(), "Advanced.CheckFrameTest"); view_listener_t::addMenu(new LLAdvancedHandleAttachedLightParticles(), "Advanced.HandleAttachedLightParticles"); + view_listener_t::addMenu(new LLAdvancedCheckRenderShadowOption(), "Advanced.CheckRenderShadowOption"); + view_listener_t::addMenu(new LLAdvancedClickRenderShadowOption(), "Advanced.ClickRenderShadowOption"); #ifdef TOGGLE_HACKED_GODLIKE_VIEWER @@ -8069,6 +8093,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)); 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 +8109,13 @@ 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)); - enable.add("Object.EnableTouch", boost::bind(&enable_object_touch, _1)); + 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.EnableStandUp", boost::bind(&enable_object_stand_up)); - enable.add("Object.EnableSit", boost::bind(&enable_object_sit, _1)); + enable.add("Object.StandUpVisible", boost::bind(&visible_object_stand_up)); + enable.add("Object.SitVisible", boost::bind(&visible_object_sit)); view_listener_t::addMenu(new LLObjectEnableReturn(), "Object.EnableReturn"); view_listener_t::addMenu(new LLObjectEnableReportAbuse(), "Object.EnableReportAbuse"); |