llfloatergodtools.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llfloatergodtools.h"
00035 
00036 #include "llcoord.h"
00037 #include "llfontgl.h"
00038 #include "llframetimer.h"
00039 #include "llgl.h"
00040 #include "llhost.h"
00041 #include "llregionflags.h"
00042 #include "llstring.h"
00043 #include "message.h"
00044 
00045 #include "llagent.h"
00046 #include "llalertdialog.h"
00047 #include "llbutton.h"
00048 #include "llcheckboxctrl.h"
00049 #include "llcombobox.h"
00050 #include "lldraghandle.h"
00051 #include "llfloater.h"
00052 #include "llfocusmgr.h"
00053 #include "llfloatertopobjects.h"
00054 #include "lllineeditor.h"
00055 #include "llmenugl.h"
00056 #include "llresmgr.h"
00057 #include "llselectmgr.h"
00058 #include "llsky.h"
00059 #include "llspinctrl.h"
00060 #include "llstatusbar.h"
00061 #include "lltabcontainer.h"
00062 #include "lltextbox.h"
00063 #include "lluictrl.h"
00064 #include "llviewerparcelmgr.h"
00065 #include "llviewerregion.h"
00066 #include "llviewerwindow.h"
00067 #include "llworld.h"
00068 #include "llfloateravatarpicker.h"
00069 #include "llnotify.h"
00070 #include "llxfermanager.h"
00071 #include "llvlcomposition.h"
00072 #include "llsurface.h"
00073 #include "llviewercontrol.h"
00074 #include "llvieweruictrlfactory.h"
00075 
00076 #include "lltransfertargetfile.h"
00077 #include "lltransfersourcefile.h"
00078 
00079 const F32 SECONDS_BETWEEN_UPDATE_REQUESTS = 5.0f;
00080 
00081 static LLFloaterGodTools* sGodTools = NULL;
00082 
00083 //*****************************************************************************
00084 // LLFloaterGodTools
00085 //*****************************************************************************
00086 
00087 // static
00088 LLFloaterGodTools* LLFloaterGodTools::instance()
00089 {
00090         if (!sGodTools)
00091         {
00092                 sGodTools = new LLFloaterGodTools();
00093                 sGodTools->open();      /*Flawfinder: ignore*/
00094                 sGodTools->center();
00095                 sGodTools->setFocus(TRUE);
00096         }
00097         return sGodTools;
00098 }
00099  
00100 
00101 // static
00102 void LLFloaterGodTools::refreshAll()
00103 {
00104         LLFloaterGodTools* god_tools = instance();
00105         if (god_tools)
00106         {
00107                 if (gAgent.getRegionHost() != god_tools->mCurrentHost)
00108                 {
00109                         // we're in a new region
00110                         god_tools->sendRegionInfoRequest();
00111                 }
00112         }
00113 }
00114 
00115 
00116 
00117 LLFloaterGodTools::LLFloaterGodTools()
00118 :       LLFloater("godtools floater"),
00119         mCurrentHost(LLHost::invalid),
00120         mUpdateTimer()
00121 {
00122         LLCallbackMap::map_t factory_map;
00123         factory_map["grid"] = LLCallbackMap(createPanelGrid, this);
00124         factory_map["region"] = LLCallbackMap(createPanelRegion, this);
00125         factory_map["objects"] = LLCallbackMap(createPanelObjects, this);
00126         factory_map["request"] = LLCallbackMap(createPanelRequest, this);
00127         gUICtrlFactory->buildFloater(this, "floater_god_tools.xml", &factory_map);
00128 
00129         childSetTabChangeCallback("GodTools Tabs", "grid", onTabChanged, this);
00130         childSetTabChangeCallback("GodTools Tabs", "region", onTabChanged, this);
00131         childSetTabChangeCallback("GodTools Tabs", "objects", onTabChanged, this);
00132         childSetTabChangeCallback("GodTools Tabs", "request", onTabChanged, this);
00133 
00134         sendRegionInfoRequest();
00135 
00136         childShowTab("GodTools Tabs", "region");
00137 }
00138 
00139 // static
00140 void* LLFloaterGodTools::createPanelGrid(void *userdata)
00141 {
00142         return new LLPanelGridTools("grid");
00143 }
00144 
00145 // static
00146 void* LLFloaterGodTools::createPanelRegion(void *userdata)
00147 {
00148         LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
00149         self->mPanelRegionTools = new LLPanelRegionTools("region");
00150         return self->mPanelRegionTools;
00151 }
00152 
00153 // static
00154 void* LLFloaterGodTools::createPanelObjects(void *userdata)
00155 {
00156         LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
00157         self->mPanelObjectTools = new LLPanelObjectTools("objects");
00158         return self->mPanelObjectTools;
00159 }
00160 
00161 // static
00162 void* LLFloaterGodTools::createPanelRequest(void *userdata)
00163 {
00164         return new LLPanelRequestTools("region");
00165 }
00166 
00167 LLFloaterGodTools::~LLFloaterGodTools()
00168 {
00169         // children automatically deleted
00170 }
00171 
00172 U32 LLFloaterGodTools::computeRegionFlags() const
00173 {
00174         U32 flags = gAgent.getRegion()->getRegionFlags();
00175         if (mPanelRegionTools) flags = mPanelRegionTools->computeRegionFlags(flags);
00176         if (mPanelObjectTools) flags = mPanelObjectTools->computeRegionFlags(flags);
00177         return flags;
00178 }
00179 
00180 
00181 void LLFloaterGodTools::updatePopup(LLCoordGL center, MASK mask)
00182 {
00183 }
00184 
00185 // virtual
00186 void LLFloaterGodTools::onClose(bool app_quitting)
00187 {
00188         if (sGodTools)
00189         {
00190                 sGodTools->setVisible(FALSE);
00191         }
00192 }
00193 
00194 // virtual
00195 void LLFloaterGodTools::draw()
00196 {
00197         if (mCurrentHost == LLHost::invalid)
00198         {
00199                 if (mUpdateTimer.getElapsedTimeF32() > SECONDS_BETWEEN_UPDATE_REQUESTS)
00200                 {
00201                         sendRegionInfoRequest();
00202                 }
00203         }
00204         else if (gAgent.getRegionHost() != mCurrentHost)
00205         {
00206                 sendRegionInfoRequest();
00207         }
00208         LLFloater::draw();
00209 }
00210 
00211 // static
00212 void LLFloaterGodTools::show(void *)
00213 {
00214         LLFloaterGodTools* god_tools = instance();
00215         god_tools->open();
00216         LLPanel *panel = god_tools->childGetVisibleTab("GodTools Tabs");
00217         if (panel) panel->setFocus(TRUE);
00218         if (god_tools->mPanelObjectTools) god_tools->mPanelObjectTools->setTargetAvatar(LLUUID::null);
00219 
00220         if (gAgent.getRegionHost() != god_tools->mCurrentHost)
00221         {
00222                 // we're in a new region
00223                 god_tools->sendRegionInfoRequest();
00224         }
00225 }
00226 
00227 void LLFloaterGodTools::showPanel(const LLString& panel_name)
00228 {
00229         childShowTab("GodTools Tabs", panel_name);
00230         open(); /*Flawfinder: ignore*/
00231         LLPanel *panel = childGetVisibleTab("GodTools Tabs");
00232         if (panel) panel->setFocus(TRUE);
00233 }
00234 
00235 
00236 // static
00237 void LLFloaterGodTools::onTabChanged(void* data, bool from_click)
00238 {
00239         LLPanel* panel = (LLPanel*)data;
00240         if (panel)
00241         {
00242                 panel->setFocus(TRUE);
00243         }
00244 }
00245 
00246 
00247 // static
00248 void LLFloaterGodTools::processRegionInfo(LLMessageSystem* msg)
00249 {
00250         LLHost host = msg->getSender();
00251         if (host != gAgent.getRegionHost())
00252         {
00253                 // update is for a different region than the one we're in
00254                 return;
00255         }
00256 
00257         //const S32 SIM_NAME_BUF = 256;
00258         U32 region_flags;
00259         U8 sim_access;
00260         U8 agent_limit;
00261         char sim_name[MAX_STRING];              /*Flawfinder: ignore*/
00262         U32 estate_id;
00263         U32 parent_estate_id;
00264         F32 water_height;
00265         F32 billable_factor;
00266         F32 object_bonus_factor;
00267         F32 terrain_raise_limit;
00268         F32 terrain_lower_limit;
00269         S32 price_per_meter;
00270         S32 redirect_grid_x;
00271         S32 redirect_grid_y;
00272         LLUUID cache_id;
00273 
00274         msg->getStringFast(_PREHASH_RegionInfo, _PREHASH_SimName, MAX_STRING, sim_name);
00275         msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_EstateID, estate_id);
00276         msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_ParentEstateID, parent_estate_id);
00277         msg->getU32Fast(_PREHASH_RegionInfo, _PREHASH_RegionFlags, region_flags);
00278         msg->getU8Fast(_PREHASH_RegionInfo, _PREHASH_SimAccess, sim_access);
00279         msg->getU8Fast(_PREHASH_RegionInfo, _PREHASH_MaxAgents, agent_limit);
00280         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_ObjectBonusFactor, object_bonus_factor);
00281         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_BillableFactor, billable_factor);
00282         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_WaterHeight, water_height);
00283         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainRaiseLimit, terrain_raise_limit);
00284         msg->getF32Fast(_PREHASH_RegionInfo, _PREHASH_TerrainLowerLimit, terrain_lower_limit);
00285         msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_PricePerMeter, price_per_meter);
00286         msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_RedirectGridX, redirect_grid_x);
00287         msg->getS32Fast(_PREHASH_RegionInfo, _PREHASH_RedirectGridY, redirect_grid_y);
00288 
00289         // push values to the current LLViewerRegion
00290         LLViewerRegion *regionp = gAgent.getRegion();
00291         if (regionp)
00292         {
00293                 regionp->setRegionNameAndZone(sim_name);
00294                 regionp->setRegionFlags(region_flags);
00295                 regionp->setSimAccess(sim_access);
00296                 regionp->setWaterHeight(water_height);
00297                 regionp->setBillableFactor(billable_factor);
00298         }
00299 
00300         // push values to god tools, if available
00301         if (sGodTools 
00302                 && sGodTools->mPanelRegionTools
00303                 && sGodTools->mPanelObjectTools
00304                 && msg
00305                 && gAgent.isGodlike())
00306         {
00307                 LLPanelRegionTools* rtool = sGodTools->mPanelRegionTools;
00308                 sGodTools->mCurrentHost = host;
00309 
00310                 // store locally
00311                 rtool->setSimName(sim_name);
00312                 rtool->setEstateID(estate_id);
00313                 rtool->setParentEstateID(parent_estate_id);
00314                 rtool->setCheckFlags(region_flags);
00315                 rtool->setBillableFactor(billable_factor);
00316                 rtool->setPricePerMeter(price_per_meter);
00317                 rtool->setRedirectGridX(redirect_grid_x);
00318                 rtool->setRedirectGridY(redirect_grid_y);
00319                 rtool->enableAllWidgets();
00320 
00321                 LLPanelObjectTools *otool = sGodTools->mPanelObjectTools;
00322                 otool->setCheckFlags(region_flags);
00323                 otool->enableAllWidgets();
00324 
00325                 LLViewerRegion *regionp = gAgent.getRegion();
00326                 if ( !regionp )
00327                 {
00328                         // -1 implies non-existent
00329                         rtool->setGridPosX(-1);
00330                         rtool->setGridPosY(-1);
00331                 }
00332                 else
00333                 {
00334                         //compute the grid position of the region
00335                         LLVector3d global_pos = regionp->getPosGlobalFromRegion(LLVector3::zero);
00336                         S32 grid_pos_x = (S32) (global_pos.mdV[VX] / 256.0f);
00337                         S32 grid_pos_y = (S32) (global_pos.mdV[VY] / 256.0f);
00338 
00339                         rtool->setGridPosX(grid_pos_x);
00340                         rtool->setGridPosY(grid_pos_y);
00341                 }
00342         }
00343 }
00344 
00345 
00346 void LLFloaterGodTools::sendRegionInfoRequest()
00347 {
00348         if (mPanelRegionTools) mPanelRegionTools->clearAllWidgets();
00349         if (mPanelObjectTools) mPanelObjectTools->clearAllWidgets();
00350         mCurrentHost = LLHost::invalid;
00351         mUpdateTimer.reset();
00352 
00353         LLMessageSystem* msg = gMessageSystem;
00354         msg->newMessage("RequestRegionInfo");
00355         msg->nextBlock("AgentData");
00356         msg->addUUID("AgentID", gAgent.getID());
00357         msg->addUUID("SessionID", gAgent.getSessionID());
00358         gAgent.sendReliableMessage();
00359 }
00360 
00361 
00362 void LLFloaterGodTools::sendGodUpdateRegionInfo()
00363 {
00364         LLViewerRegion *regionp = gAgent.getRegion();
00365         if (gAgent.isGodlike()
00366                 && sGodTools->mPanelRegionTools
00367                 && regionp
00368                 && gAgent.getRegionHost() == mCurrentHost)
00369         {
00370                 LLMessageSystem *msg = gMessageSystem;
00371                 LLPanelRegionTools *rtool = sGodTools->mPanelRegionTools;
00372 
00373                 msg->newMessage("GodUpdateRegionInfo");
00374                 msg->nextBlockFast(_PREHASH_AgentData);
00375                 msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00376                 msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00377                 msg->nextBlockFast(_PREHASH_RegionInfo);
00378                 msg->addStringFast(_PREHASH_SimName, rtool->getSimName().c_str());
00379                 msg->addU32Fast(_PREHASH_EstateID, rtool->getEstateID());
00380                 msg->addU32Fast(_PREHASH_ParentEstateID, rtool->getParentEstateID());
00381                 msg->addU32Fast(_PREHASH_RegionFlags, computeRegionFlags());
00382                 msg->addF32Fast(_PREHASH_BillableFactor, rtool->getBillableFactor());
00383                 msg->addS32Fast(_PREHASH_PricePerMeter, rtool->getPricePerMeter());
00384                 msg->addS32Fast(_PREHASH_RedirectGridX, rtool->getRedirectGridX());
00385                 msg->addS32Fast(_PREHASH_RedirectGridY, rtool->getRedirectGridY());
00386 
00387                 gAgent.sendReliableMessage();
00388         }
00389 }
00390 
00391 //*****************************************************************************
00392 // LLPanelRegionTools
00393 //*****************************************************************************
00394 
00395 
00396 //   || Region |______________________________________
00397 //   |                                                |
00398 //   |  Sim Name: [________________________________]  |
00399 //   |  ^         ^                                   |
00400 //   |  LEFT      R1         Estate id:   [----]      |
00401 //   |                       Parent id:   [----]      |
00402 //   |  [X] Prelude          Grid Pos:     [--] [--]  |
00403 //   |  [X] Visible          Redirect Pos: [--] [--]  |
00404 //   |  [X] Damage           Bill Factor  [8_______]  |
00405 //   |  [X] Block Terraform  PricePerMeter[8_______]  |
00406 //   |                                    [Apply]     |
00407 //   |                                                |
00408 //   |  [Bake Terrain]            [Select Region]     |
00409 //   |  [Revert Terrain]          [Autosave Now]      |
00410 //   |  [Swap Terrain]                                | 
00411 //   |                                                            | 
00412 //   |________________________________________________|
00413 //      ^                    ^                     ^
00414 //      LEFT                 R2                   RIGHT
00415 
00416 
00417 // Floats because spinners only support floats. JC
00418 const F32 BILLABLE_FACTOR_DEFAULT = 1;
00419 const F32 BILLABLE_FACTOR_MIN = 0.0f;
00420 const F32 BILLABLE_FACTOR_MAX = 4.f;
00421 
00422 // floats because spinners only understand floats. JC
00423 const F32 PRICE_PER_METER_DEFAULT = 1.f;
00424 const F32 PRICE_PER_METER_MIN = 0.f;
00425 const F32 PRICE_PER_METER_MAX = 100.f;
00426 
00427 
00428 LLPanelRegionTools::LLPanelRegionTools(const std::string& title)
00429 :       LLPanel(title)
00430 {
00431 }
00432 
00433 BOOL LLPanelRegionTools::postBuild()
00434 {
00435         childSetCommitCallback("region name", onChangeAnything, this);
00436         childSetKeystrokeCallback("region name", onChangeSimName, this);
00437         childSetPrevalidate("region name", &LLLineEditor::prevalidatePrintableNotPipe);
00438 
00439         childSetCommitCallback("check prelude", onChangePrelude, this);
00440         childSetCommitCallback("check fixed sun", onChangeAnything, this);
00441         childSetCommitCallback("check reset home", onChangeAnything, this);
00442         childSetCommitCallback("check visible", onChangeAnything, this);
00443         childSetCommitCallback("check damage", onChangeAnything, this);
00444         childSetCommitCallback("block dwell", onChangeAnything, this);
00445         childSetCommitCallback("block terraform", onChangeAnything, this);
00446         childSetCommitCallback("allow transfer", onChangeAnything, this);
00447         childSetCommitCallback("is sandbox", onChangeAnything, this);
00448 
00449         childSetAction("Bake Terrain", onBakeTerrain, this);
00450         childSetAction("Revert Terrain", onRevertTerrain, this);
00451         childSetAction("Swap Terrain", onSwapTerrain, this);
00452 
00453         childSetCommitCallback("estate", onChangeAnything, this);
00454         childSetPrevalidate("estate", &LLLineEditor::prevalidatePositiveS32);
00455 
00456         childSetCommitCallback("parentestate", onChangeAnything, this);
00457         childSetPrevalidate("parentestate", &LLLineEditor::prevalidatePositiveS32);
00458         childDisable("parentestate");
00459 
00460         childSetCommitCallback("gridposx", onChangeAnything, this);
00461         childSetPrevalidate("gridposx", &LLLineEditor::prevalidatePositiveS32);
00462         childDisable("gridposx");
00463 
00464         childSetCommitCallback("gridposy", onChangeAnything, this);
00465         childSetPrevalidate("gridposy", &LLLineEditor::prevalidatePositiveS32);
00466         childDisable("gridposy");
00467 
00468         childSetCommitCallback("redirectx", onChangeAnything, this);
00469         childSetPrevalidate("redirectx", &LLLineEditor::prevalidatePositiveS32);
00470 
00471         childSetCommitCallback("redirecty", onChangeAnything, this);
00472         childSetPrevalidate("redirecty", &LLLineEditor::prevalidatePositiveS32);
00473 
00474         childSetCommitCallback("billable factor", onChangeAnything, this);
00475 
00476         childSetCommitCallback("land cost", onChangeAnything, this);
00477 
00478         childSetAction("Refresh", onRefresh, this);
00479         childSetAction("Apply", onApplyChanges, this);
00480 
00481         childSetAction("Select Region", onSelectRegion, this);
00482         childSetAction("Autosave now", onSaveState, this);
00483                          
00484         return TRUE;
00485 }
00486 
00487 // Destroys the object
00488 LLPanelRegionTools::~LLPanelRegionTools()
00489 {
00490         // base class will take care of everything
00491 }
00492 
00493 U32 LLPanelRegionTools::computeRegionFlags(U32 flags) const
00494 {
00495         flags &= getRegionFlagsMask();
00496         flags |= getRegionFlags();
00497         return flags;
00498 }
00499 
00500 
00501 void LLPanelRegionTools::refresh()
00502 {
00503 }
00504 
00505 
00506 void LLPanelRegionTools::clearAllWidgets()
00507 {
00508         // clear all widgets
00509         childSetValue("region name", "unknown");
00510         childSetFocus("region name", FALSE);
00511 
00512         childSetValue("check prelude", FALSE);
00513         childDisable("check prelude");
00514 
00515         childSetValue("check fixed sun", FALSE);
00516         childDisable("check fixed sun");
00517 
00518         childSetValue("check reset home", FALSE);
00519         childDisable("check reset home");
00520 
00521         childSetValue("check damage", FALSE);
00522         childDisable("check damage");
00523 
00524         childSetValue("check visible", FALSE);
00525         childDisable("check visible");
00526 
00527         childSetValue("block terraform", FALSE);
00528         childDisable("block terraform");
00529 
00530         childSetValue("block dwell", FALSE);
00531         childDisable("block dwell");
00532 
00533         childSetValue("is sandbox", FALSE);
00534         childDisable("is sandbox");
00535 
00536         childSetValue("billable factor", BILLABLE_FACTOR_DEFAULT);
00537         childDisable("billable factor");
00538 
00539         childSetValue("land cost", PRICE_PER_METER_DEFAULT);
00540         childDisable("land cost");
00541 
00542         childDisable("Apply");
00543         childDisable("Bake Terrain");
00544         childDisable("Autosave now");
00545 }
00546 
00547 
00548 void LLPanelRegionTools::enableAllWidgets()
00549 {
00550         // enable all of the widgets
00551         
00552         childEnable("check prelude");
00553         childEnable("check fixed sun");
00554         childEnable("check reset home");
00555         childEnable("check damage");
00556         childDisable("check visible"); // use estates to update...
00557         childEnable("block terraform");
00558         childEnable("block dwell");
00559         childEnable("is sandbox");
00560         
00561         childEnable("billable factor");
00562         childEnable("land cost");
00563 
00564         childDisable("Apply");  // don't enable this one
00565         childEnable("Bake Terrain");
00566         childEnable("Autosave now");
00567 }
00568 
00569 
00570 // static
00571 void LLPanelRegionTools::onSaveState(void* userdata)
00572 {
00573         if (gAgent.isGodlike())
00574         {
00575                 // Send message to save world state
00576                 gMessageSystem->newMessageFast(_PREHASH_StateSave);
00577                 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
00578                 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00579                 gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00580                 gMessageSystem->nextBlockFast(_PREHASH_DataBlock);
00581                 gMessageSystem->addStringFast(_PREHASH_Filename, NULL);
00582                 gAgent.sendReliableMessage();
00583         }
00584 }
00585 
00586 const std::string LLPanelRegionTools::getSimName() const
00587 {
00588         return childGetValue("region name");
00589 }
00590 
00591 U32 LLPanelRegionTools::getEstateID() const
00592 {
00593         U32 id = (U32)childGetValue("estate").asInteger();
00594         return id;
00595 }
00596 
00597 U32 LLPanelRegionTools::getParentEstateID() const
00598 {
00599         U32 id = (U32)childGetValue("parentestate").asInteger();
00600         return id;
00601 }
00602 
00603 S32 LLPanelRegionTools::getRedirectGridX() const
00604 {
00605         return childGetValue("redirectx").asInteger();
00606 }
00607 
00608 S32 LLPanelRegionTools::getRedirectGridY() const
00609 {
00610         return childGetValue("redirecty").asInteger();
00611 }
00612 
00613 S32 LLPanelRegionTools::getGridPosX() const
00614 {
00615         return childGetValue("gridposx").asInteger();
00616 }
00617 
00618 S32 LLPanelRegionTools::getGridPosY() const
00619 {
00620         return childGetValue("gridposy").asInteger();
00621 }
00622 
00623 U32 LLPanelRegionTools::getRegionFlags() const
00624 {
00625         U32 flags = 0x0;
00626         flags = childGetValue("check prelude").asBoolean()  
00627                                         ? set_prelude_flags(flags)
00628                                         : unset_prelude_flags(flags);
00629 
00630         // override prelude
00631         if (childGetValue("check fixed sun").asBoolean())
00632         {
00633                 flags |= REGION_FLAGS_SUN_FIXED;
00634         }
00635         if (childGetValue("check reset home").asBoolean())
00636         {
00637                 flags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT;
00638         }
00639         if (childGetValue("check visible").asBoolean())
00640         {
00641                 flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
00642         }
00643         if (childGetValue("check damage").asBoolean())
00644         {
00645                 flags |= REGION_FLAGS_ALLOW_DAMAGE;
00646         }
00647         if (childGetValue("block terraform").asBoolean())
00648         {
00649                 flags |= REGION_FLAGS_BLOCK_TERRAFORM;
00650         }
00651         if (childGetValue("block dwell").asBoolean())
00652         {
00653                 flags |= REGION_FLAGS_BLOCK_DWELL;
00654         }
00655         if (childGetValue("is sandbox").asBoolean())
00656         {
00657                 flags |= REGION_FLAGS_SANDBOX;
00658         }
00659         return flags;
00660 }
00661 
00662 U32 LLPanelRegionTools::getRegionFlagsMask() const
00663 {
00664         U32 flags = 0xffffffff;
00665         flags = childGetValue("check prelude").asBoolean()
00666                                 ? set_prelude_flags(flags)
00667                                 : unset_prelude_flags(flags);
00668 
00669         if (!childGetValue("check fixed sun").asBoolean())
00670         {
00671                 flags &= ~REGION_FLAGS_SUN_FIXED;
00672         }
00673         if (!childGetValue("check reset home").asBoolean())
00674         {
00675                 flags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT;
00676         }
00677         if (!childGetValue("check visible").asBoolean())
00678         {
00679                 flags &= ~REGION_FLAGS_EXTERNALLY_VISIBLE;
00680         }
00681         if (!childGetValue("check damage").asBoolean())
00682         {
00683                 flags &= ~REGION_FLAGS_ALLOW_DAMAGE;
00684         }
00685         if (!childGetValue("block terraform").asBoolean())
00686         {
00687                 flags &= ~REGION_FLAGS_BLOCK_TERRAFORM;
00688         }
00689         if (!childGetValue("block dwell").asBoolean())
00690         {
00691                 flags &= ~REGION_FLAGS_BLOCK_DWELL;
00692         }
00693         if (!childGetValue("is sandbox").asBoolean())
00694         {
00695                 flags &= ~REGION_FLAGS_SANDBOX;
00696         }
00697         return flags;
00698 }
00699 
00700 F32 LLPanelRegionTools::getBillableFactor() const
00701 {
00702         return (F32)childGetValue("billable factor").asReal();
00703 }
00704 
00705 S32 LLPanelRegionTools::getPricePerMeter() const
00706 {
00707         return childGetValue("land cost");
00708 }
00709 
00710 void LLPanelRegionTools::setSimName(char *name)
00711 {
00712         childSetValue("region name", name);
00713 }
00714 
00715 void LLPanelRegionTools::setEstateID(U32 id)
00716 {
00717         childSetValue("estate", (S32)id);
00718 }
00719 
00720 void LLPanelRegionTools::setGridPosX(S32 pos)
00721 {
00722         childSetValue("gridposx", pos);
00723 }
00724 
00725 void LLPanelRegionTools::setGridPosY(S32 pos)
00726 {
00727         childSetValue("gridposy", pos);
00728 }
00729 
00730 void LLPanelRegionTools::setRedirectGridX(S32 pos)
00731 {
00732         childSetValue("redirectx", pos);
00733 }
00734 
00735 void LLPanelRegionTools::setRedirectGridY(S32 pos)
00736 {
00737         childSetValue("redirecty", pos);
00738 }
00739 
00740 void LLPanelRegionTools::setParentEstateID(U32 id)
00741 {
00742         childSetValue("parentestate", (S32)id);
00743 }
00744 
00745 void LLPanelRegionTools::setCheckFlags(U32 flags)
00746 {
00747         childSetValue("check prelude", is_prelude(flags) ? TRUE : FALSE);
00748         childSetValue("check fixed sun", flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE);
00749         childSetValue("check reset home", flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT ? TRUE : FALSE);
00750         childSetValue("check damage", flags & REGION_FLAGS_ALLOW_DAMAGE ? TRUE : FALSE);
00751         childSetValue("check visible", flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE);
00752         childSetValue("block terraform", flags & REGION_FLAGS_BLOCK_TERRAFORM ? TRUE : FALSE);
00753         childSetValue("block dwell", flags & REGION_FLAGS_BLOCK_DWELL ? TRUE : FALSE);
00754         childSetValue("is sandbox", flags & REGION_FLAGS_SANDBOX ? TRUE : FALSE );
00755 }
00756 
00757 void LLPanelRegionTools::setBillableFactor(F32 billable_factor)
00758 {
00759         childSetValue("billable factor", billable_factor);
00760 }
00761 
00762 void LLPanelRegionTools::setPricePerMeter(S32 price)
00763 {
00764         childSetValue("land cost", price);
00765 }
00766 
00767 // static
00768 void LLPanelRegionTools::onChangeAnything(LLUICtrl* ctrl, void* userdata)
00769 {
00770         if (sGodTools 
00771                 && userdata
00772                 && gAgent.isGodlike())
00773         {
00774                 LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata;
00775                 region_tools->childEnable("Apply");
00776         }
00777 }
00778 
00779 // static
00780 void LLPanelRegionTools::onChangePrelude(LLUICtrl* ctrl, void* data)
00781 {
00782         // checking prelude auto-checks fixed sun
00783         LLPanelRegionTools* self = (LLPanelRegionTools*)data;
00784         if (self->childGetValue("check prelude").asBoolean())
00785         {
00786                 self->childSetValue("check fixed sun", TRUE);
00787                 self->childSetValue("check reset home", TRUE);
00788         }
00789         // pass on to default onChange handler
00790         onChangeAnything(ctrl, data);
00791 }
00792 
00793 // static
00794 void LLPanelRegionTools::onChangeSimName(LLLineEditor* caller, void* userdata )
00795 {
00796         if (sGodTools 
00797                 && userdata
00798                 && gAgent.isGodlike())
00799         {
00800                 LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata;
00801                 region_tools->childEnable("Apply");
00802         }
00803 }
00804 
00805 //static
00806 void LLPanelRegionTools::onRefresh(void* userdata)
00807 {
00808         LLViewerRegion *region = gAgent.getRegion();
00809         if (region 
00810                 && sGodTools 
00811                 && gAgent.isGodlike())
00812         {
00813                 sGodTools->sendRegionInfoRequest();
00814         }
00815 }
00816 
00817 // static
00818 void LLPanelRegionTools::onApplyChanges(void* userdata)
00819 {
00820         LLViewerRegion *region = gAgent.getRegion();
00821         if (region 
00822                 && sGodTools 
00823                 && userdata
00824                 && gAgent.isGodlike())
00825         {
00826                 LLPanelRegionTools* region_tools = (LLPanelRegionTools*) userdata;
00827 
00828                 region_tools->childDisable("Apply");
00829                 sGodTools->sendGodUpdateRegionInfo();
00830         }
00831 }
00832 
00833 // static 
00834 void LLPanelRegionTools::onBakeTerrain(void *userdata)
00835 {
00836         LLPanelRequestTools::sendRequest("terrain", "bake", gAgent.getRegionHost());
00837 }
00838 
00839 // static 
00840 void LLPanelRegionTools::onRevertTerrain(void *userdata)
00841 {
00842         LLPanelRequestTools::sendRequest("terrain", "revert", gAgent.getRegionHost());
00843 }
00844 
00845 // static 
00846 void LLPanelRegionTools::onSwapTerrain(void *userdata)
00847 {
00848         LLPanelRequestTools::sendRequest("terrain", "swap", gAgent.getRegionHost());
00849 }
00850 
00851 // static
00852 void LLPanelRegionTools::onSelectRegion(void* userdata)
00853 {
00854         llinfos << "LLPanelRegionTools::onSelectRegion" << llendl;
00855 
00856         if (!gWorldp)
00857         {
00858                 return;
00859         }
00860         LLViewerRegion *regionp = gWorldp->getRegionFromPosGlobal(gAgent.getPositionGlobal());
00861         if (!regionp)
00862         {
00863                 return;
00864         }
00865 
00866         LLVector3d north_east(REGION_WIDTH_METERS, REGION_WIDTH_METERS, 0);
00867         gParcelMgr->selectLand(regionp->getOriginGlobal(), 
00868                                                    regionp->getOriginGlobal() + north_east, FALSE);
00869         
00870 }
00871 
00872 
00873 //*****************************************************************************
00874 // Class LLPanelGridTools
00875 //*****************************************************************************
00876 
00877 //   || Grid   |_____________________________________
00878 //   |                                               |
00879 //   |                                               |
00880 //   |  Sun Phase: >--------[]---------< [________]  |
00881 //   |                                               |
00882 //   |  ^         ^                                  |
00883 //   |  LEFT      R1                                 |
00884 //   |                                               |
00885 //   |  [Kick all users]                             | 
00886 //   |                                               |
00887 //   |                                               |
00888 //   |                                               |
00889 //   |                                               |
00890 //   |                                               |
00891 //   |_______________________________________________|
00892 //      ^                                ^        ^
00893 //      LEFT                             R2       RIGHT
00894 
00895 const F32 HOURS_TO_RADIANS = (2.f*F_PI)/24.f;
00896 const char FLOATER_GRID_ADMIN_TITLE[] = "Grid Administration";
00897 
00898 
00899 LLPanelGridTools::LLPanelGridTools(const std::string& name) :
00900         LLPanel(name)
00901 {
00902 }
00903 
00904 // Destroys the object
00905 LLPanelGridTools::~LLPanelGridTools()
00906 {
00907 }
00908 
00909 BOOL LLPanelGridTools::postBuild()
00910 {
00911         childSetAction("Kick all users", onClickKickAll, this);
00912         childSetAction("Flush This Region's Map Visibility Caches", onClickFlushMapVisibilityCaches, this);
00913 
00914         return TRUE;
00915 }
00916 
00917 void LLPanelGridTools::refresh()
00918 {
00919 }
00920 
00921 
00922 // static
00923 void LLPanelGridTools::onClickKickAll(void* userdata)
00924 {
00925         LLPanelGridTools* self = (LLPanelGridTools*) userdata;
00926 
00927         S32 left, top;
00928         gFloaterView->getNewFloaterPosition(&left, &top);
00929         LLRect rect(left, top, left+400, top-300);
00930 
00931         gViewerWindow->alertXmlEditText("KickAllUsers", LLString::format_map_t(),
00932                                                                         NULL, NULL,
00933                                                                         LLPanelGridTools::confirmKick, self);
00934 }
00935 
00936 
00937 void LLPanelGridTools::confirmKick(S32 option, const LLString& text, void* userdata)
00938 {
00939         LLPanelGridTools* self = (LLPanelGridTools*) userdata;
00940 
00941         if (option == 0)
00942         {
00943                 self->mKickMessage = text;
00944                 gViewerWindow->alertXml("ConfirmKick",LLPanelGridTools::finishKick, self);
00945         }
00946 }
00947 
00948 
00949 // static
00950 void LLPanelGridTools::finishKick(S32 option, void* userdata)
00951 {
00952         LLPanelGridTools* self = (LLPanelGridTools*) userdata;
00953 
00954         if (option == 0)
00955         {
00956                 LLMessageSystem* msg = gMessageSystem;
00957 
00958                 msg->newMessageFast(_PREHASH_GodKickUser);
00959                 msg->nextBlockFast(_PREHASH_UserInfo);
00960                 msg->addUUIDFast(_PREHASH_GodID, gAgent.getID());
00961                 msg->addUUIDFast(_PREHASH_GodSessionID, gAgent.getSessionID());
00962                 msg->addUUIDFast(_PREHASH_AgentID,   LL_UUID_ALL_AGENTS );
00963                 msg->addU32("KickFlags", KICK_FLAGS_DEFAULT );
00964                 msg->addStringFast(_PREHASH_Reason,    self->mKickMessage.c_str() );
00965                 gAgent.sendReliableMessage();
00966         }
00967 }
00968 
00969 
00970 // static
00971 void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data)
00972 {
00973         gViewerWindow->alertXml("FlushMapVisibilityCaches",
00974                                                         flushMapVisibilityCachesConfirm, data);
00975 }
00976 
00977 // static
00978 void LLPanelGridTools::flushMapVisibilityCachesConfirm(S32 option, void* data)
00979 {
00980         if (option != 0) return;
00981 
00982         LLPanelGridTools* self = (LLPanelGridTools*)data;
00983         if (!self) return;
00984 
00985         // HACK: Send this as an EstateOwnerRequest so it gets routed
00986         // correctly by the spaceserver. JC
00987         LLMessageSystem* msg = gMessageSystem;
00988         msg->newMessage("EstateOwnerMessage");
00989         msg->nextBlockFast(_PREHASH_AgentData);
00990         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
00991         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
00992         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
00993         msg->nextBlock("MethodData");
00994         msg->addString("Method", "refreshmapvisibility");
00995         msg->addUUID("Invoice", LLUUID::null);
00996         msg->nextBlock("ParamList");
00997         msg->addString("Parameter", gAgent.getID().asString());
00998         gAgent.sendReliableMessage();
00999 }
01000 
01001 
01002 //*****************************************************************************
01003 // LLPanelObjectTools
01004 //*****************************************************************************
01005 
01006 
01007 //   || Object |_______________________________________________________
01008 //   |                                                                 |
01009 //   |  Sim Name: Foo                                                  |
01010 //   |  ^         ^                                                    |
01011 //   |  LEFT      R1                                                   |
01012 //   |                                                                 |
01013 //   |  [X] Disable Scripts [X] Disable Collisions [X] Disable Physics |
01014 //   |                                                  [ Apply  ]     |
01015 //   |                                                                 |
01016 //   |  [Set Target Avatar]     Avatar Name                                |
01017 //   |  [Delete Target's Objects on Public Land    ]                   |
01018 //   |  [Delete All Target's Objects                       ]                   |
01019 //   |  [Delete All Scripted Objects on Public Land]                   |
01020 //   |  [Get Top Colliders ]                                           |
01021 //   |  [Get Top Scripts   ]                                           |
01022 //   |_________________________________________________________________|
01023 //      ^                                         ^
01024 //      LEFT                                      RIGHT
01025 
01026 // Default constructor
01027 LLPanelObjectTools::LLPanelObjectTools(const std::string& title) 
01028 :       LLPanel(title), mTargetAvatar()
01029 {
01030 }
01031 
01032 // Destroys the object
01033 LLPanelObjectTools::~LLPanelObjectTools()
01034 {
01035         // base class will take care of everything
01036 }
01037 
01038 BOOL LLPanelObjectTools::postBuild()
01039 {
01040         childSetCommitCallback("disable scripts", onChangeAnything, this);
01041         childSetCommitCallback("disable collisions", onChangeAnything, this);
01042         childSetCommitCallback("disable physics", onChangeAnything, this);
01043 
01044         childSetAction("Apply", onApplyChanges, this);
01045 
01046         childSetAction("Set Target", onClickSet, this);
01047 
01048         childSetAction("Delete Target's Scripted Objects On Others Land", onClickDeletePublicOwnedBy, this);
01049         childSetAction("Delete Target's Scripted Objects On *Any* Land", onClickDeleteAllScriptedOwnedBy, this);
01050         childSetAction("Delete *ALL* Of Target's Objects", onClickDeleteAllOwnedBy, this);
01051 
01052         childSetAction("Get Top Colliders", onGetTopColliders, this);
01053         childSetAction("Get Top Scripts", onGetTopScripts, this);
01054         childSetAction("Scripts digest", onGetScriptDigest, this);
01055 
01056         return TRUE;
01057 }
01058 
01059 void LLPanelObjectTools::setTargetAvatar(const LLUUID &target_id)
01060 {
01061         mTargetAvatar = target_id;
01062         if (target_id.isNull())
01063         {
01064                 childSetValue("target_avatar_name", "(no target)");
01065         }
01066 } 
01067 
01068 
01069 void LLPanelObjectTools::refresh()
01070 {
01071         LLViewerRegion *regionp = gAgent.getRegion();
01072         if (regionp)
01073         {
01074                 childSetText("region name", regionp->getName());
01075         }
01076 }
01077 
01078 
01079 U32 LLPanelObjectTools::computeRegionFlags(U32 flags) const
01080 {
01081         if (childGetValue("disable scripts").asBoolean())
01082         {
01083                 flags |= REGION_FLAGS_SKIP_SCRIPTS;
01084         }
01085         else
01086         {
01087                 flags &= ~REGION_FLAGS_SKIP_SCRIPTS;
01088         }
01089         if (childGetValue("disable collisions").asBoolean())
01090         {
01091                 flags |= REGION_FLAGS_SKIP_COLLISIONS;
01092         }
01093         else
01094         {
01095                 flags &= ~REGION_FLAGS_SKIP_COLLISIONS;
01096         }
01097         if (childGetValue("disable physics").asBoolean())
01098         {
01099                 flags |= REGION_FLAGS_SKIP_PHYSICS;
01100         }
01101         else
01102         {
01103                 flags &= ~REGION_FLAGS_SKIP_PHYSICS;
01104         }
01105         return flags;
01106 }
01107 
01108 
01109 void LLPanelObjectTools::setCheckFlags(U32 flags)
01110 {
01111         childSetValue("disable scripts", flags & REGION_FLAGS_SKIP_SCRIPTS ? TRUE : FALSE);
01112         childSetValue("disable collisions", flags & REGION_FLAGS_SKIP_COLLISIONS ? TRUE : FALSE);
01113         childSetValue("disable physics", flags & REGION_FLAGS_SKIP_PHYSICS ? TRUE : FALSE);
01114 }
01115 
01116 
01117 void LLPanelObjectTools::clearAllWidgets()
01118 {
01119         childSetValue("disable scripts", FALSE);
01120         childDisable("disable scripts");
01121 
01122         childDisable("Apply");
01123         childDisable("Set Target");
01124         childDisable("Delete Target's Scripted Objects On Others Land");
01125         childDisable("Delete Target's Scripted Objects On *Any* Land");
01126         childDisable("Delete *ALL* Of Target's Objects");
01127 }
01128 
01129 
01130 void LLPanelObjectTools::enableAllWidgets()
01131 {
01132         childEnable("disable scripts");
01133 
01134         childDisable("Apply");  // don't enable this one
01135         childEnable("Set Target");
01136         childEnable("Delete Target's Scripted Objects On Others Land");
01137         childEnable("Delete Target's Scripted Objects On *Any* Land");
01138         childEnable("Delete *ALL* Of Target's Objects");
01139         childEnable("Get Top Colliders");
01140         childEnable("Get Top Scripts");
01141 }
01142 
01143 
01144 // static
01145 void LLPanelObjectTools::onGetTopColliders(void* userdata)
01146 {
01147         if (sGodTools 
01148                 && gAgent.isGodlike())
01149         {
01150                 LLFloaterTopObjects::show();
01151                 LLFloaterTopObjects::setMode(STAT_REPORT_TOP_COLLIDERS);
01152                 LLFloaterTopObjects::onRefresh(NULL);
01153         }
01154 }
01155 
01156 // static
01157 void LLPanelObjectTools::onGetTopScripts(void* userdata)
01158 {
01159         if (sGodTools 
01160                 && gAgent.isGodlike()) 
01161         {
01162                 LLFloaterTopObjects::show();
01163                 LLFloaterTopObjects::setMode(STAT_REPORT_TOP_SCRIPTS);
01164                 LLFloaterTopObjects::onRefresh(NULL);
01165         }
01166 }
01167 
01168 // static
01169 void LLPanelObjectTools::onGetScriptDigest(void* userdata)
01170 {
01171         if (sGodTools 
01172                 && gAgent.isGodlike())
01173         {
01174                 // get the list of scripts and number of occurences of each
01175                 // (useful for finding self-replicating objects)
01176                 LLPanelRequestTools::sendRequest("scriptdigest","0",gAgent.getRegionHost());
01177         }
01178 }
01179 
01180 void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata)
01181 {
01182         // Bring up view-modal dialog
01183         LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata;
01184         if (!panelp->mTargetAvatar.isNull())
01185         {
01186                 panelp->mSimWideDeletesFlags = 
01187                         SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY;
01188 
01189                 LLStringBase<char>::format_map_t args;
01190                 args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString();
01191 
01192                 gViewerWindow->alertXml( "GodDeleteAllScriptedPublicObjectsByUser",
01193                                                                 args,
01194                                                                 callbackSimWideDeletes, 
01195                                                                 userdata);
01196         }
01197 }
01198 
01199 // static
01200 void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata)
01201 {
01202         // Bring up view-modal dialog
01203         LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata;
01204         if (!panelp->mTargetAvatar.isNull())
01205         {
01206                 panelp->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY;
01207 
01208                 LLStringBase<char>::format_map_t args;
01209                 args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString();
01210 
01211                 gViewerWindow->alertXml( "GodDeleteAllScriptedObjectsByUser",
01212                                                                 args,
01213                                                                 callbackSimWideDeletes, 
01214                                                                 userdata);
01215         }
01216 }
01217 
01218 // static
01219 void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata)
01220 {
01221         // Bring up view-modal dialog
01222         LLPanelObjectTools* panelp = (LLPanelObjectTools*)userdata;
01223         if (!panelp->mTargetAvatar.isNull())
01224         {
01225                 panelp->mSimWideDeletesFlags = 0;
01226 
01227                 LLStringBase<char>::format_map_t args;
01228                 args["[AVATAR_NAME]"] = panelp->childGetValue("target_avatar_name").asString();
01229 
01230                 gViewerWindow->alertXml( "GodDeleteAllObjectsByUser",
01231                                                                 args,
01232                                                                 callbackSimWideDeletes, 
01233                                                                 userdata);
01234         }
01235 }
01236 
01237 // static
01238 void LLPanelObjectTools::callbackSimWideDeletes( S32 option, void* userdata )
01239 {
01240         if (option == 0)
01241         {
01242                 LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata;
01243                 if (!object_tools->mTargetAvatar.isNull())
01244                 {
01245                         send_sim_wide_deletes(object_tools->mTargetAvatar, 
01246                                                                   object_tools->mSimWideDeletesFlags);
01247                 }
01248         }
01249 }
01250 
01251 void LLPanelObjectTools::onClickSet(void* data)
01252 {
01253         LLPanelObjectTools* panelp = (LLPanelObjectTools*) data;
01254         // grandparent is a floater, which can have a dependent
01255         gFloaterView->getParentFloater(panelp)->addDependentFloater(LLFloaterAvatarPicker::show(callbackAvatarID, data));
01256 }
01257 
01258 void LLPanelObjectTools::onClickSetBySelection(void* data)
01259 {
01260         LLPanelObjectTools* panelp = (LLPanelObjectTools*) data;
01261         if (!panelp) return;
01262 
01263         const BOOL non_root_ok = TRUE; 
01264         LLSelectNode* node = gSelectMgr->getSelection()->getFirstRootNode(NULL, non_root_ok);
01265         if (!node) return;
01266 
01267         LLString owner_name;
01268         LLUUID owner_id;
01269         gSelectMgr->selectGetOwner(owner_id, owner_name);
01270 
01271         panelp->mTargetAvatar = owner_id;
01272         LLString name = "Object " + node->mName + " owned by " + owner_name;
01273         panelp->childSetValue("target_avatar_name", name);
01274 }
01275 
01276 // static
01277 void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names, const std::vector<LLUUID>& ids, void* data)
01278 {
01279         LLPanelObjectTools* object_tools = (LLPanelObjectTools*) data;
01280         if (ids.empty() || names.empty()) return;
01281         object_tools->mTargetAvatar = ids[0];
01282         object_tools->childSetValue("target_avatar_name", names[0]);
01283         object_tools->refresh();
01284 }
01285 
01286 
01287 // static
01288 void LLPanelObjectTools::onChangeAnything(LLUICtrl* ctrl, void* userdata)
01289 {
01290         if (sGodTools 
01291                 && userdata
01292                 && gAgent.isGodlike())
01293         {
01294                 LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata;
01295                 object_tools->childEnable("Apply");
01296         }
01297 }
01298 
01299 // static
01300 void LLPanelObjectTools::onApplyChanges(void* userdata)
01301 {
01302         LLViewerRegion *region = gAgent.getRegion();
01303         if (region 
01304                 && sGodTools 
01305                 && userdata
01306                 && gAgent.isGodlike())
01307         {
01308                 LLPanelObjectTools* object_tools = (LLPanelObjectTools*) userdata;
01309                 // TODO -- implement this
01310 
01311                 object_tools->childDisable("Apply");
01312                 sGodTools->sendGodUpdateRegionInfo();
01313         }
01314 }
01315 
01316 
01317 // --------------------
01318 // LLPanelRequestTools
01319 // --------------------
01320 
01321 const char SELECTION[] = "Selection";
01322 const char AGENT_REGION[] = "Agent Region";
01323 
01324 LLPanelRequestTools::LLPanelRequestTools(const std::string& name):
01325         LLPanel(name)
01326 {
01327 }
01328 
01329 LLPanelRequestTools::~LLPanelRequestTools()
01330 {
01331 }
01332 
01333 BOOL LLPanelRequestTools::postBuild()
01334 {
01335         childSetAction("Make Request", onClickRequest, this);
01336 
01337         refresh();
01338 
01339         return TRUE;
01340 }
01341 
01342 void LLPanelRequestTools::refresh()
01343 {
01344         std::string buffer = childGetValue("destination");
01345         LLCtrlListInterface *list = childGetListInterface("destination");
01346         if (!list) return;
01347 
01348         list->operateOnAll(LLCtrlListInterface::OP_DELETE);
01349         list->addSimpleElement(SELECTION);
01350         list->addSimpleElement(AGENT_REGION);
01351         for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin();
01352                  iter != gWorldp->mActiveRegionList.end(); ++iter)
01353         {
01354                 LLViewerRegion* regionp = *iter;
01355                 LLString name = regionp->getName();
01356                 if (!name.empty())
01357                 {
01358                         list->addSimpleElement(name);
01359                 }
01360         }
01361         if(!buffer.empty())
01362         {
01363                 list->selectByValue(buffer);
01364         }
01365         else
01366         {
01367                 list->selectByValue(SELECTION);
01368         }
01369 }
01370 
01371 
01372 // static
01373 void LLPanelRequestTools::sendRequest(const char *request, 
01374                                                                           const char *parameter, 
01375                                                                           const LLHost& host)
01376 {
01377         llinfos << "Sending request '" << request << "', '"
01378                         << parameter << "' to " << host << llendl;
01379         LLMessageSystem* msg = gMessageSystem;
01380         msg->newMessage("GodlikeMessage");
01381         msg->nextBlockFast(_PREHASH_AgentData);
01382         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01383         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01384         msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); //not used
01385         msg->nextBlock("MethodData");
01386         msg->addString("Method", request);
01387         msg->addUUID("Invoice", LLUUID::null);
01388         msg->nextBlock("ParamList");
01389         msg->addString("Parameter", parameter);
01390         msg->sendReliable(host);
01391 }
01392 
01393 // static
01394 void LLPanelRequestTools::onClickRequest(void* data)
01395 {
01396         LLPanelRequestTools* self = (LLPanelRequestTools*)data;
01397         const std::string dest = self->childGetValue("destination").asString();
01398         if(dest == SELECTION)
01399         {
01400                 std::string req = self->childGetValue("request");
01401                 req = req.substr(0, req.find_first_of(" "));
01402                 std::string param = self->childGetValue("parameter");
01403                 gSelectMgr->sendGodlikeRequest(req, param);
01404         }
01405         else if(dest == AGENT_REGION)
01406         {
01407                 self->sendRequest(gAgent.getRegionHost());
01408         }
01409         else
01410         {
01411                 // find region by name
01412                 for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin();
01413                          iter != gWorldp->mActiveRegionList.end(); ++iter)
01414                 {
01415                         LLViewerRegion* regionp = *iter;
01416                         if(dest == regionp->getName())
01417                         {
01418                                 // found it
01419                                 self->sendRequest(regionp->getHost());
01420                         }
01421                 }
01422         }
01423 }
01424 
01425 void terrain_download_done(void** data, S32 status, LLExtStat ext_status)
01426 {
01427         LLNotifyBox::showXml("TerrainDownloaded");
01428 }
01429 
01430 
01431 void test_callback(const LLTSCode status)
01432 {
01433         llinfos << "Test transfer callback returned!" << llendl;
01434 }
01435 
01436 
01437 void LLPanelRequestTools::sendRequest(const LLHost& host)
01438 {
01439 
01440         // intercept viewer local actions here
01441         std::string req = childGetValue("request");
01442         if (req == "terrain download")
01443         {
01444                 gXferManager->requestFile("terrain.raw", "terrain.raw", LL_PATH_NONE,
01445                                                                   host,
01446                                                                   FALSE,
01447                                                                   terrain_download_done,
01448                                                                   NULL);
01449         }
01450         else
01451         {
01452                 req = req.substr(0, req.find_first_of(" "));
01453                 sendRequest(req.c_str(), childGetValue("parameter").asString().c_str(), host);
01454         }
01455 }
01456 
01457 // Flags are SWD_ flags.
01458 void send_sim_wide_deletes(const LLUUID& owner_id, U32 flags)
01459 {
01460         LLMessageSystem* msg = gMessageSystem;
01461         msg->newMessageFast(_PREHASH_SimWideDeletes);
01462         msg->nextBlockFast(_PREHASH_AgentData);
01463         msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
01464         msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
01465         msg->nextBlockFast(_PREHASH_DataBlock);
01466         msg->addUUIDFast(_PREHASH_TargetID, owner_id);
01467         msg->addU32Fast(_PREHASH_Flags, flags);
01468         gAgent.sendReliableMessage();
01469 }

Generated on Thu Jul 1 06:08:33 2010 for Second Life Viewer by  doxygen 1.4.7