diff options
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r-- | indra/newview/llviewermenu.cpp | 310 |
1 files changed, 149 insertions, 161 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 502bd718d3..a8b1257cf6 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -42,6 +42,7 @@ // newview includes #include "llagent.h" +#include "llagentcamera.h" #include "llagentwearables.h" #include "llagentpilot.h" #include "llbottomtray.h" @@ -72,6 +73,7 @@ #include "llhudmanager.h" #include "llimview.h" #include "llinventorybridge.h" +#include "llinventoryfunctions.h" #include "llpanellogin.h" #include "llpanelblockedlist.h" #include "llmenucommands.h" @@ -134,6 +136,7 @@ extern BOOL gDebugWindowProc; LLMenuBarGL *gMenuBarView = NULL; LLViewerMenuHolderGL *gMenuHolder = NULL; LLMenuGL *gPopupMenuView = NULL; +LLMenuGL *gEditMenu = NULL; LLMenuBarGL *gLoginMenuBarView = NULL; // Pie menus @@ -381,8 +384,10 @@ void init_menus() /// /// Context menus /// + const widget_registry_t& registry = LLViewerMenuHolderGL::child_registry_t::instance(); + gEditMenu = LLUICtrlFactory::createFromFile<LLMenuGL>("menu_edit.xml", gMenuHolder, registry); gMenuAvatarSelf = LLUICtrlFactory::createFromFile<LLContextMenu>( "menu_avatar_self.xml", gMenuHolder, registry); gMenuAvatarOther = LLUICtrlFactory::createFromFile<LLContextMenu>( @@ -1800,9 +1805,10 @@ class LLAdvancedDebugAvatarTextures : public view_listener_t { bool handleEvent(const LLSD& userdata) { -#ifndef LL_RELEASE_FOR_DOWNLOAD - handle_debug_avatar_textures(NULL); -#endif + if (gAgent.isGodlike()) + { + handle_debug_avatar_textures(NULL); + } return true; } }; @@ -2482,18 +2488,18 @@ class LLObjectBuild : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") ) + if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") ) { // zoom in if we're looking at the avatar - gAgent.setFocusOnAvatar(FALSE, ANIMATE); - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); - gAgent.cameraZoomIn(0.666f); - gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD ); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.cameraZoomIn(0.666f); + gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); gViewerWindow->moveCursorToCenter(); } else if ( gSavedSettings.getBOOL("EditCameraMovement") ) { - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); gViewerWindow->moveCursorToCenter(); } @@ -2511,7 +2517,7 @@ void handle_object_edit() { LLViewerParcelMgr::getInstance()->deselectLand(); - if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit()) + if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit()) { LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection(); @@ -2519,19 +2525,19 @@ void handle_object_edit() { // always freeze camera in space, even if camera doesn't move // so, for example, follow cam scripts can't affect you when in build mode - gAgent.setFocusGlobal(gAgent.calcFocusPositionTargetGlobal(), LLUUID::null); - gAgent.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(gAgentCamera.calcFocusPositionTargetGlobal(), LLUUID::null); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); } else { - gAgent.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); LLViewerObject* selected_objectp = selection->getFirstRootObject(); if (selected_objectp) { // zoom in on object center instead of where we clicked, as we need to see the manipulator handles - gAgent.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID()); - gAgent.cameraZoomIn(0.666f); - gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD ); + gAgentCamera.setFocusGlobal(selected_objectp->getPositionGlobal(), selected_objectp->getID()); + gAgentCamera.cameraZoomIn(0.666f); + gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); gViewerWindow->moveCursorToCenter(); } } @@ -2576,19 +2582,19 @@ class LLLandBuild : public view_listener_t { LLViewerParcelMgr::getInstance()->deselectLand(); - if (gAgent.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") ) + if (gAgentCamera.getFocusOnAvatar() && !LLToolMgr::getInstance()->inEdit() && gSavedSettings.getBOOL("EditCameraMovement") ) { // zoom in if we're looking at the avatar - gAgent.setFocusOnAvatar(FALSE, ANIMATE); - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); - gAgent.cameraZoomIn(0.666f); - gAgent.cameraOrbitOver( 30.f * DEG_TO_RAD ); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.cameraZoomIn(0.666f); + gAgentCamera.cameraOrbitOver( 30.f * DEG_TO_RAD ); gViewerWindow->moveCursorToCenter(); } else if ( gSavedSettings.getBOOL("EditCameraMovement") ) { // otherwise just move focus - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); gViewerWindow->moveCursorToCenter(); } @@ -2691,11 +2697,10 @@ class LLSelfEnableRemoveAllAttachments : public view_listener_t bool handleEvent(const LLSD& userdata) { bool new_value = false; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - LLVOAvatar* avatarp = gAgent.getAvatarObject(); - for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); - iter != avatarp->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -2823,14 +2828,14 @@ bool handle_go_to() LLViewerParcelMgr::getInstance()->deselectLand(); - if (gAgent.getAvatarObject() && !gSavedSettings.getBOOL("AutoPilotLocksCamera")) + if (isAgentAvatarValid() && !gSavedSettings.getBOOL("AutoPilotLocksCamera")) { - gAgent.setFocusGlobal(gAgent.getFocusTargetGlobal(), gAgent.getAvatarObject()->getID()); + gAgentCamera.setFocusGlobal(gAgentCamera.getFocusTargetGlobal(), gAgentAvatarp->getID()); } else { // Snap camera back to behind avatar - gAgent.setFocusOnAvatar(TRUE, ANIMATE); + gAgentCamera.setFocusOnAvatar(TRUE, ANIMATE); } // Could be first use @@ -3364,7 +3369,7 @@ class LLSelfStandUp : public view_listener_t bool enable_standup_self() { - bool new_value = gAgent.getAvatarObject() && gAgent.getAvatarObject()->isSitting(); + bool new_value = isAgentAvatarValid() && gAgentAvatarp->isSitting(); return new_value; } @@ -3693,9 +3698,9 @@ class LLLandSit : public view_listener_t LLVector3d posGlobal = LLToolPie::getInstance()->getPick().mPosGlobal; LLQuaternion target_rot; - if (gAgent.getAvatarObject()) + if (isAgentAvatarValid()) { - target_rot = gAgent.getAvatarObject()->getRotation(); + target_rot = gAgentAvatarp->getRotation(); } else { @@ -3717,14 +3722,14 @@ void reset_view_final( BOOL proceed ); void handle_reset_view() { - if( (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgent.getCameraMode()) && gFloaterCustomize ) + if( (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) && gFloaterCustomize ) { // Show dialog box if needed. gFloaterCustomize->askToSaveIfDirty( reset_view_final ); } else { - gAgent.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); + gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW); reset_view_final( TRUE ); LLFloaterCamera::resetCameraMode(); } @@ -3747,15 +3752,15 @@ void reset_view_final( BOOL proceed ) return; } - gAgent.resetView(TRUE, TRUE); - gAgent.setLookAt(LOOKAT_TARGET_CLEAR); + gAgentCamera.resetView(TRUE, TRUE); + gAgentCamera.setLookAt(LOOKAT_TARGET_CLEAR); } class LLViewLookAtLastChatter : public view_listener_t { bool handleEvent(const LLSD& userdata) { - gAgent.lookAtLastChat(); + gAgentCamera.lookAtLastChat(); return true; } }; @@ -3764,13 +3769,13 @@ class LLViewMouselook : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if (!gAgent.cameraMouselook()) + if (!gAgentCamera.cameraMouselook()) { - gAgent.changeCameraToMouselook(); + gAgentCamera.changeCameraToMouselook(); } else { - gAgent.changeCameraToDefault(); + gAgentCamera.changeCameraToDefault(); } return true; } @@ -3989,9 +3994,9 @@ void handle_god_request_avatar_geometry(void *) void derez_objects(EDeRezDestination dest, const LLUUID& dest_id) { - if(gAgent.cameraMouselook()) + if(gAgentCamera.cameraMouselook()) { - gAgent.changeCameraToDefault(); + gAgentCamera.changeCameraToDefault(); } //gInventoryView->setPanelOpen(TRUE); @@ -4586,13 +4591,9 @@ BOOL sitting_on_selection() } // Need to determine if avatar is sitting on this object - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if (!avatar) - { - return FALSE; - } + if (!isAgentAvatarValid()) return FALSE; - return (avatar->isSitting() && avatar->getRoot() == root_object); + return (gAgentAvatarp->isSitting() && gAgentAvatarp->getRoot() == root_object); } class LLToolsSaveToInventory : public view_listener_t @@ -5034,7 +5035,7 @@ class LLViewEnableLastChatter : public view_listener_t bool handleEvent(const LLSD& userdata) { // *TODO: add check that last chatter is in range - bool new_value = (gAgent.cameraThirdPerson() && gAgent.getLastChatter().notNull()); + bool new_value = (gAgentCamera.cameraThirdPerson() && gAgent.getLastChatter().notNull()); return new_value; } }; @@ -5148,7 +5149,7 @@ void print_agent_nvpairs(void*) llinfos << "Can't find agent object" << llendl; } - llinfos << "Camera at " << gAgent.getCameraPositionGlobal() << llendl; + llinfos << "Camera at " << gAgentCamera.getCameraPositionGlobal() << llendl; } void show_debug_menus() @@ -5185,10 +5186,6 @@ void toggle_debug_menus(void*) { BOOL visible = ! gSavedSettings.getBOOL("UseDebugMenus"); gSavedSettings.setBOOL("UseDebugMenus", visible); - if(visible) - { - //LLFirstUse::useDebugMenus(); - } show_debug_menus(); } @@ -5339,7 +5336,7 @@ void handle_look_at_selection(const LLSD& param) BOOL zoom = (param.asString() == "zoom"); if (!LLSelectMgr::getInstance()->getSelection()->isEmpty()) { - gAgent.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); LLBBox selection_bbox = LLSelectMgr::getInstance()->getBBoxOfSelection(); F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView()); @@ -5356,17 +5353,17 @@ void handle_look_at_selection(const LLSD& param) if (zoom) { // Make sure we are not increasing the distance between the camera and object - LLVector3d orig_distance = gAgent.getCameraPositionGlobal() - LLSelectMgr::getInstance()->getSelectionCenterGlobal(); + LLVector3d orig_distance = gAgentCamera.getCameraPositionGlobal() - LLSelectMgr::getInstance()->getSelectionCenterGlobal(); distance = llmin(distance, (F32) orig_distance.length()); - gAgent.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance), + gAgentCamera.setCameraPosAndFocusGlobal(LLSelectMgr::getInstance()->getSelectionCenterGlobal() + LLVector3d(obj_to_cam * distance), LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id ); } else { - gAgent.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id ); + gAgentCamera.setFocusGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal(), object_id ); } } } @@ -5379,7 +5376,7 @@ void handle_zoom_to_object(LLUUID object_id) if (object) { - gAgent.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); LLBBox bbox = object->getBoundingBoxAgent() ; F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView()); @@ -5391,7 +5388,7 @@ void handle_zoom_to_object(LLUUID object_id) LLVector3d object_center_global = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent()); - gAgent.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance), + gAgentCamera.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance), object_center_global, object_id ); } @@ -5589,7 +5586,7 @@ void handle_customize_avatar() { if (gAgentWearables.areWearablesLoaded()) { - gAgent.changeCameraToCustomizeAvatar(); + gAgentCamera.changeCameraToCustomizeAvatar(); } } @@ -5775,18 +5772,18 @@ class LLLandEdit : public view_listener_t { bool handleEvent(const LLSD& userdata) { - if (gAgent.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") ) + if (gAgentCamera.getFocusOnAvatar() && gSavedSettings.getBOOL("EditCameraMovement") ) { // zoom in if we're looking at the avatar - gAgent.setFocusOnAvatar(FALSE, ANIMATE); - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.setFocusOnAvatar(FALSE, ANIMATE); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); - gAgent.cameraOrbitOver( F_PI * 0.25f ); + gAgentCamera.cameraOrbitOver( F_PI * 0.25f ); gViewerWindow->moveCursorToCenter(); } else if ( gSavedSettings.getBOOL("EditCameraMovement") ) { - gAgent.setFocusGlobal(LLToolPie::getInstance()->getPick()); + gAgentCamera.setFocusGlobal(LLToolPie::getInstance()->getPick()); gViewerWindow->moveCursorToCenter(); } @@ -5845,7 +5842,7 @@ private: S32 index = userdata.asInteger(); LLViewerJointAttachment* attachment_point = NULL; if (index > 0) - attachment_point = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL); + attachment_point = get_if_there(gAgentAvatarp->mAttachmentPoints, index, (LLViewerJointAttachment*)NULL); confirm_replace_attachment(0, attachment_point); } return true; @@ -5866,8 +5863,8 @@ void near_attach_object(BOOL success, void *user_data) U8 attachment_id = 0; if (attachment) { - for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgent.getAvatarObject()->mAttachmentPoints.begin(); - iter != gAgent.getAvatarObject()->mAttachmentPoints.end(); ++iter) + for (LLVOAvatar::attachment_map_t::const_iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end(); ++iter) { if (iter->second == attachment) { @@ -5912,7 +5909,7 @@ void confirm_replace_attachment(S32 option, void* user_data) walkToSpot -= delta; gAgent.startAutoPilotGlobal(gAgent.getPosGlobalFromAgent(walkToSpot), "Attach", NULL, near_attach_object, user_data, stop_distance); - gAgent.clearFocusObject(); + gAgentCamera.clearFocusObject(); } } } @@ -5992,7 +5989,7 @@ class LLAttachmentDetachFromPoint : public view_listener_t { bool handleEvent(const LLSD& user_data) { - const LLViewerJointAttachment *attachment = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL); + const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, user_data.asInteger(), (LLViewerJointAttachment*)NULL); if (attachment->getNumObjects() > 0) { gMessageSystem->newMessage("ObjectDetach"); @@ -6020,7 +6017,7 @@ static bool onEnableAttachmentLabel(LLUICtrl* ctrl, const LLSD& data) LLMenuItemGL* menu = dynamic_cast<LLMenuItemGL*>(ctrl); if (menu) { - const LLViewerJointAttachment *attachment = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL); + const LLViewerJointAttachment *attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, data["index"].asInteger(), (LLViewerJointAttachment*)NULL); if (attachment) { label = data["label"].asString(); @@ -6138,7 +6135,7 @@ class LLAttachmentEnableDrop : public view_listener_t if (object && LLSelectMgr::getInstance()->getSelection()->contains(object,SELECT_ALL_TES )) { S32 attachmentID = ATTACHMENT_ID_FROM_STATE(object->getState()); - attachment = get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL); + attachment = get_if_there(gAgentAvatarp->mAttachmentPoints, attachmentID, (LLViewerJointAttachment*)NULL); if (attachment) { @@ -6270,8 +6267,8 @@ class LLAttachmentPointFilled : public view_listener_t bool handleEvent(const LLSD& user_data) { bool enable = false; - LLVOAvatar::attachment_map_t::iterator found_it = gAgent.getAvatarObject()->mAttachmentPoints.find(user_data.asInteger()); - if (found_it != gAgent.getAvatarObject()->mAttachmentPoints.end()) + LLVOAvatar::attachment_map_t::iterator found_it = gAgentAvatarp->mAttachmentPoints.find(user_data.asInteger()); + if (found_it != gAgentAvatarp->mAttachmentPoints.end()) { enable = found_it->second->getNumObjects() > 0; } @@ -6467,13 +6464,13 @@ void handle_selected_texture_info(void*) void handle_test_male(void*) { - LLAppearanceManager::instance().wearOutfitByName("Male Shape & Outfit"); + LLAppearanceMgr::instance().wearOutfitByName("Male Shape & Outfit"); //gGestureList.requestResetFromServer( TRUE ); } void handle_test_female(void*) { - LLAppearanceManager::instance().wearOutfitByName("Female Shape & Outfit"); + LLAppearanceMgr::instance().wearOutfitByName("Female Shape & Outfit"); //gGestureList.requestResetFromServer( FALSE ); } @@ -6488,15 +6485,10 @@ void handle_toggle_pg(void*) void handle_dump_attachments(void*) { - LLVOAvatar* avatar = gAgent.getAvatarObject(); - if( !avatar ) - { - llinfos << "NO AVATAR" << llendl; - return; - } + if(!isAgentAvatarValid()) return; - for (LLVOAvatar::attachment_map_t::iterator iter = avatar->mAttachmentPoints.begin(); - iter != avatar->mAttachmentPoints.end(); ) + for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); + iter != gAgentAvatarp->mAttachmentPoints.end(); ) { LLVOAvatar::attachment_map_t::iterator curiter = iter++; LLViewerJointAttachment* attachment = curiter->second; @@ -6758,7 +6750,7 @@ class LLViewEnableMouselook : public view_listener_t { // You can't go directly from customize avatar to mouselook. // TODO: write code with appropriate dialogs to handle this transition. - bool new_value = (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgent.getCameraMode() && !gSavedSettings.getBOOL("FreezeTime")); + bool new_value = (CAMERA_MODE_CUSTOMIZE_AVATAR != gAgentCamera.getCameraMode() && !gSavedSettings.getBOOL("FreezeTime")); return new_value; } }; @@ -6916,7 +6908,7 @@ void reload_vertex_shader(void *) void handle_dump_avatar_local_textures(void*) { - gAgent.getAvatarObject()->dumpLocalTextures(); + gAgentAvatarp->dumpLocalTextures(); } void handle_dump_timers() @@ -6936,86 +6928,83 @@ void handle_debug_avatar_textures(void*) void handle_grab_texture(void* data) { ETextureIndex tex_index = (ETextureIndex)((intptr_t)data); - const LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); - if ( avatar ) - { - // MULTI-WEARABLE: change to support an index - const LLUUID& asset_id = avatar->grabLocalTexture(tex_index, 0); - LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << llendl; - LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE; - LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE; - const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)); - if(folder_id.notNull()) - { - std::string name = "Unknown"; - const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(tex_index); - if (texture_dict->mIsBakedTexture) - { - EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; - name = "Baked " + LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index)->mNameCapitalized; - } - name += " Texture"; - - LLUUID item_id; - item_id.generate(); - LLPermissions perm; - perm.init(gAgentID, - gAgentID, - LLUUID::null, - LLUUID::null); - U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER; - perm.initMasks(PERM_ALL, - PERM_ALL, - PERM_NONE, - PERM_NONE, - next_owner_perm); - time_t creation_date_now = time_corrected(); - LLPointer<LLViewerInventoryItem> item - = new LLViewerInventoryItem(item_id, - folder_id, - perm, - asset_id, - asset_type, - inv_type, - name, - LLStringUtil::null, - LLSaleInfo::DEFAULT, - LLInventoryItem::II_FLAGS_NONE, - creation_date_now); - - item->updateServer(TRUE); - gInventory.updateItem(item); - gInventory.notifyObservers(); - - // Show the preview panel for textures to let - // user know that the image is now in inventory. - LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); - if(active_panel) - { - LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); - - active_panel->setSelection(item_id, TAKE_FOCUS_NO); - active_panel->openSelected(); - //LLFloaterInventory::dumpSelectionInformation((void*)view); - // restore keyboard focus - gFocusMgr.setKeyboardFocus(focus_ctrl); - } - } - else - { - llwarns << "Can't find a folder to put it in" << llendl; + if (!isAgentAvatarValid()) return; + + // MULTI-WEARABLE: change to support an index + const LLUUID& asset_id = gAgentAvatarp->grabLocalTexture(tex_index, 0); + LL_INFOS("texture") << "Adding baked texture " << asset_id << " to inventory." << llendl; + LLAssetType::EType asset_type = LLAssetType::AT_TEXTURE; + LLInventoryType::EType inv_type = LLInventoryType::IT_TEXTURE; + const LLUUID folder_id = gInventory.findCategoryUUIDForType(LLFolderType::assetTypeToFolderType(asset_type)); + if(folder_id.notNull()) + { + std::string name = "Unknown"; + const LLVOAvatarDictionary::TextureEntry *texture_dict = LLVOAvatarDictionary::getInstance()->getTexture(tex_index); + if (texture_dict->mIsBakedTexture) + { + EBakedTextureIndex baked_index = texture_dict->mBakedTextureIndex; + name = "Baked " + LLVOAvatarDictionary::getInstance()->getBakedTexture(baked_index)->mNameCapitalized; + } + name += " Texture"; + + LLUUID item_id; + item_id.generate(); + LLPermissions perm; + perm.init(gAgentID, + gAgentID, + LLUUID::null, + LLUUID::null); + U32 next_owner_perm = PERM_MOVE | PERM_TRANSFER; + perm.initMasks(PERM_ALL, + PERM_ALL, + PERM_NONE, + PERM_NONE, + next_owner_perm); + time_t creation_date_now = time_corrected(); + LLPointer<LLViewerInventoryItem> item + = new LLViewerInventoryItem(item_id, + folder_id, + perm, + asset_id, + asset_type, + inv_type, + name, + LLStringUtil::null, + LLSaleInfo::DEFAULT, + LLInventoryItem::II_FLAGS_NONE, + creation_date_now); + + item->updateServer(TRUE); + gInventory.updateItem(item); + gInventory.notifyObservers(); + + // Show the preview panel for textures to let + // user know that the image is now in inventory. + LLInventoryPanel *active_panel = LLInventoryPanel::getActiveInventoryPanel(); + if(active_panel) + { + LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus(); + + active_panel->setSelection(item_id, TAKE_FOCUS_NO); + active_panel->openSelected(); + //LLFloaterInventory::dumpSelectionInformation((void*)view); + // restore keyboard focus + gFocusMgr.setKeyboardFocus(focus_ctrl); } } + else + { + llwarns << "Can't find a folder to put it in" << llendl; + } } BOOL enable_grab_texture(void* data) { ETextureIndex index = (ETextureIndex)((intptr_t)data); - const LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); - if ( avatar ) + if (isAgentAvatarValid()) { // MULTI-WEARABLE: - return avatar->canGrabLocalTexture(index,0); + return gAgentAvatarp->canGrabLocalTexture(index,0); } return FALSE; } @@ -7226,12 +7215,11 @@ void handle_buy_currency_test(void*) void handle_rebake_textures(void*) { - LLVOAvatarSelf* avatar = gAgent.getAvatarObject(); - if (!avatar) return; + if (!isAgentAvatarValid()) return; // Slam pending upload count to "unstick" things bool slam_for_debug = true; - avatar->forceBakeAllTextures(slam_for_debug); + gAgentAvatarp->forceBakeAllTextures(slam_for_debug); } void toggle_visibility(void* user_data) |