aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewermenu.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:16 -0500
committerJacek Antonelli2008-08-15 23:45:16 -0500
commit3f27ba891ac4d032753b219b4b96d1ffbc9fb488 (patch)
tree504932ee91a0356fba7ea48798887c96867e492f /linden/indra/newview/llviewermenu.cpp
parentSecond Life viewer sources 1.18.4.3 (diff)
downloadmeta-impy-3f27ba891ac4d032753b219b4b96d1ffbc9fb488.zip
meta-impy-3f27ba891ac4d032753b219b4b96d1ffbc9fb488.tar.gz
meta-impy-3f27ba891ac4d032753b219b4b96d1ffbc9fb488.tar.bz2
meta-impy-3f27ba891ac4d032753b219b4b96d1ffbc9fb488.tar.xz
Second Life viewer sources 1.18.5.0-RC
Diffstat (limited to 'linden/indra/newview/llviewermenu.cpp')
-rw-r--r--linden/indra/newview/llviewermenu.cpp213
1 files changed, 199 insertions, 14 deletions
diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp
index 2ac9caf..45006c1 100644
--- a/linden/indra/newview/llviewermenu.cpp
+++ b/linden/indra/newview/llviewermenu.cpp
@@ -138,6 +138,7 @@
138#include "llinventoryview.h" 138#include "llinventoryview.h"
139#include "llkeyboard.h" 139#include "llkeyboard.h"
140#include "llpanellogin.h" 140#include "llpanellogin.h"
141#include "llfloaterlandmark.h"
141#include "llmenucommands.h" 142#include "llmenucommands.h"
142#include "llmenugl.h" 143#include "llmenugl.h"
143#include "llmorphview.h" 144#include "llmorphview.h"
@@ -196,6 +197,9 @@
196 197
197#include "lltexlayer.h" 198#include "lltexlayer.h"
198 199
200void init_landmark_menu(LLMenuGL* menu);
201void clear_landmark_menu(LLMenuGL* menu);
202
199void init_client_menu(LLMenuGL* menu); 203void init_client_menu(LLMenuGL* menu);
200void init_server_menu(LLMenuGL* menu); 204void init_server_menu(LLMenuGL* menu);
201 205
@@ -244,6 +248,7 @@ LLPieMenu *gPieAttachment = NULL;
244LLPieMenu *gPieLand = NULL; 248LLPieMenu *gPieLand = NULL;
245 249
246// local constants 250// local constants
251const LLString LANDMARK_MENU_NAME("Landmarks");
247const LLString CLIENT_MENU_NAME("Client"); 252const LLString CLIENT_MENU_NAME("Client");
248const LLString SERVER_MENU_NAME("Server"); 253const LLString SERVER_MENU_NAME("Server");
249 254
@@ -273,6 +278,7 @@ LLPieMenu* gDetachPieMenu = NULL;
273LLPieMenu* gDetachScreenPieMenu = NULL; 278LLPieMenu* gDetachScreenPieMenu = NULL;
274LLPieMenu* gDetachBodyPartPieMenus[8]; 279LLPieMenu* gDetachBodyPartPieMenus[8];
275 280
281LLMenuGL* gLandmarkMenu = NULL;
276LLMenuItemCallGL* gAFKMenu = NULL; 282LLMenuItemCallGL* gAFKMenu = NULL;
277LLMenuItemCallGL* gBusyMenu = NULL; 283LLMenuItemCallGL* gBusyMenu = NULL;
278 284
@@ -334,6 +340,9 @@ void handle_audio_status_2(void*);
334void handle_audio_status_3(void*); 340void handle_audio_status_3(void*);
335void handle_audio_status_4(void*); 341void handle_audio_status_4(void*);
336#endif 342#endif
343void manage_landmarks(void*);
344void create_new_landmark(void*);
345void landmark_menu_action(void*);
337void reload_ui(void*); 346void reload_ui(void*);
338void handle_agent_stop_moving(void*); 347void handle_agent_stop_moving(void*);
339void print_packets_lost(void*); 348void print_packets_lost(void*);
@@ -362,6 +371,7 @@ void toggle_show_xui_names(void *);
362BOOL check_show_xui_names(void *); 371BOOL check_show_xui_names(void *);
363 372
364// Debug UI 373// Debug UI
374void handle_web_search_demo(void*);
365void handle_slurl_test(void*); 375void handle_slurl_test(void*);
366void handle_save_to_xml(void*); 376void handle_save_to_xml(void*);
367void handle_load_from_xml(void*); 377void handle_load_from_xml(void*);
@@ -483,6 +493,54 @@ BOOL enable_have_card(void*);
483BOOL enable_detach(void*); 493BOOL enable_detach(void*);
484BOOL enable_region_owner(void*); 494BOOL enable_region_owner(void*);
485 495
496class LLLandmarkObserver : public LLInventoryObserver
497{
498public:
499 LLLandmarkObserver();
500 virtual ~LLLandmarkObserver();
501
502 virtual void changed(U32 mask)
503 {
504 // JAMESDEBUG disabled for now - slows down client or causes crashes
505 // in inventory code.
506 //
507 // Also, this may not be faster than just rebuilding the menu each time.
508 // I believe gInventory.getObject() is not fast.
509 //
510 //const std::set<LLUUID>& changed_ids = gInventory.getChangedIDs();
511 //std::set<LLUUID>::const_iterator id_it;
512 //BOOL need_to_rebuild_menu = FALSE;
513 //for(id_it = changed_ids.begin(); id_it != changed_ids.end(); ++id_it)
514 //{
515 // LLInventoryObject* objectp = gInventory.getObject(*id_it);
516 // if (objectp && (objectp->getType() == LLAssetType::AT_LANDMARK || objectp->getType() == LLAssetType::AT_CATEGORY))
517 // {
518 // need_to_rebuild_menu = TRUE;
519 // }
520 //}
521 //if (need_to_rebuild_menu)
522 //{
523 // init_landmark_menu(gLandmarkMenu);
524 //}
525 }
526};
527
528// For debugging only, I think the inventory observer doesn't get
529// called if the inventory is loaded from cache.
530void build_landmark_menu(void*)
531{
532 init_landmark_menu(gLandmarkMenu);
533}
534
535LLLandmarkObserver::LLLandmarkObserver()
536{
537 gInventory.addObserver(this);
538}
539
540LLLandmarkObserver::~LLLandmarkObserver()
541{
542 gInventory.removeObserver(this);
543}
486 544
487class LLMenuParcelObserver : public LLParcelObserver 545class LLMenuParcelObserver : public LLParcelObserver
488{ 546{
@@ -493,6 +551,7 @@ public:
493}; 551};
494 552
495static LLMenuParcelObserver* gMenuParcelObserver = NULL; 553static LLMenuParcelObserver* gMenuParcelObserver = NULL;
554static LLLandmarkObserver* gLandmarkObserver = NULL;
496 555
497LLMenuParcelObserver::LLMenuParcelObserver() 556LLMenuParcelObserver::LLMenuParcelObserver()
498{ 557{
@@ -584,7 +643,7 @@ void init_menus()
584 gDetachScreenPieMenu = (LLPieMenu*)gMenuHolder->getChildByName("Object Detach HUD", true); 643 gDetachScreenPieMenu = (LLPieMenu*)gMenuHolder->getChildByName("Object Detach HUD", true);
585 gDetachPieMenu = (LLPieMenu*)gMenuHolder->getChildByName("Object Detach", true); 644 gDetachPieMenu = (LLPieMenu*)gMenuHolder->getChildByName("Object Detach", true);
586 645
587 if (gAgent.mAccess < SIM_ACCESS_MATURE) 646 if (gAgent.isTeen())
588 { 647 {
589 gMenuHolder->getChildByName("Self Underpants", TRUE)->setVisible(FALSE); 648 gMenuHolder->getChildByName("Self Underpants", TRUE)->setVisible(FALSE);
590 gMenuHolder->getChildByName("Self Undershirt", TRUE)->setVisible(FALSE); 649 gMenuHolder->getChildByName("Self Undershirt", TRUE)->setVisible(FALSE);
@@ -648,7 +707,7 @@ void init_menus()
648 gAttachSubMenu = gMenuBarView->getChildMenuByName("Attach Object", TRUE); 707 gAttachSubMenu = gMenuBarView->getChildMenuByName("Attach Object", TRUE);
649 gDetachSubMenu = gMenuBarView->getChildMenuByName("Detach Object", TRUE); 708 gDetachSubMenu = gMenuBarView->getChildMenuByName("Detach Object", TRUE);
650 709
651 if (gAgent.mAccess < SIM_ACCESS_MATURE) 710 if (gAgent.isTeen())
652 { 711 {
653 gMenuBarView->getChildByName("Menu Underpants", TRUE)->setVisible(FALSE); 712 gMenuBarView->getChildByName("Menu Underpants", TRUE)->setVisible(FALSE);
654 gMenuBarView->getChildByName("Menu Undershirt", TRUE)->setVisible(FALSE); 713 gMenuBarView->getChildByName("Menu Undershirt", TRUE)->setVisible(FALSE);
@@ -656,6 +715,18 @@ void init_menus()
656 715
657 // TomY TODO convert these two 716 // TomY TODO convert these two
658 LLMenuGL*menu; 717 LLMenuGL*menu;
718
719 // JAMESDEBUG - Maybe we don't want a global landmark menu
720 /*
721 menu = new LLMenuGL(LANDMARK_MENU_NAME);
722 // Defer init_landmark_menu() until inventory observer reports that we actually
723 // have inventory. Otherwise findCategoryByUUID() will create an empty
724 // Landmarks folder in inventory. JC
725 gMenuBarView->appendMenu( menu );
726 menu->updateParent(LLMenuGL::sMenuContainer);
727 gLandmarkMenu = menu;
728 */
729
659 menu = new LLMenuGL(CLIENT_MENU_NAME); 730 menu = new LLMenuGL(CLIENT_MENU_NAME);
660 init_client_menu(menu); 731 init_client_menu(menu);
661 gMenuBarView->appendMenu( menu ); 732 gMenuBarView->appendMenu( menu );
@@ -671,12 +742,74 @@ void init_menus()
671 // Let land based option enable when parcel changes 742 // Let land based option enable when parcel changes
672 gMenuParcelObserver = new LLMenuParcelObserver(); 743 gMenuParcelObserver = new LLMenuParcelObserver();
673 744
745 // Let landmarks menu update when landmarks are added/removed
746 gLandmarkObserver = new LLLandmarkObserver();
747
674 // 748 //
675 // Debug menu visiblity 749 // Debug menu visiblity
676 // 750 //
677 show_debug_menus(); 751 show_debug_menus();
678} 752}
679 753
754void init_landmark_menu(LLMenuGL* menu)
755{
756 if (!menu) return;
757
758 // clear existing menu, as we might be rebuilding as result of inventory update
759 clear_landmark_menu(menu);
760
761 menu->append(new LLMenuItemCallGL("Organize Landmarks",
762 &manage_landmarks, NULL));
763 menu->append(new LLMenuItemCallGL("New Landmark...",
764 &create_new_landmark, NULL));
765 menu->appendSeparator();
766
767 // now collect all landmarks in inventory and build menu...
768 LLInventoryModel::cat_array_t* cats;
769 LLInventoryModel::item_array_t* items;
770 gInventory.getDirectDescendentsOf(gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK), cats, items);
771 if(items)
772 {
773 S32 count = items->count();
774 for(S32 i = 0; i < count; ++i)
775 {
776 LLInventoryItem* item = items->get(i);
777 LLString landmark_name = item->getName();
778 LLUUID* landmark_id_ptr = new LLUUID( item->getUUID() );
779 LLMenuItemCallGL* menu_item =
780 new LLMenuItemCallGL(landmark_name, landmark_menu_action,
781 NULL, NULL, landmark_id_ptr);
782 menu->append(menu_item);
783 }
784 }
785}
786
787void clear_landmark_menu(LLMenuGL* menu)
788{
789 if (!menu) return;
790
791 // We store the UUIDs of the landmark inventory items in the userdata
792 // field of the menus. Therefore when we clean up the menu we need to
793 // delete that data.
794 const LLView::child_list_t* child_list = menu->getChildList();
795 LLView::child_list_const_iter_t it = child_list->begin();
796 for ( ; it != child_list->end(); ++it)
797 {
798 LLView* view = *it;
799 if (view->getWidgetType() == WIDGET_TYPE_MENU_ITEM_CALL)
800 {
801 LLMenuItemCallGL* menu_item = (LLMenuItemCallGL*)view;
802 if (menu_item->getMenuCallback() == landmark_menu_action)
803 {
804 void* user_data = menu_item->getUserData();
805 delete (LLUUID*)user_data;
806 }
807 }
808 }
809
810 menu->empty();
811}
812
680void init_client_menu(LLMenuGL* menu) 813void init_client_menu(LLMenuGL* menu)
681{ 814{
682 LLMenuGL* sub_menu = NULL; 815 LLMenuGL* sub_menu = NULL;
@@ -1010,7 +1143,7 @@ void init_debug_ui_menu(LLMenuGL* menu)
1010 menu->append(new LLMenuItemCallGL( "Dump VolumeMgr", &dump_volume_mgr, NULL, NULL)); 1143 menu->append(new LLMenuItemCallGL( "Dump VolumeMgr", &dump_volume_mgr, NULL, NULL));
1011 menu->append(new LLMenuItemCallGL( "Print Selected Object Info", &print_object_info, NULL, NULL, 'P', MASK_CONTROL|MASK_SHIFT )); 1144 menu->append(new LLMenuItemCallGL( "Print Selected Object Info", &print_object_info, NULL, NULL, 'P', MASK_CONTROL|MASK_SHIFT ));
1012 menu->append(new LLMenuItemCallGL( "Print Agent Info", &print_agent_nvpairs, NULL, NULL, 'P', MASK_SHIFT )); 1145 menu->append(new LLMenuItemCallGL( "Print Agent Info", &print_agent_nvpairs, NULL, NULL, 'P', MASK_SHIFT ));
1013 menu->append(new LLMenuItemCallGL( "Print Texture Memory Stats", &output_statistics, NULL, NULL, 'M', MASK_SHIFT | MASK_ALT | MASK_CONTROL)); 1146 menu->append(new LLMenuItemCallGL( "Texture Memory Stats", &output_statistics, NULL, NULL, 'M', MASK_SHIFT | MASK_ALT | MASK_CONTROL));
1014 menu->append(new LLMenuItemCheckGL("Double-Click Auto-Pilot", 1147 menu->append(new LLMenuItemCheckGL("Double-Click Auto-Pilot",
1015 menu_toggle_control, NULL, menu_check_control, 1148 menu_toggle_control, NULL, menu_check_control,
1016 (void*)"DoubleClickAutoPilot")); 1149 (void*)"DoubleClickAutoPilot"));
@@ -1456,9 +1589,14 @@ static std::vector<LLPointer<view_listener_t> > sMenus;
1456//----------------------------------------------------------------------------- 1589//-----------------------------------------------------------------------------
1457void cleanup_menus() 1590void cleanup_menus()
1458{ 1591{
1592 clear_landmark_menu(gLandmarkMenu);
1593
1459 delete gMenuParcelObserver; 1594 delete gMenuParcelObserver;
1460 gMenuParcelObserver = NULL; 1595 gMenuParcelObserver = NULL;
1461 1596
1597 delete gLandmarkObserver;
1598 gLandmarkObserver = NULL;
1599
1462 delete gPieSelf; 1600 delete gPieSelf;
1463 gPieSelf = NULL; 1601 gPieSelf = NULL;
1464 1602
@@ -2860,6 +2998,60 @@ void handle_audio_status_4(void*)
2860} 2998}
2861#endif 2999#endif
2862 3000
3001void manage_landmarks(void*)
3002{
3003 LLFloaterLandmark::showInstance(1);
3004}
3005
3006void create_new_landmark(void*)
3007{
3008 // Note this is temporary cut and paste of legacy functionality.
3009 // TODO: Make this spawn a floater allowing user customize before creating the inventory object
3010
3011 LLViewerRegion* agent_region = gAgent.getRegion();
3012 if(!agent_region)
3013 {
3014 llwarns << "No agent region" << llendl;
3015 return;
3016 }
3017 LLParcel* agent_parcel = gParcelMgr->getAgentParcel();
3018 if (!agent_parcel)
3019 {
3020 llwarns << "No agent parcel" << llendl;
3021 return;
3022 }
3023 if (!agent_parcel->getAllowLandmark()
3024 && !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
3025 {
3026 gViewerWindow->alertXml("CannotCreateLandmarkNotOwner");
3027 return;
3028 }
3029
3030 LLUUID folder_id;
3031 folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
3032 std::string pos_string;
3033 gAgent.buildLocationString(pos_string);
3034
3035 create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
3036 folder_id, LLTransactionID::tnull,
3037 pos_string, pos_string, // name, desc
3038 LLAssetType::AT_LANDMARK,
3039 LLInventoryType::IT_LANDMARK,
3040 NOT_WEARABLE, PERM_ALL,
3041 NULL);
3042}
3043
3044void landmark_menu_action(void* userdata)
3045{
3046 LLUUID item_id = *(LLUUID*)userdata;
3047
3048 LLViewerInventoryItem* itemp = gInventory.getItem(item_id);
3049 if (itemp)
3050 {
3051 open_landmark(itemp, itemp->getName(), FALSE);
3052 }
3053}
3054
2863void reload_ui(void *) 3055void reload_ui(void *)
2864{ 3056{
2865 gUICtrlFactory->rebuild(); 3057 gUICtrlFactory->rebuild();
@@ -5160,7 +5352,7 @@ class LLShowFloater : public view_listener_t
5160 else if (floater_name == "help f1") 5352 else if (floater_name == "help f1")
5161 { 5353 {
5162#if LL_LIBXUL_ENABLED 5354#if LL_LIBXUL_ENABLED
5163 gViewerHtmlHelp.show(); 5355 gViewerHtmlHelp.show( gSavedSettings.getString("HelpHomeURL") );
5164#endif 5356#endif
5165 } 5357 }
5166 else if (floater_name == "help in-world") 5358 else if (floater_name == "help in-world")
@@ -5363,7 +5555,7 @@ class LLShowAgentProfile : public view_listener_t
5363 LLVOAvatar* avatar = find_avatar_from_object(agent_id); 5555 LLVOAvatar* avatar = find_avatar_from_object(agent_id);
5364 if (avatar) 5556 if (avatar)
5365 { 5557 {
5366 LLFloaterAvatarInfo::showFromAvatar(avatar); 5558 LLFloaterAvatarInfo::show(agent_id);
5367 } 5559 }
5368 return true; 5560 return true;
5369 } 5561 }
@@ -6080,18 +6272,11 @@ void handle_test_female(void*)
6080 6272
6081void handle_toggle_pg(void*) 6273void handle_toggle_pg(void*)
6082{ 6274{
6083 if (gAgent.mAccess < SIM_ACCESS_MATURE) 6275 gAgent.setTeen( !gAgent.isTeen() );
6084 {
6085 gAgent.mAccess = SIM_ACCESS_MATURE;
6086 }
6087 else
6088 {
6089 gAgent.mAccess = SIM_ACCESS_PG;
6090 }
6091 6276
6092 LLFloaterWorldMap::reloadIcons(NULL); 6277 LLFloaterWorldMap::reloadIcons(NULL);
6093 6278
6094 llinfos << "Access set to " << (S32)gAgent.mAccess << llendl; 6279 llinfos << "PG status set to " << (S32)gAgent.isTeen() << llendl;
6095} 6280}
6096 6281
6097void handle_dump_attachments(void*) 6282void handle_dump_attachments(void*)