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
481
482
483
484
485
486
487
488
489
|
/**
* @file llfloatertopobjects.cpp
* @brief Shows top colliders, top scripts, etc.
*
* $LicenseInfo:firstyear=2005&license=viewergpl$
*
* Copyright (c) 2005-2009, 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 "llfloatertopobjects.h"
#include "message.h"
#include "llfontgl.h"
#include "llagent.h"
#include "llbutton.h"
#include "llfloatergodtools.h"
#include "llfloaterreg.h"
#include "llnotificationsutil.h"
#include "llparcel.h"
#include "llscrolllistctrl.h"
#include "llscrolllistitem.h"
#include "llscrolllistcell.h"
#include "lllineeditor.h"
#include "lltextbox.h"
#include "lltracker.h"
#include "llviewermessage.h"
#include "llviewerparcelmgr.h"
#include "llviewerregion.h"
#include "lluictrlfactory.h"
#include "llviewerwindow.h"
//LLFloaterTopObjects* LLFloaterTopObjects::sInstance = NULL;
// Globals
// const U32 TIME_STR_LENGTH = 30;
/*
// static
void LLFloaterTopObjects::show()
{
if (sInstance)
{
sInstance->setVisibleAndFrontmost();
return;
}
sInstance = new LLFloaterTopObjects();
sInstance->center();
}
*/
LLFloaterTopObjects::LLFloaterTopObjects(const LLSD& key)
: LLFloater(key),
mInitialized(FALSE),
mtotalScore(0.f)
{
mCommitCallbackRegistrar.add("TopObjects.ShowBeacon", boost::bind(&LLFloaterTopObjects::onClickShowBeacon, this));
mCommitCallbackRegistrar.add("TopObjects.ReturnSelected", boost::bind(&LLFloaterTopObjects::onReturnSelected, this));
mCommitCallbackRegistrar.add("TopObjects.ReturnAll", boost::bind(&LLFloaterTopObjects::onReturnAll, this));
mCommitCallbackRegistrar.add("TopObjects.DisableSelected", boost::bind(&LLFloaterTopObjects::onDisableSelected, this));
mCommitCallbackRegistrar.add("TopObjects.DisableAll", boost::bind(&LLFloaterTopObjects::onDisableAll, this));
mCommitCallbackRegistrar.add("TopObjects.Refresh", boost::bind(&LLFloaterTopObjects::onRefresh, this));
mCommitCallbackRegistrar.add("TopObjects.GetByObjectName", boost::bind(&LLFloaterTopObjects::onGetByObjectName, this));
mCommitCallbackRegistrar.add("TopObjects.GetByOwnerName", boost::bind(&LLFloaterTopObjects::onGetByOwnerName, this));
mCommitCallbackRegistrar.add("TopObjects.CommitObjectsList",boost::bind(&LLFloaterTopObjects::onCommitObjectsList, this));
}
LLFloaterTopObjects::~LLFloaterTopObjects()
{
}
// virtual
BOOL LLFloaterTopObjects::postBuild()
{
LLScrollListCtrl *objects_list = getChild<LLScrollListCtrl>("objects_list");
getChild<LLUICtrl>("objects_list")->setFocus(TRUE);
objects_list->setDoubleClickCallback(onDoubleClickObjectsList, this);
objects_list->setCommitOnSelectionChange(TRUE);
setDefaultBtn("show_beacon_btn");
/*
LLLineEditor* line_editor = getChild<LLLineEditor>("owner_name_editor");
if (line_editor)
{
line_editor->setCommitOnFocusLost(FALSE);
line_editor->setCommitCallback(onGetByOwnerName, this);
}
line_editor = getChild<LLLineEditor>("object_name_editor");
if (line_editor)
{
line_editor->setCommitOnFocusLost(FALSE);
line_editor->setCommitCallback(onGetByObjectName, this);
}*/
mCurrentMode = STAT_REPORT_TOP_SCRIPTS;
mFlags = 0;
mFilter.clear();
return TRUE;
}
// static
void LLFloaterTopObjects::setMode(U32 mode)
{
LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
if(!instance) return;
instance->mCurrentMode = mode;
}
// static
void LLFloaterTopObjects::handle_land_reply(LLMessageSystem* msg, void** data)
{
LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
if(!instance) return;
// Make sure dialog is on screen
LLFloaterReg::showInstance("top_objects");
instance->handleReply(msg, data);
//HACK: for some reason sometimes top scripts originally comes back
//with no results even though they're there
if (!instance->mObjectListIDs.size() && !instance->mInitialized)
{
instance->onRefresh();
instance->mInitialized = TRUE;
}
}
void LLFloaterTopObjects::handleReply(LLMessageSystem *msg, void** data)
{
U32 request_flags;
U32 total_count;
msg->getU32Fast(_PREHASH_RequestData, _PREHASH_RequestFlags, request_flags);
msg->getU32Fast(_PREHASH_RequestData, _PREHASH_TotalObjectCount, total_count);
msg->getU32Fast(_PREHASH_RequestData, _PREHASH_ReportType, mCurrentMode);
LLScrollListCtrl *list = getChild<LLScrollListCtrl>("objects_list");
S32 block_count = msg->getNumberOfBlocks("ReportData");
for (S32 block = 0; block < block_count; ++block)
{
U32 task_local_id;
U32 time_stamp = 0;
LLUUID task_id;
F32 location_x, location_y, location_z;
F32 score;
std::string name_buf;
std::string owner_buf;
F32 mono_score = 0.f;
bool have_extended_data = false;
S32 public_urls = 0;
msg->getU32Fast(_PREHASH_ReportData, _PREHASH_TaskLocalID, task_local_id, block);
msg->getUUIDFast(_PREHASH_ReportData, _PREHASH_TaskID, task_id, block);
msg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationX, location_x, block);
msg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationY, location_y, block);
msg->getF32Fast(_PREHASH_ReportData, _PREHASH_LocationZ, location_z, block);
msg->getF32Fast(_PREHASH_ReportData, _PREHASH_Score, score, block);
msg->getStringFast(_PREHASH_ReportData, _PREHASH_TaskName, name_buf, block);
msg->getStringFast(_PREHASH_ReportData, _PREHASH_OwnerName, owner_buf, block);
if(msg->has("DataExtended"))
{
have_extended_data = true;
msg->getU32("DataExtended", "TimeStamp", time_stamp, block);
msg->getF32("DataExtended", "MonoScore", mono_score, block);
msg->getS32(_PREHASH_ReportData,"PublicURLs",public_urls,block);
}
LLSD element;
element["id"] = task_id;
element["object_name"] = name_buf;
element["owner_name"] = owner_buf;
element["columns"][0]["column"] = "score";
element["columns"][0]["value"] = llformat("%0.3f", score);
element["columns"][0]["font"] = "SANSSERIF";
element["columns"][1]["column"] = "name";
element["columns"][1]["value"] = name_buf;
element["columns"][1]["font"] = "SANSSERIF";
element["columns"][2]["column"] = "owner";
element["columns"][2]["value"] = owner_buf;
element["columns"][2]["font"] = "SANSSERIF";
element["columns"][3]["column"] = "location";
element["columns"][3]["value"] = llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z);
element["columns"][3]["font"] = "SANSSERIF";
element["columns"][4]["column"] = "time";
element["columns"][4]["value"] = formatted_time((time_t)time_stamp);
element["columns"][4]["font"] = "SANSSERIF";
if (mCurrentMode == STAT_REPORT_TOP_SCRIPTS
&& have_extended_data)
{
element["columns"][5]["column"] = "mono_time";
element["columns"][5]["value"] = llformat("%0.3f", mono_score);
element["columns"][5]["font"] = "SANSSERIF";
element["columns"][6]["column"] = "URLs";
element["columns"][6]["value"] = llformat("%d", public_urls);
element["columns"][6]["font"] = "SANSSERIF";
}
list->addElement(element);
mObjectListData.append(element);
mObjectListIDs.push_back(task_id);
mtotalScore += score;
}
if (total_count == 0 && list->getItemCount() == 0)
{
list->setCommentText(getString("none_descriptor"));
}
else
{
list->selectFirstItem();
}
if (mCurrentMode == STAT_REPORT_TOP_SCRIPTS)
{
setTitle(getString("top_scripts_title"));
list->setColumnLabel("score", getString("scripts_score_label"));
list->setColumnLabel("mono_time", getString("scripts_mono_time_label"));
LLUIString format = getString("top_scripts_text");
format.setArg("[COUNT]", llformat("%d", total_count));
format.setArg("[TIME]", llformat("%0.1f", mtotalScore));
getChild<LLUICtrl>("title_text")->setValue(LLSD(format));
}
else
{
setTitle(getString("top_colliders_title"));
list->setColumnLabel("score", getString("colliders_score_label"));
list->setColumnLabel("mono_time", "");
LLUIString format = getString("top_colliders_text");
format.setArg("[COUNT]", llformat("%d", total_count));
getChild<LLUICtrl>("title_text")->setValue(LLSD(format));
}
}
void LLFloaterTopObjects::onCommitObjectsList()
{
updateSelectionInfo();
}
void LLFloaterTopObjects::updateSelectionInfo()
{
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("objects_list");
if (!list) return;
LLUUID object_id = list->getCurrentID();
if (object_id.isNull()) return;
std::string object_id_string = object_id.asString();
getChild<LLUICtrl>("id_editor")->setValue(LLSD(object_id_string));
LLScrollListItem* sli = list->getFirstSelected();
llassert(sli);
if (sli)
{
getChild<LLUICtrl>("object_name_editor")->setValue(sli->getColumn(1)->getValue().asString());
getChild<LLUICtrl>("owner_name_editor")->setValue(sli->getColumn(2)->getValue().asString());
}
}
// static
void LLFloaterTopObjects::onDoubleClickObjectsList(void* data)
{
LLFloaterTopObjects* self = (LLFloaterTopObjects*)data;
self->showBeacon();
}
// static
void LLFloaterTopObjects::onClickShowBeacon()
{
showBeacon();
}
void LLFloaterTopObjects::doToObjects(int action, bool all)
{
LLMessageSystem *msg = gMessageSystem;
LLViewerRegion* region = gAgent.getRegion();
if (!region) return;
LLCtrlListInterface *list = getChild<LLUICtrl>("objects_list")->getListInterface();
if (!list || list->getItemCount() == 0) return;
uuid_vec_t::iterator id_itor;
bool start_message = true;
for (id_itor = mObjectListIDs.begin(); id_itor != mObjectListIDs.end(); ++id_itor)
{
LLUUID task_id = *id_itor;
if (!all && !list->isSelected(task_id))
{
// Selected only
continue;
}
if (start_message)
{
if (action == ACTION_RETURN)
{
msg->newMessageFast(_PREHASH_ParcelReturnObjects);
}
else
{
msg->newMessageFast(_PREHASH_ParcelDisableObjects);
}
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
msg->addUUIDFast(_PREHASH_SessionID,gAgent.getSessionID());
msg->nextBlockFast(_PREHASH_ParcelData);
msg->addS32Fast(_PREHASH_LocalID, -1); // Whole region
msg->addS32Fast(_PREHASH_ReturnType, RT_NONE);
start_message = false;
}
msg->nextBlockFast(_PREHASH_TaskIDs);
msg->addUUIDFast(_PREHASH_TaskID, task_id);
if (msg->isSendFullFast(_PREHASH_TaskIDs))
{
msg->sendReliable(region->getHost());
start_message = true;
}
}
if (!start_message)
{
msg->sendReliable(region->getHost());
}
}
//static
bool LLFloaterTopObjects::callbackReturnAll(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
if(!instance) return false;
if (option == 0)
{
instance->doToObjects(ACTION_RETURN, true);
}
return false;
}
void LLFloaterTopObjects::onReturnAll()
{
LLNotificationsUtil::add("ReturnAllTopObjects", LLSD(), LLSD(), &callbackReturnAll);
}
void LLFloaterTopObjects::onReturnSelected()
{
doToObjects(ACTION_RETURN, false);
}
//static
bool LLFloaterTopObjects::callbackDisableAll(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLFloaterTopObjects* instance = LLFloaterReg::getTypedInstance<LLFloaterTopObjects>("top_objects");
if(!instance) return false;
if (option == 0)
{
instance->doToObjects(ACTION_DISABLE, true);
}
return false;
}
void LLFloaterTopObjects::onDisableAll()
{
LLNotificationsUtil::add("DisableAllTopObjects", LLSD(), LLSD(), callbackDisableAll);
}
void LLFloaterTopObjects::onDisableSelected()
{
doToObjects(ACTION_DISABLE, false);
}
void LLFloaterTopObjects::clearList()
{
LLCtrlListInterface *list = childGetListInterface("objects_list");
if (list)
{
list->operateOnAll(LLCtrlListInterface::OP_DELETE);
}
mObjectListData.clear();
mObjectListIDs.clear();
mtotalScore = 0.f;
}
void LLFloaterTopObjects::onRefresh()
{
U32 mode = STAT_REPORT_TOP_SCRIPTS;
U32 flags = 0;
std::string filter = "";
mode = mCurrentMode;
flags = mFlags;
filter = mFilter;
clearList();
LLMessageSystem *msg = gMessageSystem;
msg->newMessageFast(_PREHASH_LandStatRequest);
msg->nextBlockFast(_PREHASH_AgentData);
msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() );
msg->nextBlockFast(_PREHASH_RequestData);
msg->addU32Fast(_PREHASH_ReportType, mode);
msg->addU32Fast(_PREHASH_RequestFlags, flags);
msg->addStringFast(_PREHASH_Filter, filter);
msg->addS32Fast(_PREHASH_ParcelLocalID, 0);
msg->sendReliable(gAgent.getRegionHost());
mFilter.clear();
mFlags = 0;
}
void LLFloaterTopObjects::onGetByObjectName()
{
mFlags = STAT_FILTER_BY_OBJECT;
mFilter = getChild<LLUICtrl>("object_name_editor")->getValue().asString();
onRefresh();
}
void LLFloaterTopObjects::onGetByOwnerName()
{
mFlags = STAT_FILTER_BY_OWNER;
mFilter = getChild<LLUICtrl>("owner_name_editor")->getValue().asString();
onRefresh();
}
void LLFloaterTopObjects::showBeacon()
{
LLScrollListCtrl* list = getChild<LLScrollListCtrl>("objects_list");
if (!list) return;
LLScrollListItem* first_selected = list->getFirstSelected();
if (!first_selected) return;
std::string name = first_selected->getColumn(1)->getValue().asString();
std::string pos_string = first_selected->getColumn(3)->getValue().asString();
F32 x, y, z;
S32 matched = sscanf(pos_string.c_str(), "<%g,%g,%g>", &x, &y, &z);
if (matched != 3) return;
LLVector3 pos_agent(x, y, z);
LLVector3d pos_global = gAgent.getPosGlobalFromAgent(pos_agent);
std::string tooltip("");
LLTracker::trackLocation(pos_global, name, tooltip, LLTracker::LOCATION_ITEM);
}
|