diff options
Diffstat (limited to 'indra/newview/llfloaterregioninfo.cpp')
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 1027 |
1 files changed, 758 insertions, 269 deletions
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 6b3e3088d5..07c0878877 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -40,6 +40,10 @@ #include "llxfermanager.h" #include "indra_constants.h" #include "message.h" +#include "llloadingindicator.h" +#include "llradiogroup.h" +#include "llsd.h" +#include "llsdserialize.h" #include "llagent.h" #include "llappviewer.h" @@ -48,6 +52,8 @@ #include "llbutton.h" #include "llcheckboxctrl.h" #include "llcombobox.h" +#include "lldaycyclemanager.h" +#include "llenvmanager.h" #include "llfilepicker.h" #include "llfloatergodtools.h" // for send_sim_wide_deletes() #include "llfloatertopobjects.h" // added to fix SL-32336 @@ -55,12 +61,12 @@ #include "llfloaterreg.h" #include "llfloaterregiondebugconsole.h" #include "llfloatertelehub.h" -#include "llfloaterwindlight.h" #include "llinventorymodel.h" #include "lllineeditor.h" #include "llnamelistctrl.h" #include "llnotifications.h" #include "llnotificationsutil.h" +#include "llregioninfomodel.h" #include "llscrolllistitem.h" #include "llsliderctrl.h" #include "llslurl.h" @@ -80,6 +86,7 @@ #include "llviewertexteditor.h" #include "llviewerwindow.h" #include "llvlcomposition.h" +#include "llwaterparammanager.h" #include "lltrans.h" #include "llagentui.h" #include "llmeshrepository.h" @@ -87,6 +94,8 @@ const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; +#define TMP_DISABLE_WLES // STORM-1180 + ///---------------------------------------------------------------------------- /// Local class declaration ///---------------------------------------------------------------------------- @@ -190,24 +199,24 @@ LLFloaterRegionInfo::LLFloaterRegionInfo(const LLSD& seed) BOOL LLFloaterRegionInfo::postBuild() { mTab = getChild<LLTabContainer>("region_panels"); + mTab->setCommitCallback(boost::bind(&LLFloaterRegionInfo::onTabSelected, this, _2)); // contruct the panels LLPanelRegionInfo* panel; - panel = new LLPanelRegionGeneralInfo; + panel = new LLPanelEstateInfo; mInfoPanels.push_back(panel); - panel->getCommitCallbackRegistrar().add("RegionInfo.ManageTelehub", boost::bind(&LLPanelRegionInfo::onClickManageTelehub, panel)); - - panel->buildFromFile("panel_region_general.xml"); + panel->buildFromFile("panel_region_estate.xml"); mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(true)); - panel = new LLPanelRegionDebugInfo; + panel = new LLPanelEstateCovenant; mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_debug.xml"); + panel->buildFromFile("panel_region_covenant.xml"); mTab->addTabPanel(panel); - panel = new LLPanelRegionTextureInfo; + panel = new LLPanelRegionGeneralInfo; mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_texture.xml"); + panel->getCommitCallbackRegistrar().add("RegionInfo.ManageTelehub", boost::bind(&LLPanelRegionInfo::onClickManageTelehub, panel)); + panel->buildFromFile("panel_region_general.xml"); mTab->addTabPanel(panel); panel = new LLPanelRegionTerrainInfo; @@ -215,20 +224,23 @@ BOOL LLFloaterRegionInfo::postBuild() panel->buildFromFile("panel_region_terrain.xml"); mTab->addTabPanel(panel); - panel = new LLPanelEstateInfo; + panel = new LLPanelEnvironmentInfo; mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_estate.xml"); + panel->buildFromFile("panel_region_environment.xml"); mTab->addTabPanel(panel); - panel = new LLPanelEstateCovenant; + panel = new LLPanelRegionDebugInfo; mInfoPanels.push_back(panel); - panel->buildFromFile("panel_region_covenant.xml"); + panel->buildFromFile("panel_region_debug.xml"); mTab->addTabPanel(panel); gMessageSystem->setHandlerFunc( "EstateOwnerMessage", &processEstateOwnerRequest); + // Request region info when agent region changes. + LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this)); + return TRUE; } @@ -305,6 +317,8 @@ void LLFloaterRegionInfo::processEstateOwnerRequest(LLMessageSystem* msg,void**) // static void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { + LL_DEBUGS("Windlight") << "Processing region info" << LL_ENDL; + LLPanel* panel; LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); llinfos << "LLFloaterRegionInfo::processRegionInfo" << llendl; @@ -312,12 +326,20 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } + + // We need to re-request environment setting here, + // otherwise after we apply (send) updated region settings we won't get them back, + // so our environment won't be updated. + LLEnvManagerNew::instance().requestRegionSettings(); LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); LLViewerRegion* region = gAgent.getRegion(); BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); + // *TODO: Replace parcing msg with accessing the region info model. + LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); + // extract message std::string sim_name; std::string sim_type = LLTrans::getString("land_type_unknown"); @@ -389,15 +411,10 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) panel = tab->getChild<LLPanel>("Terrain"); panel->getChild<LLUICtrl>("region_text")->setValue(LLSD(sim_name)); - panel->getChild<LLUICtrl>("water_height_spin")->setValue(LLSD(water_height)); - panel->getChild<LLUICtrl>("terrain_raise_spin")->setValue(LLSD(terrain_raise_limit)); - panel->getChild<LLUICtrl>("terrain_lower_spin")->setValue(LLSD(terrain_lower_limit)); - panel->getChild<LLUICtrl>("use_estate_sun_check")->setValue(LLSD(use_estate_sun)); - - panel->getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD((BOOL)(region_flags & REGION_FLAGS_SUN_FIXED))); - panel->getChildView("fixed_sun_check")->setEnabled(allow_modify && !use_estate_sun); - panel->getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(sun_hour)); - panel->getChildView("sun_hour_slider")->setEnabled(allow_modify && !use_estate_sun); + panel->getChild<LLUICtrl>("water_height_spin")->setValue(region_info.mWaterHeight); + panel->getChild<LLUICtrl>("terrain_raise_spin")->setValue(region_info.mTerrainRaiseLimit); + panel->getChild<LLUICtrl>("terrain_lower_spin")->setValue(region_info.mTerrainLowerLimit); + panel->setCtrlsEnabled(allow_modify); floater->refreshFromRegion( gAgent.getRegion() ); @@ -423,6 +440,29 @@ LLPanelEstateCovenant* LLFloaterRegionInfo::getPanelCovenant() return panel; } +// static +LLPanelRegionTerrainInfo* LLFloaterRegionInfo::getPanelRegionTerrain() +{ + LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); + if (!floater) + { + llassert(floater); + return NULL; + } + + LLTabContainer* tab_container = floater->getChild<LLTabContainer>("region_panels"); + LLPanelRegionTerrainInfo* panel = + dynamic_cast<LLPanelRegionTerrainInfo*>(tab_container->getChild<LLPanel>("Terrain")); + llassert(panel); + return panel; +} + +void LLFloaterRegionInfo::onTabSelected(const LLSD& param) +{ + LLPanel* active_panel = getChild<LLPanel>(param.asString()); + active_panel->onOpen(LLSD()); +} + void LLFloaterRegionInfo::refreshFromRegion(LLViewerRegion* region) { if (!region) @@ -503,8 +543,13 @@ void LLPanelRegionInfo::onChangeText(LLLineEditor* caller, void* user_data) // virtual BOOL LLPanelRegionInfo::postBuild() { - getChild<LLUICtrl>("apply_btn")->setCommitCallback(boost::bind(&LLPanelRegionInfo::onBtnSet, this)); - getChildView("apply_btn")->setEnabled(FALSE); + // If the panel has an Apply button, set a callback for it. + LLUICtrl* apply_btn = findChild<LLUICtrl>("apply_btn"); + if (apply_btn) + { + apply_btn->setCommitCallback(boost::bind(&LLPanelRegionInfo::onBtnSet, this)); + } + refresh(); return TRUE; } @@ -556,12 +601,14 @@ void LLPanelRegionInfo::sendEstateOwnerMessage( void LLPanelRegionInfo::enableButton(const std::string& btn_name, BOOL enable) { - getChildView(btn_name)->setEnabled(enable); + LLView* button = findChildView(btn_name); + if (button) button->setEnabled(enable); } void LLPanelRegionInfo::disableButton(const std::string& btn_name) { - getChildView(btn_name)->setEnabled(FALSE); + LLView* button = findChildView(btn_name); + if (button) button->setEnabled(FALSE); } void LLPanelRegionInfo::initCtrl(const std::string& name) @@ -1052,131 +1099,7 @@ void LLPanelRegionDebugInfo::onClickCancelRestart(void* data) } -///////////////////////////////////////////////////////////////////////////// -// LLPanelRegionTextureInfo -// -LLPanelRegionTextureInfo::LLPanelRegionTextureInfo() : LLPanelRegionInfo() -{ - // nothing. -} - -bool LLPanelRegionTextureInfo::refreshFromRegion(LLViewerRegion* region) -{ - BOOL allow_modify = gAgent.isGodlike() || (region && region->canManageEstate()); - setCtrlsEnabled(allow_modify); - getChildView("apply_btn")->setEnabled(FALSE); - - if (region) - { - getChild<LLUICtrl>("region_text")->setValue(LLSD(region->getName())); - } - else - { - getChild<LLUICtrl>("region_text")->setValue(LLSD("")); - } - - if (!region) return LLPanelRegionInfo::refreshFromRegion(region); - - LLVLComposition* compp = region->getComposition(); - LLTextureCtrl* texture_ctrl; - std::string buffer; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("texture_detail_%d", i); - texture_ctrl = getChild<LLTextureCtrl>(buffer); - if(texture_ctrl) - { - lldebugs << "Detail Texture " << i << ": " - << compp->getDetailTextureID(i) << llendl; - LLUUID tmp_id(compp->getDetailTextureID(i)); - texture_ctrl->setImageAssetID(tmp_id); - } - } - - for(S32 i = 0; i < CORNER_COUNT; ++i) - { - buffer = llformat("height_start_spin_%d", i); - getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getStartHeight(i))); - buffer = llformat("height_range_spin_%d", i); - getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getHeightRange(i))); - } - - // Call the parent for common book-keeping - return LLPanelRegionInfo::refreshFromRegion(region); -} - - -BOOL LLPanelRegionTextureInfo::postBuild() -{ - LLPanelRegionInfo::postBuild(); - std::string buffer; - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("texture_detail_%d", i); - initCtrl(buffer); - } - - for(S32 i = 0; i < CORNER_COUNT; ++i) - { - buffer = llformat("height_start_spin_%d", i); - initCtrl(buffer); - buffer = llformat("height_range_spin_%d", i); - initCtrl(buffer); - } - -// LLButton* btn = ("dump", LLRect(0, 20, 100, 0), "", onClickDump, this); -// btn->setFollows(FOLLOWS_TOP|FOLLOWS_LEFT); -// addChild(btn); - - return LLPanelRegionInfo::postBuild(); -} - -BOOL LLPanelRegionTextureInfo::sendUpdate() -{ - llinfos << "LLPanelRegionTextureInfo::sendUpdate()" << llendl; - - // Make sure user hasn't chosen wacky textures. - if (!validateTextureSizes()) - { - return FALSE; - } - - LLTextureCtrl* texture_ctrl; - std::string buffer; - std::string id_str; - LLMessageSystem* msg = gMessageSystem; - strings_t strings; - - LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - - for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) - { - buffer = llformat("texture_detail_%d", i); - texture_ctrl = getChild<LLTextureCtrl>(buffer); - if(texture_ctrl) - { - LLUUID tmp_id(texture_ctrl->getImageAssetID()); - tmp_id.toString(id_str); - buffer = llformat("%d %s", i, id_str.c_str()); - strings.push_back(buffer); - } - } - sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); - strings.clear(); - for(S32 i = 0; i < CORNER_COUNT; ++i) - { - buffer = llformat("height_start_spin_%d", i); - std::string buffer2 = llformat("height_range_spin_%d", i); - std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal()); - strings.push_back(buffer3); - } - sendEstateOwnerMessage(msg, "textureheights", invoice, strings); - strings.clear(); - sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); - return TRUE; -} - -BOOL LLPanelRegionTextureInfo::validateTextureSizes() +BOOL LLPanelRegionTerrainInfo::validateTextureSizes() { for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { @@ -1219,49 +1142,86 @@ BOOL LLPanelRegionTextureInfo::validateTextureSizes() return TRUE; } - -// static -void LLPanelRegionTextureInfo::onClickDump(void* data) -{ - llinfos << "LLPanelRegionTextureInfo::onClickDump()" << llendl; -} - - ///////////////////////////////////////////////////////////////////////////// // LLPanelRegionTerrainInfo ///////////////////////////////////////////////////////////////////////////// +// Initialize statics + BOOL LLPanelRegionTerrainInfo::postBuild() { LLPanelRegionInfo::postBuild(); - + initCtrl("water_height_spin"); initCtrl("terrain_raise_spin"); initCtrl("terrain_lower_spin"); - initCtrl("fixed_sun_check"); - getChild<LLUICtrl>("fixed_sun_check")->setCommitCallback(boost::bind(&LLPanelRegionTerrainInfo::onChangeFixedSun, this)); - getChild<LLUICtrl>("use_estate_sun_check")->setCommitCallback(boost::bind(&LLPanelRegionTerrainInfo::onChangeUseEstateTime, this)); - getChild<LLUICtrl>("sun_hour_slider")->setCommitCallback(boost::bind(&LLPanelRegionTerrainInfo::onChangeSunHour, this)); + std::string buffer; + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("texture_detail_%d", i); + initCtrl(buffer); + } + + for(S32 i = 0; i < CORNER_COUNT; ++i) + { + buffer = llformat("height_start_spin_%d", i); + initCtrl(buffer); + buffer = llformat("height_range_spin_%d", i); + initCtrl(buffer); + } childSetAction("download_raw_btn", onClickDownloadRaw, this); childSetAction("upload_raw_btn", onClickUploadRaw, this); childSetAction("bake_terrain_btn", onClickBakeTerrain, this); - return TRUE; + return LLPanelRegionInfo::postBuild(); } // virtual bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) { - llinfos << "LLPanelRegionTerrainInfo::refreshFromRegion" << llendl; - BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); setCtrlsEnabled(owner_or_god_or_manager); + getChildView("apply_btn")->setEnabled(FALSE); + if (region) + { + getChild<LLUICtrl>("region_text")->setValue(LLSD(region->getName())); + + LLVLComposition* compp = region->getComposition(); + LLTextureCtrl* texture_ctrl; + std::string buffer; + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) + { + buffer = llformat("texture_detail_%d", i); + texture_ctrl = getChild<LLTextureCtrl>(buffer); + if(texture_ctrl) + { + lldebugs << "Detail Texture " << i << ": " + << compp->getDetailTextureID(i) << llendl; + LLUUID tmp_id(compp->getDetailTextureID(i)); + texture_ctrl->setImageAssetID(tmp_id); + } + } + + for(S32 i = 0; i < CORNER_COUNT; ++i) + { + buffer = llformat("height_start_spin_%d", i); + getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getStartHeight(i))); + buffer = llformat("height_range_spin_%d", i); + getChild<LLUICtrl>(buffer)->setValue(LLSD(compp->getHeightRange(i))); + } + } + else + { + lldebugs << "no region set" << llendl; + getChild<LLUICtrl>("region_text")->setValue(LLSD("")); + } + getChildView("download_raw_btn")->setEnabled(owner_or_god); getChildView("upload_raw_btn")->setEnabled(owner_or_god); getChildView("bake_terrain_btn")->setEnabled(owner_or_god); @@ -1269,6 +1229,7 @@ bool LLPanelRegionTerrainInfo::refreshFromRegion(LLViewerRegion* region) return LLPanelRegionInfo::refreshFromRegion(region); } + // virtual BOOL LLPanelRegionTerrainInfo::sendUpdate() { @@ -1277,76 +1238,62 @@ BOOL LLPanelRegionTerrainInfo::sendUpdate() strings_t strings; LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); - buffer = llformat("%f", (F32)getChild<LLUICtrl>("water_height_spin")->getValue().asReal()); - strings.push_back(buffer); - buffer = llformat("%f", (F32)getChild<LLUICtrl>("terrain_raise_spin")->getValue().asReal()); - strings.push_back(buffer); - buffer = llformat("%f", (F32)getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal()); - strings.push_back(buffer); - buffer = llformat("%s", (getChild<LLUICtrl>("use_estate_sun_check")->getValue().asBoolean() ? "Y" : "N")); - strings.push_back(buffer); - buffer = llformat("%s", (getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean() ? "Y" : "N")); - strings.push_back(buffer); - buffer = llformat("%f", (F32)getChild<LLUICtrl>("sun_hour_slider")->getValue().asReal() ); - strings.push_back(buffer); - - // Grab estate information in case the user decided to set the - // region back to estate time. JC - LLFloaterRegionInfo* floater = LLFloaterReg::getTypedInstance<LLFloaterRegionInfo>("region_info"); - if (!floater) return true; - - LLTabContainer* tab = floater->getChild<LLTabContainer>("region_panels"); - if (!tab) return true; + // update the model + LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); + region_info.mWaterHeight = (F32) getChild<LLUICtrl>("water_height_spin")->getValue().asReal(); + region_info.mTerrainRaiseLimit = (F32) getChild<LLUICtrl>("terrain_raise_spin")->getValue().asReal(); + region_info.mTerrainLowerLimit = (F32) getChild<LLUICtrl>("terrain_lower_spin")->getValue().asReal(); - LLPanelEstateInfo* panel = (LLPanelEstateInfo*)tab->getChild<LLPanel>("Estate"); - if (!panel) return true; + // and sync the region with it + region_info.sendRegionTerrain(invoice); + + // ======================================= + // Assemble and send texturedetail message - BOOL estate_global_time = panel->getGlobalTime(); - BOOL estate_fixed_sun = panel->getFixedSun(); - F32 estate_sun_hour; - if (estate_global_time) + // Make sure user hasn't chosen wacky textures. + if (!validateTextureSizes()) { - estate_sun_hour = 0.f; + return FALSE; } - else + + LLTextureCtrl* texture_ctrl; + std::string id_str; + LLMessageSystem* msg = gMessageSystem; + + for(S32 i = 0; i < TERRAIN_TEXTURE_COUNT; ++i) { - estate_sun_hour = panel->getSunHour(); + buffer = llformat("texture_detail_%d", i); + texture_ctrl = getChild<LLTextureCtrl>(buffer); + if(texture_ctrl) + { + LLUUID tmp_id(texture_ctrl->getImageAssetID()); + tmp_id.toString(id_str); + buffer = llformat("%d %s", i, id_str.c_str()); + strings.push_back(buffer); + } } + sendEstateOwnerMessage(msg, "texturedetail", invoice, strings); + strings.clear(); - buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); - strings.push_back(buffer); - buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); - strings.push_back(buffer); - buffer = llformat("%f", estate_sun_hour); - strings.push_back(buffer); - - sendEstateOwnerMessage(gMessageSystem, "setregionterrain", invoice, strings); - return TRUE; -} + // ======================================== + // Assemble and send textureheights message -void LLPanelRegionTerrainInfo::onChangeUseEstateTime() -{ - BOOL use_estate_sun = getChild<LLUICtrl>("use_estate_sun_check")->getValue().asBoolean(); - getChildView("fixed_sun_check")->setEnabled(!use_estate_sun); - getChildView("sun_hour_slider")->setEnabled(!use_estate_sun); - if (use_estate_sun) + for(S32 i = 0; i < CORNER_COUNT; ++i) { - getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD(FALSE)); - getChild<LLUICtrl>("sun_hour_slider")->setValue(LLSD(0.f)); + buffer = llformat("height_start_spin_%d", i); + std::string buffer2 = llformat("height_range_spin_%d", i); + std::string buffer3 = llformat("%d %f %f", i, (F32)getChild<LLUICtrl>(buffer)->getValue().asReal(), (F32)getChild<LLUICtrl>(buffer2)->getValue().asReal()); + strings.push_back(buffer3); } - getChildView("apply_btn")->setEnabled(TRUE); -} + sendEstateOwnerMessage(msg, "textureheights", invoice, strings); + strings.clear(); -void LLPanelRegionTerrainInfo::onChangeFixedSun() -{ - // Just enable the apply button. We let the sun-hour slider be enabled - // for both fixed-sun and non-fixed-sun. JC - getChildView("apply_btn")->setEnabled(TRUE); -} + // ======================================== + // Send texturecommit message -void LLPanelRegionTerrainInfo::onChangeSunHour() -{ - getChildView("apply_btn")->setEnabled(TRUE); + sendEstateOwnerMessage(msg, "texturecommit", invoice, strings); + + return TRUE; } // static @@ -1406,6 +1353,7 @@ bool LLPanelRegionTerrainInfo::callbackBakeTerrain(const LLSD& notification, con strings.push_back("bake"); LLUUID invoice(LLFloaterRegionInfo::getLastInvoice()); sendEstateOwnerMessage(gMessageSystem, "terrain", invoice, strings); + return false; } @@ -1439,6 +1387,7 @@ void LLPanelEstateInfo::initDispatch(LLDispatcher& dispatch) estate_dispatch_initialized = true; } +#ifndef TMP_DISABLE_WLES // Disables the sun-hour slider and the use fixed time check if the use global time is check void LLPanelEstateInfo::onChangeUseGlobalTime() { @@ -1457,23 +1406,13 @@ void LLPanelEstateInfo::onChangeFixedSun() getChild<LLUICtrl>("use_global_time_check")->setValue(LLSD(FALSE)); enableButton("apply_btn"); } - +#endif // TMP_DISABLE_WLES //--------------------------------------------------------------------------- // Add/Remove estate access button callbacks //--------------------------------------------------------------------------- -void LLPanelEstateInfo::onClickEditSky() -{ - LLFloaterReg::showInstance("env_windlight"); -} - -void LLPanelEstateInfo::onClickEditDayCycle() -{ - LLFloaterReg::showInstance("env_day_cycle"); -} - void LLPanelEstateInfo::onClickAddAllowedAgent() { LLCtrlListInterface *list = childGetListInterface("allowed_avatar_name_list"); @@ -2030,7 +1969,6 @@ void LLPanelEstateInfo::updateControls(LLViewerRegion* region) BOOL manager = (region && region->isEstateManager()); setCtrlsEnabled(god || owner || manager); - getChildView("apply_btn")->setEnabled(FALSE); getChildView("add_allowed_avatar_btn")->setEnabled(god || owner || manager); getChildView("remove_allowed_avatar_btn")->setEnabled(god || owner || manager); getChildView("add_allowed_group_btn")->setEnabled(god || owner || manager); @@ -2088,10 +2026,6 @@ void LLPanelEstateInfo::updateChild(LLUICtrl* child_ctrl) { // do nothing } - else if (checkSunHourSlider(child_ctrl)) - { - // do nothing - } } bool LLPanelEstateInfo::estateUpdate(LLMessageSystem* msg) @@ -2105,18 +2039,11 @@ BOOL LLPanelEstateInfo::postBuild() { // set up the callbacks for the generic controls initCtrl("externally_visible_check"); - initCtrl("use_global_time_check"); - initCtrl("fixed_sun_check"); initCtrl("allow_direct_teleport"); initCtrl("limit_payment"); initCtrl("limit_age_verified"); initCtrl("voice_chat_check"); - // set up the use global time checkbox - getChild<LLUICtrl>("use_global_time_check")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeUseGlobalTime, this)); - getChild<LLUICtrl>("fixed_sun_check")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeFixedSun, this)); - getChild<LLUICtrl>("sun_hour_slider")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1)); - getChild<LLUICtrl>("allowed_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1)); LLNameListCtrl *avatar_name_list = getChild<LLNameListCtrl>("allowed_avatar_name_list"); if (avatar_name_list) @@ -2163,9 +2090,6 @@ BOOL LLPanelEstateInfo::postBuild() childSetAction("message_estate_btn", boost::bind(&LLPanelEstateInfo::onClickMessageEstate, this)); childSetAction("kick_user_from_estate_btn", boost::bind(&LLPanelEstateInfo::onClickKickUser, this)); - childSetAction("WLEditSky", boost::bind(&LLPanelEstateInfo::onClickEditSky, this)); - childSetAction("WLEditDayCycle", boost::bind(&LLPanelEstateInfo::onClickEditDayCycle, this)); - return LLPanelRegionInfo::postBuild(); } @@ -2304,7 +2228,6 @@ bool LLPanelEstateInfo::commitEstateInfoCaps() body["is_externally_visible"] = getChild<LLUICtrl>("externally_visible_check")->getValue().asBoolean(); body["allow_direct_teleport"] = getChild<LLUICtrl>("allow_direct_teleport")->getValue().asBoolean(); - body["is_sun_fixed" ] = getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean(); body["deny_anonymous" ] = getChild<LLUICtrl>("limit_payment")->getValue().asBoolean(); body["deny_age_unverified" ] = getChild<LLUICtrl>("limit_age_verified")->getValue().asBoolean(); body["allow_voice_chat" ] = getChild<LLUICtrl>("voice_chat_check")->getValue().asBoolean(); @@ -2369,7 +2292,6 @@ void LLPanelEstateInfo::commitEstateInfoDataserver() void LLPanelEstateInfo::setEstateFlags(U32 flags) { getChild<LLUICtrl>("externally_visible_check")->setValue(LLSD(flags & REGION_FLAGS_EXTERNALLY_VISIBLE ? TRUE : FALSE) ); - getChild<LLUICtrl>("fixed_sun_check")->setValue(LLSD(flags & REGION_FLAGS_SUN_FIXED ? TRUE : FALSE) ); getChild<LLUICtrl>("voice_chat_check")->setValue( LLSD(flags & REGION_FLAGS_ALLOW_VOICE ? TRUE : FALSE)); getChild<LLUICtrl>("allow_direct_teleport")->setValue(LLSD(flags & REGION_FLAGS_ALLOW_DIRECT_TELEPORT ? TRUE : FALSE) ); @@ -2398,11 +2320,6 @@ U32 LLPanelEstateInfo::computeEstateFlags() flags |= REGION_FLAGS_ALLOW_DIRECT_TELEPORT; } - if (getChild<LLUICtrl>("fixed_sun_check")->getValue().asBoolean()) - { - flags |= REGION_FLAGS_SUN_FIXED; - } - if (getChild<LLUICtrl>("limit_payment")->getValue().asBoolean()) { flags |= REGION_FLAGS_DENY_ANONYMOUS; @@ -2566,17 +2483,6 @@ BOOL LLPanelEstateInfo::checkRemovalButton(std::string name) return (btn_name != ""); } -BOOL LLPanelEstateInfo::checkSunHourSlider(LLUICtrl* child_ctrl) -{ - BOOL found_child_ctrl = FALSE; - if (child_ctrl->getName() == "sun_hour_slider") - { - enableButton("apply_btn"); - found_child_ctrl = TRUE; - } - return found_child_ctrl; -} - // static void LLPanelEstateInfo::onClickMessageEstate(void* userdata) { @@ -2978,6 +2884,8 @@ bool LLDispatchEstateUpdateInfo::operator()( const LLUUID& invoice, const sparam_t& strings) { + lldebugs << "Received estate update" << llendl; + LLPanelEstateInfo* panel = LLFloaterRegionInfo::getPanelEstate(); if (!panel) return true; @@ -3004,10 +2912,12 @@ bool LLDispatchEstateUpdateInfo::operator()( F32 sun_hour = ((F32)(strtod(strings[4].c_str(), NULL)))/1024.0f; if(sun_hour == 0 && (flags & REGION_FLAGS_SUN_FIXED ? FALSE : TRUE)) { + lldebugs << "Estate uses global time" << llendl; panel->setGlobalTime(TRUE); } else { + lldebugs << "Estate sun hour: " << sun_hour << llendl; panel->setGlobalTime(FALSE); panel->setSunHour(sun_hour); } @@ -3198,3 +3108,582 @@ bool LLDispatchSetEstateAccess::operator()( return true; } + +LLPanelEnvironmentInfo::LLPanelEnvironmentInfo() +: mEnableEditing(false), + mRegionSettingsRadioGroup(NULL), + mDayCycleSettingsRadioGroup(NULL), + mWaterPresetCombo(NULL), + mSkyPresetCombo(NULL), + mDayCyclePresetCombo(NULL) +{ +} + +// virtual +BOOL LLPanelEnvironmentInfo::postBuild() +{ + mRegionSettingsRadioGroup = getChild<LLRadioGroup>("region_settings_radio_group"); + mRegionSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchRegionSettings, this)); + + mDayCycleSettingsRadioGroup = getChild<LLRadioGroup>("sky_dayc_settings_radio_group"); + mDayCycleSettingsRadioGroup->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSwitchDayCycle, this)); + + mWaterPresetCombo = getChild<LLComboBox>("water_settings_preset_combo"); + mWaterPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectWaterPreset, this)); + + mSkyPresetCombo = getChild<LLComboBox>("sky_settings_preset_combo"); + mSkyPresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectSkyPreset, this)); + + mDayCyclePresetCombo = getChild<LLComboBox>("dayc_settings_preset_combo"); + mDayCyclePresetCombo->setCommitCallback(boost::bind(&LLPanelEnvironmentInfo::onSelectDayCycle, this)); + + childSetCommitCallback("apply_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnApply, this), NULL); + getChild<LLButton>("apply_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpUserPrefs, LLEnvManagerNew::getInstance())); + childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); + getChild<LLButton>("cancel_btn")->setRightMouseDownCallback(boost::bind(&LLEnvManagerNew::dumpPresets, LLEnvManagerNew::getInstance())); + + LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); + LLEnvManagerNew::instance().setRegionSettingsAppliedCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingsApplied, this, _1)); + + LLDayCycleManager::instance().setModifyCallback(boost::bind(&LLPanelEnvironmentInfo::populateDayCyclesList, this)); + LLWLParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateSkyPresetsList, this)); + LLWaterParamManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelEnvironmentInfo::populateWaterPresetsList, this)); + + return TRUE; +} + +// virtual +void LLPanelEnvironmentInfo::onOpen(const LLSD& key) +{ + LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; + refresh(); +} + +// virtual +void LLPanelEnvironmentInfo::handleVisibilityChange(BOOL new_visibility) +{ + // If hiding (user switched to another tab or closed the floater), + // display user's preferred environment. + if (!new_visibility) + { + LLEnvManagerNew::instance().usePrefs(); + } +} + +// virtual +bool LLPanelEnvironmentInfo::refreshFromRegion(LLViewerRegion* region) +{ + LL_DEBUGS("Windlight") << "Region updated, enabling/disabling controls" << LL_ENDL; + BOOL owner_or_god = gAgent.isGodlike() || (region && (region->getOwner() == gAgent.getID())); + BOOL owner_or_god_or_manager = owner_or_god || (region && region->isEstateManager()); + + // Don't refresh from region settings to avoid flicker after applying new region settings. + mEnableEditing = owner_or_god_or_manager; + setControlsEnabled(mEnableEditing); + + return LLPanelRegionInfo::refreshFromRegion(region); +} + +void LLPanelEnvironmentInfo::refresh() +{ + populateWaterPresetsList(); + populateSkyPresetsList(); + populateDayCyclesList(); + + // Init radio groups. + const LLEnvironmentSettings& settings = LLEnvManagerNew::instance().getRegionSettings(); + const LLSD& dc = settings.getWLDayCycle(); + LLSD::Real first_frame_time = dc.size() > 0 ? dc[0][0].asReal() : 0.0f; + const bool use_fixed_sky = dc.size() == 1 && first_frame_time < 0; + mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); + mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); + + setControlsEnabled(mEnableEditing); + + setDirty(false); +} + +void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +{ + mRegionSettingsRadioGroup->setEnabled(enabled); + mDayCycleSettingsRadioGroup->setEnabled(enabled); + + mWaterPresetCombo->setEnabled(enabled); + mSkyPresetCombo->setEnabled(enabled); + mDayCyclePresetCombo->setEnabled(enabled); + + getChildView("apply_btn")->setEnabled(enabled); + getChildView("cancel_btn")->setEnabled(enabled); + + if (enabled) + { + // Enable/disable some controls based on currently selected radio buttons. + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + } +} + +void LLPanelEnvironmentInfo::setApplyProgress(bool started) +{ + LLLoadingIndicator* indicator = getChild<LLLoadingIndicator>("progress_indicator"); + + indicator->setVisible(started); + + if (started) + { + indicator->start(); + } + else + { + indicator->stop(); + } +} + +void LLPanelEnvironmentInfo::setDirty(bool dirty) +{ + getChildView("apply_btn")->setEnabled(dirty); + getChildView("cancel_btn")->setEnabled(dirty); +} + +void LLPanelEnvironmentInfo::sendRegionSunUpdate(F32 sun_angle) +{ + LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); + bool region_use_fixed_sky = sun_angle >= 0.f; + + // Set sun hour. + if (region_use_fixed_sky) + { + LLWLParamSet param_set; + LLSD params; + std::string unused; + if (!getSelectedSkyParams(params, unused)) + { + return; + } + param_set.setAll(params); + + // convert value range from 0..2pi to 6..30 + region_info.mSunHour = fmodf((sun_angle / F_TWO_PI) * 24.f, 24.f) + 6.f; + } + + region_info.setUseFixedSun(region_use_fixed_sky); + region_info.mUseEstateSun = !region_use_fixed_sky; + + region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); +} + +void LLPanelEnvironmentInfo::populateWaterPresetsList() +{ + mWaterPresetCombo->removeall(); + + // If the region already has water params, add them to the list. + const LLEnvironmentSettings& region_settings = LLEnvManagerNew::instance().getRegionSettings(); + if (region_settings.getWaterParams().size() != 0) + { + const std::string& region_name = gAgent.getRegion()->getName(); + mWaterPresetCombo->add(region_name, LLWLParamKey(region_name, LLEnvKey::SCOPE_REGION).toLLSD()); + mWaterPresetCombo->addSeparator(); + } + + std::list<std::string> user_presets, system_presets; + LLWaterParamManager::instance().getPresetNames(user_presets, system_presets); + + // Add local user presets first. + for (std::list<std::string>::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); + } + + if (user_presets.size() > 0) + { + mWaterPresetCombo->addSeparator(); + } + + // Add local system presets. + for (std::list<std::string>::const_iterator it = system_presets.begin(); it != system_presets.end(); ++it) + { + mWaterPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toLLSD()); + } + + // There's no way to select current preset because its name is not stored on server. +} + +void LLPanelEnvironmentInfo::populateSkyPresetsList() +{ + mSkyPresetCombo->removeall(); + + LLWLParamManager::preset_name_list_t region_presets; + LLWLParamManager::preset_name_list_t user_presets, sys_presets; + LLWLParamManager::instance().getPresetNames(region_presets, user_presets, sys_presets); + + // Add region presets. + std::string region_name = gAgent.getRegion() ? gAgent.getRegion()->getName() : LLTrans::getString("Unknown"); + for (LLWLParamManager::preset_name_list_t::const_iterator it = region_presets.begin(); it != region_presets.end(); ++it) + { + std::string preset_name = *it; + std::string item_title = preset_name + " (" + region_name + ")"; + mSkyPresetCombo->add(item_title, LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); + } + + if (!region_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } + + // Add user presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = user_presets.begin(); it != user_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + if (!user_presets.empty()) + { + mSkyPresetCombo->addSeparator(); + } + + // Add system presets. + for (LLWLParamManager::preset_name_list_t::const_iterator it = sys_presets.begin(); it != sys_presets.end(); ++it) + { + mSkyPresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + // Select current preset. + LLSD sky_map = LLEnvManagerNew::instance().getRegionSettings().getSkyMap(); + if (sky_map.size() == 1) // if the region is set to fixed sky + { + std::string preset_name = sky_map.beginMap()->first; + mSkyPresetCombo->selectByValue(LLWLParamKey(preset_name, LLEnvKey::SCOPE_REGION).toStringVal()); + } +} + +void LLPanelEnvironmentInfo::populateDayCyclesList() +{ + mDayCyclePresetCombo->removeall(); + + // If the region already has env. settings, add its day cycle to the list. + const LLSD& cur_region_dc = LLEnvManagerNew::instance().getRegionSettings().getWLDayCycle(); + if (cur_region_dc.size() != 0) + { + LLViewerRegion* region = gAgent.getRegion(); + llassert(region != NULL); + + LLWLParamKey key(region->getName(), LLEnvKey::SCOPE_REGION); + mDayCyclePresetCombo->add(region->getName(), key.toStringVal()); + mDayCyclePresetCombo->addSeparator(); + } + + // Add local user day cycles. + LLDayCycleManager::preset_name_list_t user_days, sys_days; + LLDayCycleManager::instance().getPresetNames(user_days, sys_days); + for (LLDayCycleManager::preset_name_list_t::const_iterator it = user_days.begin(); it != user_days.end(); ++it) + { + mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + if (user_days.size() > 0) + { + mDayCyclePresetCombo->addSeparator(); + } + + // Add local system day cycles. + for (LLDayCycleManager::preset_name_list_t::const_iterator it = sys_days.begin(); it != sys_days.end(); ++it) + { + mDayCyclePresetCombo->add(*it, LLWLParamKey(*it, LLEnvKey::SCOPE_LOCAL).toStringVal()); + } + + // Current day cycle is already selected. +} + +bool LLPanelEnvironmentInfo::getSelectedWaterParams(LLSD& water_params) +{ + LLWLParamKey water_key(mWaterPresetCombo->getSelectedValue()); + + if (water_key.scope == LLEnvKey::SCOPE_REGION) + { + water_params = LLEnvManagerNew::instance().getRegionSettings().getWaterParams(); + } + else + { + LLWaterParamSet param_set; + if (!LLWaterParamManager::instance().getParamSet(water_key.name, param_set)) + { + llwarns << "Error getting water preset: " << water_key.name << llendl; + return false; + } + + water_params = param_set.getAll(); + } + + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedSkyParams(LLSD& sky_params, std::string& preset_name) +{ + std::string preset_key(mSkyPresetCombo->getValue().asString()); + LLWLParamKey preset(preset_key); + + // Get the preset sky params. + LLWLParamSet param_set; + if (!LLWLParamManager::instance().getParamSet(preset, param_set)) + { + llwarns << "Error getting sky params: " << preset.toLLSD() << llendl; + return false; + } + + sky_params = param_set.getAll(); + preset_name = preset.name; + return true; +} + +bool LLPanelEnvironmentInfo::getSelectedDayCycleParams(LLSD& day_cycle, LLSD& sky_map, short& scope) +{ + std::string preset_key(mDayCyclePresetCombo->getValue().asString()); + LLWLParamKey dc(preset_key); + LL_DEBUGS("Windlight") << "Use day cycle: " << dc.toLLSD() << LL_ENDL; + + if (dc.scope == LLEnvKey::SCOPE_REGION) // current region day cycle + { + const LLEnvironmentSettings& cur_region_settings = LLEnvManagerNew::instance().getRegionSettings(); + day_cycle = cur_region_settings.getWLDayCycle(); + sky_map = cur_region_settings.getSkyMap(); + } + else // a local day cycle + { + if (!LLDayCycleManager::instance().getPreset(dc.name, day_cycle)) + { + llwarns << "Error getting day cycle " << dc.name << llendl; + return false; + } + + // Create sky map from the day cycle. + { + LLWLDayCycle tmp_day; + tmp_day.loadDayCycle(day_cycle, dc.scope); + tmp_day.getSkyMap(sky_map); + } + } + + scope = dc.scope; + + return true; +} +void LLPanelEnvironmentInfo::onSwitchRegionSettings() +{ + bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + getChild<LLView>("user_environment_settings")->setEnabled(!use_defaults); + + if (use_defaults) + { + LLEnvManagerNew::instance().useDefaults(); + } + else + { + onSelectWaterPreset(); + onSwitchDayCycle(); + } + + setDirty(true); +} + +void LLPanelEnvironmentInfo::onSwitchDayCycle() +{ + bool is_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + + mSkyPresetCombo->setEnabled(is_fixed_sky); + mDayCyclePresetCombo->setEnabled(!is_fixed_sky); + + if (is_fixed_sky) + { + onSelectSkyPreset(); + } + else + { + onSelectDayCycle(); + } + + setDirty(true); +} + +void LLPanelEnvironmentInfo::onSelectWaterPreset() +{ + LLSD water_params; + + if (getSelectedWaterParams(water_params)) + { + LLEnvManagerNew::instance().useWaterParams(water_params); + } + + setDirty(true); +} + +void LLPanelEnvironmentInfo::onSelectSkyPreset() +{ + LLSD params; + std::string dummy; + + if (getSelectedSkyParams(params, dummy)) + { + LLEnvManagerNew::instance().useSkyParams(params); + } + + setDirty(true); +} + +void LLPanelEnvironmentInfo::onSelectDayCycle() +{ + LLSD day_cycle; + LLSD sky_map; // unused + short scope; + + if (getSelectedDayCycleParams(day_cycle, sky_map, scope)) + { + LLEnvManagerNew::instance().useDayCycleParams(day_cycle, (LLEnvKey::EScope) scope); + } + + setDirty(true); +} + +void LLPanelEnvironmentInfo::onBtnApply() +{ + const bool use_defaults = mRegionSettingsRadioGroup->getSelectedIndex() == 0; + const bool use_fixed_sky = mDayCycleSettingsRadioGroup->getSelectedIndex() == 0; + + LLSD day_cycle; + LLSD sky_map; + LLSD water_params; + F32 sun_angle = -1.f; // invalid value meaning no fixed sky + + if (use_defaults) + { + // settings will be empty + LL_DEBUGS("Windlight") << "Defaults" << LL_ENDL; + } + else // use custom region settings + { + if (use_fixed_sky) + { + LL_DEBUGS("Windlight") << "Use fixed sky" << LL_ENDL; + + // Get selected sky params. + LLSD params; + std::string preset_name; + if (!getSelectedSkyParams(params, preset_name)) + { + return; + } + + // Create a day cycle consisting of a single sky preset. + LLSD key(LLSD::emptyArray()); + key.append(-1.0f); // indicate that user preference is actually fixed sky, not a day cycle + key.append(preset_name); + day_cycle.append(key); + + // Create a sky map consisting of only the sky preset. + std::map<LLWLParamKey, LLWLParamSet> refs; + LLWLParamSet param_set; + param_set.setAll(params); + refs[LLWLParamKey(preset_name, LLEnvKey::SCOPE_LOCAL)] = param_set; // scope doesn't matter here + sky_map = LLWLParamManager::createSkyMap(refs); + + // Remember the sun angle to set fixed region sun hour below. + sun_angle = param_set.getSunAngle(); + } + else // use day cycle + { + LL_DEBUGS("Windlight") << "Use day cycle" << LL_ENDL; + + short scope; // unused + if (!getSelectedDayCycleParams(day_cycle, sky_map, scope)) + { + return; + } + + // If it's a special single-preset day cycle meaning using a fixed sky, + // reset the frame time to a non-negative value, + // so that the region setting is displayed in the floater as + // a day cycle, not a preset. (STORM-1289) + if (day_cycle.size() == 1 && day_cycle[0][0].asReal() < 0.0f) + { + LL_DEBUGS("Windlight") << "Fixing negative time" << LL_ENDL; + day_cycle[0][0] = 0.0f; + } + + // If the day cycle contains exactly one preset (i.e it's effectively a fixed sky), + // remember the preset's sun angle to set fixed region sun hour below. + if (sky_map.size() == 1) + { + LLWLParamSet param_set; + llassert(sky_map.isMap()); + param_set.setAll(sky_map.beginMap()->second); + sun_angle = param_set.getSunAngle(); + } + } + + // Get water params. + if (!getSelectedWaterParams(water_params)) + { + // *TODO: show a notification? + return; + } + } + + // Send settings apply request. + LLEnvironmentSettings new_region_settings; + new_region_settings.saveParams(day_cycle, sky_map, water_params, 0.0f); + if (!LLEnvManagerNew::instance().sendRegionSettings(new_region_settings)) + { + llwarns << "Error applying region environment settings" << llendl; + return; + } + + // Set the region sun phase/flags according to the chosen new preferences. + sendRegionSunUpdate(sun_angle); + + // Start spinning the progress indicator. + setApplyProgress(true); +} + +void LLPanelEnvironmentInfo::onBtnCancel() +{ + // Reload last saved region settings. + refresh(); + + // Apply them. + LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); + const LLEnvironmentSettings& cur_settings = env_mgr.getRegionSettings(); + const LLSD& region_day_cycle = cur_settings.getWLDayCycle(); + const LLSD& region_water = cur_settings.getWaterParams(); + env_mgr.useWaterParams(region_water); + env_mgr.useDayCycleParams(region_day_cycle, LLEnvKey::SCOPE_REGION); +} + +void LLPanelEnvironmentInfo::onRegionSettingschange() +{ + LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; + refresh(); + + // Stop applying progress indicator (it may be running if it's us who initiated settings update). + setApplyProgress(false); +} + +void LLPanelEnvironmentInfo::onRegionSettingsApplied(bool ok) +{ + LL_DEBUGS("Windlight") << "Applying region settings finished, stopping indicator" << LL_ENDL; + // If applying new settings has failed, stop the indicator right away. + // Otherwise it will be stopped when we receive the updated settings from server. + if (!ok) + { + setApplyProgress(false); + + // We need to re-request environment setting here, + // otherwise our subsequent attempts to change region settings will fail with the following error: + // "Unable to update environment settings because the last update your viewer saw was not the same + // as the last update sent from the simulator. Try sending your update again, and if this + // does not work, try leaving and returning to the region." + LLEnvManagerNew::instance().requestRegionSettings(); + } +} |