diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llenvmanager.cpp | 32 | ||||
-rw-r--r-- | indra/newview/llenvmanager.h | 13 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.cpp | 63 | ||||
-rw-r--r-- | indra/newview/llfloaterregioninfo.h | 8 |
4 files changed, 100 insertions, 16 deletions
diff --git a/indra/newview/llenvmanager.cpp b/indra/newview/llenvmanager.cpp index 9f15f9adfc..688e2ea9bf 100644 --- a/indra/newview/llenvmanager.cpp +++ b/indra/newview/llenvmanager.cpp @@ -770,6 +770,11 @@ LLSD LLEnvManagerNew::getDayCycleByName(const std::string name) return LLWLDayCycle::loadCycleDataFromFile(name + ".xml"); } +void LLEnvManagerNew::requestRegionSettings() +{ + LLEnvironmentRequest::initiate(); +} + bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settings) { LLSD metadata; @@ -781,6 +786,16 @@ bool LLEnvManagerNew::sendRegionSettings(const LLEnvironmentSettings& new_settin return LLEnvironmentApply::initiateRequest(new_settings.makePacket(metadata)); } +boost::signals2::connection LLEnvManagerNew::setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb) +{ + return mRegionSettingsChangeSignal.connect(cb); +} + +boost::signals2::connection LLEnvManagerNew::setRegionChangeCallback(const region_change_signal_t::slot_type& cb) +{ + return mRegionChangeSignal.connect(cb); +} + void LLEnvManagerNew::onRegionCrossing() { LL_DEBUGS("Windlight") << "Crossed region" << LL_ENDL; @@ -798,18 +813,22 @@ void LLEnvManagerNew::onRegionSettingsResponse(const LLSD& content) // If the message was valid, grab the UUID from it and save it for next outbound update message. mLastReceivedID = content[0]["messageID"].asUUID(); - // 1. Refresh cached region settings. + // Refresh cached region settings. LL_DEBUGS("Windlight") << "Caching region environment settings: " << content << LL_ENDL; F32 sun_hour = 0; // *TODO LLEnvironmentSettings new_settings(content[1], content[2], content[3], sun_hour); mCachedRegionPrefs = new_settings; - // 2. If using server settings, update managers. + // If using server settings, update managers. if (getUseRegionSettings()) { updateManagersFromPrefs(mInterpNextChangeMessage); } + // Let interested parties know about the region settings update. + mRegionSettingsChangeSignal(); + + // reset mInterpNextChangeMessage = false; } @@ -832,12 +851,6 @@ void LLEnvManagerNew::updateManagersFromPrefs(bool interpolate) LLWLParamManager::instance().applyUserPrefs(interpolate); } -void LLEnvManagerNew::requestRegionSettings() -{ - LLEnvironmentRequest::initiate(); - // *TODO: Indicate that current cached region settings have been invalidated? -} - void LLEnvManagerNew::onRegionChange(bool interpolate) { // Avoid duplicating region setting requests @@ -854,4 +867,7 @@ void LLEnvManagerNew::onRegionChange(bool interpolate) mCurRegionUUID = region_uuid; mInterpNextChangeMessage = interpolate; requestRegionSettings(); + + // Let interested parties know agent region has been changed. + mRegionChangeSignal(); } diff --git a/indra/newview/llenvmanager.h b/indra/newview/llenvmanager.h index f52eaf5a4b..eb678e000e 100644 --- a/indra/newview/llenvmanager.h +++ b/indra/newview/llenvmanager.h @@ -259,6 +259,9 @@ class LLEnvManagerNew : public LLSingleton<LLEnvManagerNew> { LOG_CLASS(LLEnvManagerNew); public: + typedef boost::signals2::signal<void()> region_settings_change_signal_t; + typedef boost::signals2::signal<void()> region_change_signal_t; + LLEnvManagerNew(); // getters to access user env. preferences @@ -293,7 +296,10 @@ public: static LLSD getDayCycleByName(const std::string name); // Misc. + void requestRegionSettings(); bool sendRegionSettings(const LLEnvironmentSettings& new_settings); + boost::signals2::connection setRegionSettingsChangeCallback(const region_settings_change_signal_t::slot_type& cb); + boost::signals2::connection setRegionChangeCallback(const region_change_signal_t::slot_type& cb); // Public callbacks. void onRegionCrossing(); @@ -305,10 +311,15 @@ private: /*virtual*/ void initSingleton(); void updateManagersFromPrefs(bool interpolate); - void requestRegionSettings(); void onRegionChange(bool interpolate); + /// Emitted when region environment settings update comes. + region_settings_change_signal_t mRegionSettingsChangeSignal; + + /// Emitted when agent region changes. Move to LLAgent? + region_settings_change_signal_t mRegionChangeSignal; + LLEnvPrefs mUserPrefs; /// User environment preferences. LLEnvironmentSettings mCachedRegionPrefs; /// Cached region environment settings. bool mInterpNextChangeMessage; /// Interpolate env. settings on next region change. diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 56025c3143..657dd67035 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -218,6 +218,9 @@ BOOL LLFloaterRegionInfo::postBuild() "EstateOwnerMessage", &processEstateOwnerRequest); + // Request region info when agent region changes. + LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLFloaterRegionInfo::requestRegionInfo, this)); + return TRUE; } @@ -292,6 +295,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; @@ -299,11 +304,12 @@ void LLFloaterRegionInfo::processRegionInfo(LLMessageSystem* msg) { return; } - - - // currently, region can send this message when its windlight settings change - LLEnvManager::instance().refreshFromStorage(LLEnvKey::SCOPE_REGION); + // 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(); @@ -3171,7 +3177,8 @@ bool LLDispatchSetEstateAccess::operator()( } LLPanelEnvironmentInfo::LLPanelEnvironmentInfo() -: mRegionSettingsRadioGroup(NULL), +: mEnableEditing(false), + mRegionSettingsRadioGroup(NULL), mDayCycleSettingsRadioGroup(NULL), mWaterPresetCombo(NULL), mSkyPresetCombo(NULL), @@ -3195,15 +3202,32 @@ BOOL LLPanelEnvironmentInfo::postBuild() childSetCommitCallback("save_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnSave, this), NULL); childSetCommitCallback("cancel_btn", boost::bind(&LLPanelEnvironmentInfo::onBtnCancel, this), NULL); + LLEnvManagerNew::instance().setRegionSettingsChangeCallback(boost::bind(&LLPanelEnvironmentInfo::onRegionSettingschange, this)); + return TRUE; } // virtual void LLPanelEnvironmentInfo::onOpen(const LLSD& key) { + LL_DEBUGS("Windlight") << "Panel opened, refreshing" << LL_ENDL; refresh(); } +// 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(); @@ -3218,8 +3242,27 @@ void LLPanelEnvironmentInfo::refresh() mRegionSettingsRadioGroup->setSelectedIndex(settings.getSkyMap().size() == 0 ? 0 : 1); mDayCycleSettingsRadioGroup->setSelectedIndex(use_fixed_sky ? 0 : 1); - LLPanelEnvironmentInfo::onSwitchRegionSettings(); - LLPanelEnvironmentInfo::onSwitchDayCycle(); + setControlsEnabled(mEnableEditing); +} + +void LLPanelEnvironmentInfo::setControlsEnabled(bool enabled) +{ + mRegionSettingsRadioGroup->setEnabled(enabled); + mDayCycleSettingsRadioGroup->setEnabled(enabled); + + mWaterPresetCombo->setEnabled(enabled); + mSkyPresetCombo->setEnabled(enabled); + mDayCyclePresetCombo->setEnabled(enabled); + + getChildView("save_btn")->setEnabled(enabled); + getChildView("cancel_btn")->setEnabled(enabled); + + if (enabled) + { + // Enable/disable some controls based on currently selected radio buttons. + LLPanelEnvironmentInfo::onSwitchRegionSettings(); + LLPanelEnvironmentInfo::onSwitchDayCycle(); + } } void LLPanelEnvironmentInfo::populateWaterPresetsList() @@ -3422,3 +3465,9 @@ void LLPanelEnvironmentInfo::onBtnCancel() // Reload current region settings. refresh(); } + +void LLPanelEnvironmentInfo::onRegionSettingschange() +{ + LL_DEBUGS("Windlight") << "Region settings changed, refreshing" << LL_ENDL; + refresh(); +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index dc5e250cc4..4dc235ad19 100644 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -433,8 +433,12 @@ public: /*virtual*/ BOOL postBuild(); /*virtual*/ void onOpen(const LLSD& key); + // LLPanelRegionInfo + /*virtual*/ bool refreshFromRegion(LLViewerRegion* region); + private: void refresh(); + void setControlsEnabled(bool enabled); void populateWaterPresetsList(); void populateSkyPresetsList(); @@ -446,6 +450,10 @@ private: void onBtnSave(); void onBtnCancel(); + void onRegionSettingschange(); + + bool mEnableEditing; + LLRadioGroup* mRegionSettingsRadioGroup; LLRadioGroup* mDayCycleSettingsRadioGroup; |