aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltooldraganddrop.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/newview/lltooldraganddrop.cpp
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltooldraganddrop.cpp402
1 files changed, 143 insertions, 259 deletions
diff --git a/linden/indra/newview/lltooldraganddrop.cpp b/linden/indra/newview/lltooldraganddrop.cpp
index c492c7b..39070b7 100644
--- a/linden/indra/newview/lltooldraganddrop.cpp
+++ b/linden/indra/newview/lltooldraganddrop.cpp
@@ -42,6 +42,7 @@
42#include "llfirstuse.h" 42#include "llfirstuse.h"
43#include "llfloater.h" 43#include "llfloater.h"
44#include "llfloatertools.h" 44#include "llfloatertools.h"
45#include "llfocusmgr.h"
45#include "llgesturemgr.h" 46#include "llgesturemgr.h"
46#include "llhudeffecttrail.h" 47#include "llhudeffecttrail.h"
47#include "llhudmanager.h" 48#include "llhudmanager.h"
@@ -52,6 +53,7 @@
52#include "llpreviewnotecard.h" 53#include "llpreviewnotecard.h"
53#include "llselectmgr.h" 54#include "llselectmgr.h"
54#include "lltoolmgr.h" 55#include "lltoolmgr.h"
56#include "lltrans.h"
55#include "llui.h" 57#include "llui.h"
56#include "llviewerimagelist.h" 58#include "llviewerimagelist.h"
57#include "llviewerinventory.h" 59#include "llviewerinventory.h"
@@ -70,10 +72,6 @@
70// or 18 * count < 1200 => count < 1200/18 => 66. I've cut it down a 72// or 18 * count < 1200 => count < 1200/18 => 66. I've cut it down a
71// bit from there to give some pad. 73// bit from there to give some pad.
72const S32 MAX_ITEMS = 42; 74const S32 MAX_ITEMS = 42;
73const char* FOLDER_INCLUDES_ATTACHMENTS_BEING_WORN =
74 "Cannot give folders that contain objects that are attached to you.\n"
75 "Detach the object(s) and then try again.";
76
77 75
78// syntactic sugar 76// syntactic sugar
79#define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember)) 77#define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember))
@@ -127,41 +125,17 @@ protected:
127}; 125};
128 126
129bool LLDroppableItem::operator()(LLInventoryCategory* cat, 127bool LLDroppableItem::operator()(LLInventoryCategory* cat,
130 LLInventoryItem* item) 128 LLInventoryItem* item)
131{ 129{
132 bool allowed = false; 130 bool allowed = false;
133 if(item) 131 if(item)
134 { 132 {
135 LLVOAvatar* my_avatar = NULL; 133 allowed = itemTransferCommonlyAllowed(item);
136 switch(item->getType())
137 {
138 case LLAssetType::AT_CALLINGCARD:
139 // not allowed
140 break;
141
142 case LLAssetType::AT_OBJECT:
143 my_avatar = gAgent.getAvatarObject();
144 if(my_avatar && !my_avatar->isWearingAttachment(item->getUUID()))
145 {
146 allowed = true;
147 }
148 break;
149 134
150 case LLAssetType::AT_BODYPART: 135 if(allowed
151 case LLAssetType::AT_CLOTHING: 136 && mIsTransfer
152 if(!gAgent.isWearingItem(item->getUUID()))
153 {
154 allowed = true;
155 }
156 break;
157
158 default:
159 allowed = true;
160 break;
161 }
162 if(mIsTransfer
163 && !item->getPermissions().allowOperationBy(PERM_TRANSFER, 137 && !item->getPermissions().allowOperationBy(PERM_TRANSFER,
164 gAgent.getID())) 138 gAgent.getID()))
165 { 139 {
166 allowed = false; 140 allowed = false;
167 } 141 }
@@ -182,45 +156,18 @@ public:
182}; 156};
183 157
184bool LLUncopyableItems::operator()(LLInventoryCategory* cat, 158bool LLUncopyableItems::operator()(LLInventoryCategory* cat,
185 LLInventoryItem* item) 159 LLInventoryItem* item)
186{ 160{
187 BOOL uncopyable = FALSE; 161 bool uncopyable = false;
188 if(item) 162 if(item)
189 { 163 {
190 BOOL allowed = FALSE; 164 if (itemTransferCommonlyAllowed(item) &&
191 LLVOAvatar* my_avatar = NULL; 165 !item->getPermissions().allowCopyBy(gAgent.getID()))
192 switch(item->getType())
193 {
194 case LLAssetType::AT_CALLINGCARD:
195 // not allowed
196 break;
197
198 case LLAssetType::AT_OBJECT:
199 my_avatar = gAgent.getAvatarObject();
200 if(my_avatar && !my_avatar->isWearingAttachment(item->getUUID()))
201 {
202 allowed = TRUE;
203 }
204 break;
205
206 case LLAssetType::AT_BODYPART:
207 case LLAssetType::AT_CLOTHING:
208 if(!gAgent.isWearingItem(item->getUUID()))
209 {
210 allowed = TRUE;
211 }
212 break;
213
214 default:
215 allowed = TRUE;
216 break;
217 }
218 if(allowed && !item->getPermissions().allowCopyBy(gAgent.getID()))
219 { 166 {
220 uncopyable = TRUE; 167 uncopyable = true;
221 } 168 }
222 } 169 }
223 return (uncopyable ? true : false); 170 return uncopyable;
224} 171}
225 172
226class LLDropCopyableItems : public LLInventoryCollectFunctor 173class LLDropCopyableItems : public LLInventoryCollectFunctor
@@ -233,45 +180,21 @@ public:
233 180
234 181
235bool LLDropCopyableItems::operator()( 182bool LLDropCopyableItems::operator()(
236 LLInventoryCategory* cat, LLInventoryItem* item) 183 LLInventoryCategory* cat,
184 LLInventoryItem* item)
237{ 185{
238 BOOL allowed = FALSE; 186 bool allowed = false;
239 if(item) 187 if(item)
240 { 188 {
241 LLVOAvatar* my_avatar = NULL; 189 allowed = itemTransferCommonlyAllowed(item);
242 switch(item->getType()) 190 if(allowed &&
243 { 191 !item->getPermissions().allowCopyBy(gAgent.getID()))
244 case LLAssetType::AT_CALLINGCARD:
245 // not allowed
246 break;
247
248 case LLAssetType::AT_OBJECT:
249 my_avatar = gAgent.getAvatarObject();
250 if(my_avatar && !my_avatar->isWearingAttachment(item->getUUID()))
251 {
252 allowed = TRUE;
253 }
254 break;
255
256 case LLAssetType::AT_BODYPART:
257 case LLAssetType::AT_CLOTHING:
258 if(!gAgent.isWearingItem(item->getUUID()))
259 {
260 allowed = TRUE;
261 }
262 break;
263
264 default:
265 allowed = TRUE;
266 break;
267 }
268 if(allowed && !item->getPermissions().allowCopyBy(gAgent.getID()))
269 { 192 {
270 // whoops, can't copy it - don't allow it. 193 // whoops, can't copy it - don't allow it.
271 allowed = FALSE; 194 allowed = false;
272 } 195 }
273 } 196 }
274 return (allowed ? true : false); 197 return allowed;
275} 198}
276 199
277class LLGiveable : public LLInventoryCollectFunctor 200class LLGiveable : public LLInventoryCollectFunctor
@@ -289,48 +212,26 @@ protected:
289bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item) 212bool LLGiveable::operator()(LLInventoryCategory* cat, LLInventoryItem* item)
290{ 213{
291 // All categories can be given. 214 // All categories can be given.
292 if(cat) return TRUE; 215 if (cat)
293 BOOL allowed = FALSE; 216 return true;
217
218 bool allowed = false;
294 if(item) 219 if(item)
295 { 220 {
296 LLVOAvatar* my_avatar = NULL; 221 allowed = itemTransferCommonlyAllowed(item);
297 switch(item->getType()) 222 if(allowed &&
298 { 223 !item->getPermissions().allowOperationBy(PERM_TRANSFER,
299 case LLAssetType::AT_CALLINGCARD: 224 gAgent.getID()))
300 // not allowed
301 break;
302
303 case LLAssetType::AT_OBJECT:
304 my_avatar = gAgent.getAvatarObject();
305 if(my_avatar && !my_avatar->isWearingAttachment(item->getUUID()))
306 {
307 allowed = TRUE;
308 }
309 break;
310
311 case LLAssetType::AT_BODYPART:
312 case LLAssetType::AT_CLOTHING:
313 if(!gAgent.isWearingItem(item->getUUID()))
314 {
315 allowed = TRUE;
316 }
317 break;
318
319 default:
320 allowed = TRUE;
321 break;
322 }
323 if(!item->getPermissions().allowOperationBy(PERM_TRANSFER,
324 gAgent.getID()))
325 { 225 {
326 allowed = FALSE; 226 allowed = FALSE;
327 } 227 }
328 if(allowed && !item->getPermissions().allowCopyBy(gAgent.getID())) 228 if(allowed &&
229 !item->getPermissions().allowCopyBy(gAgent.getID()))
329 { 230 {
330 ++mCountLosing; 231 ++mCountLosing;
331 } 232 }
332 } 233 }
333 return (allowed ? true : false); 234 return allowed;
334} 235}
335 236
336class LLCategoryFireAndForget : public LLInventoryFetchComboObserver 237class LLCategoryFireAndForget : public LLInventoryFetchComboObserver
@@ -569,8 +470,7 @@ LLToolDragAndDrop::dragOrDrop3dImpl LLToolDragAndDrop::sDragAndDrop3d[DAD_COUNT]
569}; 470};
570 471
571LLToolDragAndDrop::LLToolDragAndDrop() 472LLToolDragAndDrop::LLToolDragAndDrop()
572 : 473: LLTool(std::string("draganddrop"), NULL),
573 LLTool("draganddrop", NULL),
574 mDragStartX(0), 474 mDragStartX(0),
575 mDragStartY(0), 475 mDragStartY(0),
576 mSource(SOURCE_AGENT), 476 mSource(SOURCE_AGENT),
@@ -688,7 +588,7 @@ void LLToolDragAndDrop::beginMultiDrag(
688 mCursor = UI_CURSOR_NO; 588 mCursor = UI_CURSOR_NO;
689 if((mSource == SOURCE_AGENT) || (mSource == SOURCE_LIBRARY)) 589 if((mSource == SOURCE_AGENT) || (mSource == SOURCE_LIBRARY))
690 { 590 {
691 // find cats in the cargo. 591 // find categories (i.e. inventory folders) in the cargo.
692 LLInventoryCategory* cat = NULL; 592 LLInventoryCategory* cat = NULL;
693 S32 count = llmin(cargo_ids.size(), types.size()); 593 S32 count = llmin(cargo_ids.size(), types.size());
694 std::set<LLUUID> cat_ids; 594 std::set<LLUUID> cat_ids;
@@ -737,7 +637,7 @@ void LLToolDragAndDrop::endDrag()
737 637
738void LLToolDragAndDrop::onMouseCaptureLost() 638void LLToolDragAndDrop::onMouseCaptureLost()
739{ 639{
740 // Called whenever the drag ends or if mouse captue is simply lost 640 // Called whenever the drag ends or if mouse capture is simply lost
741 LLToolMgr::getInstance()->clearTransientTool(); 641 LLToolMgr::getInstance()->clearTransientTool();
742 mCargoTypes.clear(); 642 mCargoTypes.clear();
743 mCargoIDs.clear(); 643 mCargoIDs.clear();
@@ -757,11 +657,8 @@ BOOL LLToolDragAndDrop::handleMouseUp( S32 x, S32 y, MASK mask )
757 return TRUE; 657 return TRUE;
758} 658}
759 659
760BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask ) 660ECursorType LLToolDragAndDrop::acceptanceToCursor( EAcceptance acceptance )
761{ 661{
762 EAcceptance acceptance = ACCEPT_NO;
763 dragOrDrop( x, y, mask, FALSE, &acceptance );
764
765 switch( acceptance ) 662 switch( acceptance )
766 { 663 {
767 case ACCEPT_YES_MULTI: 664 case ACCEPT_YES_MULTI:
@@ -774,8 +671,16 @@ BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
774 mCursor = UI_CURSOR_ARROWDRAG; 671 mCursor = UI_CURSOR_ARROWDRAG;
775 } 672 }
776 break; 673 break;
777 case ACCEPT_YES_SINGLE: 674 case ACCEPT_YES_SINGLE:
778 mCursor = UI_CURSOR_ARROWDRAG; 675 if (mCargoIDs.size() > 1)
676 {
677 mToolTipMsg = LLTrans::getString("TooltipMustSingleDrop");
678 mCursor = UI_CURSOR_NO;
679 }
680 else
681 {
682 mCursor = UI_CURSOR_ARROWDRAG;
683 }
779 break; 684 break;
780 685
781 case ACCEPT_NO_LOCKED: 686 case ACCEPT_NO_LOCKED:
@@ -797,7 +702,15 @@ BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
797 } 702 }
798 break; 703 break;
799 case ACCEPT_YES_COPY_SINGLE: 704 case ACCEPT_YES_COPY_SINGLE:
800 mCursor = UI_CURSOR_ARROWCOPY; 705 if (mCargoIDs.size() > 1)
706 {
707 mToolTipMsg = LLTrans::getString("TooltipMustSingleDrop");
708 mCursor = UI_CURSOR_NO;
709 }
710 else
711 {
712 mCursor = UI_CURSOR_ARROWCOPY;
713 }
801 break; 714 break;
802 case ACCEPT_POSTPONED: 715 case ACCEPT_POSTPONED:
803 break; 716 break;
@@ -805,7 +718,17 @@ BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
805 llassert( FALSE ); 718 llassert( FALSE );
806 } 719 }
807 720
808 gViewerWindow->getWindow()->setCursor( mCursor ); 721 return mCursor;
722}
723
724BOOL LLToolDragAndDrop::handleHover( S32 x, S32 y, MASK mask )
725{
726 EAcceptance acceptance = ACCEPT_NO;
727 dragOrDrop( x, y, mask, FALSE, &acceptance );
728
729 ECursorType cursor = acceptanceToCursor(acceptance);
730 gViewerWindow->getWindow()->setCursor( cursor );
731
809 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolDragAndDrop" << llendl; 732 lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolDragAndDrop" << llendl;
810 return TRUE; 733 return TRUE;
811} 734}
@@ -822,12 +745,12 @@ BOOL LLToolDragAndDrop::handleKey(KEY key, MASK mask)
822 return FALSE; 745 return FALSE;
823} 746}
824 747
825BOOL LLToolDragAndDrop::handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen) 748BOOL LLToolDragAndDrop::handleToolTip(S32 x, S32 y, std::string& msg, LLRect *sticky_rect_screen)
826{ 749{
827 if (!mToolTipMsg.empty()) 750 if (!mToolTipMsg.empty())
828 { 751 {
829 msg = mToolTipMsg; 752 msg = mToolTipMsg;
830 //*stick_rect_screen = gViewerWindow->getWindowRect(); 753 //*sticky_rect_screen = gViewerWindow->getWindowRect();
831 return TRUE; 754 return TRUE;
832 } 755 }
833 return FALSE; 756 return FALSE;
@@ -846,11 +769,11 @@ void LLToolDragAndDrop::dragOrDrop( S32 x, S32 y, MASK mask, BOOL drop,
846 769
847 BOOL handled = FALSE; 770 BOOL handled = FALSE;
848 771
849 LLView* top_view = gViewerWindow->getTopCtrl(); 772 LLView* top_view = gFocusMgr.getTopCtrl();
850 LLViewerInventoryItem* item; 773 LLViewerInventoryItem* item;
851 LLViewerInventoryCategory* cat; 774 LLViewerInventoryCategory* cat;
852 775
853 mToolTipMsg.assign(""); 776 mToolTipMsg.clear();
854 777
855 if(top_view) 778 if(top_view)
856 { 779 {
@@ -885,17 +808,15 @@ void LLToolDragAndDrop::dragOrDrop( S32 x, S32 y, MASK mask, BOOL drop,
885 // all objects passed, go ahead and perform drop if necessary 808 // all objects passed, go ahead and perform drop if necessary
886 if (handled && drop && (U32)*acceptance >= ACCEPT_YES_COPY_SINGLE) 809 if (handled && drop && (U32)*acceptance >= ACCEPT_YES_COPY_SINGLE)
887 { 810 {
888 // drop all items 811 if ((U32)*acceptance < ACCEPT_YES_COPY_MULTI &&
889 if ((U32)*acceptance >= ACCEPT_YES_COPY_MULTI) 812 mCargoIDs.size() > 1)
890 { 813 {
891 mCurItemIndex = 0; 814 // tried to give multi-cargo to a single-acceptor - refuse and return.
892 } 815 *acceptance = ACCEPT_NO;
893 // drop just last item 816 return;
894 else
895 {
896 mCurItemIndex = mCargoIDs.size() - 1;
897 } 817 }
898 for (; mCurItemIndex < (S32)mCargoIDs.size(); mCurItemIndex++) 818
819 for (mCurItemIndex = 0; mCurItemIndex < (S32)mCargoIDs.size(); mCurItemIndex++)
899 { 820 {
900 LLInventoryObject* cargo = locateInventory(item, cat); 821 LLInventoryObject* cargo = locateInventory(item, cat);
901 822
@@ -944,30 +865,26 @@ void LLToolDragAndDrop::dragOrDrop( S32 x, S32 y, MASK mask, BOOL drop,
944 // all objects passed, go ahead and perform drop if necessary 865 // all objects passed, go ahead and perform drop if necessary
945 if (handled && drop && (U32)*acceptance > ACCEPT_NO_LOCKED) 866 if (handled && drop && (U32)*acceptance > ACCEPT_NO_LOCKED)
946 { 867 {
947 // drop all items 868 if ((U32)*acceptance < ACCEPT_YES_COPY_MULTI &&
948 if ((U32)*acceptance >= ACCEPT_YES_COPY_MULTI) 869 mCargoIDs.size() > 1)
949 { 870 {
950 mCurItemIndex = 0; 871 // tried to give multi-cargo to a single-acceptor - refuse and return.
951 } 872 *acceptance = ACCEPT_NO;
952 // drop just last item 873 return;
953 else
954 {
955 mCurItemIndex = mCargoIDs.size() - 1;
956 } 874 }
957 for (; mCurItemIndex < (S32)mCargoIDs.size(); mCurItemIndex++) 875
876 for (mCurItemIndex = 0; mCurItemIndex < (S32)mCargoIDs.size(); mCurItemIndex++)
958 { 877 {
959 LLInventoryObject* cargo = locateInventory(item, cat); 878 LLInventoryObject* cargo = locateInventory(item, cat);
960 879
961 if (cargo) 880 if (cargo)
962 { 881 {
963 //S32 local_x, local_y;
964
965 EAcceptance item_acceptance; 882 EAcceptance item_acceptance;
966 handled = handled && root_view->handleDragAndDrop(x, y, mask, TRUE, 883 handled = handled && root_view->handleDragAndDrop(x, y, mask, TRUE,
967 mCargoTypes[mCurItemIndex], 884 mCargoTypes[mCurItemIndex],
968 (void*)cargo, 885 (void*)cargo,
969 &item_acceptance, 886 &item_acceptance,
970 mToolTipMsg); 887 mToolTipMsg);
971 } 888 }
972 } 889 }
973 } 890 }
@@ -989,32 +906,37 @@ void LLToolDragAndDrop::dragOrDrop3D( S32 x, S32 y, MASK mask, BOOL drop, EAccep
989 mDrop = drop; 906 mDrop = drop;
990 if (mDrop) 907 if (mDrop)
991 { 908 {
992 gPickFaces = TRUE;
993 // don't allow drag and drop onto transparent objects 909 // don't allow drag and drop onto transparent objects
994 gViewerWindow->hitObjectOrLandGlobalImmediate(x, y, pickCallback, FALSE); 910 pickCallback(gViewerWindow->pickImmediate(x, y, FALSE));
995 } 911 }
996 else 912 else
997 { 913 {
998 // Don't pick faces during hover. Nothing currently requires per-face
999 // data.
1000 // don't allow drag and drop onto transparent objects 914 // don't allow drag and drop onto transparent objects
1001 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback, FALSE); 915 gViewerWindow->pickAsync(x, y, mask, pickCallback, FALSE);
1002 } 916 }
1003 917
1004 *acceptance = mLastAccept; 918 *acceptance = mLastAccept;
1005} 919}
1006 920
1007void LLToolDragAndDrop::pickCallback(S32 x, S32 y, MASK mask) 921void LLToolDragAndDrop::pickCallback(const LLPickInfo& pick_info)
1008{ 922{
1009 EDropTarget target = DT_NONE; 923 EDropTarget target = DT_NONE;
1010 S32 hit_face = -1; 924 S32 hit_face = -1;
1011 925
1012 LLViewerObject* hit_obj = gViewerWindow->lastNonFloraObjectHit(); 926 LLViewerObject* hit_obj = pick_info.getObject();
1013 LLSelectMgr::getInstance()->unhighlightAll(); 927 LLSelectMgr::getInstance()->unhighlightAll();
1014 928
1015 // Treat attachments as part of the avatar they are attached to. 929 // Treat attachments as part of the avatar they are attached to.
1016 if (hit_obj) 930 if (hit_obj)
1017 { 931 {
932 // don't allow drag and drop on grass, trees, etc.
933 if(pick_info.mPickType == LLPickInfo::PICK_FLORA)
934 {
935 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_NO;
936 gViewerWindow->getWindow()->setCursor( LLToolDragAndDrop::getInstance()->mCursor );
937 return;
938 }
939
1018 if(hit_obj->isAttachment() && !hit_obj->isHUDAttachment()) 940 if(hit_obj->isAttachment() && !hit_obj->isHUDAttachment())
1019 { 941 {
1020 LLVOAvatar* avatar = LLVOAvatar::findAvatarFromAttachment( hit_obj ); 942 LLVOAvatar* avatar = LLVOAvatar::findAvatarFromAttachment( hit_obj );
@@ -1045,12 +967,12 @@ void LLToolDragAndDrop::pickCallback(S32 x, S32 y, MASK mask)
1045 else 967 else
1046 { 968 {
1047 target = DT_OBJECT; 969 target = DT_OBJECT;
1048 hit_face = gLastHitNonFloraObjectFace; 970 hit_face = pick_info.mObjectFace;
1049 // if any item being dragged will be applied to the object under our cursor 971 // if any item being dragged will be applied to the object under our cursor
1050 // highlight that object 972 // highlight that object
1051 for (S32 i = 0; i < (S32)LLToolDragAndDrop::getInstance()->mCargoIDs.size(); i++) 973 for (S32 i = 0; i < (S32)LLToolDragAndDrop::getInstance()->mCargoIDs.size(); i++)
1052 { 974 {
1053 if (LLToolDragAndDrop::getInstance()->mCargoTypes[i] != DAD_OBJECT || (mask & MASK_CONTROL)) 975 if (LLToolDragAndDrop::getInstance()->mCargoTypes[i] != DAD_OBJECT || (pick_info.mKeyMask & MASK_CONTROL))
1054 { 976 {
1055 LLSelectMgr::getInstance()->highlightObjectAndFamily(hit_obj); 977 LLSelectMgr::getInstance()->highlightObjectAndFamily(hit_obj);
1056 break; 978 break;
@@ -1058,7 +980,7 @@ void LLToolDragAndDrop::pickCallback(S32 x, S32 y, MASK mask)
1058 } 980 }
1059 } 981 }
1060 } 982 }
1061 else if(gLastHitLand) 983 else if(pick_info.mPickType == LLPickInfo::PICK_LAND)
1062 { 984 {
1063 target = DT_LAND; 985 target = DT_LAND;
1064 hit_face = -1; 986 hit_face = -1;
@@ -1074,79 +996,39 @@ void LLToolDragAndDrop::pickCallback(S32 x, S32 y, MASK mask)
1074 (U32)LLToolDragAndDrop::getInstance()->mLastAccept, 996 (U32)LLToolDragAndDrop::getInstance()->mLastAccept,
1075 (U32)callMemberFunction((*LLToolDragAndDrop::getInstance()), 997 (U32)callMemberFunction((*LLToolDragAndDrop::getInstance()),
1076 LLToolDragAndDrop::getInstance()->sDragAndDrop3d[LLToolDragAndDrop::getInstance()->mCargoTypes[LLToolDragAndDrop::getInstance()->mCurItemIndex]][target]) 998 LLToolDragAndDrop::getInstance()->sDragAndDrop3d[LLToolDragAndDrop::getInstance()->mCargoTypes[LLToolDragAndDrop::getInstance()->mCurItemIndex]][target])
1077 (hit_obj, hit_face, mask, FALSE)); 999 (hit_obj, hit_face, pick_info.mKeyMask, FALSE));
1078 } 1000 }
1079 1001
1080 if (LLToolDragAndDrop::getInstance()->mDrop && (U32)LLToolDragAndDrop::getInstance()->mLastAccept >= ACCEPT_YES_COPY_SINGLE) 1002 if (LLToolDragAndDrop::getInstance()->mDrop &&
1003 (U32)LLToolDragAndDrop::getInstance()->mLastAccept >= ACCEPT_YES_COPY_SINGLE)
1081 { 1004 {
1082 // if target allows multi-drop, go ahead and start iteration at beginning of cargo list 1005 // if target allows multi-drop or there is only one item being dropped, go ahead
1083 if (LLToolDragAndDrop::getInstance()->mLastAccept >= ACCEPT_YES_COPY_MULTI) 1006 if (LLToolDragAndDrop::getInstance()->mLastAccept >= ACCEPT_YES_COPY_MULTI ||
1007 LLToolDragAndDrop::getInstance()->mCargoIDs.size() == 1)
1084 { 1008 {
1085 LLToolDragAndDrop::getInstance()->mCurItemIndex = 0; 1009 // Target accepts multi, or cargo is a single-drop
1010 for (LLToolDragAndDrop::getInstance()->mCurItemIndex = 0;
1011 LLToolDragAndDrop::getInstance()->mCurItemIndex < (S32)LLToolDragAndDrop::getInstance()->mCargoIDs.size();
1012 LLToolDragAndDrop::getInstance()->mCurItemIndex++)
1013 {
1014 // Call the right implementation function
1015 (U32)callMemberFunction((*LLToolDragAndDrop::getInstance()),
1016 LLToolDragAndDrop::getInstance()->sDragAndDrop3d[LLToolDragAndDrop::getInstance()->mCargoTypes[LLToolDragAndDrop::getInstance()->mCurItemIndex]][target])
1017 (hit_obj, hit_face, pick_info.mKeyMask, TRUE);
1018 }
1086 } 1019 }
1087 // otherwise start at end, to follow selection rules (last selected item is most current)
1088 else 1020 else
1089 { 1021 {
1090 LLToolDragAndDrop::getInstance()->mCurItemIndex = LLToolDragAndDrop::getInstance()->mCargoIDs.size() - 1; 1022 // Target does not accept multi, but cargo is multi
1091 } 1023 LLToolDragAndDrop::getInstance()->mLastAccept = ACCEPT_NO;
1092
1093 for (; LLToolDragAndDrop::getInstance()->mCurItemIndex < (S32)LLToolDragAndDrop::getInstance()->mCargoIDs.size();
1094 LLToolDragAndDrop::getInstance()->mCurItemIndex++)
1095 {
1096 // Call the right implementation function
1097 (U32)callMemberFunction((*LLToolDragAndDrop::getInstance()),
1098 LLToolDragAndDrop::getInstance()->sDragAndDrop3d[LLToolDragAndDrop::getInstance()->mCargoTypes[LLToolDragAndDrop::getInstance()->mCurItemIndex]][target])
1099 (hit_obj, hit_face, mask, TRUE);
1100 } 1024 }
1101 } 1025 }
1102 1026
1103 switch( LLToolDragAndDrop::getInstance()->mLastAccept ) 1027 ECursorType cursor = LLToolDragAndDrop::getInstance()->acceptanceToCursor( LLToolDragAndDrop::getInstance()->mLastAccept );
1104 { 1028 gViewerWindow->getWindow()->setCursor( cursor );
1105 case ACCEPT_YES_MULTI:
1106 if (LLToolDragAndDrop::getInstance()->mCargoIDs.size() > 1)
1107 {
1108 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWDRAGMULTI;
1109 }
1110 else
1111 {
1112 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWDRAG;
1113 }
1114 break;
1115 case ACCEPT_YES_SINGLE:
1116 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWDRAG;
1117 break;
1118 1029
1119 case ACCEPT_NO_LOCKED: 1030 LLToolDragAndDrop::getInstance()->mLastHitPos = pick_info.mPosGlobal;
1120 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_NOLOCKED;
1121 break;
1122
1123 case ACCEPT_NO:
1124 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_NO;
1125 break;
1126
1127 case ACCEPT_YES_COPY_MULTI:
1128 if (LLToolDragAndDrop::getInstance()->mCargoIDs.size() > 1)
1129 {
1130 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWCOPYMULTI;
1131 }
1132 else
1133 {
1134 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWCOPY;
1135 }
1136 break;
1137 case ACCEPT_YES_COPY_SINGLE:
1138 LLToolDragAndDrop::getInstance()->mCursor = UI_CURSOR_ARROWCOPY;
1139 break;
1140 case ACCEPT_POSTPONED:
1141 break;
1142 default:
1143 llassert( FALSE );
1144 }
1145
1146 LLToolDragAndDrop::getInstance()->mLastHitPos = gLastHitPosGlobal + gLastHitObjectOffset;
1147 LLToolDragAndDrop::getInstance()->mLastCameraPos = gAgent.getCameraPositionGlobal(); 1031 LLToolDragAndDrop::getInstance()->mLastCameraPos = gAgent.getCameraPositionGlobal();
1148
1149 gViewerWindow->getWindow()->setCursor( LLToolDragAndDrop::getInstance()->mCursor );
1150} 1032}
1151 1033
1152// static 1034// static
@@ -1169,7 +1051,7 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
1169 if (hit_obj->isInventoryDirty()) 1051 if (hit_obj->isInventoryDirty())
1170 { 1052 {
1171 hit_obj->fetchInventoryFromServer(); 1053 hit_obj->fetchInventoryFromServer();
1172 LLString::format_map_t args; 1054 LLStringUtil::format_map_t args;
1173 args["[ERROR_MESSAGE]"] = "Unable to add texture.\nPlease wait a few seconds and try again."; 1055 args["[ERROR_MESSAGE]"] = "Unable to add texture.\nPlease wait a few seconds and try again.";
1174 gViewerWindow->alertXml("ErrorMessage", args); 1056 gViewerWindow->alertXml("ErrorMessage", args);
1175 return FALSE; 1057 return FALSE;
@@ -1225,7 +1107,7 @@ BOOL LLToolDragAndDrop::handleDropTextureProtections(LLViewerObject* hit_obj,
1225 else if(!item->getPermissions().allowOperationBy(PERM_TRANSFER, 1107 else if(!item->getPermissions().allowOperationBy(PERM_TRANSFER,
1226 gAgent.getID())) 1108 gAgent.getID()))
1227 { 1109 {
1228 // Check that we can add the testure as inventory to the object 1110 // Check that we can add the texture as inventory to the object
1229 if (willObjectAcceptInventory(hit_obj,item) < ACCEPT_YES_COPY_SINGLE ) 1111 if (willObjectAcceptInventory(hit_obj,item) < ACCEPT_YES_COPY_SINGLE )
1230 { 1112 {
1231 return FALSE; 1113 return FALSE;
@@ -1546,7 +1428,7 @@ void LLToolDragAndDrop::dropInventory(LLViewerObject* hit_obj,
1546 } 1428 }
1547 1429
1548 LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); 1430 LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
1549 S32 creation_date = time_corrected(); 1431 time_t creation_date = time_corrected();
1550 new_item->setCreationDate(creation_date); 1432 new_item->setCreationDate(creation_date);
1551 1433
1552 if(!item->getPermissions().allowCopyBy(gAgent.getID())) 1434 if(!item->getPermissions().allowCopyBy(gAgent.getID()))
@@ -1601,7 +1483,7 @@ struct LLGiveInventoryInfo
1601}; 1483};
1602 1484
1603void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent, 1485void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent,
1604 LLInventoryItem* item) 1486 LLInventoryItem* item)
1605{ 1487{
1606 llinfos << "LLToolDragAndDrop::giveInventory()" << llendl; 1488 llinfos << "LLToolDragAndDrop::giveInventory()" << llendl;
1607 if(!isInventoryGiveAcceptable(item)) 1489 if(!isInventoryGiveAcceptable(item))
@@ -1617,11 +1499,11 @@ void LLToolDragAndDrop::giveInventory(const LLUUID& to_agent,
1617 { 1499 {
1618 // ask if the agent is sure. 1500 // ask if the agent is sure.
1619 LLGiveInventoryInfo* info = new LLGiveInventoryInfo(to_agent, 1501 LLGiveInventoryInfo* info = new LLGiveInventoryInfo(to_agent,
1620 item->getUUID()); 1502 item->getUUID());
1621 1503
1622 gViewerWindow->alertXml("CannotCopyWarning", 1504 gViewerWindow->alertXml("CannotCopyWarning",
1623 &LLToolDragAndDrop::handleCopyProtectedItem, 1505 &LLToolDragAndDrop::handleCopyProtectedItem,
1624 (void*)info); 1506 (void*)info);
1625 } 1507 }
1626} 1508}
1627 1509
@@ -1674,8 +1556,8 @@ void LLToolDragAndDrop::commitGiveInventoryItem(const LLUUID& to_agent,
1674 FALSE, 1556 FALSE,
1675 gAgent.getSessionID(), 1557 gAgent.getSessionID(),
1676 to_agent, 1558 to_agent,
1677 name.c_str(), 1559 name,
1678 item->getName().c_str(), 1560 item->getName(),
1679 IM_ONLINE, 1561 IM_ONLINE,
1680 IM_INVENTORY_OFFERED, 1562 IM_INVENTORY_OFFERED,
1681 transaction_id, 1563 transaction_id,
@@ -1756,7 +1638,7 @@ void LLToolDragAndDrop::giveInventoryCategory(const LLUUID& to_agent,
1756 { 1638 {
1757 LLGiveInventoryInfo* info = NULL; 1639 LLGiveInventoryInfo* info = NULL;
1758 info = new LLGiveInventoryInfo(to_agent, cat->getUUID()); 1640 info = new LLGiveInventoryInfo(to_agent, cat->getUUID());
1759 LLStringBase<char>::format_map_t args; 1641 LLStringUtil::format_map_t args;
1760 args["[COUNT]"] = llformat("%d",giveable.countNoCopy()); 1642 args["[COUNT]"] = llformat("%d",giveable.countNoCopy());
1761 gViewerWindow->alertXml("CannotCopyCountItems", args, 1643 gViewerWindow->alertXml("CannotCopyCountItems", args,
1762 &LLToolDragAndDrop::handleCopyProtectedCategory, 1644 &LLToolDragAndDrop::handleCopyProtectedCategory,
@@ -1877,8 +1759,8 @@ void LLToolDragAndDrop::commitGiveInventoryCategory(const LLUUID& to_agent,
1877 FALSE, 1759 FALSE,
1878 gAgent.getSessionID(), 1760 gAgent.getSessionID(),
1879 to_agent, 1761 to_agent,
1880 name.c_str(), 1762 name,
1881 cat->getName().c_str(), 1763 cat->getName(),
1882 IM_ONLINE, 1764 IM_ONLINE,
1883 IM_INVENTORY_OFFERED, 1765 IM_INVENTORY_OFFERED,
1884 transaction_id, 1766 transaction_id,
@@ -1916,11 +1798,13 @@ BOOL LLToolDragAndDrop::isInventoryGiveAcceptable(LLInventoryItem* item)
1916 } 1798 }
1917 BOOL copyable = FALSE; 1799 BOOL copyable = FALSE;
1918 if(item->getPermissions().allowCopyBy(gAgent.getID())) copyable = TRUE; 1800 if(item->getPermissions().allowCopyBy(gAgent.getID())) copyable = TRUE;
1801
1919 LLVOAvatar* my_avatar = gAgent.getAvatarObject(); 1802 LLVOAvatar* my_avatar = gAgent.getAvatarObject();
1920 if(!my_avatar) 1803 if(!my_avatar)
1921 { 1804 {
1922 return FALSE; 1805 return FALSE;
1923 } 1806 }
1807
1924 BOOL acceptable = TRUE; 1808 BOOL acceptable = TRUE;
1925 switch(item->getType()) 1809 switch(item->getType())
1926 { 1810 {
@@ -2990,11 +2874,11 @@ LLInventoryObject* LLToolDragAndDrop::locateMultipleInventory(LLViewerInventoryC
2990} 2874}
2991*/ 2875*/
2992 2876
2993void LLToolDragAndDrop::createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name ) 2877// void LLToolDragAndDrop::createContainer(LLViewerInventoryItem::item_array_t &items, const char* preferred_name )
2994{ 2878// {
2995 llwarns << "LLToolDragAndDrop::createContainer()" << llendl; 2879// llwarns << "LLToolDragAndDrop::createContainer()" << llendl;
2996 return; 2880// return;
2997} 2881// }
2998 2882
2999 2883
3000// utility functions 2884// utility functions