1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
/**
* @file llfloaterlandmark.cpp
* @author Richard Nelson, James Cook, Sam Kolb
*
* $LicenseInfo:firstyear=2007&license=viewergpl$
*
* Copyright (c) 2007-2008, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llfloaterlandmark.h"
#include "llagent.h"
#include "llviewerimagelist.h"
#include "llcheckboxctrl.h"
#include "llcombobox.h"
#include "llbutton.h"
#include "lldraghandle.h"
#include "llfocusmgr.h"
#include "llviewerimage.h"
#include "llviewerparcelmgr.h"
#include "llfolderview.h"
#include "llinventory.h"
#include "llinventorymodel.h"
#include "llinventoryview.h"
#include "lllineeditor.h"
#include "llui.h"
#include "llviewerinventory.h"
#include "llpermissions.h"
#include "llsaleinfo.h"
#include "llassetstorage.h"
#include "lltextbox.h"
#include "llparcel.h"
#include "llresizehandle.h"
#include "llscrollcontainer.h"
#include "lltoolmgr.h"
#include "lltoolpipette.h"
#include "lltool.h"
#include "llviewerwindow.h"
#include "llviewerobject.h"
#include "llviewercontrol.h"
#include "llglheaders.h"
#include "lluictrlfactory.h"
#include "roles_constants.h"
static const S32 CLOSE_BTN_WIDTH = 100;
const S32 PIPETTE_BTN_WIDTH = 32;
static const S32 HPAD = 4;
static const S32 VPAD = 4;
static const S32 LINE = 16;
static const S32 SMALL_BTN_WIDTH = 64;
static const S32 TEX_PICKER_MIN_WIDTH =
(HPAD +
CLOSE_BTN_WIDTH +
HPAD +
CLOSE_BTN_WIDTH +
HPAD +
SMALL_BTN_WIDTH +
HPAD +
SMALL_BTN_WIDTH +
HPAD +
30 +
RESIZE_HANDLE_WIDTH * 2);
static const S32 CLEAR_BTN_WIDTH = 50;
static const S32 TEX_PICKER_MIN_HEIGHT = 290;
static const S32 FOOTER_HEIGHT = 100;
static const S32 BORDER_PAD = HPAD;
static const S32 TEXTURE_INVENTORY_PADDING = 30;
static const F32 CONTEXT_CONE_IN_ALPHA = 0.0f;
static const F32 CONTEXT_CONE_OUT_ALPHA = 1.f;
static const F32 CONTEXT_FADE_TIME = 0.08f;
//static const char CURRENT_IMAGE_NAME[] = "Current Landmark";
//static const char WHITE_IMAGE_NAME[] = "Blank Landmark";
//static const char NO_IMAGE_NAME[] = "None";
LLFloaterLandmark::LLFloaterLandmark(const LLSD& data)
:
mTentativeLabel(NULL),
mResolutionLabel(NULL),
mIsDirty( FALSE ),
mActive( TRUE ),
mSearchEdit(NULL),
mContextConeOpacity(0.f)
{
LLUICtrlFactory::getInstance()->buildFloater(this,"floater_landmark_ctrl.xml");
mTentativeLabel = getChild<LLTextBox>("Multiple");
mResolutionLabel = getChild<LLTextBox>("unknown");
childSetCommitCallback("show_folders_check", onShowFolders, this);
childSetVisible("show_folders_check", FALSE);
mSearchEdit = getChild<LLSearchEditor>("inventory search editor");
mSearchEdit->setSearchCallback(onSearchEdit, this);
mInventoryPanel = getChild<LLInventoryPanel>("inventory panel");
if(mInventoryPanel)
{
U32 filter_types = 0x0;
filter_types |= 0x1 << LLInventoryType::IT_LANDMARK;
// filter_types |= 0x1 << LLInventoryType::IT_SNAPSHOT;
mInventoryPanel->setFilterTypes(filter_types);
//mInventoryPanel->setFilterPermMask(getFilterPermMask()); //Commented out due to no-copy texture loss.
mInventoryPanel->setSelectCallback(onSelectionChange, this);
mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
mInventoryPanel->setAllowMultiSelect(FALSE);
// store this filter as the default one
mInventoryPanel->getRootFolder()->getFilter()->markDefault();
// Commented out to stop opening all folders with textures
mInventoryPanel->openDefaultFolderForType(LLAssetType::AT_LANDMARK);
// don't put keyboard focus on selected item, because the selection callback
// will assume that this was user input
mInventoryPanel->setSelection(findItemID(mImageAssetID, FALSE), TAKE_FOCUS_NO);
}
mSavedFolderState = new LLSaveFolderState();
mNoCopyLandmarkSelected = FALSE;
childSetAction("Close", LLFloaterLandmark::onBtnClose,this);
childSetAction("New", LLFloaterLandmark::onBtnNew,this);
childSetAction("NewFolder", LLFloaterLandmark::onBtnNewFolder,this);
childSetAction("Edit", LLFloaterLandmark::onBtnEdit,this);
childSetAction("Rename", LLFloaterLandmark::onBtnRename,this);
childSetAction("Delete", LLFloaterLandmark::onBtnDelete,this);
setCanMinimize(FALSE);
mSavedFolderState->setApply(FALSE);
}
LLFloaterLandmark::~LLFloaterLandmark()
{
delete mSavedFolderState;
}
void LLFloaterLandmark::setActive( BOOL active )
{
mActive = active;
}
// virtual
BOOL LLFloaterLandmark::handleDragAndDrop(
S32 x, S32 y, MASK mask,
BOOL drop,
EDragAndDropType cargo_type, void *cargo_data,
EAcceptance *accept,
std::string& tooltip_msg)
{
BOOL handled = FALSE;
if (cargo_type == DAD_LANDMARK)
{
LLInventoryItem *item = (LLInventoryItem *)cargo_data;
BOOL copy = item->getPermissions().allowCopyBy(gAgent.getID());
BOOL mod = item->getPermissions().allowModifyBy(gAgent.getID());
BOOL xfer = item->getPermissions().allowOperationBy(PERM_TRANSFER,
gAgent.getID());
PermissionMask item_perm_mask = 0;
if (copy) item_perm_mask |= PERM_COPY;
if (mod) item_perm_mask |= PERM_MODIFY;
if (xfer) item_perm_mask |= PERM_TRANSFER;
//PermissionMask filter_perm_mask = getFilterPermMask(); Commented out due to no-copy texture loss.
PermissionMask filter_perm_mask = mImmediateFilterPermMask;
if ( (item_perm_mask & filter_perm_mask) == filter_perm_mask )
{
*accept = ACCEPT_YES_SINGLE;
}
else
{
*accept = ACCEPT_NO;
}
}
else
{
*accept = ACCEPT_NO;
}
handled = TRUE;
lldebugst(LLERR_USER_INPUT) << "dragAndDrop handled by LLFloaterLandmark " << getName() << llendl;
return handled;
}
BOOL LLFloaterLandmark::handleKeyHere(KEY key, MASK mask)
{
LLFolderView* root_folder = mInventoryPanel->getRootFolder();
if (root_folder && mSearchEdit)
{
if (mSearchEdit->hasFocus() &&
(key == KEY_RETURN || key == KEY_DOWN) &&
mask == MASK_NONE)
{
if (!root_folder->getCurSelectedItem())
{
LLFolderViewItem* itemp = root_folder->getItemByID(gAgent.getInventoryRootID());
if (itemp)
{
root_folder->setSelection(itemp, FALSE, FALSE);
}
}
root_folder->scrollToShowSelection();
// move focus to inventory proper
root_folder->setFocus(TRUE);
return TRUE;
}
if (root_folder->hasFocus() && key == KEY_UP)
{
mSearchEdit->focusFirstItem(TRUE);
}
}
return LLFloater::handleKeyHere(key, mask);
}
// virtual
void LLFloaterLandmark::onClose(bool app_quitting)
{
destroy();
}
const LLUUID& LLFloaterLandmark::findItemID(const LLUUID& asset_id, BOOL copyable_only)
{
LLViewerInventoryCategory::cat_array_t cats;
LLViewerInventoryItem::item_array_t items;
LLAssetIDMatches asset_id_matches(asset_id);
gInventory.collectDescendentsIf(LLUUID::null,
cats,
items,
LLInventoryModel::INCLUDE_TRASH,
asset_id_matches);
if (items.count())
{
// search for copyable version first
for (S32 i = 0; i < items.count(); i++)
{
LLInventoryItem* itemp = items[i];
LLPermissions item_permissions = itemp->getPermissions();
if (item_permissions.allowCopyBy(gAgent.getID(), gAgent.getGroupID()))
{
return itemp->getUUID();
}
}
// otherwise just return first instance, unless copyable requested
if (copyable_only)
{
return LLUUID::null;
}
else
{
return items[0]->getUUID();
}
}
return LLUUID::null;
}
// static
void LLFloaterLandmark::onBtnClose(void* userdata)
{
LLFloaterLandmark* self = (LLFloaterLandmark*) userdata;
self->mIsDirty = FALSE;
self->close();
}
// static
void LLFloaterLandmark::onBtnEdit(void* userdata)
{
LLFloaterLandmark* self = (LLFloaterLandmark*) userdata;
// There isn't one, so make a new preview
LLViewerInventoryItem* itemp = gInventory.getItem(self->mImageAssetID);
if(itemp)
{
open_landmark(itemp, itemp->getName(), TRUE);
}
}
// static
void LLFloaterLandmark::onBtnNew(void* userdata)
{
LLViewerRegion* agent_region = gAgent.getRegion();
if(!agent_region)
{
llwarns << "No agent region" << llendl;
return;
}
LLParcel* agent_parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
if (!agent_parcel)
{
llwarns << "No agent parcel" << llendl;
return;
}
if (!agent_parcel->getAllowLandmark()
&& !LLViewerParcelMgr::isParcelOwnedByAgent(agent_parcel, GP_LAND_ALLOW_LANDMARK))
{
gViewerWindow->alertXml("CannotCreateLandmarkNotOwner");
return;
}
LLUUID folder_id;
folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
std::string pos_string;
gAgent.buildLocationString(pos_string);
create_inventory_item(gAgent.getID(), gAgent.getSessionID(),
folder_id, LLTransactionID::tnull,
pos_string, pos_string, // name, desc
LLAssetType::AT_LANDMARK,
LLInventoryType::IT_LANDMARK,
NOT_WEARABLE, PERM_ALL,
NULL);
}
// static
void LLFloaterLandmark::onBtnNewFolder(void* userdata)
{
}
// static
void LLFloaterLandmark::onBtnDelete(void* userdata)
{
LLFloaterLandmark* self = (LLFloaterLandmark*)userdata;
LLViewerInventoryItem* item = gInventory.getItem(self->mImageAssetID);
if(item)
{
// Move the item to the trash
LLUUID trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH);
if (item->getParentUUID() != trash_id)
{
LLInventoryModel::update_list_t update;
LLInventoryModel::LLCategoryUpdate old_folder(item->getParentUUID(),-1);
update.push_back(old_folder);
LLInventoryModel::LLCategoryUpdate new_folder(trash_id, 1);
update.push_back(new_folder);
gInventory.accountForUpdate(update);
LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item);
new_item->setParent(trash_id);
// no need to restamp it though it's a move into trash because
// it's a brand new item already.
new_item->updateParentOnServer(FALSE);
gInventory.updateItem(new_item);
gInventory.notifyObservers();
}
}
// Delete the item entirely
/*
item->removeFromServer();
gInventory.deleteObject(item->getUUID());
gInventory.notifyObservers();
*/
}
// static
void LLFloaterLandmark::onBtnRename(void* userdata)
{
}
// static
void LLFloaterLandmark::onSelectionChange(const std::deque<LLFolderViewItem*> &items, BOOL user_action, void* data)
{
LLFloaterLandmark* self = (LLFloaterLandmark*)data;
if (items.size())
{
LLFolderViewItem* first_item = items.front();
LLInventoryItem* itemp = gInventory.getItem(first_item->getListener()->getUUID());
self->mNoCopyLandmarkSelected = FALSE;
if (itemp)
{
if (!itemp->getPermissions().allowCopyBy(gAgent.getID()))
{
self->mNoCopyLandmarkSelected = TRUE;
}
self->mImageAssetID = itemp->getUUID();
self->mIsDirty = TRUE;
}
}
}
// static
void LLFloaterLandmark::onShowFolders(LLUICtrl* ctrl, void *user_data)
{
LLCheckBoxCtrl* check_box = (LLCheckBoxCtrl*)ctrl;
LLFloaterLandmark* picker = (LLFloaterLandmark*)user_data;
if (check_box->get())
{
picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS);
}
else
{
picker->mInventoryPanel->setShowFolderState(LLInventoryFilter::SHOW_NO_FOLDERS);
}
}
void LLFloaterLandmark::onSearchEdit(const std::string& search_string, void* user_data )
{
LLFloaterLandmark* picker = (LLFloaterLandmark*)user_data;
std::string upper_case_search_string = search_string;
LLStringUtil::toUpper(upper_case_search_string);
if (upper_case_search_string.empty())
{
if (picker->mInventoryPanel->getFilterSubString().empty())
{
// current filter and new filter empty, do nothing
return;
}
picker->mSavedFolderState->setApply(TRUE);
picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(*picker->mSavedFolderState);
// add folder with current item to list of previously opened folders
LLOpenFoldersWithSelection opener;
picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(opener);
picker->mInventoryPanel->getRootFolder()->scrollToShowSelection();
}
else if (picker->mInventoryPanel->getFilterSubString().empty())
{
// first letter in search term, save existing folder open state
if (!picker->mInventoryPanel->getRootFolder()->isFilterModified())
{
picker->mSavedFolderState->setApply(FALSE);
picker->mInventoryPanel->getRootFolder()->applyFunctorRecursively(*picker->mSavedFolderState);
}
}
picker->mInventoryPanel->setFilterSubString(upper_case_search_string);
}
|