123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323 |
- /**
- * @file llfloatergodtools.cpp
- * @brief The on-screen rectangle with tool options.
- *
- * $LicenseInfo:firstyear=2002&license=viewergpl$
- *
- * Copyright (c) 2002-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include "llfloatergodtools.h"
- #include "llcombobox.h"
- #include "llfloater.h"
- #include "llhost.h"
- #include "lllineeditor.h"
- #include "llnotifications.h"
- #include "llregionflags.h"
- #include "lluictrl.h"
- #include "lluictrlfactory.h"
- #include "llxfermanager.h"
- #include "llmessage.h"
- #include "llagent.h"
- #include "llfloateravatarpicker.h"
- #include "llfloatertopobjects.h"
- //MK
- #include "mkrlinterface.h"
- //mk
- #include "llselectmgr.h"
- #include "llviewercontrol.h"
- #include "llviewerparcelmgr.h"
- #include "llviewerregion.h"
- #include "llworld.h"
- constexpr F32 SECONDS_BETWEEN_UPDATE_REQUESTS = 5.f;
- //*****************************************************************************
- // LLFloaterGodTools
- //*****************************************************************************
- LLFloaterGodTools::LLFloaterGodTools(const LLSD&)
- : mCurrentHost(LLHost()),
- mUpdateTimer()
- {
- LLCallbackMap::map_t factory_map;
- factory_map["grid"] = LLCallbackMap(createPanelGrid, this);
- factory_map["region"] = LLCallbackMap(createPanelRegion, this);
- factory_map["objects"] = LLCallbackMap(createPanelObjects, this);
- factory_map["request"] = LLCallbackMap(createPanelRequest, this);
- LLUICtrlFactory::getInstance()->buildFloater(this, "floater_god_tools.xml",
- &factory_map);
- }
- ///virtual
- bool LLFloaterGodTools::postBuild()
- {
- childSetTabChangeCallback("GodTools Tabs", "grid", onTabChanged, this);
- childSetTabChangeCallback("GodTools Tabs", "region", onTabChanged, this);
- childSetTabChangeCallback("GodTools Tabs", "objects", onTabChanged, this);
- childSetTabChangeCallback("GodTools Tabs", "request", onTabChanged, this);
- childShowTab("GodTools Tabs", "region");
- center();
- setFocus(true);
- return true;
- }
- //virtual
- void LLFloaterGodTools::onOpen()
- {
- LLPanel* panel = childGetVisibleTab("GodTools Tabs");
- panel->setFocus(true);
- if (mPanelObjectTools)
- {
- mPanelObjectTools->setTargetAvatar(LLUUID::null);
- }
- if (gAgent.getRegionHost() != mCurrentHost)
- {
- // we're in a new region
- sendRegionInfoRequest();
- }
- }
- //static
- void* LLFloaterGodTools::createPanelGrid(void* userdata)
- {
- return new LLPanelGridTools("grid");
- }
- //static
- void* LLFloaterGodTools::createPanelRegion(void* userdata)
- {
- LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
- self->mPanelRegionTools = new LLPanelRegionTools("region");
- return self->mPanelRegionTools;
- }
- //static
- void* LLFloaterGodTools::createPanelObjects(void* userdata)
- {
- LLFloaterGodTools* self = (LLFloaterGodTools*)userdata;
- self->mPanelObjectTools = new LLPanelObjectTools("objects");
- return self->mPanelObjectTools;
- }
- //static
- void* LLFloaterGodTools::createPanelRequest(void* userdata)
- {
- return new LLPanelRequestTools("region");
- }
- U64 LLFloaterGodTools::computeRegionFlags() const
- {
- if (!gAgent.getRegion()) return 0;
- U64 flags = gAgent.getRegion()->getRegionFlags();
- if (mPanelRegionTools) flags = mPanelRegionTools->computeRegionFlags(flags);
- if (mPanelObjectTools) flags = mPanelObjectTools->computeRegionFlags(flags);
- return flags;
- }
- // virtual
- void LLFloaterGodTools::draw()
- {
- if (mCurrentHost.isInvalid())
- {
- if (mUpdateTimer.getElapsedTimeF32() > SECONDS_BETWEEN_UPDATE_REQUESTS)
- {
- sendRegionInfoRequest();
- }
- }
- else if (gAgent.getRegionHost() != mCurrentHost)
- {
- sendRegionInfoRequest();
- }
- LLFloater::draw();
- }
- //static
- void LLFloaterGodTools::onTabChanged(void* data, bool from_click)
- {
- LLPanel* panel = (LLPanel*)data;
- if (panel)
- {
- panel->setFocus(true);
- }
- }
- //static
- void LLFloaterGodTools::updateFromRegionInfo()
- {
- LLFloaterGodTools* self = findInstance();
- // Push values to god tools, if available
- if (self && self->mPanelRegionTools && self->mPanelObjectTools &&
- gAgent.isGodlike())
- {
- LLPanelRegionTools* rtool = self->mPanelRegionTools;
- // We know we are in the agent's region, else this method would not
- // have been called by LLViewerRegion::processRegionInfo()
- self->mCurrentHost = gAgent.getRegionHost();
- // Store locally
- rtool->setSimName(LLRegionInfoModel::sSimName);
- rtool->setEstateID(LLRegionInfoModel::sEstateID);
- rtool->setParentEstateID(LLRegionInfoModel::sParentEstateID);
- rtool->setCheckFlags(LLRegionInfoModel::sRegionFlags);
- rtool->setBillableFactor(LLRegionInfoModel::sBillableFactor);
- rtool->setPricePerMeter(LLRegionInfoModel::sPricePerMeter);
- rtool->setRedirectGridX(LLRegionInfoModel::sRedirectGridX);
- rtool->setRedirectGridY(LLRegionInfoModel::sRedirectGridY);
- rtool->enableAllWidgets();
- LLPanelObjectTools* otool = self->mPanelObjectTools;
- otool->setCheckFlags(LLRegionInfoModel::sRegionFlags);
- otool->enableAllWidgets();
- LLViewerRegion* regionp = gAgent.getRegion();
- if (!regionp)
- {
- // -1 implies non-existent
- rtool->setGridPosX(-1);
- rtool->setGridPosY(-1);
- }
- else
- {
- // Compute the grid position of the region
- LLVector3d global_pos =
- regionp->getPosGlobalFromRegion(LLVector3::zero);
- S32 grid_pos_x = (S32) (global_pos.mdV[VX] / 256.0f);
- S32 grid_pos_y = (S32) (global_pos.mdV[VY] / 256.0f);
- rtool->setGridPosX(grid_pos_x);
- rtool->setGridPosY(grid_pos_y);
- }
- }
- }
- void LLFloaterGodTools::sendRegionInfoRequest()
- {
- if (mPanelRegionTools)
- {
- mPanelRegionTools->clearAllWidgets();
- }
- if (mPanelObjectTools)
- {
- mPanelObjectTools->clearAllWidgets();
- }
- mCurrentHost = LLHost();
- mUpdateTimer.reset();
- LLMessageSystem* msg = gMessageSystemp;
- if (msg)
- {
- msg->newMessage(_PREHASH_RequestRegionInfo);
- msg->nextBlock(_PREHASH_AgentData);
- msg->addUUID(_PREHASH_AgentID, gAgentID);
- msg->addUUID(_PREHASH_SessionID, gAgentSessionID);
- gAgent.sendReliableMessage();
- }
- }
- void LLFloaterGodTools::sendGodUpdateRegionInfo()
- {
- if (mPanelRegionTools && gAgent.isGodlike() && gAgent.getRegion() &&
- gAgent.getRegionHost() == mCurrentHost)
- {
- U64 region_flags = computeRegionFlags();
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessage("GodUpdateRegionInfo");
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
- msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
- msg->nextBlockFast(_PREHASH_RegionInfo);
- msg->addStringFast(_PREHASH_SimName,
- mPanelRegionTools->getSimName());
- msg->addU32Fast(_PREHASH_EstateID, mPanelRegionTools->getEstateID());
- msg->addU32Fast(_PREHASH_ParentEstateID,
- mPanelRegionTools->getParentEstateID());
- // Legacy flags
- msg->addU32Fast(_PREHASH_RegionFlags, U32(region_flags));
- msg->addF32Fast(_PREHASH_BillableFactor,
- mPanelRegionTools->getBillableFactor());
- msg->addS32Fast(_PREHASH_PricePerMeter,
- mPanelRegionTools->getPricePerMeter());
- msg->addS32Fast(_PREHASH_RedirectGridX,
- mPanelRegionTools->getRedirectGridX());
- msg->addS32Fast(_PREHASH_RedirectGridY,
- mPanelRegionTools->getRedirectGridY());
- msg->nextBlockFast(_PREHASH_RegionInfo2);
- msg->addU64Fast(_PREHASH_RegionFlagsExtended, region_flags);
- gAgent.sendReliableMessage();
- }
- }
- //*****************************************************************************
- // LLPanelRegionTools
- //*****************************************************************************
- // || Region |______________________________________
- // | |
- // | Sim Name: [________________________________] |
- // | ^ ^ |
- // | LEFT R1 Estate id: [----] |
- // | Parent id: [----] |
- // | [X] Prelude Grid Pos: [--] [--] |
- // | [X] Visible Redirect Pos: [--] [--] |
- // | [X] Damage Bill Factor [8_______] |
- // | [X] Block Terraform PricePerMeter[8_______] |
- // | [Apply] |
- // | |
- // | [Bake Terrain] [Select Region] |
- // | [Revert Terrain] [Autosave Now] |
- // | [Swap Terrain] |
- // | |
- // |________________________________________________|
- // ^ ^ ^
- // LEFT R2 RIGHT
- // Floats because spinners only support floats. JC
- constexpr F32 BILLABLE_FACTOR_DEFAULT = 1.f;
- constexpr F32 PRICE_PER_METER_DEFAULT = 1.f;
- LLPanelRegionTools::LLPanelRegionTools(const std::string& title)
- : LLPanel(title)
- {
- }
- //virtual
- bool LLPanelRegionTools::postBuild()
- {
- childSetCommitCallback("region name", onChangeAnything, this);
- childSetKeystrokeCallback("region name", onChangeSimName, this);
- childSetPrevalidate("region name", &LLLineEditor::prevalidatePrintableNotPipe);
- childSetCommitCallback("check prelude", onChangePrelude, this);
- childSetCommitCallback("check fixed sun", onChangeAnything, this);
- childSetCommitCallback("check reset home", onChangeAnything, this);
- childSetCommitCallback("check visible", onChangeAnything, this);
- childSetCommitCallback("check damage", onChangeAnything, this);
- childSetCommitCallback("block dwell", onChangeAnything, this);
- childSetCommitCallback("block terraform", onChangeAnything, this);
- childSetCommitCallback("is sandbox", onChangeAnything, this);
- childSetAction("Bake Terrain", onBakeTerrain, this);
- childSetAction("Revert Terrain", onRevertTerrain, this);
- childSetAction("Swap Terrain", onSwapTerrain, this);
- childSetCommitCallback("estate", onChangeAnything, this);
- childSetPrevalidate("estate", &LLLineEditor::prevalidatePositiveS32);
- childSetCommitCallback("parentestate", onChangeAnything, this);
- childSetPrevalidate("parentestate", &LLLineEditor::prevalidatePositiveS32);
- childDisable("parentestate");
- childSetCommitCallback("gridposx", onChangeAnything, this);
- childSetPrevalidate("gridposx", &LLLineEditor::prevalidatePositiveS32);
- childDisable("gridposx");
- childSetCommitCallback("gridposy", onChangeAnything, this);
- childSetPrevalidate("gridposy", &LLLineEditor::prevalidatePositiveS32);
- childDisable("gridposy");
- childSetCommitCallback("redirectx", onChangeAnything, this);
- childSetPrevalidate("redirectx", &LLLineEditor::prevalidatePositiveS32);
- childSetCommitCallback("redirecty", onChangeAnything, this);
- childSetPrevalidate("redirecty", &LLLineEditor::prevalidatePositiveS32);
- childSetCommitCallback("billable factor", onChangeAnything, this);
- childSetCommitCallback("land cost", onChangeAnything, this);
- childSetAction("Refresh", onRefresh, this);
- childSetAction("Apply", onApplyChanges, this);
- childSetAction("Select Region", onSelectRegion, this);
- childSetAction("Autosave now", onSaveState, this);
- return true;
- }
- U64 LLPanelRegionTools::computeRegionFlags(U64 flags) const
- {
- flags &= getRegionFlagsMask();
- flags |= getRegionFlags();
- return flags;
- }
- void LLPanelRegionTools::clearAllWidgets()
- {
- // clear all widgets
- childSetValue("region name", "unknown");
- childSetFocus("region name", false);
- childSetValue("check prelude", false);
- childDisable("check prelude");
- childSetValue("check fixed sun", false);
- childDisable("check fixed sun");
- childSetValue("check reset home", false);
- childDisable("check reset home");
- childSetValue("check damage", false);
- childDisable("check damage");
- childSetValue("check visible", false);
- childDisable("check visible");
- childSetValue("block terraform", false);
- childDisable("block terraform");
- childSetValue("block dwell", false);
- childDisable("block dwell");
- childSetValue("is sandbox", false);
- childDisable("is sandbox");
- childSetValue("billable factor", BILLABLE_FACTOR_DEFAULT);
- childDisable("billable factor");
- childSetValue("land cost", PRICE_PER_METER_DEFAULT);
- childDisable("land cost");
- childDisable("Apply");
- childDisable("Bake Terrain");
- childDisable("Autosave now");
- }
- void LLPanelRegionTools::enableAllWidgets()
- {
- // enable all of the widgets
- childEnable("check prelude");
- childEnable("check fixed sun");
- childEnable("check reset home");
- childEnable("check damage");
- childDisable("check visible"); // use estates to update...
- childEnable("block terraform");
- childEnable("block dwell");
- childEnable("is sandbox");
- childEnable("billable factor");
- childEnable("land cost");
- childDisable("Apply"); // don't enable this one
- childEnable("Bake Terrain");
- childEnable("Autosave now");
- }
- //static
- void LLPanelRegionTools::onSaveState(void* userdata)
- {
- if (gAgent.isGodlike())
- {
- // Send message to save world state
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessageFast(_PREHASH_StateSave);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
- msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
- msg->nextBlockFast(_PREHASH_DataBlock);
- msg->addStringFast(_PREHASH_Filename, NULL);
- gAgent.sendReliableMessage();
- }
- }
- const std::string LLPanelRegionTools::getSimName() const
- {
- return childGetValue("region name");
- }
- U32 LLPanelRegionTools::getEstateID() const
- {
- U32 id = (U32)childGetValue("estate").asInteger();
- return id;
- }
- U32 LLPanelRegionTools::getParentEstateID() const
- {
- U32 id = (U32)childGetValue("parentestate").asInteger();
- return id;
- }
- S32 LLPanelRegionTools::getRedirectGridX() const
- {
- return childGetValue("redirectx").asInteger();
- }
- S32 LLPanelRegionTools::getRedirectGridY() const
- {
- return childGetValue("redirecty").asInteger();
- }
- S32 LLPanelRegionTools::getGridPosX() const
- {
- return childGetValue("gridposx").asInteger();
- }
- S32 LLPanelRegionTools::getGridPosY() const
- {
- return childGetValue("gridposy").asInteger();
- }
- U64 LLPanelRegionTools::getRegionFlags() const
- {
- U64 flags = 0x0;
- flags = childGetValue("check prelude").asBoolean() ? set_prelude_flags(flags)
- : unset_prelude_flags(flags);
- // override prelude
- if (childGetValue("check fixed sun").asBoolean())
- {
- flags |= REGION_FLAGS_SUN_FIXED;
- }
- if (childGetValue("check reset home").asBoolean())
- {
- flags |= REGION_FLAGS_RESET_HOME_ON_TELEPORT;
- }
- if (childGetValue("check visible").asBoolean())
- {
- flags |= REGION_FLAGS_EXTERNALLY_VISIBLE;
- }
- if (childGetValue("check damage").asBoolean())
- {
- flags |= REGION_FLAGS_ALLOW_DAMAGE;
- }
- if (childGetValue("block terraform").asBoolean())
- {
- flags |= REGION_FLAGS_BLOCK_TERRAFORM;
- }
- if (childGetValue("block dwell").asBoolean())
- {
- flags |= REGION_FLAGS_BLOCK_DWELL;
- }
- if (childGetValue("is sandbox").asBoolean())
- {
- flags |= REGION_FLAGS_SANDBOX;
- }
- return flags;
- }
- U64 LLPanelRegionTools::getRegionFlagsMask() const
- {
- U64 flags = 0xFFFFFFFFFFFFFFFFULL;
- flags = childGetValue("check prelude").asBoolean() ? set_prelude_flags(flags)
- : unset_prelude_flags(flags);
- if (!childGetValue("check fixed sun").asBoolean())
- {
- flags &= ~REGION_FLAGS_SUN_FIXED;
- }
- if (!childGetValue("check reset home").asBoolean())
- {
- flags &= ~REGION_FLAGS_RESET_HOME_ON_TELEPORT;
- }
- if (!childGetValue("check visible").asBoolean())
- {
- flags &= ~REGION_FLAGS_EXTERNALLY_VISIBLE;
- }
- if (!childGetValue("check damage").asBoolean())
- {
- flags &= ~REGION_FLAGS_ALLOW_DAMAGE;
- }
- if (!childGetValue("block terraform").asBoolean())
- {
- flags &= ~REGION_FLAGS_BLOCK_TERRAFORM;
- }
- if (!childGetValue("block dwell").asBoolean())
- {
- flags &= ~REGION_FLAGS_BLOCK_DWELL;
- }
- if (!childGetValue("is sandbox").asBoolean())
- {
- flags &= ~REGION_FLAGS_SANDBOX;
- }
- return flags;
- }
- F32 LLPanelRegionTools::getBillableFactor() const
- {
- return (F32)childGetValue("billable factor").asReal();
- }
- S32 LLPanelRegionTools::getPricePerMeter() const
- {
- return childGetValue("land cost");
- }
- void LLPanelRegionTools::setSimName(const std::string& name)
- {
- //MK
- if (gRLenabled && gRLInterface.mContainsShowloc)
- {
- childSetVisible("region name", false);
- }
- else
- {
- childSetVisible("region name", true);
- }
- //mk
- childSetValue("region name", name);
- }
- void LLPanelRegionTools::setEstateID(U32 id)
- {
- childSetValue("estate", (S32)id);
- }
- void LLPanelRegionTools::setGridPosX(S32 pos)
- {
- childSetValue("gridposx", pos);
- }
- void LLPanelRegionTools::setGridPosY(S32 pos)
- {
- childSetValue("gridposy", pos);
- }
- void LLPanelRegionTools::setRedirectGridX(S32 pos)
- {
- childSetValue("redirectx", pos);
- }
- void LLPanelRegionTools::setRedirectGridY(S32 pos)
- {
- childSetValue("redirecty", pos);
- }
- void LLPanelRegionTools::setParentEstateID(U32 id)
- {
- childSetValue("parentestate", (S32)id);
- }
- void LLPanelRegionTools::setCheckFlags(U64 flags)
- {
- childSetValue("check prelude", is_prelude(flags));
- childSetValue("check fixed sun", (flags & REGION_FLAGS_SUN_FIXED) != 0);
- childSetValue("check reset home",
- (flags & REGION_FLAGS_RESET_HOME_ON_TELEPORT) != 0);
- childSetValue("check damage", (flags & REGION_FLAGS_ALLOW_DAMAGE) != 0);
- childSetValue("check visible",
- (flags & REGION_FLAGS_EXTERNALLY_VISIBLE) != 0);
- childSetValue("block terraform",
- (flags & REGION_FLAGS_BLOCK_TERRAFORM) != 0);
- childSetValue("block dwell", (flags & REGION_FLAGS_BLOCK_DWELL) != 0);
- childSetValue("is sandbox", (flags & REGION_FLAGS_SANDBOX) != 0);
- }
- void LLPanelRegionTools::setBillableFactor(F32 billable_factor)
- {
- childSetValue("billable factor", billable_factor);
- }
- void LLPanelRegionTools::setPricePerMeter(S32 price)
- {
- childSetValue("land cost", price);
- }
- //static
- void LLPanelRegionTools::onChangeAnything(LLUICtrl* ctrl, void* userdata)
- {
- LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
- if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- self->childEnable("Apply");
- }
- }
- //static
- void LLPanelRegionTools::onChangePrelude(LLUICtrl* ctrl, void* userdata)
- {
- // checking prelude auto-checks fixed sun
- LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
- if (self && self->childGetValue("check prelude").asBoolean())
- {
- self->childSetValue("check fixed sun", true);
- self->childSetValue("check reset home", true);
- }
- // pass on to default onChange handler
- onChangeAnything(ctrl, userdata);
- }
- //static
- void LLPanelRegionTools::onChangeSimName(LLLineEditor* caller, void* userdata)
- {
- LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
- if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- self->childEnable("Apply");
- }
- }
- //static
- void LLPanelRegionTools::onRefresh(void*)
- {
- LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
- if (fgt && gAgent.getRegion() && gAgent.isGodlike())
- {
- fgt->sendRegionInfoRequest();
- }
- }
- //static
- void LLPanelRegionTools::onApplyChanges(void* userdata)
- {
- LLPanelRegionTools* self = (LLPanelRegionTools*)userdata;
- LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
- if (self && fgt && gAgent.getRegion() && gAgent.isGodlike())
- {
- self->childDisable("Apply");
- fgt->sendGodUpdateRegionInfo();
- }
- }
- //static
- void LLPanelRegionTools::onBakeTerrain(void* userdata)
- {
- LLPanelRequestTools::sendRequest("terrain", "bake",
- gAgent.getRegionHost());
- }
- //static
- void LLPanelRegionTools::onRevertTerrain(void* userdata)
- {
- LLPanelRequestTools::sendRequest("terrain", "revert",
- gAgent.getRegionHost());
- }
- //static
- void LLPanelRegionTools::onSwapTerrain(void* userdata)
- {
- LLPanelRequestTools::sendRequest("terrain", "swap",
- gAgent.getRegionHost());
- }
- //static
- void LLPanelRegionTools::onSelectRegion(void* userdata)
- {
- LLViewerRegion* regionp =
- gWorld.getRegionFromPosGlobal(gAgent.getPositionGlobal());
- if (regionp)
- {
- LLVector3d origin = regionp->getOriginGlobal();
- LLVector3d north_east(REGION_WIDTH_METERS, REGION_WIDTH_METERS, 0);
- gViewerParcelMgr.selectLand(origin, origin + north_east, false);
- }
- }
- //*****************************************************************************
- // Class LLPanelGridTools
- //*****************************************************************************
- // || Grid |_____________________________________
- // | |
- // | |
- // | Sun Phase: >--------[]---------< [________] |
- // | |
- // | ^ ^ |
- // | LEFT R1 |
- // | |
- // | [Kick all users] |
- // | |
- // | |
- // | |
- // | |
- // | |
- // |_______________________________________________|
- // ^ ^ ^
- // LEFT R2 RIGHT
- LLPanelGridTools::LLPanelGridTools(const std::string& name)
- : LLPanel(name)
- {
- }
- //virtual
- bool LLPanelGridTools::postBuild()
- {
- childSetAction("Kick all users", onClickKickAll, this);
- childSetAction("Flush This Region's Map Visibility Caches",
- onClickFlushMapVisibilityCaches, this);
- return true;
- }
- //static
- void LLPanelGridTools::onClickKickAll(void* userdata)
- {
- gNotifications.add("KickAllUsers", LLSD(), LLSD(),
- LLPanelGridTools::confirmKick);
- }
- bool LLPanelGridTools::confirmKick(const LLSD& notification,
- const LLSD& response)
- {
- if (LLNotification::getSelectedOption(notification, response) == 0)
- {
- LLSD payload;
- payload["kick_message"] = response["message"].asString();
- gNotifications.add("ConfirmKick", LLSD(), payload, finishKick);
- }
- return false;
- }
- //static
- bool LLPanelGridTools::finishKick(const LLSD& notification,
- const LLSD& response)
- {
- if (LLNotification::getSelectedOption(notification, response) == 0)
- {
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessageFast(_PREHASH_GodKickUser);
- msg->nextBlockFast(_PREHASH_UserInfo);
- msg->addUUIDFast(_PREHASH_GodID, gAgentID);
- msg->addUUIDFast(_PREHASH_GodSessionID, gAgentSessionID);
- msg->addUUIDFast(_PREHASH_AgentID, LL_UUID_ALL_AGENTS);
- msg->addU32("KickFlags", KICK_FLAGS_DEFAULT );
- msg->addStringFast(_PREHASH_Reason,
- notification["payload"]["kick_message"].asString());
- gAgent.sendReliableMessage();
- }
- return false;
- }
- //static
- void LLPanelGridTools::onClickFlushMapVisibilityCaches(void* data)
- {
- gNotifications.add("FlushMapVisibilityCaches", LLSD(), LLSD(),
- flushMapVisibilityCachesConfirm);
- }
- //static
- bool LLPanelGridTools::flushMapVisibilityCachesConfirm(const LLSD& notification,
- const LLSD& response)
- {
- S32 option = LLNotification::getSelectedOption(notification, response);
- if (option != 0) return false;
- // HACK: Send this as an EstateOwnerRequest so it gets routed
- // correctly by the spaceserver. JC
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessage("EstateOwnerMessage");
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
- msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
- msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
- msg->nextBlock("MethodData");
- msg->addString("Method", "refreshmapvisibility");
- msg->addUUID("Invoice", LLUUID::null);
- msg->nextBlock("ParamList");
- msg->addString("Parameter", gAgentID.asString());
- gAgent.sendReliableMessage();
- return false;
- }
- //*****************************************************************************
- // LLPanelObjectTools
- //*****************************************************************************
- // || Object |_______________________________________________________
- // | |
- // | Sim Name: Foo |
- // | ^ ^ |
- // | LEFT R1 |
- // | |
- // | [X] Disable Scripts [X] Disable Collisions [X] Disable Physics |
- // | [ Apply ] |
- // | |
- // | [Set Target Avatar] Avatar Name |
- // | [Delete Target's Objects on Public Land ] |
- // | [Delete All Target's Objects ] |
- // | [Delete All Scripted Objects on Public Land] |
- // | [Get Top Colliders ] |
- // | [Get Top Scripts ] |
- // |_________________________________________________________________|
- // ^ ^
- // LEFT RIGHT
- // Default constructor
- LLPanelObjectTools::LLPanelObjectTools(const std::string& name)
- : LLPanel(name),
- mTargetAvatar()
- {
- }
- //virtual
- bool LLPanelObjectTools::postBuild()
- {
- childSetCommitCallback("disable scripts", onChangeAnything, this);
- childSetCommitCallback("disable collisions", onChangeAnything, this);
- childSetCommitCallback("disable physics", onChangeAnything, this);
- childSetAction("Apply", onApplyChanges, this);
- childSetAction("Set Target", onClickSet, this);
- childSetAction("Delete Target's Scripted Objects On Others Land",
- onClickDeletePublicOwnedBy, this);
- childSetAction("Delete Target's Scripted Objects On *Any* Land",
- onClickDeleteAllScriptedOwnedBy, this);
- childSetAction("Delete *ALL* Of Target's Objects",
- onClickDeleteAllOwnedBy, this);
- childSetAction("Get Top Colliders", onGetTopColliders, this);
- childSetAction("Get Top Scripts", onGetTopScripts, this);
- childSetAction("Scripts digest", onGetScriptDigest, this);
- return true;
- }
- void LLPanelObjectTools::setTargetAvatar(const LLUUID& target_id)
- {
- mTargetAvatar = target_id;
- if (target_id.isNull())
- {
- childSetValue("target_avatar_name", "(no target)");
- }
- }
- //virtual
- void LLPanelObjectTools::refresh()
- {
- //MK
- if (gRLenabled && gRLInterface.mContainsShowloc)
- {
- childSetVisible("region name", false);
- }
- else
- {
- childSetVisible("region name", true);
- }
- //mk
- LLViewerRegion *regionp = gAgent.getRegion();
- if (regionp)
- {
- childSetText("region name", regionp->getName());
- }
- }
- U64 LLPanelObjectTools::computeRegionFlags(U64 flags) const
- {
- if (childGetValue("disable scripts").asBoolean())
- {
- flags |= REGION_FLAGS_SKIP_SCRIPTS;
- }
- else
- {
- flags &= ~REGION_FLAGS_SKIP_SCRIPTS;
- }
- if (childGetValue("disable collisions").asBoolean())
- {
- flags |= REGION_FLAGS_SKIP_COLLISIONS;
- }
- else
- {
- flags &= ~REGION_FLAGS_SKIP_COLLISIONS;
- }
- if (childGetValue("disable physics").asBoolean())
- {
- flags |= REGION_FLAGS_SKIP_PHYSICS;
- }
- else
- {
- flags &= ~REGION_FLAGS_SKIP_PHYSICS;
- }
- return flags;
- }
- void LLPanelObjectTools::setCheckFlags(U64 flags)
- {
- childSetValue("disable scripts", (flags & REGION_FLAGS_SKIP_SCRIPTS) != 0);
- childSetValue("disable collisions",
- (flags & REGION_FLAGS_SKIP_COLLISIONS) != 0);
- childSetValue("disable physics", (flags & REGION_FLAGS_SKIP_PHYSICS) != 0);
- }
- void LLPanelObjectTools::clearAllWidgets()
- {
- childSetValue("disable scripts", false);
- childDisable("disable scripts");
- childDisable("Apply");
- childDisable("Set Target");
- childDisable("Delete Target's Scripted Objects On Others Land");
- childDisable("Delete Target's Scripted Objects On *Any* Land");
- childDisable("Delete *ALL* Of Target's Objects");
- }
- void LLPanelObjectTools::enableAllWidgets()
- {
- childEnable("disable scripts");
- childDisable("Apply"); // don't enable this one
- childEnable("Set Target");
- childEnable("Delete Target's Scripted Objects On Others Land");
- childEnable("Delete Target's Scripted Objects On *Any* Land");
- childEnable("Delete *ALL* Of Target's Objects");
- childEnable("Get Top Colliders");
- childEnable("Get Top Scripts");
- }
- //static
- void LLPanelObjectTools::onGetTopColliders(void*)
- {
- if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- LLFloaterTopObjects::showInstance();
- LLFloaterTopObjects::setMode(STAT_REPORT_TOP_COLLIDERS);
- LLFloaterTopObjects::sendRefreshRequest();
- }
- }
- //static
- void LLPanelObjectTools::onGetTopScripts(void*)
- {
- if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- LLFloaterTopObjects::showInstance();
- LLFloaterTopObjects::setMode(STAT_REPORT_TOP_SCRIPTS);
- LLFloaterTopObjects::sendRefreshRequest();
- }
- }
- //static
- void LLPanelObjectTools::onGetScriptDigest(void*)
- {
- if (LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- // get the list of scripts and number of occurences of each
- // (useful for finding self-replicating objects)
- LLPanelRequestTools::sendRequest("scriptdigest", "0",
- gAgent.getRegionHost());
- }
- }
- void LLPanelObjectTools::onClickDeletePublicOwnedBy(void* userdata)
- {
- // Bring up view-modal dialog
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self && self->mTargetAvatar.notNull())
- {
- self->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY | SWD_OTHERS_LAND_ONLY;
- LLSD args;
- args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
- LLSD payload;
- payload["avatar_id"] = self->mTargetAvatar;
- payload["flags"] = (S32)self->mSimWideDeletesFlags;
- gNotifications.add("GodDeleteAllScriptedPublicObjectsByUser", args,
- payload, callbackSimWideDeletes);
- }
- }
- //static
- void LLPanelObjectTools::onClickDeleteAllScriptedOwnedBy(void* userdata)
- {
- // Bring up view-modal dialog
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self->mTargetAvatar.notNull())
- {
- self->mSimWideDeletesFlags = SWD_SCRIPTED_ONLY;
- LLSD args;
- args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
- LLSD payload;
- payload["avatar_id"] = self->mTargetAvatar;
- payload["flags"] = (S32)self->mSimWideDeletesFlags;
- gNotifications.add("GodDeleteAllScriptedObjectsByUser", args, payload,
- callbackSimWideDeletes);
- }
- }
- //static
- void LLPanelObjectTools::onClickDeleteAllOwnedBy(void* userdata)
- {
- // Bring up view-modal dialog
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self->mTargetAvatar.notNull())
- {
- self->mSimWideDeletesFlags = 0;
- LLSD args;
- args["AVATAR_NAME"] = self->childGetValue("target_avatar_name").asString();
- LLSD payload;
- payload["avatar_id"] = self->mTargetAvatar;
- payload["flags"] = (S32)self->mSimWideDeletesFlags;
- gNotifications.add("GodDeleteAllObjectsByUser", args, payload,
- callbackSimWideDeletes);
- }
- }
- //static
- bool LLPanelObjectTools::callbackSimWideDeletes(const LLSD& notification,
- const LLSD& response)
- {
- S32 option = LLNotification::getSelectedOption(notification, response);
- if (option == 0)
- {
- if (notification["payload"]["avatar_id"].asUUID().notNull())
- {
- send_sim_wide_deletes(notification["payload"]["avatar_id"].asUUID(),
- notification["payload"]["flags"].asInteger());
- }
- }
- return false;
- }
- void LLPanelObjectTools::onClickSet(void* userdata)
- {
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self)
- {
- LLFloaterAvatarPicker* pickerp =
- LLFloaterAvatarPicker::show(callbackAvatarID, userdata);
- if (pickerp && gFloaterViewp)
- {
- LLFloater* parentp = gFloaterViewp->getParentFloater(self);
- if (parentp)
- {
- parentp->addDependentFloater(pickerp);
- }
- }
- }
- }
- void LLPanelObjectTools::onClickSetBySelection(void* userdata)
- {
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (!self) return;
- LLSelectNode* node = gSelectMgr.getSelection()->getFirstRootNode(NULL,
- true);
- if (!node) return;
- std::string owner_name;
- LLUUID owner_id;
- gSelectMgr.selectGetOwner(owner_id, owner_name);
- self->mTargetAvatar = owner_id;
- std::string name = "Object " + node->mName + " owned by " + owner_name;
- self->childSetValue("target_avatar_name", name);
- }
- //static
- void LLPanelObjectTools::callbackAvatarID(const std::vector<std::string>& names,
- const uuid_vec_t& ids,
- void* userdata)
- {
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self && !ids.empty() && !names.empty())
- {
- self->mTargetAvatar = ids[0];
- self->childSetValue("target_avatar_name", names[0]);
- self->refresh();
- }
- }
- //static
- void LLPanelObjectTools::onChangeAnything(LLUICtrl*, void* userdata)
- {
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- if (self && LLFloaterGodTools::findInstance() && gAgent.isGodlike())
- {
- self->childEnable("Apply");
- }
- }
- //static
- void LLPanelObjectTools::onApplyChanges(void* userdata)
- {
- LLPanelObjectTools* self = (LLPanelObjectTools*)userdata;
- LLFloaterGodTools* fgt = LLFloaterGodTools::findInstance();
- if (self && fgt && gAgent.isGodlike() && gAgent.getRegion())
- {
- self->childDisable("Apply");
- fgt->sendGodUpdateRegionInfo();
- }
- }
- // --------------------
- // LLPanelRequestTools
- // --------------------
- const std::string SELECTION = "Selection";
- const std::string AGENT_REGION = "Agent Region";
- LLPanelRequestTools::LLPanelRequestTools(const std::string& name)
- : LLPanel(name)
- {
- }
- //virtual
- bool LLPanelRequestTools::postBuild()
- {
- childSetAction("Make Request", onClickRequest, this);
- refresh();
- return true;
- }
- //virtual
- void LLPanelRequestTools::refresh()
- {
- LLComboBox* combop = getChild<LLComboBox>("destination");
- std::string buffer = combop->getValue();
- combop->operateOnAll(LLComboBox::OP_DELETE);
- combop->addSimpleElement(SELECTION);
- combop->addSimpleElement(AGENT_REGION);
- for (LLWorld::region_list_t::const_iterator
- iter = gWorld.getRegionList().begin(),
- end = gWorld.getRegionList().end();
- iter != end; ++iter)
- {
- LLViewerRegion* regionp = *iter;
- std::string name = regionp->getName();
- //MK
- if (gRLenabled && gRLInterface.mContainsShowloc)
- {
- name = "(Hidden)";
- }
- //mk
- if (!name.empty())
- {
- combop->addSimpleElement(name);
- }
- }
- if (!buffer.empty())
- {
- combop->selectByValue(buffer);
- }
- else
- {
- combop->selectByValue(SELECTION);
- }
- }
- //static
- void LLPanelRequestTools::sendRequest(const std::string& request,
- const std::string& parameter,
- const LLHost& host)
- {
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessage("GodlikeMessage");
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
- msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
- msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null); // not used
- msg->nextBlock("MethodData");
- msg->addString("Method", request);
- msg->addUUID("Invoice", LLUUID::null);
- msg->nextBlock("ParamList");
- msg->addString("Parameter", parameter);
- msg->sendReliable(host);
- }
- //static
- void LLPanelRequestTools::onClickRequest(void* data)
- {
- LLPanelRequestTools* self = (LLPanelRequestTools*)data;
- const std::string dest = self->childGetValue("destination").asString();
- if (dest == SELECTION)
- {
- std::string req = self->childGetValue("request");
- req = req.substr(0, req.find_first_of(" "));
- std::string param = self->childGetValue("parameter");
- gSelectMgr.sendGodlikeRequest(req, param);
- }
- else if (dest == AGENT_REGION)
- {
- self->sendRequest(gAgent.getRegionHost());
- }
- else
- {
- // find region by name
- for (LLWorld::region_list_t::const_iterator
- iter = gWorld.getRegionList().begin(),
- end = gWorld.getRegionList().end();
- iter != end; ++iter)
- {
- LLViewerRegion* regionp = *iter;
- if (regionp && dest == regionp->getName())
- {
- // found it
- self->sendRequest(regionp->getHost());
- }
- }
- }
- }
- void terrain_download_done(void** data, S32 status, LLExtStat ext_status)
- {
- gNotifications.add("TerrainDownloaded");
- }
- void LLPanelRequestTools::sendRequest(const LLHost& host)
- {
- // intercept viewer local actions here
- std::string req = childGetValue("request");
- if (req == "terrain download")
- {
- if (!gXferManagerp)
- {
- llwarns << "No transfer manager. Aborted." << llendl;
- return;
- }
- gXferManagerp->requestFile("terrain.raw", "terrain.raw", LL_PATH_NONE,
- host, false, terrain_download_done, NULL);
- }
- else
- {
- req = req.substr(0, req.find_first_of(" "));
- sendRequest(req, childGetValue("parameter").asString(), host);
- }
- }
- // Flags are SWD_ flags.
- void send_sim_wide_deletes(const LLUUID& owner_id, U32 flags)
- {
- LLMessageSystem* msg = gMessageSystemp;
- msg->newMessageFast(_PREHASH_SimWideDeletes);
- msg->nextBlockFast(_PREHASH_AgentData);
- msg->addUUIDFast(_PREHASH_AgentID, gAgentID);
- msg->addUUIDFast(_PREHASH_SessionID, gAgentSessionID);
- msg->nextBlockFast(_PREHASH_DataBlock);
- msg->addUUIDFast(_PREHASH_TargetID, owner_id);
- msg->addU32Fast(_PREHASH_Flags, flags);
- gAgent.sendReliableMessage();
- }
|