diff options
Diffstat (limited to 'indra/newview/llviewermessage.cpp')
-rw-r--r-- | indra/newview/llviewermessage.cpp | 127 |
1 files changed, 105 insertions, 22 deletions
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index fc0e6da7a0..e934c38c22 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -37,6 +37,7 @@ #include "lleconomy.h" #include "lleventtimer.h" #include "llfloaterreg.h" +#include "llfolderview.h" #include "llfollowcamparams.h" #include "llinventorydefines.h" #include "lllslconstants.h" @@ -87,6 +88,7 @@ #include "lluri.h" #include "llviewergenericmessage.h" #include "llviewermenu.h" +#include "llviewerinventory.h" #include "llviewerjoystick.h" #include "llviewerobjectlist.h" #include "llviewerparcelmgr.h" @@ -694,7 +696,7 @@ bool join_group_response(const LLSD& notification, const LLSD& response) return false; } -static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel) +static void highlight_inventory_objects_in_panel(const std::vector<LLUUID>& items, LLInventoryPanel *inventory_panel) { if (NULL == inventory_panel) return; @@ -708,7 +710,7 @@ static void highlight_inventory_items_in_panel(const std::vector<LLUUID>& items, continue; } - LLInventoryItem* item = gInventory.getItem(item_id); + LLInventoryObject* item = gInventory.getObject(item_id); llassert(item); if (!item) { continue; @@ -787,7 +789,6 @@ class LLViewerInventoryMoveFromWorldObserver : public LLInventoryAddItemByAssetO public: LLViewerInventoryMoveFromWorldObserver() : LLInventoryAddItemByAssetObserver() - , mActivePanel(NULL) { } @@ -798,13 +799,16 @@ private: /*virtual */void onAssetAdded(const LLUUID& asset_id) { // Store active Inventory panel. - mActivePanel = LLInventoryPanel::getActiveInventoryPanel(); + if (LLInventoryPanel::getActiveInventoryPanel()) + { + mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle(); + } // Store selected items (without destination folder) mSelectedItems.clear(); - if (mActivePanel) + if (LLInventoryPanel::getActiveInventoryPanel()) { - mSelectedItems = mActivePanel->getRootFolder()->getSelectionList(); + mSelectedItems = LLInventoryPanel::getActiveInventoryPanel()->getRootFolder()->getSelectionList(); } mSelectedItems.erase(mMoveIntoFolderID); } @@ -815,12 +819,14 @@ private: */ void done() { + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); + // if selection is not changed since watch started lets hightlight new items. - if (mActivePanel && !isSelectionChanged()) + if (active_panel && !isSelectionChanged()) { LL_DEBUGS("Inventory_Move") << "Selecting new items..." << LL_ENDL; - mActivePanel->clearSelection(); - highlight_inventory_items_in_panel(mAddedItems, mActivePanel); + active_panel->clearSelection(); + highlight_inventory_objects_in_panel(mAddedItems, active_panel); } } @@ -828,16 +834,16 @@ private: * Returns true if selected inventory items were changed since moved inventory items were started to watch. */ bool isSelectionChanged() - { - const LLInventoryPanel * const current_active_panel = LLInventoryPanel::getActiveInventoryPanel(); + { + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); - if (NULL == mActivePanel || current_active_panel != mActivePanel) + if (NULL == active_panel) { return true; } // get selected items (without destination folder) - selected_items_t selected_items = mActivePanel->getRootFolder()->getSelectionList(); + selected_items_t selected_items = active_panel->getRootFolder()->getSelectionList(); selected_items.erase(mMoveIntoFolderID); // compare stored & current sets of selected items @@ -851,7 +857,7 @@ private: return different_items.size() > 0; } - LLInventoryPanel *mActivePanel; + LLHandle<LLPanel> mActivePanel; typedef std::set<LLUUID> selected_items_t; selected_items_t mSelectedItems; @@ -880,6 +886,75 @@ void set_dad_inventory_item(LLInventoryItem* inv_item, const LLUUID& into_folder gInventoryMoveObserver->watchAsset(inv_item->getAssetUUID()); } + +/** + * Class to observe moving of items and to select them in inventory. + * + * Used currently for dragging from inbox to regular inventory folders + */ + +class LLViewerInventoryMoveObserver : public LLInventoryObserver +{ +public: + + LLViewerInventoryMoveObserver(const LLUUID& object_id) + : LLInventoryObserver() + , mObjectID(object_id) + { + if (LLInventoryPanel::getActiveInventoryPanel()) + { + mActivePanel = LLInventoryPanel::getActiveInventoryPanel()->getHandle(); + } + } + + virtual ~LLViewerInventoryMoveObserver() {} + virtual void changed(U32 mask); + +private: + LLUUID mObjectID; + LLHandle<LLPanel> mActivePanel; + +}; + +void LLViewerInventoryMoveObserver::changed(U32 mask) +{ + LLInventoryPanel* active_panel = dynamic_cast<LLInventoryPanel*>(mActivePanel.get()); + + if (NULL == active_panel) + { + gInventory.removeObserver(this); + return; + } + + if((mask & (LLInventoryObserver::STRUCTURE)) != 0) + { + const std::set<LLUUID>& changed_items = gInventory.getChangedIDs(); + + std::set<LLUUID>::const_iterator id_it = changed_items.begin(); + std::set<LLUUID>::const_iterator id_end = changed_items.end(); + for (;id_it != id_end; ++id_it) + { + if ((*id_it) == mObjectID) + { + active_panel->clearSelection(); + std::vector<LLUUID> items; + items.push_back(mObjectID); + highlight_inventory_objects_in_panel(items, active_panel); + active_panel->getRootFolder()->scrollToShowSelection(); + + gInventory.removeObserver(this); + break; + } + } + } +} + +void set_dad_inbox_object(const LLUUID& object_id) +{ + LLViewerInventoryMoveObserver* move_observer = new LLViewerInventoryMoveObserver(object_id); + gInventory.addObserver(move_observer); +} + //unlike the FetchObserver for AgentOffer, we only make one //instance of the AddedObserver for TaskOffers //and it never dies. We do this because we don't know the UUID of @@ -936,7 +1011,6 @@ protected: //one global instance to bind them LLOpenTaskOffer* gNewInventoryObserver=NULL; - class LLNewInventoryHintObserver : public LLInventoryAddedObserver { protected: @@ -946,6 +1020,8 @@ protected: } }; +LLNewInventoryHintObserver* gNewInventoryHintObserver=NULL; + void start_new_inventory_observer() { if (!gNewInventoryObserver) //task offer observer @@ -962,7 +1038,12 @@ void start_new_inventory_observer() gInventory.addObserver(gInventoryMoveObserver); } - gInventory.addObserver(new LLNewInventoryHintObserver()); + if (!gNewInventoryHintObserver) + { + // Observer is deleted by gInventory + gNewInventoryHintObserver = new LLNewInventoryHintObserver(); + gInventory.addObserver(gNewInventoryHintObserver); + } } class LLDiscardAgentOffer : public LLInventoryFetchItemsObserver @@ -4265,8 +4346,7 @@ void process_time_synch(LLMessageSystem *mesgsys, void **user_data) LLWorld::getInstance()->setSpaceTimeUSec(space_time_usec); - //LL_DEBUGS("Messaging") << "time_synch() - " << sun_direction << ", " << sun_ang_velocity - // << ", " << phase << LL_ENDL; + LL_DEBUGS("Windlight Sync") << "Sun phase: " << phase << " rad = " << fmodf(phase / F_TWO_PI + 0.25, 1.f) * 24.f << " h" << LL_ENDL; gSky.setSunPhase(phase); gSky.setSunTargetDirection(sun_direction, sun_ang_velocity); @@ -4324,10 +4404,13 @@ void process_sound_trigger(LLMessageSystem *msg, void **) { return; } - - // Don't play sounds from gestures if they are not enabled. - if (!gSavedSettings.getBOOL("EnableGestureSounds")) return; + // Don't play sounds from gestures if they are not enabled. + if (object_id == owner_id && !gSavedSettings.getBOOL("EnableGestureSounds")) + { + return; + } + gAudiop->triggerSound(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX, pos_global); } @@ -6496,7 +6579,7 @@ void process_script_dialog(LLMessageSystem* msg, void**) LLUUID owner_id; if (gMessageSystem->getNumberOfBlocks("OwnerData") > 0) { - msg->getUUID("OwnerData", "OwnerID", owner_id); + msg->getUUID("OwnerData", "OwnerID", owner_id); } if (LLMuteList::getInstance()->isMuted(object_id) || LLMuteList::getInstance()->isMuted(owner_id)) |