diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llfloateropenobject.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llfloateropenobject.cpp')
-rw-r--r-- | linden/indra/newview/llfloateropenobject.cpp | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloateropenobject.cpp b/linden/indra/newview/llfloateropenobject.cpp new file mode 100644 index 0000000..1f0cd5d --- /dev/null +++ b/linden/indra/newview/llfloateropenobject.cpp | |||
@@ -0,0 +1,215 @@ | |||
1 | /** | ||
2 | * @file llfloateropenobject.cpp | ||
3 | * @brief LLFloaterOpenObject class implementation | ||
4 | * | ||
5 | * Copyright (c) 2004-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | /* | ||
29 | * Shows the contents of an object. | ||
30 | * A floater wrapper for llpanelinventory | ||
31 | */ | ||
32 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | #include "llfloateropenobject.h" | ||
36 | |||
37 | #include "llcachename.h" | ||
38 | #include "llbutton.h" | ||
39 | #include "lltextbox.h" | ||
40 | |||
41 | #include "llagent.h" // for agent id | ||
42 | #include "llalertdialog.h" | ||
43 | #include "llinventoryview.h" | ||
44 | #include "llinventorymodel.h" | ||
45 | #include "llpanelinventory.h" | ||
46 | #include "llselectmgr.h" | ||
47 | #include "lluiconstants.h" | ||
48 | #include "llviewerobject.h" | ||
49 | #include "llvieweruictrlfactory.h" | ||
50 | #include "llviewerwindow.h" | ||
51 | |||
52 | |||
53 | LLFloaterOpenObject* LLFloaterOpenObject::sInstance = NULL; | ||
54 | |||
55 | LLFloaterOpenObject::LLFloaterOpenObject() | ||
56 | : LLFloater("object_contents"), | ||
57 | mPanelInventory(NULL), | ||
58 | mDirty(TRUE) | ||
59 | { | ||
60 | LLCallbackMap::map_t factory_map; | ||
61 | factory_map["object_contents"] = LLCallbackMap(createPanelInventory, this); | ||
62 | gUICtrlFactory->buildFloater(this,"floater_openobject.xml",&factory_map); | ||
63 | |||
64 | childSetAction("copy_to_inventory_button", onClickMoveToInventory, this); | ||
65 | childSetAction("copy_and_wear_button", onClickMoveAndWear, this); | ||
66 | childSetTextArg("object_name", "[DESC]", "Object"); | ||
67 | } | ||
68 | |||
69 | LLFloaterOpenObject::~LLFloaterOpenObject() | ||
70 | { | ||
71 | gSelectMgr->deselectAll(); | ||
72 | sInstance = NULL; | ||
73 | } | ||
74 | |||
75 | void LLFloaterOpenObject::refresh() | ||
76 | { | ||
77 | mPanelInventory->refresh(); | ||
78 | |||
79 | LLSelectNode* node = gSelectMgr->getFirstRootNode(); | ||
80 | if (node) | ||
81 | { | ||
82 | std::string name = node->mName; | ||
83 | childSetTextArg("object_name", "[DESC]", name); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void LLFloaterOpenObject::draw() | ||
88 | { | ||
89 | if (mDirty) | ||
90 | { | ||
91 | refresh(); | ||
92 | mDirty = FALSE; | ||
93 | } | ||
94 | LLFloater::draw(); | ||
95 | } | ||
96 | |||
97 | // static | ||
98 | void LLFloaterOpenObject::dirty() | ||
99 | { | ||
100 | if (sInstance) sInstance->mDirty = TRUE; | ||
101 | } | ||
102 | |||
103 | // static | ||
104 | void LLFloaterOpenObject::show() | ||
105 | { | ||
106 | if (gSelectMgr->getRootObjectCount() != 1) | ||
107 | { | ||
108 | gViewerWindow->alertXml("UnableToViewContentsMoreThanOne"); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | // Create a new instance only if needed | ||
113 | if (!sInstance) | ||
114 | { | ||
115 | sInstance = new LLFloaterOpenObject(); | ||
116 | sInstance->center(); | ||
117 | } | ||
118 | |||
119 | sInstance->open(); | ||
120 | sInstance->setFocus(TRUE); | ||
121 | } | ||
122 | |||
123 | |||
124 | // static | ||
125 | void LLFloaterOpenObject::moveToInventory(bool wear) | ||
126 | { | ||
127 | if (gSelectMgr->getRootObjectCount() != 1) | ||
128 | { | ||
129 | gViewerWindow->alertXml("OnlyCopyContentsOfSingleItem"); | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | LLSelectNode* node = gSelectMgr->getFirstRootNode(); | ||
134 | if (!node) return; | ||
135 | LLViewerObject* object = node->getObject(); | ||
136 | if (!object) return; | ||
137 | |||
138 | LLUUID object_id = object->getID(); | ||
139 | std::string name = node->mName; | ||
140 | |||
141 | // Either create a sub-folder of clothing, or of the root folder. | ||
142 | LLUUID parent_category_id; | ||
143 | if (wear) | ||
144 | { | ||
145 | parent_category_id = gInventory.findCategoryUUIDForType( | ||
146 | LLAssetType::AT_CLOTHING); | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | parent_category_id = gAgent.getInventoryRootID(); | ||
151 | } | ||
152 | LLUUID category_id = gInventory.createNewCategory(parent_category_id, | ||
153 | LLAssetType::AT_NONE, | ||
154 | name); | ||
155 | |||
156 | LLCatAndWear* data = new LLCatAndWear; | ||
157 | data->mCatID = category_id; | ||
158 | data->mWear = wear; | ||
159 | |||
160 | // Copy and/or move the items into the newly created folder. | ||
161 | // Ignore any "you're going to break this item" messages. | ||
162 | BOOL success = move_inv_category_world_to_agent(object_id, category_id, TRUE, | ||
163 | callbackMoveInventory, | ||
164 | (void*)data); | ||
165 | if (!success) | ||
166 | { | ||
167 | delete data; | ||
168 | data = NULL; | ||
169 | |||
170 | gViewerWindow->alertXml("OpenObjectCannotCopy"); | ||
171 | } | ||
172 | } | ||
173 | |||
174 | // static | ||
175 | void LLFloaterOpenObject::callbackMoveInventory(S32 result, void* data) | ||
176 | { | ||
177 | LLCatAndWear* cat = (LLCatAndWear*)data; | ||
178 | |||
179 | if (result == 0) | ||
180 | { | ||
181 | LLInventoryView::showAgentInventory(); | ||
182 | LLInventoryView* view = LLInventoryView::getActiveInventory(); | ||
183 | if (view) | ||
184 | { | ||
185 | view->getPanel()->setSelection(cat->mCatID, TAKE_FOCUS_NO); | ||
186 | } | ||
187 | } | ||
188 | |||
189 | delete cat; | ||
190 | } | ||
191 | |||
192 | |||
193 | // static | ||
194 | void LLFloaterOpenObject::onClickMoveToInventory(void* data) | ||
195 | { | ||
196 | LLFloaterOpenObject* self = (LLFloaterOpenObject*)data; | ||
197 | moveToInventory(false); | ||
198 | self->close(); | ||
199 | } | ||
200 | |||
201 | // static | ||
202 | void LLFloaterOpenObject::onClickMoveAndWear(void* data) | ||
203 | { | ||
204 | LLFloaterOpenObject* self = (LLFloaterOpenObject*)data; | ||
205 | moveToInventory(true); | ||
206 | self->close(); | ||
207 | } | ||
208 | |||
209 | //static | ||
210 | void* LLFloaterOpenObject::createPanelInventory(void* data) | ||
211 | { | ||
212 | LLFloaterOpenObject* floater = (LLFloaterOpenObject*)data; | ||
213 | floater->mPanelInventory = new LLPanelInventory("Object Contents", LLRect()); | ||
214 | return floater->mPanelInventory; | ||
215 | } | ||