PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

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