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/llfloatergodtools.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/llfloatergodtools.cpp')
-rw-r--r-- | linden/indra/newview/llfloatergodtools.cpp | 1467 |
1 files changed, 1467 insertions, 0 deletions
diff --git a/linden/indra/newview/llfloatergodtools.cpp b/linden/indra/newview/llfloatergodtools.cpp new file mode 100644 index 0000000..d2ce3fd --- /dev/null +++ b/linden/indra/newview/llfloatergodtools.cpp | |||
@@ -0,0 +1,1467 @@ | |||
1 | /** | ||
2 | * @file llfloatergodtools.cpp | ||
3 | * @brief The on-screen rectangle with tool options. | ||
4 | * | ||
5 | * Copyright (c) 2002-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 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llfloatergodtools.h" | ||
31 | |||
32 | #include "llcoord.h" | ||
33 | #include "llfontgl.h" | ||
34 | #include "llframetimer.h" | ||
35 | #include "llgl.h" | ||
36 | #include "llhost.h" | ||
37 | #include "llregionflags.h" | ||
38 | #include "llstring.h" | ||
39 | #include "message.h" | ||
40 | |||
41 | #include "llagent.h" | ||
42 | #include "llalertdialog.h" | ||
43 | #include "llbutton.h" | ||
44 | #include "llcheckboxctrl.h" | ||
45 | #include "llcombobox.h" | ||
46 | #include "lldraghandle.h" | ||
47 | #include "llfloater.h" | ||
48 | #include "llfocusmgr.h" | ||
49 | #include "llfloatertopobjects.h" | ||
50 | #include "lllineeditor.h" | ||
51 | #include "llmenugl.h" | ||
52 | #include "llresmgr.h" | ||
53 | #include "llselectmgr.h" | ||
54 | #include "llsky.h" | ||
55 | #include "llspinctrl.h" | ||
56 | #include "llstatusbar.h" | ||
57 | #include "lltabcontainer.h" | ||
58 | #include "lltextbox.h" | ||
59 | #include "lluictrl.h" | ||
60 | #include "llviewerparcelmgr.h" | ||
61 | #include "llviewerregion.h" | ||
62 | #include "llviewerwindow.h" | ||
63 | #include "llworld.h" | ||
64 | #include "llfloateravatarpicker.h" | ||
65 | #include "llnotify.h" | ||
66 | #include "llxfermanager.h" | ||
67 | #include "llvlcomposition.h" | ||
68 | #include "llsurface.h" | ||
69 | #include "llviewercontrol.h" | ||
70 | #include "llvieweruictrlfactory.h" | ||
71 | |||
72 | #include "lltransfertargetfile.h" | ||
73 | #include "lltransfersourcefile.h" | ||
74 | |||
75 | const F32 SECONDS_BETWEEN_UPDATE_REQUESTS = 5.0f; | ||
76 | |||
77 | static LLFloaterGodTools* sGodTools = NULL; | ||
78 | |||
79 | //***************************************************************************** | ||
80 | // LLFloaterGodTools | ||
81 | //***************************************************************************** | ||
82 | |||
83 | // static | ||
84 | LLFloaterGodTools* LLFloaterGodTools::instance() | ||
85 | { | ||
86 | if (!sGodTools) | ||
87 | { | ||
88 | sGodTools = new LLFloaterGodTools(); | ||
89 | sGodTools->open(); | ||
90 | sGodTools->center(); | ||
91 | sGodTools->setFocus(TRUE); | ||
92 | } | ||
93 | return sGodTools; | ||
94 | } | ||
95 | |||
96 | |||
97 | // static | ||
98 | void LLFloaterGodTools::refreshAll() | ||
99 | { | ||
100 | LLFloaterGodTools* god_tools = instance(); | ||
101 | if (god_tools) | ||
102 | { | ||
103 | if (gAgent.getRegionHost() != god_tools->mCurrentHost) | ||
104 | { | ||
105 | // we're in a new region | ||
106 | god_tools->sendRegionInfoRequest(); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | |||
111 | |||
112 | |||
113 | LLFloaterGodTools::LLFloaterGodTools() | ||
114 | : LLFloater("godtools floater"), | ||
115 | mCurrentHost(LLHost::invalid), | ||
116 | mUpdateTimer() | ||
117 | { | ||
118 | LLCallbackMap::map_t factory_map; | ||
119 | factory_map["grid"] = LLCallbackMap(createPanelGrid, this); | ||
120 | factory_map["region"] = LLCallbackMap(createPanelRegion, this); | ||
121 | factory_map["objects"] = LLCallbackMap(createPanelObjects, this); | ||
122 | factory_map["request"] = LLCallbackMap(createPanelRequest, this); | ||
123 | gUICtrlFactory->buildFloater(this, "floater_god_tools.xml", &factory_map); | ||
124 | |||
125 | childSetTabChangeCallback("GodTools Tabs", "grid", onTabChanged, this); | ||
126 | childSetTabChangeCallback("GodTools Tabs", "region", onTabChanged, this); | ||
127 | childSetTabChangeCallback("GodTools Tabs", "objects", onTabChanged, this); | ||
128 | childSetTabChangeCallback("GodTools Tabs", "request", onTabChanged, this); | ||
129 | |||
130 | sendRegionInfoRequest(); | ||
131 | |||
132 | childShowTab("GodTools Tabs", "region"); | ||
133 | } | ||
134 | |||
135 | // static | ||
136 | void* LLFloaterGodTools::createPanelGrid(void *userdata) | ||
137 | { | ||
138 | return new LLPanelGridTools("grid"); | ||
139 | } | ||
140 | |||
141 | // static | ||
142 | void* LLFloaterGodTools::createPanelRegion(void *userdata) | ||
143 | { | ||
144 | LLFloaterGodTools* self = (LLFloaterGodTools*)userdata; | ||
145 | self->mPanelRegionTools = new LLPanelRegionTools("region"); | ||
146 | return self->mPanelRegionTools; | ||
147 | } | ||
148 | |||
149 | // static | ||
150 | void* LLFloaterGodTools::createPanelObjects(void *userdata) | ||
151 | { | ||
152 | LLFloaterGodTools* self = (LLFloaterGodTools*)userdata; | ||
153 | self->mPanelObjectTools = new LLPanelObjectTools("objects"); | ||
154 | return self->mPanelObjectTools; | ||
155 | } | ||
156 | |||
157 | // static | ||
158 | void* LLFloaterGodTools::createPanelRequest(void *userdata) | ||
159 | { | ||
160 | return new LLPanelRequestTools("region"); | ||
161 | } | ||
162 | |||
163 | LLFloaterGodTools::~LLFloaterGodTools() | ||
164 | { | ||
165 | // children automatically deleted | ||
166 | } | ||
167 | |||
168 | U32 LLFloaterGodTools::computeRegionFlags() const | ||
169 | { | ||
170 | U32 flags = gAgent.getRegion()->getRegionFlags(); | ||
171 | if (mPanelRegionTools) flags = mPanelRegionTools->computeRegionFlags(flags); | ||
172 | if (mPanelObjectTools) flags = mPanelObjectTools->computeRegionFlags(flags); | ||
173 | return flags; | ||
174 | } | ||
175 | |||
176 | |||
177 | void LLFloaterGodTools::updatePopup(LLCoordGL center, MASK mask) | ||
178 | { | ||
179 | } | ||
180 | |||
181 | // virtual | ||
182 | void LLFloaterGodTools::onClose(bool app_quitting) | ||
183 | { | ||
184 | if (sGodTools) | ||
185 | { | ||
186 | sGodTools->setVisible(FALSE); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | // virtual | ||
191 | void LLFloaterGodTools::draw() | ||
192 | { | ||
193 | if (mCurrentHost == LLHost::invalid) | ||
194 | { | ||
195 | if (mUpdateTimer.getElapsedTimeF32() > SECONDS_BETWEEN_UPDATE_REQUESTS) | ||
196 | { | ||
197 | sendRegionInfoRequest(); | ||
198 | } | ||
199 | } | ||
200 | else if (gAgent.getRegionHost() != mCurrentHost) | ||
201 | { | ||
202 | sendRegionInfoRequest(); | ||
203 | } | ||
204 | LLFloater::draw(); | ||
205 | } | ||
206 | |||
207 | // static | ||
208 | void LLFloaterGodTools::show(void *) | ||
209 | { | ||
210 | LLFloaterGodTools* god_tools = instance(); | ||
211 | god_tools->open(); | ||
212 | LLPanel *panel = god_tools->childGetVisibleTab("GodTools Tabs"); | ||
213 | if (panel) panel->setFocus(TRUE); | ||
214 | if (god_tools->mPanelObjectTools) god_tools->mPanelObjectTools->setTargetAvatar(LLUUID::null); | ||
215 | |||
216 | if (gAgent.getRegionHost() != god_tools->mCurrentHost) | ||
217 | { | ||
218 | // we're in a new region | ||
219 | god_tools->sendRegionInfoRequest(); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | void LLFloaterGodTools::showPanel(const LLString& panel_name) | ||
224 | { | ||
225 | childShowTab("GodTools Tabs", panel_name); | ||
226 | open(); | ||
227 | LLPanel *panel = childGetVisibleTab("GodTools Tabs"); | ||
228 | if (panel) panel->setFocus(TRUE); | ||
229 | } | ||
230 | |||
231 | |||
232 | // static | ||
233 | void LLFloaterGodTools::onTabChanged(void* data, bool from_click) | ||
234 | { | ||
235 | LLPanel* panel = (LLPanel*)data; | ||
236 | if (panel) | ||
237 | { | ||
238 | panel->setFocus(TRUE); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | |||
243 | // static | ||
244 | void LLFloaterGodTools::processRegionInfo(LLMessageSystem* msg) | ||
245 | { | ||
246 | LLHost host = msg->getSender(); | ||
247 | if (host != gAgent.getRegionHost()) | ||
248 | { | ||
249 | // update is for a different region than the one we're in | ||
250 | return; | ||
251 | } | ||
252 | |||
253 | //const S32 SIM_NAME_BUF = 256; | ||
254 | U32 region_flags; | ||
255 | U8 sim_access; | ||
256 | U8 agent_limit; | ||
257 | char sim_name[MAX_STRING]; | ||
258 | U32 estate_id; | ||
259 | U32 parent_estate_id; | ||
260 | F32 water_height; | ||
261 | F32 billable_factor; | ||
262 | F32 object_bonus_factor; | ||
263 | F32 terrain_raise_limit; | ||
264 | F32 terrain_lower_limit; | ||
265 | S32 price_per_meter; | ||
266 | S32 redirect_grid_x; | ||
267 | S32 redirect_grid_y; | ||
268 | LLUUID cache_id; | ||
269 | |||
270 | msg->getStringFast(_PREHASH_RegionInfo, _PREHASH_SimName, MAX_STRING, sim_name); | ||
271 | msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_EstateID, estate_id); | ||
272 | msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_ParentEstateID, parent_estate_id); | ||
273 | msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_RegionFlags, region_flags); | ||
274 | msg->getU8Fast(_PREHASH_RegionInfo, _PREHASH_SimAccess, sim_access); | ||
275 | msg->getU8Fast(_PREHASH_RegionInfo, _PREHASH_MaxAgents, agent_limit); | ||
276 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_ObjectBonusFactor, object_bonus_factor); | ||
277 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_BillableFactor, billable_factor); | ||
278 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height); | ||
279 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit); | ||
280 | msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit); | ||
281 | msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_PricePerMeter, price_per_meter); | ||
282 | msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_RedirectGridX, redirect_grid_x); | ||
283 | msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_RedirectGridY, redirect_grid_y); | ||
284 | |||
285 | // push values to the current LLViewerRegion | ||
286 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
287 | if (regionp) | ||
288 | { | ||
289 | regionp->setRegionNameAndZone(sim_name); | ||
290 | regionp->setRegionFlags(region_flags); | ||
291 | regionp->setSimAccess(sim_access); | ||
292 | regionp->setWaterHeight(water_height); | ||
293 | regionp->setBillableFactor(billable_factor); | ||
294 | } | ||
295 | |||
296 | // push values to god tools, if available | ||
297 | if (sGodTools | ||
298 | && sGodTools->mPanelRegionTools | ||
299 | && sGodTools->mPanelObjectTools | ||
300 | && msg | ||
301 | && gAgent.isGodlike()) | ||
302 | { | ||
303 | LLPanelRegionTools* rtool = sGodTools->mPanelRegionTools; | ||
304 | sGodTools->mCurrentHost = host; | ||
305 | |||
306 | // store locally | ||
307 | rtool->setSimName(sim_name); | ||
308 | rtool->setEstateID(estate_id); | ||
309 | rtool->setParentEstateID(parent_estate_id); | ||
310 | rtool->setCheckFlags(region_flags); | ||
311 | rtool->setBillableFactor(billable_factor); | ||
312 | rtool->setPricePerMeter(price_per_meter); | ||
313 | rtool->setRedirectGridX(redirect_grid_x); | ||
314 | rtool->setRedirectGridY(redirect_grid_y); | ||
315 | rtool->enableAllWidgets(); | ||
316 | |||
317 | LLPanelObjectTools *otool = sGodTools->mPanelObjectTools; | ||
318 | otool->setCheckFlags(region_flags); | ||
319 | otool->enableAllWidgets(); | ||
320 | |||
321 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
322 | if ( !regionp ) | ||
323 | { | ||
324 | // -1 implies non-existent | ||
325 | rtool->setGridPosX(-1); | ||
326 | rtool->setGridPosY(-1); | ||
327 | } | ||
328 | else | ||
329 | { | ||
330 | //compute the grid position of the region | ||
331 | LLVector3d global_pos = regionp->getPosGlobalFromRegion(LLVector3::zero); | ||
332 | S32 grid_pos_x = (S32) (global_pos.mdV[VX] / 256.0f); | ||
333 | S32 grid_pos_y = (S32) (global_pos.mdV[VY] / 256.0f); | ||
334 | |||
335 | rtool->setGridPosX(grid_pos_x); | ||
336 | rtool->setGridPosY(grid_pos_y); | ||
337 | } | ||
338 | } | ||
339 | } | ||
340 | |||
341 | |||
342 | void LLFloaterGodTools::sendRegionInfoRequest() | ||
343 | { | ||
344 | if (mPanelRegionTools) mPanelRegionTools->clearAllWidgets(); | ||
345 | if (mPanelObjectTools) mPanelObjectTools->clearAllWidgets(); | ||
346 | mCurrentHost = LLHost::invalid; | ||
347 | mUpdateTimer.reset(); | ||
348 | |||
349 | LLMessageSystem* msg = gMessageSystem; | ||
350 | msg->newMessage("RequestRegionInfo"); | ||
351 | msg->nextBlock("AgentData"); | ||
352 | msg->addUUID("AgentID", gAgent.getID()); | ||
353 | msg->addUUID("SessionID", gAgent.getSessionID()); | ||
354 | gAgent.sendReliableMessage(); | ||
355 | } | ||
356 | |||
357 | |||
358 | void LLFloaterGodTools::sendGodUpdateRegionInfo() | ||
359 | { | ||
360 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
361 | if (gAgent.isGodlike() | ||
362 | && sGodTools->mPanelRegionTools | ||
363 | && regionp | ||
364 | && gAgent.getRegionHost() == mCurrentHost) | ||
365 | { | ||
366 | LLMessageSystem *msg = gMessageSystem; | ||
367 | LLPanelRegionTools *rtool = sGodTools->mPanelRegionTools; | ||
368 | |||
369 | msg->newMessage("GodUpdateRegionInfo"); | ||
370 | msg->nextBlockFast(_PREHASH_AgentData); | ||
371 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
372 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
373 | msg->nextBlockFast(_PREHASH_RegionInfo); | ||
374 | msg->addStringFast(_PREHASH_SimName, rtool->getSimName().c_str()); | ||
375 | msg->addU32Fast(_PREHASH_EstateID, rtool->getEstateID()); | ||
376 | msg->addU32Fast(_PREHASH_ParentEstateID, rtool->getParentEstateID()); | ||
377 | msg->addU32Fast(_PREHASH_RegionFlags, computeRegionFlags()); | ||
378 | msg->addF32Fast(_PREHASH_BillableFactor, rtool->getBillableFactor()); | ||
379 | msg->addS32Fast(_PREHASH_PricePerMeter, rtool->getPricePerMeter()); | ||
380 | msg->addS32Fast(_PREHASH_RedirectGridX, rtool->getRedirectGridX()); | ||
381 | msg->addS32Fast(_PREHASH_RedirectGridY, rtool->getRedirectGridY()); | ||
382 | |||
383 | gAgent.sendReliableMessage(); | ||
384 | } | ||
385 | } | ||
386 | |||
387 | //***************************************************************************** | ||
388 | // LLPanelRegionTools | ||
389 | //***************************************************************************** | ||
390 | |||
391 | |||
392 | // || Region |______________________________________ | ||
393 | // | | | ||
394 | // | Sim Name: [________________________________] | | ||
395 | // | ^ ^ | | ||
396 | // | LEFT R1 Estate id: [----] | | ||
397 | // | Parent id: [----] | | ||
398 | // | [X] Prelude Grid Pos: [--] [--] | | ||
399 | // | [X] Visible Redirect Pos: [--] [--] | | ||
400 | // | [X] Damage Bill Factor [8_______] | | ||
401 | // | [X] Block Terraform PricePerMeter[8_______] | | ||
402 | // | [Apply] | | ||
403 | // | | | ||
404 | // | [Bake Terrain] [Select Region] | | ||
405 | // | [Revert Terrain] [Autosave Now] | | ||
406 | // | [Swap Terrain] | | ||
407 | // | | | ||
408 | // |________________________________________________| | ||
409 | // ^ ^ ^ | ||
410 | // LEFT R2 RIGHT | ||
411 | |||
412 | |||
413 | // Floats because spinners only support floats. JC | ||
414 | const F32 BILLABLE_FACTOR_DEFAULT = 1; | ||
415 | const F32 BILLABLE_FACTOR_MIN = 0.0f; | ||
416 | const F32 BILLABLE_FACTOR_MAX = 4.f; | ||
417 | |||
418 | // floats because spinners only understand floats. JC | ||
419 | const F32 PRICE_PER_METER_DEFAULT = 1.f; | ||
420 | const F32 PRICE_PER_METER_MIN = 0.f; | ||
421 | const F32 PRICE_PER_METER_MAX = 100.f; | ||
422 | |||
423 | |||
424 | LLPanelRegionTools::LLPanelRegionTools(const std::string& title) | ||
425 | : LLPanel(title) | ||
426 | { | ||
427 | } | ||
428 | |||
429 | BOOL LLPanelRegionTools::postBuild() | ||
430 | { | ||
431 | childSetCommitCallback("region name", onChangeAnything, this); | ||
432 | childSetKeystrokeCallback("region name", onChangeSimName, this); | ||
433 | childSetPrevalidate("region name", &LLLineEditor::prevalidatePrintableNotPipe); | ||
434 | |||
435 | childSetCommitCallback("check prelude", onChangePrelude, this); | ||
436 | childSetCommitCallback("check fixed sun", onChangeAnything, this); | ||
437 | childSetCommitCallback("check reset home", onChangeAnything, this); | ||
438 | childSetCommitCallback("check visible", onChangeAnything, this); | ||
439 | childSetCommitCallback("check damage", onChangeAnything, this); | ||
440 | childSetCommitCallback("block dwell", onChangeAnything, this); | ||
441 | childSetCommitCallback("block terraform", onChangeAnything, this); | ||
442 | childSetCommitCallback("allow transfer", onChangeAnything, this); | ||
443 | childSetCommitCallback("is sandbox", onChangeAnything, this); | ||
444 | |||
445 | childSetAction("Bake Terrain", onBakeTerrain, this); | ||
446 | childSetAction("Revert Terrain", onRevertTerrain, this); | ||
447 | childSetAction("Swap Terrain", onSwapTerrain, this); | ||
448 | |||
449 | childSetCommitCallback("estate", onChangeAnything, this); | ||
450 | childSetPrevalidate("estate", &LLLineEditor::prevalidatePositiveS32); | ||
451 | |||
452 | childSetCommitCallback("parentestate", onChangeAnything, this); | ||
453 | childSetPrevalidate("parentestate", &LLLineEditor::prevalidatePositiveS32); | ||
454 | childDisable("parentestate"); | ||
455 | |||
456 | childSetCommitCallback("gridposx", onChangeAnything, this); | ||
457 | childSetPrevalidate("gridposx", &LLLineEditor::prevalidatePositiveS32); | ||
458 | childDisable("gridposx"); | ||
459 | |||
460 | childSetCommitCallback("gridposy", onChangeAnything, this); | ||
461 | childSetPrevalidate("gridposy", &LLLineEditor::prevalidatePositiveS32); | ||
462 | childDisable("gridposy"); | ||
463 | |||
464 | childSetCommitCallback("redirectx", onChangeAnything, this); | ||
465 | childSetPrevalidate("redirectx", &LLLineEditor::prevalidatePositiveS32); | ||
466 | |||
467 | childSetCommitCallback("redirecty", onChangeAnything, this); | ||
468 | childSetPrevalidate("redirecty", &LLLineEditor::prevalidatePositiveS32); | ||
469 | |||
470 | childSetCommitCallback("billable factor", onChangeAnything, this); | ||
471 | |||
472 | childSetCommitCallback("land cost", onChangeAnything, this); | ||
473 | |||
474 | childSetAction("Refresh", onRefresh, this); | ||
475 | childSetAction("Apply", onApplyChanges, this); | ||
476 | |||
477 | childSetAction("Select Region", onSelectRegion, this); | ||
478 | childSetAction("Autosave now", onSaveState, this); | ||
479 | |||
480 | return TRUE; | ||
481 | } | ||
482 | |||
483 | // Destroys the object | ||
484 | LLPanelRegionTools::~LLPanelRegionTools() | ||
485 | { | ||
486 | // base class will take care of everything | ||
487 | } | ||
488 | |||
489 | U32 LLPanelRegionTools::computeRegionFlags(U32 flags) const | ||
490 | { | ||
491 | flags &= getRegionFlagsMask(); | ||
492 | flags |= getRegionFlags(); | ||
493 | return flags; | ||
494 | } | ||
495 | |||
496 | |||
497 | void LLPanelRegionTools::refresh() | ||
498 | { | ||
499 | } | ||
500 | |||
501 | |||
502 | void LLPanelRegionTools::clearAllWidgets() | ||
503 | { | ||
504 | // clear all widgets | ||
505 | childSetValue("region name", "unknown"); | ||
506 | childSetFocus("region name", FALSE); | ||
507 | |||
508 | childSetValue("check prelude", FALSE); | ||
509 | childDisable("check prelude"); | ||
510 | |||
511 | childSetValue("check fixed sun", FALSE); | ||
512 | childDisable("check fixed sun"); | ||
513 | |||
514 | childSetValue("check reset home", FALSE); | ||
515 | childDisable("check reset home"); | ||
516 | |||
517 | childSetValue("check damage", FALSE); | ||
518 | childDisable("check damage"); | ||
519 | |||
520 | childSetValue("check visible", FALSE); | ||
521 | childDisable("check visible"); | ||
522 | |||
523 | childSetValue("block terraform", FALSE); | ||
524 | childDisable("block terraform"); | ||
525 | |||
526 | childSetValue("block dwell", FALSE); | ||
527 | childDisable("block dwell"); | ||
528 | |||
529 | childSetValue("is sandbox", FALSE); | ||
530 | childDisable("is sandbox"); | ||
531 | |||
532 | childSetValue("billable factor", BILLABLE_FACTOR_DEFAULT); | ||
533 | childDisable("billable factor"); | ||
534 | |||
535 | childSetValue("land cost", PRICE_PER_METER_DEFAULT); | ||
536 | childDisable("land cost"); | ||
537 | |||
538 | childDisable("Apply"); | ||
539 | childDisable("Bake Terrain"); | ||
540 | childDisable("Autosave now"); | ||
541 | } | ||
542 | |||
543 | |||
544 | void LLPanelRegionTools::enableAllWidgets() | ||
545 | { | ||
546 | // enable all of the widgets | ||
547 | |||
548 | childEnable("check prelude"); | ||
549 | childEnable("check fixed sun"); | ||
550 | childEnable("check reset home"); | ||
551 | childEnable("check damage"); | ||
552 | childDisable("check visible"); // use estates to update... | ||
553 | childEnable("block terraform"); | ||
554 | childEnable("block dwell"); | ||
555 | childEnable("is sandbox"); | ||
556 | |||
557 | childEnable("billable factor"); | ||
558 | childEnable("land cost"); | ||
559 | |||
560 | childDisable("Apply"); // don't enable this one | ||
561 | childEnable("Bake Terrain"); | ||
562 | childEnable("Autosave now"); | ||
563 | } | ||
564 | |||
565 | |||
566 | // static | ||
567 | void LLPanelRegionTools::onSaveState(void* userdata) | ||
568 | { | ||
569 | if (gAgent.isGodlike()) | ||
570 | { | ||
571 | // Send message to save world state | ||
572 | gMessageSystem->newMessageFast(_PREHASH_StateSave); | ||
573 | gMessageSystem->nextBlockFast(_PREHASH_AgentData); | ||
574 | gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
575 | gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
576 | gMessageSystem->nextBlockFast(_PREHASH_DataBlock); | ||
577 | gMessageSystem->addStringFast(_PREHASH_Filename, NULL); | ||
578 | gAgent.sendReliableMessage(); | ||
579 | } | ||
580 | } | ||
581 | |||
582 | const std::string LLPanelRegionTools::getSimName() const | ||
583 | { | ||
584 | return childGetValue("region name"); | ||
585 | } | ||
586 | |||
587 | U32 LLPanelRegionTools::getEstateID() const | ||
588 | { | ||
589 | U32 id = (U32)childGetValue("estate").asInteger(); | ||
590 | return id; | ||
591 | } | ||
592 | |||
593 | U32 LLPanelRegionTools::getParentEstateID() const | ||
594 | { | ||
595 | U32 id = (U32)childGetValue("parentestate").asInteger(); | ||
596 | return id; | ||
597 | } | ||
598 | |||
599 | S32 LLPanelRegionTools::getRedirectGridX() const | ||
600 | { | ||
601 | return childGetValue("redirectx").asInteger(); | ||
602 | } | ||
603 | |||
604 | S32 LLPanelRegionTools::getRedirectGridY() const | ||
605 | { | ||
606 | return childGetValue("redirecty").asInteger(); | ||
607 | } | ||
608 | |||
609 | S32 LLPanelRegionTools::getGridPosX() const | ||
610 | { | ||
611 | return childGetValue("gridposx").asInteger(); | ||
612 | } | ||
613 | |||
614 | S32 LLPanelRegionTools::getGridPosY() const | ||
615 | { | ||
616 | return childGetValue("gridposy").asInteger(); | ||
617 | } | ||
618 | |||
619 | U32 LLPanelRegionTools::getRegionFlags() const | ||
620 | { | ||
621 | U32 flags = 0x0; | ||
622 | flags = childGetValue("check prelude").asBoolean() | ||
623 | ? set_prelude_flags(flags) | ||
624 | : unset_prelude_flags(flags); | ||
625 | |||
626 | // override prelude | ||
627 | if (childGetValue("check fixed sun").asBoolean()) | ||
628 | { | ||
629 | flags |= REGION_FLAGS_SUN_FIXED; | ||
630 | } | ||
631 | if (childGetValue("check reset home").asBoolean()) | ||
632 | { | ||
633 | flags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT; | ||
634 | } | ||
635 | if (childGetValue("check visible").asBoolean()) | ||
636 | { | ||
637 | flags |= REGION_FLAGS_EXTERNALLY_VISIBLE; | ||
638 | } | ||
639 | if (childGetValue("check damage").asBoolean()) | ||
640 | { | ||
641 | flags |= REGION_FLAGS_ALLOW_DAMAGE; | ||
642 | } | ||
643 | if (childGetValue("block terraform").asBoolean()) | ||
644 | { | ||
645 | flags |= REGION_FLAGS_BLOCK_TERRAFORM; | ||
646 | } | ||
647 | if (childGetValue("block dwell").asBoolean()) | ||
648 | { | ||
649 | flags |= REGION_FLAGS_BLOCK_DWELL; | ||
650 | } | ||
651 | if (childGetValue("is sandbox").asBoolean()) | ||
652 | { | ||
653 | flags |= REGION_FLAGS_SANDBOX; | ||
654 | } | ||
655 | return flags; | ||
656 | } | ||
657 | |||
658 | U32 LLPanelRegionTools::getRegionFlagsMask() const | ||
659 | { | ||
660 | U32 flags = 0xffffffff; | ||
661 | flags = childGetValue("check prelude").asBoolean() | ||
662 | ? set_prelude_flags(flags) | ||
663 | : unset_prelude_flags(flags); | ||
664 | |||
665 | if (!childGetValue("check fixed sun").asBoolean()) | ||
666 | { | ||
667 | flags &= ~REGION_FLAGS_SUN_FIXED; | ||
668 | } | ||
669 | if (!childGetValue("check reset home").asBoolean()) | ||
670 | { | ||
671 | flags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT; | ||
672 | } | ||
673 | if (!childGetValue("check visible").asBoolean()) | ||
674 | { | ||
675 | flags &= ~REGION_FLAGS_EXTERNALLY_VISIBLE; | ||
676 | } | ||
677 | if (!childGetValue("check damage").asBoolean()) | ||
678 | { | ||
679 | flags &= ~REGION_FLAGS_ALLOW_DAMAGE; | ||
680 | } | ||
681 | if (!childGetValue("block terraform").asBoolean()) | ||
682 | { | ||
683 | flags &= ~REGION_FLAGS_BLOCK_TERRAFORM; | ||
684 | } | ||
685 | if (!childGetValue("block dwell").asBoolean()) | ||
686 | { | ||
687 | flags &= ~REGION_FLAGS_BLOCK_DWELL; | ||
688 | } | ||
689 | if (!childGetValue("is sandbox").asBoolean()) | ||
690 | { | ||
691 | flags &= ~REGION_FLAGS_SANDBOX; | ||
692 | } | ||
693 | return flags; | ||
694 | } | ||
695 | |||
696 | F32 LLPanelRegionTools::getBillableFactor() const | ||
697 | { | ||
698 | return (F32)childGetValue("billable factor").asReal(); | ||
699 | } | ||
700 | |||
701 | S32 LLPanelRegionTools::getPricePerMeter() const | ||
702 | { | ||
703 | return childGetValue("land cost"); | ||
704 | } | ||
705 | |||
706 | void LLPanelRegionTools::setSimName(char *name) | ||
707 | { | ||
708 | childSetValue("region name", name); | ||
709 | } | ||
710 | |||
711 | void LLPanelRegionTools::setEstateID(U32 id) | ||
712 | { | ||
713 | childSetValue("estate", (S32)id); | ||
714 | } | ||
715 | |||
716 | void LLPanelRegionTools::setGridPosX(S32 pos) | ||
717 | { | ||
718 | childSetValue("gridposx", pos); | ||
719 | } | ||
720 | |||
721 | void LLPanelRegionTools::setGridPosY(S32 pos) | ||
722 | { | ||
723 | childSetValue("gridposy", pos); | ||
724 | } | ||
725 | |||
726 | void LLPanelRegionTools::setRedirectGridX(S32 pos) | ||
727 | { | ||
728 | childSetValue("redirectx", pos); | ||
729 | } | ||
730 | |||
731 | void LLPanelRegionTools::setRedirectGridY(S32 pos) | ||
732 | { | ||
733 | childSetValue("redirecty", pos); | ||
734 | } | ||
735 | |||
736 | void LLPanelRegionTools::setParentEstateID(U32 id) | ||
737 | { | ||
738 | childSetValue("parentestate", (S32)id); | ||
739 | } | ||
740 | |||
741 | void LLPanelRegionTools::setCheckFlags(U32 flags) | ||
742 | { | ||
743 | childSetValue("check prelude", is_prelude(flags) ? TRUE : FALSE); | ||
744 | childSetValue("check fixed sun", flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE); | ||
745 | childSetValue("check reset home", flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT ? TRUE : FALSE); | ||
746 | childSetValue("check damage", flags & REGION_FLAGS_ALLOW_DAMAGE ? TRUE : FALSE); | ||
747 | childSetValue("check visible", flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE); | ||
748 | childSetValue("block terraform", flags & REGION_FLAGS_BLOCK_TERRAFORM ? TRUE : FALSE); | ||
749 | childSetValue("block dwell", flags & REGION_FLAGS_BLOCK_DWELL ? TRUE : FALSE); | ||
750 | childSetValue("is sandbox", flags & REGION_FLAGS_SANDBOX ? TRUE : FALSE ); | ||
751 | } | ||
752 | |||
753 | void LLPanelRegionTools::setBillableFactor(F32 billable_factor) | ||
754 | { | ||
755 | childSetValue("billable factor", billable_factor); | ||
756 | } | ||
757 | |||
758 | void LLPanelRegionTools::setPricePerMeter(S32 price) | ||
759 | { | ||
760 | childSetValue("land cost", price); | ||
761 | } | ||
762 | |||
763 | // static | ||
764 | void LLPanelRegionTools::onChangeAnything(LLUICtrl* ctrl, void* userdata) | ||
765 | { | ||
766 | if (sGodTools | ||
767 | && userdata | ||
768 | && gAgent.isGodlike()) | ||
769 | { | ||
770 | LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata; | ||
771 | region_tools->childEnable("Apply"); | ||
772 | } | ||
773 | } | ||
774 | |||
775 | // static | ||
776 | void LLPanelRegionTools::onChangePrelude(LLUICtrl* ctrl, void* data) | ||
777 | { | ||
778 | // checking prelude auto-checks fixed sun | ||
779 | LLPanelRegionTools* self = (LLPanelRegionTools*)data; | ||
780 | if (self->childGetValue("check prelude").asBoolean()) | ||
781 | { | ||
782 | self->childSetValue("check fixed sun", TRUE); | ||
783 | self->childSetValue("check reset home", TRUE); | ||
784 | } | ||
785 | // pass on to default onChange handler | ||
786 | onChangeAnything(ctrl, data); | ||
787 | } | ||
788 | |||
789 | // static | ||
790 | void LLPanelRegionTools::onChangeSimName(LLLineEditor* caller, void* userdata ) | ||
791 | { | ||
792 | if (sGodTools | ||
793 | && userdata | ||
794 | && gAgent.isGodlike()) | ||
795 | { | ||
796 | LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata; | ||
797 | region_tools->childEnable("Apply"); | ||
798 | } | ||
799 | } | ||
800 | |||
801 | //static | ||
802 | void LLPanelRegionTools::onRefresh(void* userdata) | ||
803 | { | ||
804 | LLViewerRegion *region = gAgent.getRegion(); | ||
805 | if (region | ||
806 | && sGodTools | ||
807 | && gAgent.isGodlike()) | ||
808 | { | ||
809 | sGodTools->sendRegionInfoRequest(); | ||
810 | } | ||
811 | } | ||
812 | |||
813 | // static | ||
814 | void LLPanelRegionTools::onApplyChanges(void* userdata) | ||
815 | { | ||
816 | LLViewerRegion *region = gAgent.getRegion(); | ||
817 | if (region | ||
818 | && sGodTools | ||
819 | && userdata | ||
820 | && gAgent.isGodlike()) | ||
821 | { | ||
822 | LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata; | ||
823 | |||
824 | region_tools->childDisable("Apply"); | ||
825 | sGodTools->sendGodUpdateRegionInfo(); | ||
826 | } | ||
827 | } | ||
828 | |||
829 | // static | ||
830 | void LLPanelRegionTools::onBakeTerrain(void *userdata) | ||
831 | { | ||
832 | LLPanelRequestTools::sendRequest("terrain", "bake", gAgent.getRegionHost()); | ||
833 | } | ||
834 | |||
835 | // static | ||
836 | void LLPanelRegionTools::onRevertTerrain(void *userdata) | ||
837 | { | ||
838 | LLPanelRequestTools::sendRequest("terrain", "revert", gAgent.getRegionHost()); | ||
839 | } | ||
840 | |||
841 | // static | ||
842 | void LLPanelRegionTools::onSwapTerrain(void *userdata) | ||
843 | { | ||
844 | LLPanelRequestTools::sendRequest("terrain", "swap", gAgent.getRegionHost()); | ||
845 | } | ||
846 | |||
847 | // static | ||
848 | void LLPanelRegionTools::onSelectRegion(void* userdata) | ||
849 | { | ||
850 | llinfos << "LLPanelRegionTools::onSelectRegion" << llendl; | ||
851 | |||
852 | if (!gWorldp) | ||
853 | { | ||
854 | return; | ||
855 | } | ||
856 | LLViewerRegion *regionp = gWorldp->getRegionFromPosGlobal(gAgent.getPositionGlobal()); | ||
857 | if (!regionp) | ||
858 | { | ||
859 | return; | ||
860 | } | ||
861 | |||
862 | LLVector3d north_east(REGION_WIDTH_METERS, REGION_WIDTH_METERS, 0); | ||
863 | gParcelMgr->selectLand(regionp->getOriginGlobal(), | ||
864 | regionp->getOriginGlobal() + north_east, FALSE); | ||
865 | |||
866 | } | ||
867 | |||
868 | |||
869 | //***************************************************************************** | ||
870 | // Class LLPanelGridTools | ||
871 | //***************************************************************************** | ||
872 | |||
873 | // || Grid |_____________________________________ | ||
874 | // | | | ||
875 | // | | | ||
876 | // | Sun Phase: >--------[]---------< [________] | | ||
877 | // | | | ||
878 | // | ^ ^ | | ||
879 | // | LEFT R1 | | ||
880 | // | | | ||
881 | // | [Kick all users] | | ||
882 | // | | | ||
883 | // | | | ||
884 | // | | | ||
885 | // | | | ||
886 | // | | | ||
887 | // |_______________________________________________| | ||
888 | // ^ ^ ^ | ||
889 | // LEFT R2 RIGHT | ||
890 | |||
891 | const F32 HOURS_TO_RADIANS = (2.f*F_PI)/24.f; | ||
892 | const char FLOATER_GRID_ADMIN_TITLE[] = "Grid Administration"; | ||
893 | |||
894 | |||
895 | LLPanelGridTools::LLPanelGridTools(const std::string& name) : | ||
896 | LLPanel(name) | ||
897 | { | ||
898 | } | ||
899 | |||
900 | // Destroys the object | ||
901 | LLPanelGridTools::~LLPanelGridTools() | ||
902 | { | ||
903 | } | ||
904 | |||
905 | BOOL LLPanelGridTools::postBuild() | ||
906 | { | ||
907 | childSetAction("Kick all users", onClickKickAll, this); | ||
908 | childSetAction("Flush This Region's Map Visibility Caches", onClickFlushMapVisibilityCaches, this); | ||
909 | |||
910 | return TRUE; | ||
911 | } | ||
912 | |||
913 | void LLPanelGridTools::refresh() | ||
914 | { | ||
915 | } | ||
916 | |||
917 | |||
918 | // static | ||
919 | void LLPanelGridTools::onClickKickAll(void* userdata) | ||
920 | { | ||
921 | LLPanelGridTools* self = (LLPanelGridTools*) userdata; | ||
922 | |||
923 | S32 left, top; | ||
924 | gFloaterView->getNewFloaterPosition(&left, &top); | ||
925 | LLRect rect(left, top, left+400, top-300); | ||
926 | |||
927 | gViewerWindow->alertXmlEditText("KickAllUsers", LLString::format_map_t(), | ||
928 | NULL, NULL, | ||
929 | LLPanelGridTools::confirmKick, self); | ||
930 | } | ||
931 | |||
932 | |||
933 | void LLPanelGridTools::confirmKick(S32 option, const LLString& text, void* userdata) | ||
934 | { | ||
935 | LLPanelGridTools* self = (LLPanelGridTools*) userdata; | ||
936 | |||
937 | if (option == 0) | ||
938 | { | ||
939 | self->mKickMessage = text; | ||
940 | gViewerWindow->alertXml("ConfirmKick",LLPanelGridTools::finishKick, self); | ||
941 | } | ||
942 | } | ||
943 | |||
944 | |||
945 | // static | ||
946 | void LLPanelGridTools::finishKick(S32 option, void* userdata) | ||
947 | { | ||
948 | LLPanelGridTools* self = (LLPanelGridTools*) userdata; | ||
949 | |||
950 | if (option == 0) | ||
951 | { | ||
952 | LLMessageSystem* msg = gMessageSystem; | ||
953 | |||
954 | msg->newMessageFast(_PREHASH_GodKickUser); | ||
955 | msg->nextBlockFast(_PREHASH_UserInfo); | ||
956 | msg->addUUIDFast(_PREHASH_GodID, gAgent.getID()); | ||
957 | msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID()); | ||
958 | msg->addUUIDFast(_PREHASH_AgentID, LL_UUID_ALL_AGENTS ); | ||
959 | msg->addU32("KickFlags", KICK_FLAGS_DEFAULT ); | ||
960 | msg->addStringFast(_PREHASH_Reason, self->mKickMessage.c_str() ); | ||
961 | gAgent.sendReliableMessage(); | ||
962 | } | ||
963 | } | ||
964 | |||
965 | |||
966 | // static | ||
967 | void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data) | ||
968 | { | ||
969 | gViewerWindow->alertXml("FlushMapVisibilityCaches", | ||
970 | flushMapVisibilityCachesConfirm, data); | ||
971 | } | ||
972 | |||
973 | // static | ||
974 | void LLPanelGridTools::flushMapVisibilityCachesConfirm(S32 option, void* data) | ||
975 | { | ||
976 | if (option != 0) return; | ||
977 | |||
978 | LLPanelGridTools* self = (LLPanelGridTools*)data; | ||
979 | if (!self) return; | ||
980 | |||
981 | // HACK: Send this as an EstateOwnerRequest so it gets routed | ||
982 | // correctly by the spaceserver. JC | ||
983 | LLMessageSystem* msg = gMessageSystem; | ||
984 | msg->newMessage("EstateOwnerMessage"); | ||
985 | msg->nextBlockFast(_PREHASH_AgentData); | ||
986 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
987 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
988 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | ||
989 | msg->nextBlock("MethodData"); | ||
990 | msg->addString("Method", "refreshmapvisibility"); | ||
991 | msg->addUUID("Invoice", LLUUID::null); | ||
992 | msg->nextBlock("ParamList"); | ||
993 | msg->addString("Parameter", gAgent.getID().getString()); | ||
994 | gAgent.sendReliableMessage(); | ||
995 | } | ||
996 | |||
997 | |||
998 | //***************************************************************************** | ||
999 | // LLPanelObjectTools | ||
1000 | //***************************************************************************** | ||
1001 | |||
1002 | |||
1003 | // || Object |_______________________________________________________ | ||
1004 | // | | | ||
1005 | // | Sim Name: Foo | | ||
1006 | // | ^ ^ | | ||
1007 | // | LEFT R1 | | ||
1008 | // | | | ||
1009 | // | [X] Disable Scripts [X] Disable Collisions [X] Disable Physics | | ||
1010 | // | [ Apply ] | | ||
1011 | // | | | ||
1012 | // | [Set Target Avatar] Avatar Name | | ||
1013 | // | [Delete Target's Objects on Public Land ] | | ||
1014 | // | [Delete All Target's Objects ] | | ||
1015 | // | [Delete All Scripted Objects on Public Land] | | ||
1016 | // | [Get Top Colliders ] | | ||
1017 | // | [Get Top Scripts ] | | ||
1018 | // |_________________________________________________________________| | ||
1019 | // ^ ^ | ||
1020 | // LEFT RIGHT | ||
1021 | |||
1022 | // Default constructor | ||
1023 | LLPanelObjectTools::LLPanelObjectTools(const std::string& title) | ||
1024 | : LLPanel(title), mTargetAvatar() | ||
1025 | { | ||
1026 | } | ||
1027 | |||
1028 | // Destroys the object | ||
1029 | LLPanelObjectTools::~LLPanelObjectTools() | ||
1030 | { | ||
1031 | // base class will take care of everything | ||
1032 | } | ||
1033 | |||
1034 | BOOL LLPanelObjectTools::postBuild() | ||
1035 | { | ||
1036 | childSetCommitCallback("disable scripts", onChangeAnything, this); | ||
1037 | childSetCommitCallback("disable collisions", onChangeAnything, this); | ||
1038 | childSetCommitCallback("disable physics", onChangeAnything, this); | ||
1039 | |||
1040 | childSetAction("Apply", onApplyChanges, this); | ||
1041 | |||
1042 | childSetAction("Set Target", onClickSet, this); | ||
1043 | |||
1044 | childSetAction("Delete Target's Scripted Objects On Others Land", onClickDeletePublicOwnedBy, this); | ||
1045 | childSetAction("Delete Target's Scripted Objects On *Any* Land", onClickDeleteAllScriptedOwnedBy, this); | ||
1046 | childSetAction("Delete *ALL* Of Target's Objects", onClickDeleteAllOwnedBy, this); | ||
1047 | |||
1048 | childSetAction("Get Top Colliders", onGetTopColliders, this); | ||
1049 | childSetAction("Get Top Scripts", onGetTopScripts, this); | ||
1050 | childSetAction("Scripts digest", onGetScriptDigest, this); | ||
1051 | |||
1052 | return TRUE; | ||
1053 | } | ||
1054 | |||
1055 | void LLPanelObjectTools::setTargetAvatar(const LLUUID &target_id) | ||
1056 | { | ||
1057 | mTargetAvatar = target_id; | ||
1058 | if (target_id.isNull()) | ||
1059 | { | ||
1060 | childSetValue("target_avatar_name", "(no target)"); | ||
1061 | } | ||
1062 | } | ||
1063 | |||
1064 | |||
1065 | void LLPanelObjectTools::refresh() | ||
1066 | { | ||
1067 | LLViewerRegion *regionp = gAgent.getRegion(); | ||
1068 | if (regionp) | ||
1069 | { | ||
1070 | childSetText("region name", regionp->getName()); | ||
1071 | } | ||
1072 | } | ||
1073 | |||
1074 | |||
1075 | U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const | ||
1076 | { | ||
1077 | if (childGetValue("disable scripts").asBoolean()) | ||
1078 | { | ||
1079 | flags |= REGION_FLAGS_SKIP_SCRIPTS; | ||
1080 | } | ||
1081 | else | ||
1082 | { | ||
1083 | flags &= ~REGION_FLAGS_SKIP_SCRIPTS; | ||
1084 | } | ||
1085 | if (childGetValue("disable collisions").asBoolean()) | ||
1086 | { | ||
1087 | flags |= REGION_FLAGS_SKIP_COLLISIONS; | ||
1088 | } | ||
1089 | else | ||
1090 | { | ||
1091 | flags &= ~REGION_FLAGS_SKIP_COLLISIONS; | ||
1092 | } | ||
1093 | if (childGetValue("disable physics").asBoolean()) | ||
1094 | { | ||
1095 | flags |= REGION_FLAGS_SKIP_PHYSICS; | ||
1096 | } | ||
1097 | else | ||
1098 | { | ||
1099 | flags &= ~REGION_FLAGS_SKIP_PHYSICS; | ||
1100 | } | ||
1101 | return flags; | ||
1102 | } | ||
1103 | |||
1104 | |||
1105 | void LLPanelObjectTools::setCheckFlags(U32 flags) | ||
1106 | { | ||
1107 | childSetValue("disable scripts", flags & REGION_FLAGS_SKIP_SCRIPTS ? TRUE : FALSE); | ||
1108 | childSetValue("disable collisions", flags & REGION_FLAGS_SKIP_COLLISIONS ? TRUE : FALSE); | ||
1109 | childSetValue("disable physics", flags & REGION_FLAGS_SKIP_PHYSICS ? TRUE : FALSE); | ||
1110 | } | ||
1111 | |||
1112 | |||
1113 | void LLPanelObjectTools::clearAllWidgets() | ||
1114 | { | ||
1115 | childSetValue("disable scripts", FALSE); | ||
1116 | childDisable("disable scripts"); | ||
1117 | |||
1118 | childDisable("Apply"); | ||
1119 | childDisable("Set Target"); | ||
1120 | childDisable("Delete Target's Scripted Objects On Others Land"); | ||
1121 | childDisable("Delete Target's Scripted Objects On *Any* Land"); | ||
1122 | childDisable("Delete *ALL* Of Target's Objects"); | ||
1123 | } | ||
1124 | |||
1125 | |||
1126 | void LLPanelObjectTools::enableAllWidgets() | ||
1127 | { | ||
1128 | childEnable("disable scripts"); | ||
1129 | |||
1130 | childDisable("Apply"); // don't enable this one | ||
1131 | childEnable("Set Target"); | ||
1132 | childEnable("Delete Target's Scripted Objects On Others Land"); | ||
1133 | childEnable("Delete Target's Scripted Objects On *Any* Land"); | ||
1134 | childEnable("Delete *ALL* Of Target's Objects"); | ||
1135 | childEnable("Get Top Colliders"); | ||
1136 | childEnable("Get Top Scripts"); | ||
1137 | } | ||
1138 | |||
1139 | |||
1140 | // static | ||
1141 | void LLPanelObjectTools::onGetTopColliders(void* userdata) | ||
1142 | { | ||
1143 | if (sGodTools | ||
1144 | && gAgent.isGodlike()) | ||
1145 | { | ||
1146 | LLFloaterTopObjects::show(); | ||
1147 | LLFloaterTopObjects::setMode(STAT_REPORT_TOP_COLLIDERS); | ||
1148 | LLFloaterTopObjects::onRefresh(NULL); | ||
1149 | } | ||
1150 | } | ||
1151 | |||
1152 | // static | ||
1153 | void LLPanelObjectTools::onGetTopScripts(void* userdata) | ||
1154 | { | ||
1155 | if (sGodTools | ||
1156 | && gAgent.isGodlike()) | ||
1157 | { | ||
1158 | LLFloaterTopObjects::show(); | ||
1159 | LLFloaterTopObjects::setMode(STAT_REPORT_TOP_SCRIPTS); | ||
1160 | LLFloaterTopObjects::onRefresh(NULL); | ||
1161 | } | ||
1162 | } | ||
1163 | |||
1164 | // static | ||
1165 | void LLPanelObjectTools::onGetScriptDigest(void* userdata) | ||
1166 | { | ||
1167 | if (sGodTools | ||
1168 | && gAgent.isGodlike()) | ||
1169 | { | ||
1170 | // get the list of scripts and number of occurences of each | ||
1171 | // (useful for finding self-replicating objects) | ||
1172 | LLPanelRequestTools::sendRequest("scriptdigest","0",gAgent.getRegionHost()); | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata) | ||
1177 | { | ||
1178 | // Bring up view-modal dialog | ||
1179 | LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata; | ||
1180 | if (!panelp->mTargetAvatar.isNull()) | ||
1181 | { | ||
1182 | panelp->mSimWideDeletesFlags = | ||
1183 | SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY; | ||
1184 | |||
1185 | LLStringBase<char>::format_map_t args; | ||
1186 | args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); | ||
1187 | |||
1188 | gViewerWindow->alertXml( "GodDeleteAllScriptedPublicObjectsByUser", | ||
1189 | args, | ||
1190 | callbackSimWideDeletes, | ||
1191 | userdata); | ||
1192 | } | ||
1193 | } | ||
1194 | |||
1195 | // static | ||
1196 | void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata) | ||
1197 | { | ||
1198 | // Bring up view-modal dialog | ||
1199 | LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata; | ||
1200 | if (!panelp->mTargetAvatar.isNull()) | ||
1201 | { | ||
1202 | panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY; | ||
1203 | |||
1204 | LLStringBase<char>::format_map_t args; | ||
1205 | args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); | ||
1206 | |||
1207 | gViewerWindow->alertXml( "GodDeleteAllScriptedObjectsByUser", | ||
1208 | args, | ||
1209 | callbackSimWideDeletes, | ||
1210 | userdata); | ||
1211 | } | ||
1212 | } | ||
1213 | |||
1214 | // static | ||
1215 | void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata) | ||
1216 | { | ||
1217 | // Bring up view-modal dialog | ||
1218 | LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata; | ||
1219 | if (!panelp->mTargetAvatar.isNull()) | ||
1220 | { | ||
1221 | panelp->mSimWideDeletesFlags = 0; | ||
1222 | |||
1223 | LLStringBase<char>::format_map_t args; | ||
1224 | args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString(); | ||
1225 | |||
1226 | gViewerWindow->alertXml( "GodDeleteAllObjectsByUser", | ||
1227 | args, | ||
1228 | callbackSimWideDeletes, | ||
1229 | userdata); | ||
1230 | } | ||
1231 | } | ||
1232 | |||
1233 | // static | ||
1234 | void LLPanelObjectTools::callbackSimWideDeletes( S32 option, void* userdata ) | ||
1235 | { | ||
1236 | if (option == 0) | ||
1237 | { | ||
1238 | LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata; | ||
1239 | if (!object_tools->mTargetAvatar.isNull()) | ||
1240 | { | ||
1241 | send_sim_wide_deletes(object_tools->mTargetAvatar, | ||
1242 | object_tools->mSimWideDeletesFlags); | ||
1243 | } | ||
1244 | } | ||
1245 | } | ||
1246 | |||
1247 | void LLPanelObjectTools::onClickSet(void* data) | ||
1248 | { | ||
1249 | LLPanelObjectTools* panelp = (LLPanelObjectTools*) data; | ||
1250 | // grandparent is a floater, which can have a dependent | ||
1251 | gFloaterView->getParentFloater(panelp)->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarID, data)); | ||
1252 | } | ||
1253 | |||
1254 | void LLPanelObjectTools::onClickSetBySelection(void* data) | ||
1255 | { | ||
1256 | LLPanelObjectTools* panelp = (LLPanelObjectTools*) data; | ||
1257 | if (!panelp) return; | ||
1258 | |||
1259 | LLSelectNode* node = gSelectMgr->getFirstRootNode(); | ||
1260 | if (!node) node = gSelectMgr->getFirstNode(); | ||
1261 | if (!node) return; | ||
1262 | |||
1263 | LLString owner_name; | ||
1264 | LLUUID owner_id; | ||
1265 | gSelectMgr->selectGetOwner(owner_id, owner_name); | ||
1266 | |||
1267 | panelp->mTargetAvatar = owner_id; | ||
1268 | LLString name = "Object " + node->mName + " owned by " + owner_name; | ||
1269 | panelp->childSetValue("target_avatar_name", name); | ||
1270 | } | ||
1271 | |||
1272 | // static | ||
1273 | void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data) | ||
1274 | { | ||
1275 | LLPanelObjectTools* object_tools = (LLPanelObjectTools*) data; | ||
1276 | if (ids.empty() || names.empty()) return; | ||
1277 | object_tools->mTargetAvatar = ids[0]; | ||
1278 | object_tools->childSetValue("target_avatar_name", names[0]); | ||
1279 | object_tools->refresh(); | ||
1280 | } | ||
1281 | |||
1282 | |||
1283 | // static | ||
1284 | void LLPanelObjectTools::onChangeAnything(LLUICtrl* ctrl, void* userdata) | ||
1285 | { | ||
1286 | if (sGodTools | ||
1287 | && userdata | ||
1288 | && gAgent.isGodlike()) | ||
1289 | { | ||
1290 | LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata; | ||
1291 | object_tools->childEnable("Apply"); | ||
1292 | } | ||
1293 | } | ||
1294 | |||
1295 | // static | ||
1296 | void LLPanelObjectTools::onApplyChanges(void* userdata) | ||
1297 | { | ||
1298 | LLViewerRegion *region = gAgent.getRegion(); | ||
1299 | if (region | ||
1300 | && sGodTools | ||
1301 | && userdata | ||
1302 | && gAgent.isGodlike()) | ||
1303 | { | ||
1304 | LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata; | ||
1305 | // TODO -- implement this | ||
1306 | |||
1307 | object_tools->childDisable("Apply"); | ||
1308 | sGodTools->sendGodUpdateRegionInfo(); | ||
1309 | } | ||
1310 | } | ||
1311 | |||
1312 | |||
1313 | // -------------------- | ||
1314 | // LLPanelRequestTools | ||
1315 | // -------------------- | ||
1316 | |||
1317 | const char SELECTION[] = "Selection"; | ||
1318 | const char AGENT_REGION[] = "Agent Region"; | ||
1319 | |||
1320 | LLPanelRequestTools::LLPanelRequestTools(const std::string& name): | ||
1321 | LLPanel(name) | ||
1322 | { | ||
1323 | } | ||
1324 | |||
1325 | LLPanelRequestTools::~LLPanelRequestTools() | ||
1326 | { | ||
1327 | } | ||
1328 | |||
1329 | BOOL LLPanelRequestTools::postBuild() | ||
1330 | { | ||
1331 | childSetAction("Make Request", onClickRequest, this); | ||
1332 | |||
1333 | refresh(); | ||
1334 | |||
1335 | return TRUE; | ||
1336 | } | ||
1337 | |||
1338 | void LLPanelRequestTools::refresh() | ||
1339 | { | ||
1340 | std::string buffer = childGetValue("destination"); | ||
1341 | LLCtrlListInterface *list = childGetListInterface("destination"); | ||
1342 | if (!list) return; | ||
1343 | |||
1344 | list->operateOnAll(LLCtrlListInterface::OP_DELETE); | ||
1345 | list->addSimpleElement(SELECTION); | ||
1346 | list->addSimpleElement(AGENT_REGION); | ||
1347 | LLViewerRegion* regionp; | ||
1348 | for(regionp = gWorldp->mActiveRegionList.getFirstData(); | ||
1349 | regionp != NULL; | ||
1350 | regionp = gWorldp->mActiveRegionList.getNextData()) | ||
1351 | { | ||
1352 | LLString name = regionp->getName(); | ||
1353 | if (!name.empty()) | ||
1354 | { | ||
1355 | list->addSimpleElement(name); | ||
1356 | } | ||
1357 | } | ||
1358 | if(!buffer.empty()) | ||
1359 | { | ||
1360 | list->selectByValue(buffer); | ||
1361 | } | ||
1362 | else | ||
1363 | { | ||
1364 | list->selectByValue(SELECTION); | ||
1365 | } | ||
1366 | } | ||
1367 | |||
1368 | |||
1369 | // static | ||
1370 | void LLPanelRequestTools::sendRequest(const char *request, | ||
1371 | const char *parameter, | ||
1372 | const LLHost& host) | ||
1373 | { | ||
1374 | llinfos << "Sending request '" << request << "', '" | ||
1375 | << parameter << "' to " << host << llendl; | ||
1376 | LLMessageSystem* msg = gMessageSystem; | ||
1377 | msg->newMessage("GodlikeMessage"); | ||
1378 | msg->nextBlockFast(_PREHASH_AgentData); | ||
1379 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
1380 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
1381 | msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used | ||
1382 | msg->nextBlock("MethodData"); | ||
1383 | msg->addString("Method", request); | ||
1384 | msg->addUUID("Invoice", LLUUID::null); | ||
1385 | msg->nextBlock("ParamList"); | ||
1386 | msg->addString("Parameter", parameter); | ||
1387 | msg->sendReliable(host); | ||
1388 | } | ||
1389 | |||
1390 | // static | ||
1391 | void LLPanelRequestTools::onClickRequest(void* data) | ||
1392 | { | ||
1393 | LLPanelRequestTools* self = (LLPanelRequestTools*)data; | ||
1394 | const std::string dest = self->childGetValue("destination").asString(); | ||
1395 | if(dest == SELECTION) | ||
1396 | { | ||
1397 | std::string req = self->childGetValue("request"); | ||
1398 | req = req.substr(0, req.find_first_of(" ")); | ||
1399 | std::string param = self->childGetValue("parameter"); | ||
1400 | gSelectMgr->sendGodlikeRequest(req, param); | ||
1401 | } | ||
1402 | else if(dest == AGENT_REGION) | ||
1403 | { | ||
1404 | self->sendRequest(gAgent.getRegionHost()); | ||
1405 | } | ||
1406 | else | ||
1407 | { | ||
1408 | // find region by name | ||
1409 | LLViewerRegion* regionp; | ||
1410 | for(regionp = gWorldp->mActiveRegionList.getFirstData(); | ||
1411 | regionp != NULL; | ||
1412 | regionp = gWorldp->mActiveRegionList.getNextData()) | ||
1413 | { | ||
1414 | if(dest == regionp->getName()) | ||
1415 | { | ||
1416 | // found it | ||
1417 | self->sendRequest(regionp->getHost()); | ||
1418 | } | ||
1419 | } | ||
1420 | } | ||
1421 | } | ||
1422 | |||
1423 | void terrain_download_done(void** data, S32 status) | ||
1424 | { | ||
1425 | LLNotifyBox::showXml("TerrainDownloaded"); | ||
1426 | } | ||
1427 | |||
1428 | |||
1429 | void test_callback(const LLTSCode status) | ||
1430 | { | ||
1431 | llinfos << "Test transfer callback returned!" << llendl; | ||
1432 | } | ||
1433 | |||
1434 | |||
1435 | void LLPanelRequestTools::sendRequest(const LLHost& host) | ||
1436 | { | ||
1437 | |||
1438 | // intercept viewer local actions here | ||
1439 | std::string req = childGetValue("request"); | ||
1440 | if (req == "terrain download") | ||
1441 | { | ||
1442 | gXferManager->requestFile("terrain.raw", "terrain.raw", LL_PATH_NONE, | ||
1443 | host, | ||
1444 | FALSE, | ||
1445 | terrain_download_done, | ||
1446 | NULL); | ||
1447 | } | ||
1448 | else | ||
1449 | { | ||
1450 | req = req.substr(0, req.find_first_of(" ")); | ||
1451 | sendRequest(req.c_str(), childGetValue("parameter").asString().c_str(), host); | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | // Flags are SWD_ flags. | ||
1456 | void send_sim_wide_deletes(const LLUUID& owner_id, U32 flags) | ||
1457 | { | ||
1458 | LLMessageSystem* msg = gMessageSystem; | ||
1459 | msg->newMessageFast(_PREHASH_SimWideDeletes); | ||
1460 | msg->nextBlockFast(_PREHASH_AgentData); | ||
1461 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | ||
1462 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | ||
1463 | msg->nextBlockFast(_PREHASH_DataBlock); | ||
1464 | msg->addUUIDFast(_PREHASH_TargetID, owner_id); | ||
1465 | msg->addU32Fast(_PREHASH_Flags, flags); | ||
1466 | gAgent.sendReliableMessage(); | ||
1467 | } | ||