diff options
Diffstat (limited to 'linden/indra/newview/llviewermenu.cpp')
-rw-r--r-- | linden/indra/newview/llviewermenu.cpp | 829 |
1 files changed, 232 insertions, 597 deletions
diff --git a/linden/indra/newview/llviewermenu.cpp b/linden/indra/newview/llviewermenu.cpp index 0d7a2cd..28c5049 100644 --- a/linden/indra/newview/llviewermenu.cpp +++ b/linden/indra/newview/llviewermenu.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | * @file llviewermenu.cpp | 2 | * @file llviewermenu.cpp |
3 | * @brief Builds menus out of items. | 3 | * @brief Builds menus out of items. |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
6 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | 7 | * Copyright (c) 2002-2007, Linden Research, Inc. |
6 | * | 8 | * |
7 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
@@ -24,6 +26,7 @@ | |||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
26 | * COMPLETENESS OR PERFORMANCE. | 28 | * COMPLETENESS OR PERFORMANCE. |
29 | * $/LicenseInfo$ | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
@@ -103,8 +106,8 @@ | |||
103 | #include "llfloatergroups.h" | 106 | #include "llfloatergroups.h" |
104 | #include "llfloaterhtml.h" | 107 | #include "llfloaterhtml.h" |
105 | #include "llfloaterhtmlhelp.h" | 108 | #include "llfloaterhtmlhelp.h" |
106 | #include "llfloaterhtmlfind.h" | ||
107 | #include "llfloaterinspect.h" | 109 | #include "llfloaterinspect.h" |
110 | #include "llfloaterlagmeter.h" | ||
108 | #include "llfloaterland.h" | 111 | #include "llfloaterland.h" |
109 | #include "llfloaterlandholdings.h" | 112 | #include "llfloaterlandholdings.h" |
110 | #include "llfloatermap.h" | 113 | #include "llfloatermap.h" |
@@ -359,6 +362,7 @@ void toggle_show_xui_names(void *); | |||
359 | BOOL check_show_xui_names(void *); | 362 | BOOL check_show_xui_names(void *); |
360 | 363 | ||
361 | // Debug UI | 364 | // Debug UI |
365 | void handle_slurl_test(void*); | ||
362 | void handle_save_to_xml(void*); | 366 | void handle_save_to_xml(void*); |
363 | void handle_load_from_xml(void*); | 367 | void handle_load_from_xml(void*); |
364 | 368 | ||
@@ -632,10 +636,12 @@ void init_menus() | |||
632 | // flash when an item is triggered (the flash occurs in the holder) | 636 | // flash when an item is triggered (the flash occurs in the holder) |
633 | gViewerWindow->getRootView()->addChild(gMenuHolder); | 637 | gViewerWindow->getRootView()->addChild(gMenuHolder); |
634 | 638 | ||
635 | gMenuHolder->childSetLabelArg("Upload Image", "[COST]", "10"); | 639 | // *TODO:Get the cost info from the server |
636 | gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", "10"); | 640 | const LLString upload_cost("10"); |
637 | gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", "10"); | 641 | gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost); |
638 | gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", "10"); | 642 | gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost); |
643 | gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost); | ||
644 | gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost); | ||
639 | 645 | ||
640 | gAFKMenu = (LLMenuItemCallGL*)gMenuBarView->getChildByName("Set Away", TRUE); | 646 | gAFKMenu = (LLMenuItemCallGL*)gMenuBarView->getChildByName("Set Away", TRUE); |
641 | gBusyMenu = (LLMenuItemCallGL*)gMenuBarView->getChildByName("Set Busy", TRUE); | 647 | gBusyMenu = (LLMenuItemCallGL*)gMenuBarView->getChildByName("Set Busy", TRUE); |
@@ -768,9 +774,12 @@ void init_client_menu(LLMenuGL* menu) | |||
768 | NULL, | 774 | NULL, |
769 | &menu_check_control, | 775 | &menu_check_control, |
770 | (void*)"HighResSnapshot")); | 776 | (void*)"HighResSnapshot")); |
771 | 777 | ||
772 | menu->append(new LLMenuItemToggleGL("Quiet Snapshots to Disk", | 778 | menu->append(new LLMenuItemCheckGL( "Quiet Snapshots to Disk", |
773 | &gQuietSnapshot)); | 779 | &menu_toggle_control, |
780 | NULL, | ||
781 | &menu_check_control, | ||
782 | (void*)"QuietSnapshotsToDisk")); | ||
774 | 783 | ||
775 | menu->append(new LLMenuItemCheckGL( "Compress Snapshots to Disk", | 784 | menu->append(new LLMenuItemCheckGL( "Compress Snapshots to Disk", |
776 | &menu_toggle_control, | 785 | &menu_toggle_control, |
@@ -897,8 +906,11 @@ void init_client_menu(LLMenuGL* menu) | |||
897 | &menu_check_control, | 906 | &menu_check_control, |
898 | (void*)"LimitSelectDistance")); | 907 | (void*)"LimitSelectDistance")); |
899 | 908 | ||
900 | menu->append(new LLMenuItemToggleGL("Disable Camera Constraints", | 909 | menu->append(new LLMenuItemCheckGL("Disable Camera Constraints", |
901 | &LLViewerCamera::sDisableCameraConstraints, 'C', MASK_ALT | MASK_CONTROL )); | 910 | &menu_toggle_control, |
911 | NULL, | ||
912 | &menu_check_control, | ||
913 | (void*)"DisableCameraConstraints")); | ||
902 | 914 | ||
903 | menu->append(new LLMenuItemCheckGL("Joystick Flycam", | 915 | menu->append(new LLMenuItemCheckGL("Joystick Flycam", |
904 | &handle_toggle_flycam,NULL,&check_flycam,NULL)); | 916 | &handle_toggle_flycam,NULL,&check_flycam,NULL)); |
@@ -989,6 +1001,7 @@ extern BOOL gVectorizePerfTest; | |||
989 | 1001 | ||
990 | void init_debug_ui_menu(LLMenuGL* menu) | 1002 | void init_debug_ui_menu(LLMenuGL* menu) |
991 | { | 1003 | { |
1004 | menu->append(new LLMenuItemCallGL("SLURL Test", &handle_slurl_test)); | ||
992 | menu->append(new LLMenuItemCallGL("Editable UI", &edit_ui)); | 1005 | menu->append(new LLMenuItemCallGL("Editable UI", &edit_ui)); |
993 | menu->append(new LLMenuItemToggleGL("Async Keystrokes", &gHandleKeysAsync)); | 1006 | menu->append(new LLMenuItemToggleGL("Async Keystrokes", &gHandleKeysAsync)); |
994 | menu->append(new LLMenuItemCallGL( "Dump SelectMgr", &dump_select_mgr)); | 1007 | menu->append(new LLMenuItemCallGL( "Dump SelectMgr", &dump_select_mgr)); |
@@ -3384,31 +3397,33 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3384 | } | 3397 | } |
3385 | //gInventoryView->setPanelOpen(TRUE); | 3398 | //gInventoryView->setPanelOpen(TRUE); |
3386 | 3399 | ||
3387 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 3400 | std::string error; |
3388 | LLViewerObject* object = NULL; | 3401 | LLDynamicArray<LLViewerObject*> derez_objects; |
3389 | LLSelectNode* node = selection->getFirstRootNode(); | 3402 | |
3390 | if(!node) return; | ||
3391 | object = node->getObject(); | ||
3392 | if(!object) return; | ||
3393 | LLViewerRegion* region = object->getRegion(); | ||
3394 | char* error = NULL; | ||
3395 | |||
3396 | // Check conditions that we can't deal with, building a list of | 3403 | // Check conditions that we can't deal with, building a list of |
3397 | // everything that we'll actually be derezzing. | 3404 | // everything that we'll actually be derezzing. |
3398 | LLDynamicArray<LLViewerObject*> derez_objects; | 3405 | LLViewerRegion* first_region = NULL; |
3399 | BOOL can_derez_current; | 3406 | for (LLObjectSelection::valid_root_iterator iter = gSelectMgr->getSelection()->valid_root_begin(); |
3400 | for( ; node != NULL; node = selection->getNextRootNode()) | 3407 | iter != gSelectMgr->getSelection()->valid_root_end(); iter++) |
3401 | { | 3408 | { |
3402 | object = node->getObject(); | 3409 | LLSelectNode* node = *iter; |
3403 | if(!object || !node->mValid) continue; | 3410 | LLViewerObject* object = node->getObject(); |
3404 | if(object->getRegion() != region) | 3411 | LLViewerRegion* region = object->getRegion(); |
3412 | if (!first_region) | ||
3405 | { | 3413 | { |
3406 | // Derez doesn't work at all if the some of the objects | 3414 | first_region = region; |
3407 | // are in regions besides the first object selected. | 3415 | } |
3408 | 3416 | else | |
3409 | // ...crosses region boundaries | 3417 | { |
3410 | error = "AcquireErrorObjectSpan"; | 3418 | if(region != first_region) |
3411 | break; | 3419 | { |
3420 | // Derez doesn't work at all if the some of the objects | ||
3421 | // are in regions besides the first object selected. | ||
3422 | |||
3423 | // ...crosses region boundaries | ||
3424 | error = "AcquireErrorObjectSpan"; | ||
3425 | break; | ||
3426 | } | ||
3412 | } | 3427 | } |
3413 | if (object->isAvatar()) | 3428 | if (object->isAvatar()) |
3414 | { | 3429 | { |
@@ -3429,7 +3444,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3429 | */ | 3444 | */ |
3430 | continue; | 3445 | continue; |
3431 | } | 3446 | } |
3432 | can_derez_current = FALSE; | 3447 | BOOL can_derez_current = FALSE; |
3433 | switch(dest) | 3448 | switch(dest) |
3434 | { | 3449 | { |
3435 | case DRD_TAKE_INTO_AGENT_INVENTORY: | 3450 | case DRD_TAKE_INTO_AGENT_INVENTORY: |
@@ -3473,7 +3488,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3473 | error = "AcquireErrorTooManyObjects"; | 3488 | error = "AcquireErrorTooManyObjects"; |
3474 | } | 3489 | } |
3475 | 3490 | ||
3476 | if(!error && derez_objects.count() > 0) | 3491 | if(error.empty() && derez_objects.count() > 0) |
3477 | { | 3492 | { |
3478 | U8 d = (U8)dest; | 3493 | U8 d = (U8)dest; |
3479 | LLUUID tid; | 3494 | LLUUID tid; |
@@ -3502,7 +3517,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3502 | && (objects_in_packet++ < MAX_ROOTS_PER_PACKET)) | 3517 | && (objects_in_packet++ < MAX_ROOTS_PER_PACKET)) |
3503 | 3518 | ||
3504 | { | 3519 | { |
3505 | object = derez_objects.get(object_index++); | 3520 | LLViewerObject* object = derez_objects.get(object_index++); |
3506 | msg->nextBlockFast(_PREHASH_ObjectData); | 3521 | msg->nextBlockFast(_PREHASH_ObjectData); |
3507 | msg->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID()); | 3522 | msg->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID()); |
3508 | // VEFFECT: DerezObject | 3523 | // VEFFECT: DerezObject |
@@ -3510,7 +3525,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3510 | effectp->setPositionGlobal(object->getPositionGlobal()); | 3525 | effectp->setPositionGlobal(object->getPositionGlobal()); |
3511 | effectp->setColor(LLColor4U(gAgent.getEffectColor())); | 3526 | effectp->setColor(LLColor4U(gAgent.getEffectColor())); |
3512 | } | 3527 | } |
3513 | msg->sendReliable(region->getHost()); | 3528 | msg->sendReliable(first_region->getHost()); |
3514 | } | 3529 | } |
3515 | make_ui_sound("UISndObjectRezOut"); | 3530 | make_ui_sound("UISndObjectRezOut"); |
3516 | 3531 | ||
@@ -3521,7 +3536,7 @@ void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) | |||
3521 | gViewerWindow->getWindow()->incBusyCount(); | 3536 | gViewerWindow->getWindow()->incBusyCount(); |
3522 | } | 3537 | } |
3523 | } | 3538 | } |
3524 | else if(error) | 3539 | else if(!error.empty()) |
3525 | { | 3540 | { |
3526 | gViewerWindow->alertXml(error); | 3541 | gViewerWindow->alertXml(error); |
3527 | } | 3542 | } |
@@ -3601,20 +3616,17 @@ class LLObjectEnableReturn : public view_listener_t | |||
3601 | } | 3616 | } |
3602 | else | 3617 | else |
3603 | { | 3618 | { |
3604 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 3619 | struct f : public LLSelectedObjectFunctor |
3605 | LLViewerObject* obj = NULL; | ||
3606 | for(obj = selection->getFirstRootObject(); | ||
3607 | obj; | ||
3608 | obj = selection->getNextRootObject()) | ||
3609 | { | 3620 | { |
3610 | if (obj->isOverAgentOwnedLand() | 3621 | virtual bool apply(LLViewerObject* obj) |
3611 | || obj->isOverGroupOwnedLand() | ||
3612 | || obj->permModify()) | ||
3613 | { | 3622 | { |
3614 | new_value = true; | 3623 | return (obj->isOverAgentOwnedLand() || |
3615 | break; | 3624 | obj->isOverGroupOwnedLand() || |
3625 | obj->permModify()); | ||
3616 | } | 3626 | } |
3617 | } | 3627 | } func; |
3628 | const bool firstonly = true; | ||
3629 | new_value = gSelectMgr->getSelection()->applyToRootObjects(&func, firstonly); | ||
3618 | } | 3630 | } |
3619 | } | 3631 | } |
3620 | } | 3632 | } |
@@ -3630,373 +3642,25 @@ void force_take_copy(void*) | |||
3630 | const LLUUID& category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT); | 3642 | const LLUUID& category_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_OBJECT); |
3631 | derez_objects(DRD_FORCE_TO_GOD_INVENTORY, category_id); | 3643 | derez_objects(DRD_FORCE_TO_GOD_INVENTORY, category_id); |
3632 | } | 3644 | } |
3633 | #ifdef _CORY_TESTING | ||
3634 | |||
3635 | void force_export_copy(void*) | ||
3636 | { | ||
3637 | LLViewerObject* object = NULL; | ||
3638 | LLSelectNode* node = gSelectMgr->getSelection()->getFirstNode(); | ||
3639 | if(!node) return; | ||
3640 | object = node->getObject(); | ||
3641 | if(!object) return; | ||
3642 | |||
3643 | |||
3644 | LLString proposed_name; | ||
3645 | proposed_name.append(node->mName); | ||
3646 | proposed_name.append( ".slg" ); | ||
3647 | |||
3648 | LLViewerRegion* region = object->getRegion(); | ||
3649 | |||
3650 | // Check conditions that we can't deal with, building a list of | ||
3651 | // everything that we'll actually be derezzing. | ||
3652 | |||
3653 | std::vector<LLViewerObject*> export_objects; | ||
3654 | std::vector<std::string> export_names; | ||
3655 | std::vector<std::string> export_descriptions; | ||
3656 | |||
3657 | S32 object_index = 0; | ||
3658 | |||
3659 | for( ; node != NULL; node = gSelectMgr->getSelection()->getNextNode()) | ||
3660 | { | ||
3661 | object = node->getObject(); | ||
3662 | if(!object || !node->mValid) | ||
3663 | { | ||
3664 | // Clicked cancel | ||
3665 | return; | ||
3666 | } | ||
3667 | if(object->getRegion() != region) | ||
3668 | { | ||
3669 | // Clicked cancel | ||
3670 | return; | ||
3671 | } | ||
3672 | if (object->isAvatar()) | ||
3673 | { | ||
3674 | continue; | ||
3675 | } | ||
3676 | |||
3677 | if (object->getNVPair("AssetContainer")) | ||
3678 | { | ||
3679 | continue; | ||
3680 | } | ||
3681 | export_objects.push_back(node->getObject()); | ||
3682 | export_names.push_back(node->mName); | ||
3683 | export_descriptions.push_back(node->mDescription); | ||
3684 | } | ||
3685 | |||
3686 | if (export_objects.empty()) | ||
3687 | { | ||
3688 | return; | ||
3689 | } | ||
3690 | |||
3691 | // pick a save file | ||
3692 | LLFilePicker& picker = LLFilePicker::instance(); | ||
3693 | if (!picker.getSaveFile(LLFilePicker::FFSAVE_GEOMETRY, proposed_name)) | ||
3694 | { | ||
3695 | // Clicked cancel | ||
3696 | return; | ||
3697 | } | ||
3698 | |||
3699 | // Copy the directory + file name | ||
3700 | char filepath[LL_MAX_PATH]; /* Flawfinder: ignore */ | ||
3701 | strncpy(filepath, picker.getFirstFile(), LL_MAX_PATH -1); /* Flawfinder: ignore */ | ||
3702 | filepath[LL_MAX_PATH -1] = '\0'; | ||
3703 | |||
3704 | apr_file_t* fp = ll_apr_file_open(filepath, LL_APR_W); | ||
3705 | |||
3706 | if (!fp) | ||
3707 | { | ||
3708 | return; | ||
3709 | } | ||
3710 | |||
3711 | object = export_objects[object_index]; | ||
3712 | LLVector3 baseoffset = object->getPositionRegion(); | ||
3713 | |||
3714 | apr_file_printf(fp, "<?xml version=\"1.0\" encoding=\"US-ASCII\" standalone=\"yes\"?>\n"); | ||
3715 | apr_file_printf(fp, "<LindenGeometry>\n"); | ||
3716 | |||
3717 | while(object_index < export_objects.size()) | ||
3718 | { | ||
3719 | apr_file_printf(fp, "<Object\n"); | ||
3720 | apr_file_printf(fp, "\tShape='%s'\n", export_names[object_index].c_str()); | ||
3721 | apr_file_printf(fp, "\tDescription='%s'\n", export_descriptions[object_index].c_str()); | ||
3722 | |||
3723 | apr_file_printf(fp, "\tPCode='%d'\n", (U32)object->getPCode()); | ||
3724 | apr_file_printf(fp, "\tMaterial='%d'\n", object->getMaterial()); | ||
3725 | apr_file_printf(fp, "\tScale='%5f %5f %5f'\n", object->getScale().mV[VX], object->getScale().mV[VY], object->getScale().mV[VZ]); | ||
3726 | LLVector3 delta = object->getPositionRegion() - baseoffset; | ||
3727 | LLQuaternion rot = object->getRotationRegion(); | ||
3728 | apr_file_printf(fp, "\tOffset='%5f %5f %5f'\n", delta.mV[VX], delta.mV[VY], delta.mV[VZ]); | ||
3729 | apr_file_printf(fp, "\tOrientation='%5f %5f %5f %5f'\n", rot.mQ[VX], rot.mQ[VY], rot.mQ[VZ], rot.mQ[VS]); | ||
3730 | const LLProfileParams pparams = object->getVolume()->getProfile().mParams; | ||
3731 | apr_file_printf(fp, "\tShapeProfile='%d %f %f %f'\n", pparams.getCurveType(), pparams.getBegin(), pparams.getEnd(), pparams.getHollow()); | ||
3732 | const LLPathParams paparams = object->getVolume()->getPath().mParams; | ||
3733 | apr_file_printf(fp, "\tShapePath='%d %f %f %f %f %f %f %f %f %f %f %f %f %f'\n", | ||
3734 | paparams.getCurveType(), paparams.getBegin(), paparams.getEnd(), paparams.getTwist(), paparams.getTwistBegin(), paparams.getScaleX(), paparams.getScaleY(), | ||
3735 | paparams.getShearX(), paparams.getShearY(), paparams.getRadiusOffset(), paparams.getTaperX(), paparams.getTaperY(), | ||
3736 | paparams.getRevolutions(), paparams.getSkew()); | ||
3737 | S32 face, numfaces; | ||
3738 | numfaces = object->getNumTEs(); | ||
3739 | apr_file_printf(fp, "\tNumberOfFaces='%d'>\n", numfaces); | ||
3740 | for (face = 0; face < numfaces; face++) | ||
3741 | { | ||
3742 | const LLTextureEntry *te = object->getTE(face); | ||
3743 | LLColor4 color = te->getColor(); | ||
3744 | apr_file_printf(fp, "\t<Face\n\t\tFaceColor='%d %5f %5f %5f %5f'\n", face, color.mV[VX], color.mV[VY], color.mV[VZ], color.mV[VW]); | ||
3745 | |||
3746 | char texture[UUID_STR_LENGTH]; /* Flawfinder: ignore */ | ||
3747 | LLUUID texid = te->getID(); | ||
3748 | texid.toString(texture); | ||
3749 | F32 sx, sy, ox, oy; | ||
3750 | te->getScale(&sx, &sy); | ||
3751 | te->getOffset(&ox, &oy); | ||
3752 | |||
3753 | apr_file_printf(fp, "\t\tFace='%d %5f %5f %5f %5f %5f %d %s'\n\t/>\n", face, sx, sy, ox, oy, te->getRotation(), te->getBumpShinyFullbright(), texture); | ||
3754 | } | ||
3755 | apr_file_printf(fp, "</Object>\n"); | ||
3756 | object = export_objects[++object_index]; | ||
3757 | } | ||
3758 | |||
3759 | apr_file_printf(fp, "</LindenGeometry>\n"); | ||
3760 | |||
3761 | fclose(fp); | ||
3762 | } | ||
3763 | |||
3764 | void undo_find_local_contact_point(LLVector3 &contact, | ||
3765 | const LLVector3& surface_norm, | ||
3766 | const LLQuaternion& rot, | ||
3767 | const LLVector3& scale ) | ||
3768 | { | ||
3769 | LLVector3 local_norm = surface_norm; | ||
3770 | local_norm.rotVec( ~rot ); | ||
3771 | |||
3772 | LLVector3 v[6]; | ||
3773 | v[0].mV[VX] = -1.f; | ||
3774 | v[1].mV[VX] = 1.f; | ||
3775 | |||
3776 | v[2].mV[VY] = -1.f; | ||
3777 | v[3].mV[VY] = 1.f; | ||
3778 | |||
3779 | v[4].mV[VZ] = -1.f; | ||
3780 | v[5].mV[VZ] = 1.f; | ||
3781 | |||
3782 | contact = v[0]; | ||
3783 | F32 cur_val = 0; | ||
3784 | |||
3785 | for( S32 i = 0; i < 6; i++ ) | ||
3786 | { | ||
3787 | F32 val = v[i] * local_norm; | ||
3788 | if( val < cur_val ) | ||
3789 | { | ||
3790 | contact = v[i]; | ||
3791 | cur_val = val; | ||
3792 | } | ||
3793 | } | ||
3794 | |||
3795 | contact.mV[VX] *= 0.5f * scale.mV[VX]; | ||
3796 | contact.mV[VY] *= 0.5f * scale.mV[VY]; | ||
3797 | contact.mV[VZ] *= 0.5f * scale.mV[VZ]; | ||
3798 | contact.rotVec( rot ); | ||
3799 | } | ||
3800 | |||
3801 | |||
3802 | 3645 | ||
3803 | void force_import_geometry(void*) | 3646 | void handle_take() |
3804 | { | 3647 | { |
3805 | LLFilePicker& picker = LLFilePicker::instance(); | 3648 | // we want to use the folder this was derezzed from if it's |
3806 | if (!picker.getOpenFile(LLFilePicker::FFLOAD_GEOMETRY)) | 3649 | // available. Otherwise, derez to the normal place. |
3807 | { | 3650 | if(gSelectMgr->getSelection()->isEmpty()) |
3808 | llinfos << "Couldn't import objects from file" << llendl; | ||
3809 | return; | ||
3810 | } | ||
3811 | |||
3812 | char directory[LL_MAX_PATH]; /* Flawfinder: ignore */ | ||
3813 | strncpy(directory, picker.getFirstFile(), LL_MAX_PATH -1); /* Flawfinder: ignore */ | ||
3814 | directory[LL_MAX_PATH -1] = '\0'; | ||
3815 | |||
3816 | llinfos << "Loading LSG file " << directory << llendl; | ||
3817 | LLXmlTree *xmlparser = new LLXmlTree(); | ||
3818 | xmlparser->parseFile(directory, TRUE); | ||
3819 | LLXmlTreeNode *root = xmlparser->getRoot(); | ||
3820 | if( !root ) | ||
3821 | { | ||
3822 | return; | ||
3823 | } | ||
3824 | // header | ||
3825 | if( !root->hasName( "LindenGeometry" ) ) | ||
3826 | { | 3651 | { |
3827 | llwarns << "Invalid LindenGeometry file header: " << directory << llendl; | ||
3828 | return; | 3652 | return; |
3829 | } | 3653 | } |
3830 | // objects | ||
3831 | for (LLXmlTreeNode *child = root->getChildByName( "Object" ); | ||
3832 | child; | ||
3833 | child = root->getNextNamedChild()) | ||
3834 | { | ||
3835 | // get object data | ||
3836 | // *NOTE: This buffer size is hard coded into scanf() below. | ||
3837 | char name[255]; /* Flawfinder: ignore */ // Shape | ||
3838 | char description[255]; /* Flawfinder: ignore */ // Description | ||
3839 | U32 material; // Material | ||
3840 | F32 sx, sy, sz; // Scale | ||
3841 | LLVector3 scale; | ||
3842 | F32 ox, oy, oz; // Offset | ||
3843 | LLVector3 offset; | ||
3844 | F32 rx, ry, rz, rs; // Orientation | ||
3845 | LLQuaternion rot; | ||
3846 | U32 curve; | ||
3847 | F32 begin; | ||
3848 | F32 end; | ||
3849 | F32 hollow; | ||
3850 | F32 twist; | ||
3851 | F32 scx, scy; | ||
3852 | F32 shx, shy; | ||
3853 | F32 twist_begin; | ||
3854 | F32 radius_offset; | ||
3855 | F32 tx, ty; | ||
3856 | F32 revolutions; | ||
3857 | F32 skew; | ||
3858 | S32 faces; | ||
3859 | U32 pcode; | ||
3860 | U32 flags = FLAGS_CREATE_SELECTED; | ||
3861 | |||
3862 | LLString attribute; | ||
3863 | |||
3864 | S32 count = 0; | ||
3865 | |||
3866 | child->getAttributeString("PCode", &attribute); | ||
3867 | pcode = atoi(attribute.c_str()); | ||
3868 | child->getAttributeString("Shape", &attribute); | ||
3869 | sscanf( /* Flawfinder: ignore */ | ||
3870 | attribute.c_str(), "%254s", name); | ||
3871 | child->getAttributeString("Description", &attribute); | ||
3872 | sscanf( /* Flawfinder: ignore */ | ||
3873 | attribute.c_str(), "%254s", description); | ||
3874 | child->getAttributeString("Material", &attribute); | ||
3875 | material = atoi(attribute.c_str()); | ||
3876 | child->getAttributeString("Scale", &attribute); | ||
3877 | sscanf(attribute.c_str(), "%f %f %f", &sx, &sy, &sz); | ||
3878 | scale.setVec(sx, sy, sz); | ||
3879 | child->getAttributeString("Offset", &attribute); | ||
3880 | sscanf(attribute.c_str(), "%f %f %f", &ox, &oy, &oz); | ||
3881 | offset.setVec(ox, oy, oz); | ||
3882 | child->getAttributeString("Orientation", &attribute); | ||
3883 | sscanf(attribute.c_str(), "%f %f %f %f", &rx, &ry, &rz, &rs); | ||
3884 | rot.mQ[VX] = rx; | ||
3885 | rot.mQ[VY] = ry; | ||
3886 | rot.mQ[VZ] = rz; | ||
3887 | rot.mQ[VS] = rs; | ||
3888 | |||
3889 | child->getAttributeString("ShapeProfile", &attribute); | ||
3890 | sscanf(attribute.c_str(), "%d %f %f %f", &curve, &begin, &end, &hollow); | ||
3891 | LLProfileParams pparams(curve, begin, end, hollow); | ||
3892 | child->getAttributeString("ShapePath", &attribute); | ||
3893 | sscanf(attribute.c_str(), "%d %f %f %f %f %f %f %f %f %f %f %f %f %f", | ||
3894 | &curve, &begin, &end, &twist, &twist_begin, &scx, &scy, &shx, ­, &radius_offset, &tx, &ty, &revolutions, &skew); | ||
3895 | LLPathParams paparams(curve, begin, end, scx, scy, shx, shy, twist, twist_begin, radius_offset, tx, ty, revolutions, skew); | ||
3896 | child->getAttributeString("NumberOfFaces", &attribute); | ||
3897 | faces = atoi(attribute.c_str()); | ||
3898 | |||
3899 | |||
3900 | |||
3901 | gMessageSystem->newMessageFast(_PREHASH_ObjectAdd); | ||
3902 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | ||
3903 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
3904 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
3905 | gMessageSystem->addUUIDFast(_PREHASH_GroupID, gAgent.getGroupID()); | ||
3906 | |||
3907 | gMessageSystem->nextBlockFast(_PREHASH_ObjectData); | ||
3908 | gMessageSystem->addU8Fast(_PREHASH_PCode, pcode); | ||
3909 | gMessageSystem->addU8Fast(_PREHASH_Material, material); | ||
3910 | gMessageSystem->addU32Fast(_PREHASH_AddFlags, flags ); | ||
3911 | pparams.packMessage(gMessageSystem); | ||
3912 | paparams.packMessage(gMessageSystem); | ||
3913 | |||
3914 | LLVector3 forward; | ||
3915 | forward.setVec(3.f, 0.f, 1.f); | ||
3916 | forward = forward * gAgent.getQuat(); | ||
3917 | |||
3918 | LLVector3 start = gAgent.getPositionAgent() + forward; | ||
3919 | |||
3920 | start += offset; | ||
3921 | |||
3922 | // offset position to make up for error introduced by placement code | ||
3923 | LLVector3 normal(0.f, 0.f, 1.f); | ||
3924 | LLVector3 delta; | ||
3925 | |||
3926 | undo_find_local_contact_point(delta, normal, rot, scale); | ||
3927 | |||
3928 | start += delta; | ||
3929 | |||
3930 | gMessageSystem->addVector3Fast(_PREHASH_Scale, scale ); | ||
3931 | gMessageSystem->addQuatFast(_PREHASH_Rotation, rot ); | ||
3932 | gMessageSystem->addVector3Fast(_PREHASH_RayStart, start ); | ||
3933 | gMessageSystem->addVector3Fast(_PREHASH_RayEnd, start ); | ||
3934 | gMessageSystem->addBOOLFast(_PREHASH_BypassRaycast, TRUE ); | ||
3935 | gMessageSystem->addBOOLFast(_PREHASH_RayEndIsIntersection, FALSE ); | ||
3936 | |||
3937 | U8 state = 0; | ||
3938 | gMessageSystem->addU8Fast(_PREHASH_State, state); | ||
3939 | |||
3940 | LLUUID ray_target_id; | ||
3941 | gMessageSystem->addUUIDFast(_PREHASH_RayTargetID, ray_target_id ); | ||
3942 | 3654 | ||
3943 | /* Setting TE info through ObjectAdd is no longer supported. | ||
3944 | LLPrimitive temp_primitive; | ||
3945 | temp_primitive.setNumTEs(faces); | ||
3946 | for (LLXmlTreeNode *face = child->getChildByName( "Face" ); | ||
3947 | face; | ||
3948 | face = child->getNextNamedChild()) | ||
3949 | { | ||
3950 | // read the faces | ||
3951 | U32 facenumber; | ||
3952 | LLColor4 color; | ||
3953 | // *NOTE: This buffer size is hard coded into scanf() below. | ||
3954 | char texture[UUID_STR_LENGTH]; | ||
3955 | LLUUID texid; | ||
3956 | texid.toString(texture); | ||
3957 | F32 sx, sy, ox, oy, rot; | ||
3958 | U8 bump; | ||
3959 | LLTextureEntry te; | ||
3960 | |||
3961 | face->getAttributeString("FaceColor", &attribute); | ||
3962 | sscanf(attribute, "%d %f %f %f %f", &facenumber, &color.mV[VX], &color.mV[VY], &color.mV[VZ], &color.mV[VW]); | ||
3963 | face->getAttributeString("Face", &attribute); | ||
3964 | sscanf(attribute, "%d %f %f %f %f %f %d %36s", &facenumber, &sx, &sy, &ox, &oy, &rot, &bump, texture); | ||
3965 | texid.set(texture); | ||
3966 | te.setColor(color); | ||
3967 | te.setBumpShinyFullbright(bump); | ||
3968 | te.setID(texid); | ||
3969 | te.setRotation(rot); | ||
3970 | te.setOffset(ox, oy); | ||
3971 | te.setScale(sx, sy); | ||
3972 | |||
3973 | temp_primitive.setTE(facenumber, te); | ||
3974 | } | ||
3975 | |||
3976 | temp_primitive.packTEMessage(gMessageSystem); | ||
3977 | */ | ||
3978 | gMessageSystem->sendReliable(gAgent.getRegionHost()); | ||
3979 | } | ||
3980 | |||
3981 | } | ||
3982 | #endif | ||
3983 | |||
3984 | void handle_take() | ||
3985 | { | ||
3986 | // we want to use the folder this was derezzed from if it's | ||
3987 | // available. Otherwise, derez to the normal place. | ||
3988 | if(gSelectMgr->getSelection()->isEmpty()) return; | ||
3989 | LLSelectNode* node = NULL; | ||
3990 | LLViewerObject* object = NULL; | ||
3991 | BOOL you_own_everything = TRUE; | 3655 | BOOL you_own_everything = TRUE; |
3992 | |||
3993 | BOOL locked_but_takeable_object = FALSE; | 3656 | BOOL locked_but_takeable_object = FALSE; |
3994 | LLUUID category_id; | 3657 | LLUUID category_id; |
3995 | for(node = gSelectMgr->getSelection()->getFirstRootNode(); | 3658 | |
3996 | node != NULL; | 3659 | for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin(); |
3997 | node = gSelectMgr->getSelection()->getNextRootNode()) | 3660 | iter != gSelectMgr->getSelection()->root_end(); iter++) |
3998 | { | 3661 | { |
3999 | object = node->getObject(); | 3662 | LLSelectNode* node = *iter; |
3663 | LLViewerObject* object = node->getObject(); | ||
4000 | if(object) | 3664 | if(object) |
4001 | { | 3665 | { |
4002 | if(!object->permYouOwner()) | 3666 | if(!object->permYouOwner()) |
@@ -4005,11 +3669,8 @@ void handle_take() | |||
4005 | } | 3669 | } |
4006 | 3670 | ||
4007 | if(!object->permMove()) | 3671 | if(!object->permMove()) |
4008 | |||
4009 | { | 3672 | { |
4010 | |||
4011 | locked_but_takeable_object = TRUE; | 3673 | locked_but_takeable_object = TRUE; |
4012 | |||
4013 | } | 3674 | } |
4014 | } | 3675 | } |
4015 | if(node->mFolderID.notNull()) | 3676 | if(node->mFolderID.notNull()) |
@@ -4060,7 +3721,6 @@ void handle_take() | |||
4060 | } | 3721 | } |
4061 | LLUUID* cat_id = new LLUUID(category_id); | 3722 | LLUUID* cat_id = new LLUUID(category_id); |
4062 | if(locked_but_takeable_object || | 3723 | if(locked_but_takeable_object || |
4063 | |||
4064 | !you_own_everything) | 3724 | !you_own_everything) |
4065 | { | 3725 | { |
4066 | if(locked_but_takeable_object && you_own_everything) | 3726 | if(locked_but_takeable_object && you_own_everything) |
@@ -4113,13 +3773,11 @@ BOOL enable_take() | |||
4113 | return FALSE; | 3773 | return FALSE; |
4114 | } | 3774 | } |
4115 | 3775 | ||
4116 | LLViewerObject* object = NULL; | 3776 | for (LLObjectSelection::valid_root_iterator iter = gSelectMgr->getSelection()->valid_root_begin(); |
4117 | for(LLSelectNode* node = gSelectMgr->getSelection()->getFirstRootNode(); | 3777 | iter != gSelectMgr->getSelection()->valid_root_end(); iter++) |
4118 | node != NULL; | ||
4119 | node = gSelectMgr->getSelection()->getNextRootNode()) | ||
4120 | { | 3778 | { |
4121 | object = node->getObject(); | 3779 | LLSelectNode* node = *iter; |
4122 | if(!object || !node->mValid) continue; | 3780 | LLViewerObject* object = node->getObject(); |
4123 | if (object->isAvatar()) | 3781 | if (object->isAvatar()) |
4124 | { | 3782 | { |
4125 | // ...don't acquire avatars | 3783 | // ...don't acquire avatars |
@@ -4229,12 +3887,11 @@ class LLToolsEnableBuyOrTake : public view_listener_t | |||
4229 | // FALSE if selection is a 'take' | 3887 | // FALSE if selection is a 'take' |
4230 | BOOL is_selection_buy_not_take() | 3888 | BOOL is_selection_buy_not_take() |
4231 | { | 3889 | { |
4232 | LLViewerObject* obj = NULL; | 3890 | for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin(); |
4233 | for(LLSelectNode* node = gSelectMgr->getSelection()->getFirstRootNode(); | 3891 | iter != gSelectMgr->getSelection()->root_end(); iter++) |
4234 | node != NULL; | ||
4235 | node = gSelectMgr->getSelection()->getNextRootNode()) | ||
4236 | { | 3892 | { |
4237 | obj = node->getObject(); | 3893 | LLSelectNode* node = *iter; |
3894 | LLViewerObject* obj = node->getObject(); | ||
4238 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | 3895 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) |
4239 | { | 3896 | { |
4240 | // you do not own the object and it is for sale, thus, | 3897 | // you do not own the object and it is for sale, thus, |
@@ -4247,13 +3904,12 @@ BOOL is_selection_buy_not_take() | |||
4247 | 3904 | ||
4248 | S32 selection_price() | 3905 | S32 selection_price() |
4249 | { | 3906 | { |
4250 | LLViewerObject* obj = NULL; | ||
4251 | S32 total_price = 0; | 3907 | S32 total_price = 0; |
4252 | for(LLSelectNode* node = gSelectMgr->getSelection()->getFirstRootNode(); | 3908 | for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin(); |
4253 | node != NULL; | 3909 | iter != gSelectMgr->getSelection()->root_end(); iter++) |
4254 | node = gSelectMgr->getSelection()->getNextRootNode()) | ||
4255 | { | 3910 | { |
4256 | obj = node->getObject(); | 3911 | LLSelectNode* node = *iter; |
3912 | LLViewerObject* obj = node->getObject(); | ||
4257 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) | 3913 | if(obj && !(obj->permYouOwner()) && (node->mSaleInfo.isForSale())) |
4258 | { | 3914 | { |
4259 | // you do not own the object and it is for sale. | 3915 | // you do not own the object and it is for sale. |
@@ -4393,12 +4049,11 @@ class LLToolsSnapObjectXY : public view_listener_t | |||
4393 | { | 4049 | { |
4394 | F64 snap_size = (F64)gSavedSettings.getF32("GridResolution"); | 4050 | F64 snap_size = (F64)gSavedSettings.getF32("GridResolution"); |
4395 | 4051 | ||
4396 | LLViewerObject* obj; | 4052 | for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin(); |
4397 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 4053 | iter != gSelectMgr->getSelection()->root_end(); iter++) |
4398 | for (obj = selection->getFirstRootObject(); | ||
4399 | obj != NULL; | ||
4400 | obj = selection->getNextRootObject()) | ||
4401 | { | 4054 | { |
4055 | LLSelectNode* node = *iter; | ||
4056 | LLViewerObject* obj = node->getObject(); | ||
4402 | if (obj->permModify()) | 4057 | if (obj->permModify()) |
4403 | { | 4058 | { |
4404 | LLVector3d pos_global = obj->getPositionGlobal(); | 4059 | LLVector3d pos_global = obj->getPositionGlobal(); |
@@ -4455,17 +4110,15 @@ class LLToolsEnableLink : public view_listener_t | |||
4455 | { | 4110 | { |
4456 | if(gSelectMgr->selectGetAllRootsValid() && gSelectMgr->getSelection()->getRootObjectCount() >= 2) | 4111 | if(gSelectMgr->selectGetAllRootsValid() && gSelectMgr->getSelection()->getRootObjectCount() >= 2) |
4457 | { | 4112 | { |
4458 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 4113 | struct f : public LLSelectedObjectFunctor |
4459 | for(LLViewerObject* object = selection->getFirstRootObject(); | ||
4460 | object != NULL; | ||
4461 | object = selection->getNextRootObject()) | ||
4462 | { | 4114 | { |
4463 | if(object->permModify()) | 4115 | virtual bool apply(LLViewerObject* object) |
4464 | { | 4116 | { |
4465 | new_value = true; | 4117 | return object->permModify(); |
4466 | break; | ||
4467 | } | 4118 | } |
4468 | } | 4119 | } func; |
4120 | const bool firstonly = true; | ||
4121 | new_value = gSelectMgr->getSelection()->applyToRootObjects(&func, firstonly); | ||
4469 | } | 4122 | } |
4470 | } | 4123 | } |
4471 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); | 4124 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); |
@@ -4903,7 +4556,6 @@ void handle_export_selected( void * ) | |||
4903 | return; | 4556 | return; |
4904 | } | 4557 | } |
4905 | llinfos << "Exporting selected objects:" << llendl; | 4558 | llinfos << "Exporting selected objects:" << llendl; |
4906 | LLViewerObject *object = selection->getFirstRootObject(); | ||
4907 | 4559 | ||
4908 | gExporterRequestID.generate(); | 4560 | gExporterRequestID.generate(); |
4909 | gExportDirectory = ""; | 4561 | gExportDirectory = ""; |
@@ -4915,8 +4567,11 @@ void handle_export_selected( void * ) | |||
4915 | msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID); | 4567 | msg->addUUIDFast(_PREHASH_RequestID, gExporterRequestID); |
4916 | msg->addS16Fast(_PREHASH_VolumeDetail, 4); | 4568 | msg->addS16Fast(_PREHASH_VolumeDetail, 4); |
4917 | 4569 | ||
4918 | for (; object != NULL; object = selection->getNextRootObject()) | 4570 | for (LLObjectSelection::root_iterator iter = selection->root_begin(); |
4571 | iter != selection->root_end(); iter++) | ||
4919 | { | 4572 | { |
4573 | LLSelectNode* node = *iter; | ||
4574 | LLViewerObject* object = node->getObject(); | ||
4920 | msg->nextBlockFast(_PREHASH_ObjectData); | 4575 | msg->nextBlockFast(_PREHASH_ObjectData); |
4921 | msg->addUUIDFast(_PREHASH_ObjectID, object->getID()); | 4576 | msg->addUUIDFast(_PREHASH_ObjectID, object->getID()); |
4922 | llinfos << "Object: " << object->getID() << llendl; | 4577 | llinfos << "Object: " << object->getID() << llendl; |
@@ -5310,16 +4965,21 @@ void handle_force_unlock(void*) | |||
5310 | gSelectMgr->sendOwner(LLUUID::null, LLUUID::null, TRUE); | 4965 | gSelectMgr->sendOwner(LLUUID::null, LLUUID::null, TRUE); |
5311 | 4966 | ||
5312 | // Second, lie to the viewer and mark it editable and unowned | 4967 | // Second, lie to the viewer and mark it editable and unowned |
5313 | LLViewerObject* object; | 4968 | |
5314 | for (object = gSelectMgr->getSelection()->getFirstObject(); object; object = gSelectMgr->getSelection()->getNextObject() ) | 4969 | struct f : public LLSelectedObjectFunctor |
5315 | { | 4970 | { |
5316 | object->mFlags |= FLAGS_OBJECT_MOVE; | 4971 | virtual bool apply(LLViewerObject* object) |
5317 | object->mFlags |= FLAGS_OBJECT_MODIFY; | 4972 | { |
5318 | object->mFlags |= FLAGS_OBJECT_COPY; | 4973 | object->mFlags |= FLAGS_OBJECT_MOVE; |
4974 | object->mFlags |= FLAGS_OBJECT_MODIFY; | ||
4975 | object->mFlags |= FLAGS_OBJECT_COPY; | ||
5319 | 4976 | ||
5320 | object->mFlags &= ~FLAGS_OBJECT_ANY_OWNER; | 4977 | object->mFlags &= ~FLAGS_OBJECT_ANY_OWNER; |
5321 | object->mFlags &= ~FLAGS_OBJECT_YOU_OWNER; | 4978 | object->mFlags &= ~FLAGS_OBJECT_YOU_OWNER; |
5322 | } | 4979 | return true; |
4980 | } | ||
4981 | } func; | ||
4982 | gSelectMgr->getSelection()->applyToObjects(&func); | ||
5323 | } | 4983 | } |
5324 | 4984 | ||
5325 | // Fullscreen debug stuff | 4985 | // Fullscreen debug stuff |
@@ -5528,6 +5188,10 @@ class LLShowFloater : public view_listener_t | |||
5528 | LLFloaterBump::show(NULL); | 5188 | LLFloaterBump::show(NULL); |
5529 | } | 5189 | } |
5530 | } | 5190 | } |
5191 | else if (floater_name == "lag meter") | ||
5192 | { | ||
5193 | LLFloaterLagMeter::show(NULL); | ||
5194 | } | ||
5531 | else if (floater_name == "bug reporter") | 5195 | else if (floater_name == "bug reporter") |
5532 | { | 5196 | { |
5533 | // Prevent menu from appearing in screen shot. | 5197 | // Prevent menu from appearing in screen shot. |
@@ -6154,11 +5818,16 @@ class LLAttachmentEnableDetach : public view_listener_t | |||
6154 | BOOL object_selected_and_point_valid(void *user_data) | 5818 | BOOL object_selected_and_point_valid(void *user_data) |
6155 | { | 5819 | { |
6156 | //LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data; | 5820 | //LLViewerJointAttachment *attachment = (LLViewerJointAttachment *)user_data; |
6157 | if (gSelectMgr == NULL) return FALSE; | 5821 | if (gSelectMgr == NULL) |
6158 | 5822 | { | |
5823 | return FALSE; | ||
5824 | } | ||
6159 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 5825 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); |
6160 | for (LLViewerObject *object = selection->getFirstRootObject(); object; object = selection->getNextRootObject()) | 5826 | for (LLObjectSelection::root_iterator iter = selection->root_begin(); |
5827 | iter != selection->root_end(); iter++) | ||
6161 | { | 5828 | { |
5829 | LLSelectNode* node = *iter; | ||
5830 | LLViewerObject* object = node->getObject(); | ||
6162 | for (U32 child_num = 0; child_num < object->mChildList.size(); child_num++ ) | 5831 | for (U32 child_num = 0; child_num < object->mChildList.size(); child_num++ ) |
6163 | { | 5832 | { |
6164 | if (object->mChildList[child_num]->isAvatar()) | 5833 | if (object->mChildList[child_num]->isAvatar()) |
@@ -6230,12 +5899,68 @@ BOOL enable_activate(void*) | |||
6230 | return FALSE; | 5899 | return FALSE; |
6231 | } | 5900 | } |
6232 | 5901 | ||
5902 | namespace | ||
5903 | { | ||
5904 | struct QueueObjects : public LLSelectedObjectFunctor | ||
5905 | { | ||
5906 | BOOL scripted; | ||
5907 | BOOL modifiable; | ||
5908 | LLFloaterScriptQueue* mQueue; | ||
5909 | QueueObjects(LLFloaterScriptQueue* q) : mQueue(q), scripted(FALSE), modifiable(FALSE) {} | ||
5910 | virtual bool apply(LLViewerObject* obj) | ||
5911 | { | ||
5912 | scripted = obj->flagScripted(); | ||
5913 | modifiable = obj->permModify(); | ||
5914 | |||
5915 | if( scripted && modifiable ) | ||
5916 | { | ||
5917 | mQueue->addObject(obj->getID()); | ||
5918 | return false; | ||
5919 | } | ||
5920 | else | ||
5921 | { | ||
5922 | return true; // fail: stop applying | ||
5923 | } | ||
5924 | } | ||
5925 | }; | ||
5926 | } | ||
5927 | |||
5928 | void queue_actions(LLFloaterScriptQueue* q, const std::string& noscriptmsg, const std::string& nomodmsg) | ||
5929 | { | ||
5930 | // Apply until an object fails | ||
5931 | QueueObjects func(q); | ||
5932 | const bool firstonly = true; | ||
5933 | bool fail = gSelectMgr->getSelection()->applyToObjects(&func, firstonly); | ||
5934 | if(fail) | ||
5935 | { | ||
5936 | if ( !func.scripted ) | ||
5937 | { | ||
5938 | gViewerWindow->alertXml(noscriptmsg); | ||
5939 | } | ||
5940 | else if ( !func.modifiable ) | ||
5941 | { | ||
5942 | gViewerWindow->alertXml(nomodmsg); | ||
5943 | } | ||
5944 | else | ||
5945 | { | ||
5946 | llerrs << "Bad logic." << llendl; | ||
5947 | } | ||
5948 | } | ||
5949 | else | ||
5950 | { | ||
5951 | if (!q->start()) | ||
5952 | { | ||
5953 | llwarns << "Unexpected script compile failure." << llendl; | ||
5954 | } | ||
5955 | } | ||
5956 | } | ||
5957 | |||
6233 | class LLToolsSelectedScriptAction : public view_listener_t | 5958 | class LLToolsSelectedScriptAction : public view_listener_t |
6234 | { | 5959 | { |
6235 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 5960 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
6236 | { | 5961 | { |
6237 | LLString action = userdata.asString(); | 5962 | LLString action = userdata.asString(); |
6238 | LLFloaterScriptQueue *queue = NULL; | 5963 | LLFloaterScriptQueue* queue = NULL; |
6239 | if (action == "compile") | 5964 | if (action == "compile") |
6240 | { | 5965 | { |
6241 | queue = LLFloaterCompileQueue::create(); | 5966 | queue = LLFloaterCompileQueue::create(); |
@@ -6252,35 +5977,13 @@ class LLToolsSelectedScriptAction : public view_listener_t | |||
6252 | { | 5977 | { |
6253 | queue = LLFloaterNotRunQueue::create(); | 5978 | queue = LLFloaterNotRunQueue::create(); |
6254 | } | 5979 | } |
6255 | if (!queue) return true; | 5980 | if (!queue) |
6256 | |||
6257 | BOOL scripted = FALSE; | ||
6258 | BOOL modifiable = FALSE; | ||
6259 | |||
6260 | for(LLViewerObject* obj = gSelectMgr->getSelection()->getFirstObject(); | ||
6261 | obj; | ||
6262 | obj = gSelectMgr->getSelection()->getNextObject()) | ||
6263 | { | 5981 | { |
6264 | scripted = obj->flagScripted(); | 5982 | return true; |
6265 | modifiable = obj->permModify(); | ||
6266 | |||
6267 | if( scripted && modifiable ) | ||
6268 | queue->addObject(obj->getID()); | ||
6269 | else | ||
6270 | break; | ||
6271 | } | 5983 | } |
6272 | 5984 | ||
6273 | if(!queue->start()) | 5985 | queue_actions(queue, "CannotRecompileSelectObjectsNoScripts", "CannotRecompileSelectObjectsNoPermission"); |
6274 | { | 5986 | |
6275 | if ( ! scripted ) | ||
6276 | { | ||
6277 | gViewerWindow->alertXml("CannotRecompileSelectObjectsNoScripts"); | ||
6278 | } | ||
6279 | else if ( ! modifiable ) | ||
6280 | { | ||
6281 | gViewerWindow->alertXml("CannotRecompileSelectObjectsNoPermission"); | ||
6282 | } | ||
6283 | } | ||
6284 | return true; | 5987 | return true; |
6285 | } | 5988 | } |
6286 | }; | 5989 | }; |
@@ -6288,109 +5991,28 @@ class LLToolsSelectedScriptAction : public view_listener_t | |||
6288 | void handle_reset_selection(void*) | 5991 | void handle_reset_selection(void*) |
6289 | { | 5992 | { |
6290 | LLFloaterResetQueue* queue = LLFloaterResetQueue::create(); | 5993 | LLFloaterResetQueue* queue = LLFloaterResetQueue::create(); |
6291 | 5994 | queue_actions(queue, "CannotResetSelectObjectsNoScripts", "CannotResetSelectObjectsNoPermission"); | |
6292 | BOOL scripted = FALSE; | ||
6293 | BOOL modifiable = FALSE; | ||
6294 | |||
6295 | for(LLViewerObject* obj = gSelectMgr->getSelection()->getFirstObject(); | ||
6296 | obj; | ||
6297 | obj = gSelectMgr->getSelection()->getNextObject()) | ||
6298 | { | ||
6299 | scripted = obj->flagScripted(); | ||
6300 | modifiable = obj->permModify(); | ||
6301 | |||
6302 | if( scripted && modifiable ) | ||
6303 | queue->addObject(obj->getID()); | ||
6304 | else | ||
6305 | break; | ||
6306 | } | ||
6307 | |||
6308 | if(!queue->start()) | ||
6309 | { | ||
6310 | if ( ! scripted ) | ||
6311 | { | ||
6312 | gViewerWindow->alertXml("CannotResetSelectObjectsNoScripts"); | ||
6313 | } | ||
6314 | else if ( ! modifiable ) | ||
6315 | { | ||
6316 | gViewerWindow->alertXml("CannotResetSelectObjectsNoPermission"); | ||
6317 | } | ||
6318 | } | ||
6319 | } | 5995 | } |
6320 | 5996 | ||
6321 | void handle_set_run_selection(void*) | 5997 | void handle_set_run_selection(void*) |
6322 | { | 5998 | { |
6323 | LLFloaterRunQueue* queue = LLFloaterRunQueue::create(); | 5999 | LLFloaterRunQueue* queue = LLFloaterRunQueue::create(); |
6324 | 6000 | queue_actions(queue, "CannotSetRunningSelectObjectsNoScripts", "CannotSerRunningSelectObjectsNoPermission"); | |
6325 | BOOL scripted = FALSE; | ||
6326 | BOOL modifiable = FALSE; | ||
6327 | |||
6328 | for(LLViewerObject* obj = gSelectMgr->getSelection()->getFirstObject(); | ||
6329 | obj; | ||
6330 | obj = gSelectMgr->getSelection()->getNextObject()) | ||
6331 | { | ||
6332 | scripted = obj->flagScripted(); | ||
6333 | modifiable = obj->permModify(); | ||
6334 | |||
6335 | if( scripted && modifiable ) | ||
6336 | queue->addObject(obj->getID()); | ||
6337 | else | ||
6338 | break; | ||
6339 | } | ||
6340 | |||
6341 | if(!queue->start()) | ||
6342 | { | ||
6343 | if ( ! scripted ) | ||
6344 | { | ||
6345 | gViewerWindow->alertXml("CannotSetRunningSelectObjectsNoScripts"); | ||
6346 | } | ||
6347 | else if ( ! modifiable ) | ||
6348 | { | ||
6349 | gViewerWindow->alertXml("CannotSerRunningSelectObjectsNoPermission"); | ||
6350 | } | ||
6351 | } | ||
6352 | } | 6001 | } |
6353 | 6002 | ||
6354 | void handle_set_not_run_selection(void*) | 6003 | void handle_set_not_run_selection(void*) |
6355 | { | 6004 | { |
6356 | LLFloaterNotRunQueue* queue = LLFloaterNotRunQueue::create(); | 6005 | LLFloaterNotRunQueue* queue = LLFloaterNotRunQueue::create(); |
6357 | 6006 | queue_actions(queue, "CannotSetRunningNotSelectObjectsNoScripts", "CannotSerRunningNotSelectObjectsNoPermission"); | |
6358 | BOOL scripted = FALSE; | ||
6359 | BOOL modifiable = FALSE; | ||
6360 | |||
6361 | for(LLViewerObject* obj = gSelectMgr->getSelection()->getFirstObject(); | ||
6362 | obj; | ||
6363 | obj = gSelectMgr->getSelection()->getNextObject()) | ||
6364 | { | ||
6365 | scripted = obj->flagScripted(); | ||
6366 | modifiable = obj->permModify(); | ||
6367 | |||
6368 | if( scripted && modifiable ) | ||
6369 | queue->addObject(obj->getID()); | ||
6370 | else | ||
6371 | break; | ||
6372 | } | ||
6373 | |||
6374 | if(!queue->start()) | ||
6375 | { | ||
6376 | if ( ! scripted ) | ||
6377 | { | ||
6378 | gViewerWindow->alertXml("CannotSetRunningNotSelectObjectsNoScripts"); | ||
6379 | } | ||
6380 | else if ( ! modifiable ) | ||
6381 | { | ||
6382 | gViewerWindow->alertXml("CannotSerRunningNotSelectObjectsNoPermission"); | ||
6383 | } | ||
6384 | } | ||
6385 | } | 6007 | } |
6386 | 6008 | ||
6387 | void handle_selected_texture_info(void*) | 6009 | void handle_selected_texture_info(void*) |
6388 | { | 6010 | { |
6389 | LLSelectNode* node = NULL; | 6011 | for (LLObjectSelection::valid_iterator iter = gSelectMgr->getSelection()->valid_begin(); |
6390 | for (node = gSelectMgr->getSelection()->getFirstNode(); node != NULL; node = gSelectMgr->getSelection()->getNextNode()) | 6012 | iter != gSelectMgr->getSelection()->valid_end(); iter++) |
6391 | { | 6013 | { |
6392 | if (!node->mValid) continue; | 6014 | LLSelectNode* node = *iter; |
6393 | 6015 | ||
6394 | std::string msg; | 6016 | std::string msg; |
6395 | msg.assign("Texture info for: "); | 6017 | msg.assign("Texture info for: "); |
6396 | msg.append(node->mName); | 6018 | msg.append(node->mName); |
@@ -6610,51 +6232,52 @@ class LLToolsEnableTakeCopy : public view_listener_t | |||
6610 | { | 6232 | { |
6611 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 6233 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
6612 | { | 6234 | { |
6613 | bool new_value = false; | 6235 | bool all_valid = false; |
6614 | if (gSelectMgr) | 6236 | if (gSelectMgr) |
6615 | { | 6237 | { |
6616 | new_value = true; | 6238 | all_valid = true; |
6617 | #ifndef HACKED_GODLIKE_VIEWER | 6239 | #ifndef HACKED_GODLIKE_VIEWER |
6618 | # ifdef TOGGLE_HACKED_GODLIKE_VIEWER | 6240 | # ifdef TOGGLE_HACKED_GODLIKE_VIEWER |
6619 | if (gInProductionGrid || !gAgent.isGodlike()) | 6241 | if (gInProductionGrid || !gAgent.isGodlike()) |
6620 | # endif | 6242 | # endif |
6621 | { | 6243 | { |
6622 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 6244 | struct f : public LLSelectedObjectFunctor |
6623 | LLViewerObject* obj = selection->getFirstRootObject(); | ||
6624 | if(obj) | ||
6625 | { | 6245 | { |
6626 | for( ; obj; obj = selection->getNextRootObject()) | 6246 | virtual bool apply(LLViewerObject* obj) |
6627 | { | 6247 | { |
6628 | if(!(obj->permCopy()) || obj->isAttachment()) | 6248 | return (!obj->permCopy() || obj->isAttachment()); |
6629 | { | ||
6630 | new_value = false; | ||
6631 | } | ||
6632 | } | 6249 | } |
6633 | } | 6250 | } func; |
6251 | const bool firstonly = true; | ||
6252 | bool any_invalid = gSelectMgr->getSelection()->applyToRootObjects(&func, firstonly); | ||
6253 | all_valid = !any_invalid; | ||
6634 | } | 6254 | } |
6635 | #endif // HACKED_GODLIKE_VIEWER | 6255 | #endif // HACKED_GODLIKE_VIEWER |
6636 | } | 6256 | } |
6637 | 6257 | ||
6638 | gMenuHolder->findControl(userdata["control"].asString())->setValue(new_value); | 6258 | gMenuHolder->findControl(userdata["control"].asString())->setValue(all_valid); |
6639 | return true; | 6259 | return true; |
6640 | } | 6260 | } |
6641 | }; | 6261 | }; |
6642 | 6262 | ||
6643 | BOOL enable_selection_you_own_all(void*) | 6263 | BOOL enable_selection_you_own_all(void*) |
6644 | { | 6264 | { |
6645 | LLViewerObject *obj; | ||
6646 | if (gSelectMgr) | 6265 | if (gSelectMgr) |
6647 | { | 6266 | { |
6648 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 6267 | struct f : public LLSelectedObjectFunctor |
6649 | for (obj = selection->getFirstRootObject(); obj; obj = selection->getNextRootObject()) | ||
6650 | { | 6268 | { |
6651 | if (!obj->permYouOwner()) | 6269 | virtual bool apply(LLViewerObject* obj) |
6652 | { | 6270 | { |
6653 | return FALSE; | 6271 | return (!obj->permYouOwner()); |
6654 | } | 6272 | } |
6273 | } func; | ||
6274 | const bool firstonly = true; | ||
6275 | bool no_perms = gSelectMgr->getSelection()->applyToRootObjects(&func, firstonly); | ||
6276 | if (no_perms) | ||
6277 | { | ||
6278 | return FALSE; | ||
6655 | } | 6279 | } |
6656 | } | 6280 | } |
6657 | |||
6658 | return TRUE; | 6281 | return TRUE; |
6659 | } | 6282 | } |
6660 | 6283 | ||
@@ -6662,17 +6285,21 @@ BOOL enable_selection_you_own_one(void*) | |||
6662 | { | 6285 | { |
6663 | if (gSelectMgr) | 6286 | if (gSelectMgr) |
6664 | { | 6287 | { |
6665 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 6288 | struct f : public LLSelectedObjectFunctor |
6666 | LLViewerObject *obj; | ||
6667 | for (obj = selection->getFirstRootObject(); obj; obj = selection->getNextRootObject()) | ||
6668 | { | 6289 | { |
6669 | if (obj->permYouOwner()) | 6290 | virtual bool apply(LLViewerObject* obj) |
6670 | { | 6291 | { |
6671 | return TRUE; | 6292 | return (obj->permYouOwner()); |
6672 | } | 6293 | } |
6294 | } func; | ||
6295 | const bool firstonly = true; | ||
6296 | bool any_perms = gSelectMgr->getSelection()->applyToRootObjects(&func, firstonly); | ||
6297 | if (!any_perms) | ||
6298 | { | ||
6299 | return FALSE; | ||
6673 | } | 6300 | } |
6674 | } | 6301 | } |
6675 | return FALSE; | 6302 | return TRUE; |
6676 | } | 6303 | } |
6677 | 6304 | ||
6678 | class LLHasAsset : public LLInventoryCollectFunctor | 6305 | class LLHasAsset : public LLInventoryCollectFunctor |
@@ -6703,13 +6330,13 @@ BOOL enable_save_into_inventory(void*) | |||
6703 | { | 6330 | { |
6704 | if(gSelectMgr) | 6331 | if(gSelectMgr) |
6705 | { | 6332 | { |
6333 | // *TODO: clean this up | ||
6706 | // find the last root | 6334 | // find the last root |
6707 | LLSelectNode* last_node = NULL; | 6335 | LLSelectNode* last_node = NULL; |
6708 | for(LLSelectNode* node = gSelectMgr->getSelection()->getFirstRootNode(); | 6336 | for (LLObjectSelection::root_iterator iter = gSelectMgr->getSelection()->root_begin(); |
6709 | node != NULL; | 6337 | iter != gSelectMgr->getSelection()->root_end(); iter++) |
6710 | node = gSelectMgr->getSelection()->getNextRootNode()) | ||
6711 | { | 6338 | { |
6712 | last_node = node; | 6339 | last_node = *iter; |
6713 | } | 6340 | } |
6714 | 6341 | ||
6715 | #ifdef HACKED_GODLIKE_VIEWER | 6342 | #ifdef HACKED_GODLIKE_VIEWER |
@@ -7191,13 +6818,15 @@ class LLToolsUseSelectionForGrid : public view_listener_t | |||
7191 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) | 6818 | bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata) |
7192 | { | 6819 | { |
7193 | gSelectMgr->clearGridObjects(); | 6820 | gSelectMgr->clearGridObjects(); |
7194 | LLObjectSelectionHandle selection = gSelectMgr->getSelection(); | 6821 | struct f : public LLSelectedObjectFunctor |
7195 | for (LLViewerObject* objectp = selection->getFirstRootObject(); | 6822 | { |
7196 | objectp; | 6823 | virtual bool apply(LLViewerObject* objectp) |
7197 | objectp = selection->getNextRootObject()) | ||
7198 | { | 6824 | { |
7199 | gSelectMgr->addGridObject(objectp); | 6825 | gSelectMgr->addGridObject(objectp); |
6826 | return true; | ||
7200 | } | 6827 | } |
6828 | } func; | ||
6829 | gSelectMgr->getSelection()->applyToRootObjects(&func); | ||
7201 | gSelectMgr->setGridMode(GRID_MODE_REF_OBJECT); | 6830 | gSelectMgr->setGridMode(GRID_MODE_REF_OBJECT); |
7202 | if (gFloaterTools) | 6831 | if (gFloaterTools) |
7203 | { | 6832 | { |
@@ -7291,6 +6920,11 @@ void handle_load_from_xml(void*) | |||
7291 | } | 6920 | } |
7292 | } | 6921 | } |
7293 | 6922 | ||
6923 | void handle_slurl_test(void*) | ||
6924 | { | ||
6925 | LLFloaterHtml::getInstance()->show("http://user.lindenlab.com/~james/slurl.html", "SLURL Test"); | ||
6926 | } | ||
6927 | |||
7294 | void handle_rebake_textures(void*) | 6928 | void handle_rebake_textures(void*) |
7295 | { | 6929 | { |
7296 | LLVOAvatar* avatar = gAgent.getAvatarObject(); | 6930 | LLVOAvatar* avatar = gAgent.getAvatarObject(); |
@@ -7774,6 +7408,7 @@ void initialize_menus() | |||
7774 | 7408 | ||
7775 | // Help menu | 7409 | // Help menu |
7776 | addMenu(new LLHelpMOTD(), "Help.MOTD"); | 7410 | addMenu(new LLHelpMOTD(), "Help.MOTD"); |
7411 | // most items use the ShowFloater method | ||
7777 | 7412 | ||
7778 | // Self pie menu | 7413 | // Self pie menu |
7779 | addMenu(new LLSelfStandUp(), "Self.StandUp"); | 7414 | addMenu(new LLSelfStandUp(), "Self.StandUp"); |