From b51615be20ad1d532487ce08334f1c6276ac55f9 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 17 Apr 2013 19:42:56 -0400 Subject: [PATCH] Support Legacy Region/Estate Environment Also Disable Environment Tab when the cap required to use it isn't supported. --- indra/newview/llestateinfomodel.h | 3 +- indra/newview/llfloaterregioninfo.cpp | 127 +++++++++++++++++- indra/newview/llregioninfomodel.cpp | 12 ++ .../default/xui/en-us/panel_region_estate.xml | 45 ++++--- .../xui/en-us/panel_region_general.xml | 9 +- 5 files changed, 172 insertions(+), 24 deletions(-) diff --git a/indra/newview/llestateinfomodel.h b/indra/newview/llestateinfomodel.h index 56391eda9..30e83b140 100644 --- a/indra/newview/llestateinfomodel.h +++ b/indra/newview/llestateinfomodel.h @@ -56,7 +56,8 @@ public: const std::string& getName() const { return mName; } const LLUUID& getOwnerID() const { return mOwnerID; } U32 getID() const { return mID; } - F32 getSunHour() const { return getUseFixedSun() ? mSunHour : 0.f; } + F32 getSunHour() const { return mSunHour; } + bool getGlobalTime() const { return !(mSunHour || getUseFixedSun()); } // setters void setUseFixedSun(bool val); diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 382d747a5..e8cb41ad5 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -160,6 +160,39 @@ void unpack_request_params( */ +namespace +{ + void on_caps_received(LLTabContainer* tab) + { + if (!tab) return; + const LLViewerRegion* region = gAgent.getRegion(); + tab->enableTabButton(tab->getIndexForPanel(tab->getPanelByName("panel_env_info")), region && !region->getCapability("EnvironmentSettings").empty()); + } + + void handle_opposite(const bool& off, LLUICtrl* opposite) + { + opposite->setEnabled(!off); + if (off) opposite->setValue(false); + } + + void on_change_use_other_sun(const LLSD& param, LLUICtrl* opposite, LLUICtrl* slider) + { + handle_opposite(param.asBoolean(), opposite); + slider->setEnabled(false); + } + + void on_change_fixed_sun(const LLSD& param, LLUICtrl* opposite, LLUICtrl* slider) + { + bool fixed_sun = param.asBoolean(); + handle_opposite(fixed_sun, opposite); + slider->setEnabled(fixed_sun); + } + + const float get_sun_hour(const LLUICtrl* sun_hour) + { + return sun_hour->getEnabled() ? sun_hour->getValue().asFloat() : 0.f; + } +} bool estate_dispatch_initialized = false; @@ -352,6 +385,15 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) LLTrans::findString(sim_type, sim_type); // try localizing sim product name } + // Disable Environment Tab when not supported + if (region) + { + if (region->capabilitiesReceived()) + on_caps_received(tab); + else + region->setCapabilitiesReceivedCallback(boost::bind(on_caps_received, tab)); + } + // GENERAL PANEL panel = tab->getChild("General"); panel->getChild("region_text")->setValue(LLSD(sim_name)); @@ -629,6 +671,27 @@ bool LLPanelRegionGeneralInfo::refreshFromRegion(LLViewerRegion* region) getChildView("im_btn")->setEnabled(allow_modify); getChildView("manage_telehub_btn")->setEnabled(allow_modify); + // Support Legacy Region Environment + { + const LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); + bool estate_sun = region_info.mUseEstateSun; + getChild("use_estate_sun_check")->setValue(estate_sun); + getChild("fixed_sun_check")->setEnabled(allow_modify && !estate_sun); + getChild("sun_hour_slider")->setEnabled(allow_modify && !estate_sun); + if (estate_sun) + { + getChild("use_estate_sun_check")->setEnabled(allow_modify); + getChild("fixed_sun_check")->setValue(false); + } + else + { + bool fixed_sun = region_info.getUseFixedSun(); + getChild("use_estate_sun_check")->setEnabled(allow_modify && !fixed_sun); + getChild("fixed_sun_check")->setValue(fixed_sun); + getChild("sun_hour_slider")->setValue(region_info.mSunHour); + } + } + // Data gets filled in by processRegionInfo return LLPanelRegionInfo::refreshFromRegion(region); @@ -647,6 +710,9 @@ BOOL LLPanelRegionGeneralInfo::postBuild() initCtrl("access_combo"); initCtrl("restrict_pushobject"); initCtrl("block_parcel_search_check"); + initCtrl("use_estate_sun_check"); + initCtrl("fixed_sun_check"); + initCtrl("sun_hour_slider"); initHelpBtn("terraform_help", "HelpRegionBlockTerraform"); initHelpBtn("fly_help", "HelpRegionBlockFly"); @@ -658,12 +724,23 @@ BOOL LLPanelRegionGeneralInfo::postBuild() initHelpBtn("land_resell_help", "HelpRegionLandResell"); initHelpBtn("parcel_changes_help", "HelpParcelChanges"); initHelpBtn("parcel_search_help", "HelpRegionSearch"); + initHelpBtn("use_estate_sun_help", "HelpRegionUseEstateSun"); + initHelpBtn("fixed_sun_help", "HelpRegionFixedSun"); childSetAction("kick_btn", boost::bind(&LLPanelRegionGeneralInfo::onClickKick, this)); childSetAction("kick_all_btn", onClickKickAll, this); childSetAction("im_btn", onClickMessage, this); childSetAction("manage_telehub_btn", boost::bind(&LLPanelRegionGeneralInfo::onClickManageTelehub, this)); + // Set up the Legacy Region Environment checkboxes + { + LLUICtrl* estate_sun = getChild("use_estate_sun_check"); + LLUICtrl* fixed_sun = getChild("fixed_sun_check"); + LLUICtrl* hour_slider = getChild("sun_hour_slider"); + estate_sun->setCommitCallback(boost::bind(on_change_use_other_sun, _2, fixed_sun, hour_slider)); + fixed_sun->setCommitCallback(boost::bind(on_change_fixed_sun, _2, estate_sun, hour_slider)); + } + return LLPanelRegionInfo::postBuild(); } @@ -839,6 +916,13 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() sendEstateOwnerMessage(gMessageSystem, "setregioninfo", invoice, strings); } + // Send the Legacy Region Environment + LLRegionInfoModel& region_info = LLRegionInfoModel::instance(); + region_info.mUseEstateSun = getChild("use_estate_sun_check")->getValue().asBoolean(); + region_info.setUseFixedSun(getChild("fixed_sun_check")->getValue().asBoolean()); + region_info.mSunHour = get_sun_hour(getChild("sun_hour_slider")); + region_info.sendRegionTerrain(LLFloaterRegionInfo::getLastInvoice()); + // if we changed access levels, tell user about it LLViewerRegion* region = gAgent.getRegion(); if (region && (getChild("access_combo")->getValue().asInteger() != region->getSimAccess()) ) @@ -2015,11 +2099,16 @@ 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("sun_hour_slider"); initCtrl("allow_direct_teleport"); initCtrl("limit_payment"); initCtrl("limit_age_verified"); initCtrl("voice_chat_check"); initHelpBtn("estate_manager_help", "HelpEstateEstateManager"); + initHelpBtn("use_global_time_help", "HelpEstateUseGlobalTime"); + initHelpBtn("fixed_sun_help", "HelpEstateFixedSun"); initHelpBtn("externally_visible_help", "HelpEstateExternallyVisible"); initHelpBtn("allow_direct_teleport_help", "HelpEstateAllowDirectTeleport"); initHelpBtn("allow_resident_help", "HelpEstateAllowResident"); @@ -2027,6 +2116,15 @@ BOOL LLPanelEstateInfo::postBuild() initHelpBtn("ban_resident_help", "HelpEstateBanResident"); initHelpBtn("voice_chat_help", "HelpEstateVoiceChat"); + // Set up the Legacy Estate Environment checkboxes + { + LLUICtrl* global_time = getChild("use_global_time_check"); + LLUICtrl* fixed_sun = getChild("fixed_sun_check"); + LLUICtrl* hour_slider = getChild("sun_hour_slider"); + global_time->setCommitCallback(boost::bind(on_change_use_other_sun, _2, fixed_sun, hour_slider)); + fixed_sun->setCommitCallback(boost::bind(on_change_fixed_sun, _2, global_time, hour_slider)); + } + getChild("allowed_avatar_name_list")->setCommitCallback(boost::bind(&LLPanelEstateInfo::onChangeChildCtrl, this, _1)); LLNameListCtrl *avatar_name_list = getChild("allowed_avatar_name_list"); if (avatar_name_list) @@ -2106,14 +2204,36 @@ void LLPanelEstateInfo::refreshFromEstate() getChild("limit_payment")->setValue(estate_info.getDenyAnonymous()); getChild("limit_age_verified")->setValue(estate_info.getDenyAgeUnverified()); - // Ensure appriopriate state of the management UI + // Ensure appropriate state of the management UI updateControls(gAgent.getRegion()); + // Support Legacy Estate Environment + { + const LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + bool global_time = estate_info.getGlobalTime(); + getChild("use_global_time_check")->setValue(global_time); + getChild("fixed_sun_check")->setEnabled(!global_time); + getChild("sun_hour_slider")->setEnabled(!global_time); + if (global_time) + { + getChild("use_global_time_check")->setEnabled(true); + getChild("fixed_sun_check")->setValue(false); + } + else + { + bool fixed_sun = estate_info.getUseFixedSun(); + getChild("use_global_time_check")->setEnabled(!fixed_sun); + getChild("fixed_sun_check")->setValue(fixed_sun); + F32 sun_hour = estate_info.getSunHour(); + if (sun_hour < 6.0f) sun_hour += 24.0f; + getChild("sun_hour_slider")->setValue(sun_hour); + } + } refresh(); } BOOL LLPanelEstateInfo::sendUpdate() { - llinfos << "LLPanelEsateInfo::sendUpdate()" << llendl; + llinfos << "LLPanelEstateInfo::sendUpdate()" << llendl; LLNotification::Params params("ChangeLindenEstate"); params.functor(boost::bind(&LLPanelEstateInfo::callbackChangeLindenEstate, this, _1, _2)); @@ -2141,8 +2261,9 @@ bool LLPanelEstateInfo::callbackChangeLindenEstate(const LLSD& notification, con LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); // update model - estate_info.setUseFixedSun(false); // we don't support fixed sun estates anymore estate_info.setIsExternallyVisible(getChild("externally_visible_check")->getValue().asBoolean()); + estate_info.setUseFixedSun(getChild("fixed_sun_check")->getValue().asBoolean()); + estate_info.setSunHour(get_sun_hour(getChild("sun_hour_slider"))); estate_info.setAllowDirectTeleport(getChild("allow_direct_teleport")->getValue().asBoolean()); estate_info.setDenyAnonymous(getChild("limit_payment")->getValue().asBoolean()); estate_info.setDenyAgeUnverified(getChild("limit_age_verified")->getValue().asBoolean()); diff --git a/indra/newview/llregioninfomodel.cpp b/indra/newview/llregioninfomodel.cpp index 590e24648..3892c8795 100644 --- a/indra/newview/llregioninfomodel.cpp +++ b/indra/newview/llregioninfomodel.cpp @@ -35,6 +35,7 @@ // viewer #include "llagent.h" #include "llviewerregion.h" +#include "llestateinfomodel.h" // For supporting legacy environment void LLRegionInfoModel::reset() { @@ -107,6 +108,17 @@ void LLRegionInfoModel::sendRegionTerrain(const LLUUID& invoice) const strings.push_back(buffer); buffer = llformat("%f", mSunHour); strings.push_back(buffer); + if (mUseEstateSun) + { + // Grab estate info, the user decided to set the region back to estate time. JC + LLEstateInfoModel& estate_info = LLEstateInfoModel::instance(); + estate_global_time = estate_info.getGlobalTime(); + if (!estate_global_time) + { + estate_fixed_sun = estate_info.getUseFixedSun(); + estate_sun_hour = estate_info.getSunHour(); + } + } buffer = llformat("%s", (estate_global_time ? "Y" : "N") ); strings.push_back(buffer); buffer = llformat("%s", (estate_fixed_sun ? "Y" : "N") ); diff --git a/indra/newview/skins/default/xui/en-us/panel_region_estate.xml b/indra/newview/skins/default/xui/en-us/panel_region_estate.xml index e22662dff..66b2e3d8a 100644 --- a/indra/newview/skins/default/xui/en-us/panel_region_estate.xml +++ b/indra/newview/skins/default/xui/en-us/panel_region_estate.xml @@ -82,10 +82,10 @@