PageRenderTime 111ms CodeModel.GetById 16ms app.highlight 85ms RepoModel.GetById 1ms app.codeStats 1ms

/indra/newview/llfloatergodtools.cpp

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