From 121ed3da67037cd24d1928bec232b8deebf76e7f Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 2 Apr 2012 02:03:55 +1000 Subject: Merge a bunch of duplicated Windlight sharing code. --- linden/indra/newview/CMakeLists.txt | 2 - linden/indra/newview/lightshare.cpp | 121 +++++------- linden/indra/newview/lightshare.h | 65 +++--- linden/indra/newview/llviewergenericmessage.cpp | 4 +- linden/indra/newview/llviewermessage.cpp | 7 +- linden/indra/newview/llwlparammanager.cpp | 64 ++++++ linden/indra/newview/llwlparammanager.h | 9 + linden/indra/newview/wlfloatermanager.cpp | 4 +- linden/indra/newview/wlretrievesettings.cpp | 1 - linden/indra/newview/wlsettingsmanager.cpp | 253 ------------------------ linden/indra/newview/wlsettingsmanager.h | 90 --------- 11 files changed, 150 insertions(+), 470 deletions(-) delete mode 100644 linden/indra/newview/wlsettingsmanager.cpp delete mode 100644 linden/indra/newview/wlsettingsmanager.h (limited to 'linden/indra') diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 1db6eab..4050d80 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -506,7 +506,6 @@ set(viewer_SOURCE_FILES wlfloatermanager.cpp wlfloaterwindlightsend.cpp wlretrievesettings.cpp - wlsettingsmanager.cpp ) set(VIEWER_BINARY_NAME "imprudence-bin" CACHE STRING @@ -979,7 +978,6 @@ set(viewer_HEADER_FILES wlfloatermanager.h wlfloaterwindlightsend.h wlretrievesettings.h - wlsettingsmanager.h ) source_group("CMake Rules" FILES ViewerInstall.cmake) diff --git a/linden/indra/newview/lightshare.cpp b/linden/indra/newview/lightshare.cpp index b00df96..1814f4a 100644 --- a/linden/indra/newview/lightshare.cpp +++ b/linden/indra/newview/lightshare.cpp @@ -27,7 +27,6 @@ */ -#include "lightshare.h" #include "linden_common.h" #include "llviewercontrol.h" @@ -38,21 +37,22 @@ #include "message.h" #include "meta7windlight.h" +#include "lightshare.h" + +#include "llagent.h" +#include "llworld.h" -const std::string WindlightMessage::sWaterPresetName = "(Region settings)"; -const std::string WindlightMessage::sSkyPresetName = "(Region settings)"; -WindlightMessage* WindlightMessage::sMostRecent = NULL; -LLTimer* WindlightMessage::sIgnoreTimer = new LLTimer(); -bool WindlightMessage::sIgnoreRegion = false; +LLWaterParamSet* LightShare::mWater = NULL; +LLWLParamSet* LightShare::mSky = NULL; +LLUUID* LightShare::mWaterNormal = NULL; +LLTimer* LightShare::sIgnoreTimer = new LLTimer(); +bool LightShare::sIgnoreRegion = false; -WindlightMessage::WindlightMessage( LLMessageSystem* msg ) : +LightShare::LightShare( LLMessageSystem* msg ) : mPacket(NULL), - mWater(NULL), - mSky(NULL), - mWaterNormal(NULL), mIsValid(false) { std::string method; @@ -93,7 +93,7 @@ WindlightMessage::WindlightMessage( LLMessageSystem* msg ) : } -WindlightMessage::~WindlightMessage() +LightShare::~LightShare() { delete mWater; // delete mSky; @@ -102,12 +102,12 @@ WindlightMessage::~WindlightMessage() // static -void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) +void LightShare::processWindlight(LLMessageSystem* msg, void**) { if( gSavedSettings.getU32("LightShareAllowed") <= LIGHTSHARE_NEVER ) return; - WindlightMessage* wl = new WindlightMessage(msg); + LightShare* wl = new LightShare(msg); if (!wl) return; @@ -118,16 +118,28 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) return; } + applyMaybe(wl->mWater, wl->mWaterNormal, wl->mSky); +} + + +//static +void LightShare::applyMaybe(LLWaterParamSet* thisWater, LLUUID* thisWaterNormal, LLWLParamSet* thisSky) +{ + if( gSavedSettings.getU32("LightShareAllowed") <= LIGHTSHARE_NEVER ) + return; + std::string water = LLWaterParamManager::instance()->mCurParams.mName; std::string sky = LLWLParamManager::instance()->mCurParams.mName; // If they are using region settings already, or LightShare is // always allowed, just apply the new settings, don't bother asking. if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ALWAYS || - (sky == sSkyPresetName && water == sWaterPresetName) ) + (sky == LLWLParamManager::sSkyPresetName && water == LLWLParamManager::sWaterPresetName) ) { - wl->apply(); - delete wl; + mSky = thisSky; + mWater = thisWater; + mWaterNormal = thisWaterNormal; + LLWLParamManager::apply(mWater, mWaterNormal, mSky); return; } @@ -136,41 +148,36 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) // The user recently ignored a windlight message, so ignore // this one too, and restart the timer. restartIgnoreTimer(); - delete wl; return; } if(sIgnoreRegion) { // We are ignoring new settings until user enters a new region. - delete wl; return; } - if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ASK && - sMostRecent == NULL ) + if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ASK && mSky == NULL && mWater == NULL) { // No most recent, so store this and create notification // asking the user whether to apply or not. - sMostRecent = wl; - LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), + mSky = thisSky; + mWater = thisWater; + mWaterNormal = thisWaterNormal; + LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), boost::bind(&applyCallback, _1, _2)); - return; } else { - // No new notification (to avoid spamming the user), just - // store this as most recent. - delete sMostRecent; - sMostRecent = wl; - return; + // No new notification (to avoid spamming the user, we do keep the saves from above) + mSky = thisSky; + mWater = thisWater; + mWaterNormal = thisWaterNormal; } } - // static -bool WindlightMessage::applyCallback(const LLSD& notification, - const LLSD& response) +bool LightShare::applyCallback(const LLSD& notification, const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); @@ -178,7 +185,8 @@ bool WindlightMessage::applyCallback(const LLSD& notification, { case 0:{ // "Apply" - sMostRecent->apply(); + LLWLParamManager::apply(mWater, mWaterNormal, mSky); + break; } case 1:{ @@ -193,22 +201,18 @@ bool WindlightMessage::applyCallback(const LLSD& notification, } } - delete sMostRecent; - sMostRecent = NULL; - return false; } - // static -void WindlightMessage::resetRegion() +void LightShare::resetRegion() { sIgnoreRegion = false; + LLWorld::getInstance()->rebuildClouds(gAgent.getRegion()); } - // static -void WindlightMessage::restartIgnoreTimer() +void LightShare::restartIgnoreTimer() { F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); sIgnoreTimer->start(); @@ -216,51 +220,24 @@ void WindlightMessage::restartIgnoreTimer() } // static -bool WindlightMessage::ignoreTimerHasExpired() +bool LightShare::ignoreTimerHasExpired() { return sIgnoreTimer->hasExpired(); } - -bool WindlightMessage::apply() -{ - LLWaterParamManager* water_mgr = LLWaterParamManager::instance(); - LLWLParamManager* sky_mgr = LLWLParamManager::instance(); - - mWater->mName = sWaterPresetName; - water_mgr->removeParamSet( sWaterPresetName, false ); - water_mgr->addParamSet( sWaterPresetName, *mWater ); - water_mgr->savePreset( sWaterPresetName ); - water_mgr->loadPreset( sWaterPresetName, true ); - water_mgr->setNormalMapID( *mWaterNormal ); - - mSky->mName = sSkyPresetName; - sky_mgr->mAnimator.mIsRunning = false; - sky_mgr->mAnimator.mUseLindenTime = false; - sky_mgr->removeParamSet( sSkyPresetName, false ); - sky_mgr->addParamSet( sSkyPresetName, *mSky ); - sky_mgr->savePreset( sSkyPresetName ); - sky_mgr->loadPreset( sSkyPresetName, true ); - - return true; -} - - -bool WindlightMessage::isValid() +bool LightShare::isValid() { return mIsValid; } - -void WindlightMessage::process_packet( char* buf ) +void LightShare::process_packet( char* buf ) { // *FIXME: Horrible idea, fragile, not byte-order or endian // safe, no validation, etc. etc. -Jacek mPacket = (Meta7WindlightPacket*)buf; } - -void WindlightMessage::process_water() +void LightShare::process_water() { mWater->set("waterFogColor", mPacket->waterColor.red / 256.f, @@ -316,7 +293,7 @@ void WindlightMessage::process_water() } -void WindlightMessage::process_sky() +void LightShare::process_sky() { mSky->setSunAngle(F_TWO_PI * mPacket->sunMoonPosiiton); mSky->setEastAngle(F_TWO_PI * mPacket->eastAngle); @@ -411,5 +388,3 @@ void WindlightMessage::process_sky() mSky->setStarBrightness(mPacket->starBrightness); } - - diff --git a/linden/indra/newview/lightshare.h b/linden/indra/newview/lightshare.h index e3cccf0..1df2084 100644 --- a/linden/indra/newview/lightshare.h +++ b/linden/indra/newview/lightshare.h @@ -30,23 +30,19 @@ #define LIGHTSHARE_H #include +#include "llwlparamset.h" +#include "llwaterparamset.h" +#include "lluuid.h" struct Meta7WindlightPacket; -class LLMessageSystem; -class LLSD; -class LLTimer; -class LLUUID; -class LLWaterParamSet; -class LLWLParamSet; // Encapsulates a "Windlight" (LightShare) message sent from the // region, allowing the settings to be applied at a later time. // -class WindlightMessage +class LightShare { - public: - +public: // The meanings of the LightShareAllowed user setting. enum LIGHTSHARE_ALLOWED { @@ -55,61 +51,40 @@ class WindlightMessage LIGHTSHARE_ALWAYS = 2, }; - // Constructs a new WindlightMessage instance from a GenericMessage + // Constructs a new LightShare instance from a GenericMessage // with the "Windlight" method, such as those sent by a // Lightshare-enabled OpenSim region. - WindlightMessage( LLMessageSystem* msg ); - - ~WindlightMessage(); - - // The name of the water preset where the region settings are stored. - static const std::string sWaterPresetName; + LightShare( LLMessageSystem* msg ); - // The name of the sky preset where the region settings are stored. - static const std::string sSkyPresetName; + ~LightShare(); // Message handler for GenericMessage with the "Windlight" method. - // Creates and applies a new WindlightMessage (or prompts user). + // Creates and applies a new LightShare (or prompts user). static void processWindlight(LLMessageSystem* msg, void**); - // Callback when the user interacts with the notification. - static bool applyCallback(const LLSD& notification, - const LLSD& response); + static void applyMaybe(LLWaterParamSet* thisWater, LLUUID* thisVaterNormal, LLWLParamSet* thisSky); // Called after the user has entered a new region, to reset the // "ignore while in this region" state. static void resetRegion(); - // Applies/activates the Windlight settings from the message. - bool apply(); - // Returns true if the message contains valid Windlight settings. // (But there's no real validation yet, so this is always true.) bool isValid(); - - protected: - - // Restart the timer for temporarily ignoring settings. - static void restartIgnoreTimer(); - - // Returns true if the ignore timer has expired (i.e. new settings - // should not be ignored anymore). - static bool ignoreTimerHasExpired(); - - - private: - - static WindlightMessage* sMostRecent; +private: static LLTimer* sIgnoreTimer; static bool sIgnoreRegion; Meta7WindlightPacket* mPacket; - LLWaterParamSet* mWater; - LLWLParamSet* mSky; - LLUUID* mWaterNormal; + static LLWaterParamSet* mWater; + static LLWLParamSet* mSky; + static LLUUID* mWaterNormal; bool mIsValid; + // Callback when the user interacts with the notification. + static bool applyCallback(const LLSD& notification, const LLSD& response); + // Converts the message's raw bytes into a Meta7WindlightPacket. void process_packet( char* buf ); @@ -119,6 +94,12 @@ class WindlightMessage // Constructs a LLWLParamSet from the Meta7WindlightPacket. void process_sky(); + // Restart the timer for temporarily ignoring settings. + static void restartIgnoreTimer(); + + // Returns true if the ignore timer has expired (i.e. new settings + // should not be ignored anymore). + static bool ignoreTimerHasExpired(); }; #endif diff --git a/linden/indra/newview/llviewergenericmessage.cpp b/linden/indra/newview/llviewergenericmessage.cpp index 536a803..53549fc 100644 --- a/linden/indra/newview/llviewergenericmessage.cpp +++ b/linden/indra/newview/llviewergenericmessage.cpp @@ -87,8 +87,8 @@ void process_generic_message(LLMessageSystem* msg, void**) // TODO: Use a proper dispatcher. if(method == "Windlight") - { - WindlightMessage::processWindlight(msg, NULL); + { + LightShare::processWindlight(msg, NULL); return; } diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index fc72147..3fdfbef 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -152,7 +152,6 @@ #include "hippogridmanager.h" #include "hippolimits.h" -#include "wlsettingsmanager.h" #if LL_WINDOWS // For Windows specific error handler #include "llwindebug.h" // For the invalid message handler @@ -3548,8 +3547,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**) // gViewerWindow->setShowProgress(TRUE); // Tell the LightShare handler that we have changed regions. - WindlightMessage::resetRegion(); - WLSettingsManager::wlresetRegion(); + LightShare::resetRegion(); } // stuff we have to do every time we get an AvatarInitComplete from a sim @@ -3827,8 +3825,7 @@ void process_crossed_region(LLMessageSystem* msg, void**) regionp->setSeedCapability(seedCap); // Tell the LightShare handler that we have changed regions. - WindlightMessage::resetRegion(); - WLSettingsManager::wlresetRegion(); + LightShare::resetRegion(); } diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp index 1148576..8f1aa23 100644 --- a/linden/indra/newview/llwlparammanager.cpp +++ b/linden/indra/newview/llwlparammanager.cpp @@ -33,6 +33,7 @@ #include "llviewerprecompiledheaders.h" #include "llwlparammanager.h" +#include "llwaterparammanager.h" #include "pipeline.h" #include "llsky.h" @@ -60,6 +61,7 @@ #include "llfloaterdaycycle.h" #include "llfloaterenvsettings.h" +#include "llworld.h" // For notecard loading #include "llvfile.h" @@ -75,6 +77,9 @@ #include "curl/curl.h" +const std::string LLWLParamManager::sWaterPresetName = "(Region settings)"; +const std::string LLWLParamManager::sSkyPresetName = "(Region settings)"; + LLWLParamManager * LLWLParamManager::sInstance = NULL; std::vector LLWLParamManager::sObservers; LLFrameTimer wlSmoothTransitionTimer; @@ -854,3 +859,62 @@ bool LLWLParamManager::isSettingsNotecard(std::string name) { return (isSkySettingsNotecard(name) || isWaterSettingsNotecard(name)); } + +//static +void LLWLParamManager::apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky) +{ + LLWaterParamManager* waterMgr = LLWaterParamManager::instance(); + LLWLParamManager* skyMgr = LLWLParamManager::instance(); + + F32 fade = 0; //Instant + bool error; + fade = newSky->getFloat("fade", error); + + newWater->mName = sWaterPresetName; + if(fade != 0 && waterMgr->mCurParams.mName == sWaterPresetName)//Load the settings forcefully the first time + { + LLWaterParamSet oldWset = waterMgr->mCurParams; + //This still needs done so that we update right, but load it to the old + waterMgr->removeParamSet( sWaterPresetName, false ); + waterMgr->addParamSet( sWaterPresetName, oldWset ); + waterMgr->savePreset( sWaterPresetName ); + waterMgr->loadPreset( sWaterPresetName, true ); + waterMgr->setNormalMapID( *newWaterNormal ); + //Then mix with the new + waterMgr->SetMixTime(newWater, fade); + } + else + { + //Instant if fade is 0 + waterMgr->removeParamSet( sWaterPresetName, false ); + waterMgr->addParamSet( sWaterPresetName, *newWater ); + waterMgr->savePreset( sWaterPresetName ); + waterMgr->loadPreset( sWaterPresetName, true ); + waterMgr->setNormalMapID( *newWaterNormal ); + } + + newSky->mName = sSkyPresetName; + if(fade != 0 && skyMgr->mCurParams.mName == sSkyPresetName)//Load the settings forcefully the first time + { + LLWLParamSet oldset = skyMgr->mCurParams; + //This still needs done so that we update right, but load it to the old + skyMgr->removeParamSet( sSkyPresetName, true ); + skyMgr->addParamSet( sSkyPresetName, oldset ); + skyMgr->savePreset( sSkyPresetName ); + skyMgr->loadPreset( sSkyPresetName, true ); + //Then mix with the new + skyMgr->SetMixTime(newSky, fade); + } + else + { + //Instant if fade is 0 + skyMgr->mAnimator.mIsRunning = false; + skyMgr->mAnimator.mUseLindenTime = false; + skyMgr->removeParamSet( sSkyPresetName, false ); + skyMgr->addParamSet( sSkyPresetName, *newSky ); + skyMgr->savePreset( sSkyPresetName ); + skyMgr->loadPreset( sSkyPresetName, true ); + } + + LLWorld::getInstance()->rebuildClouds(gAgent.getRegion()); +} diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h index 5995b9d..66975fa 100644 --- a/linden/indra/newview/llwlparammanager.h +++ b/linden/indra/newview/llwlparammanager.h @@ -36,6 +36,7 @@ #include #include #include "llwlparamset.h" +#include "llwaterparamset.h" #include "llwlanimator.h" #include "llwldaycycle.h" #include "llviewercamera.h" @@ -228,6 +229,8 @@ public: static bool isSkySettingsNotecard(std::string name); static bool isSettingsNotecard(std::string name); + static void apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky); + public: // helper variables @@ -284,6 +287,12 @@ public: // list of all the parameters, listed by name std::map mParamList; + // The name of the water preset where the region settings are stored. + static const std::string sWaterPresetName; + + // The name of the sky preset where the region settings are stored. + static const std::string sSkyPresetName; + private: // our parameter manager singleton instance static LLWLParamManager * sInstance; diff --git a/linden/indra/newview/wlfloatermanager.cpp b/linden/indra/newview/wlfloatermanager.cpp index 0b81d7e..a1b1748 100644 --- a/linden/indra/newview/wlfloatermanager.cpp +++ b/linden/indra/newview/wlfloatermanager.cpp @@ -70,7 +70,7 @@ #include "llviewerparcelmgr.h" #include "llparcel.h" #include "wlretrievesettings.h" -#include "wlsettingsmanager.h" +#include "lightshare.h" #include "wlfloaterwindlightsend.h" #undef max @@ -214,7 +214,7 @@ void WLFloaterManager::onShow(void* userData) LLWaterParamSet* mWater = mgr->mWaterParamList[name]; LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name]; if(mSky != NULL && mWater != NULL && mWaterNormal != NULL) - WLSettingsManager::Apply(mSky, mWater, mWaterNormal); + LightShare::applyMaybe(mWater, mWaterNormal, mSky); } void WLFloaterManager::onSetToCurrent(void* userData) { diff --git a/linden/indra/newview/wlretrievesettings.cpp b/linden/indra/newview/wlretrievesettings.cpp index 3fd3084..0fcaa03 100644 --- a/linden/indra/newview/wlretrievesettings.cpp +++ b/linden/indra/newview/wlretrievesettings.cpp @@ -67,7 +67,6 @@ #include "hippolimits.h" #include "wlfloaterwindlightsend.h" #include "llviewerregion.h" -#include "wlsettingsmanager.h" #include "lightshare.h" #include "linden_common.h" diff --git a/linden/indra/newview/wlsettingsmanager.cpp b/linden/indra/newview/wlsettingsmanager.cpp deleted file mode 100644 index c0a07e1..0000000 --- a/linden/indra/newview/wlsettingsmanager.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/** -* @file wlfloaterwindlightsend.cpp -* @brief WLFloaterWindLightSend class definition -* -* $LicenseInfo:firstyear=2007&license=viewergpl$ -* -* Copyright (c) 2007-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 "llfloaterwindlight.h" - -#include "pipeline.h" -#include "llsky.h" - -#include "llsliderctrl.h" -#include "llmultislider.h" -#include "llmultisliderctrl.h" -#include "llspinctrl.h" -#include "llcheckboxctrl.h" -#include "lluictrlfactory.h" -#include "llviewercamera.h" -#include "llcombobox.h" -#include "lllineeditor.h" -#include "llfloaterdaycycle.h" -#include "lltabcontainer.h" -#include "llboost.h" - -#include "llagent.h" -#include "llinventorymodel.h" -#include "llviewerinventory.h" - -#include "v4math.h" -#include "llviewerdisplay.h" -#include "llviewercontrol.h" -#include "llviewerwindow.h" -#include "llsavedsettingsglue.h" - -#include "llwlparamset.h" -#include "llwlparammanager.h" -#include "llwaterparammanager.h" -#include "llpostprocess.h" -#include "hippolimits.h" -#include "wlfloaterwindlightsend.h" -#include "llviewerregion.h" -#include "wlsettingsmanager.h" -#include "lightshare.h" - -#include "linden_common.h" -#include "llviewercontrol.h" -#include "message.h" -#include "meta7windlight.h" -#include "llworld.h" - -#undef max - -const std::string WLSettingsManager::wlWaterPresetName = "(Region settings)"; -const std::string WLSettingsManager::wlSkyPresetName = "(Region settings)"; - -LLTimer* WLSettingsManager::wlIgnoreTimer = new LLTimer(); -bool WLSettingsManager::wlIgnoreRegion = false; -LLWaterParamSet* WLSettingsManager::mWater = NULL; -LLWLParamSet* WLSettingsManager::mSky = NULL; -LLUUID* WLSettingsManager::mWaterNormal = NULL; - -void WLSettingsManager::Apply( LLWLParamSet* Sky, LLWaterParamSet* Water, LLUUID* WaterNormal ) -{ - if( gSavedSettings.getU32("LightShareAllowed") <= WindlightMessage::LIGHTSHARE_NEVER ) - return; - - std::string water = LLWaterParamManager::instance()->mCurParams.mName; - std::string sky = LLWLParamManager::instance()->mCurParams.mName; - - // If they are using region settings already, or LightShare is - // always allowed, just apply the new settings, don't bother asking. - if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ALWAYS || - (sky == wlSkyPresetName && water == wlWaterPresetName) ) - { - mSky = Sky; - mWater = Water; - mWaterNormal = WaterNormal; - Apply(); - return; - } - - if( !wlignoreTimerHasExpired() ) - { - // The user recently ignored a windlight message, so ignore - // this one too, and restart the timer. - wlrestartIgnoreTimer(); - return; - } - - if(wlIgnoreRegion) - { - // We are ignoring new settings until user enters a new region. - return; - } - - if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ASK && - mSky == NULL && mWater == NULL) - { - // No most recent, so store this and create notification - // asking the user whether to apply or not. - mSky = Sky; - mWater = Water; - mWaterNormal = WaterNormal; - LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), - boost::bind(&wlapplyCallback, _1, _2)); - } - else - { - // No new notification (to avoid spamming the user, we do keep the saves from above) - mSky = Sky; - mWater = Water; - mWaterNormal = WaterNormal; - } -} - -// static -bool WLSettingsManager::wlapplyCallback(const LLSD& notification, - const LLSD& response) -{ - S32 option = LLNotification::getSelectedOption(notification, response); - - switch(option) - { - case 0:{ - // "Apply" - Apply(); - break; - } - case 1:{ - // "Not Now", ignore until the region stops spamming - wlrestartIgnoreTimer(); - break; - } - case 2:{ - // "Ignore", ignore all until user leaves the region - wlIgnoreRegion = true; - break; - } - } - return false; -} - -//static -void WLSettingsManager::Apply() -{ - LLWaterParamManager* water_mgr = LLWaterParamManager::instance(); - LLWLParamManager* sky_mgr = LLWLParamManager::instance(); - - F32 fade = 0; //Instant - bool error; - fade = mSky->getFloat("fade", error); - - mWater->mName = wlWaterPresetName; - if(fade != 0 && water_mgr->mCurParams.mName == wlWaterPresetName)//Load the settings forcefully the first time - { - LLWaterParamSet oldWset = water_mgr->mCurParams; - //This still needs done so that we update right, but load it to the old - water_mgr->removeParamSet( wlWaterPresetName, false ); - water_mgr->addParamSet( wlWaterPresetName, oldWset ); - water_mgr->savePreset( wlWaterPresetName ); - water_mgr->loadPreset( wlWaterPresetName, true ); - water_mgr->setNormalMapID( *mWaterNormal ); - //Then mix with the new - water_mgr->SetMixTime(mWater, fade); - } - else - { - //Instant if fade is 0 - water_mgr->removeParamSet( wlWaterPresetName, false ); - water_mgr->addParamSet( wlWaterPresetName, *mWater ); - water_mgr->savePreset( wlWaterPresetName ); - water_mgr->loadPreset( wlWaterPresetName, true ); - water_mgr->setNormalMapID( *mWaterNormal ); - } - - mSky->mName = wlSkyPresetName; - if(fade != 0 && sky_mgr->mCurParams.mName == wlSkyPresetName)//Load the settings forcefully the first time - { - LLWLParamSet oldset = sky_mgr->mCurParams; - //This still needs done so that we update right, but load it to the old - sky_mgr->removeParamSet( wlSkyPresetName, true ); - sky_mgr->addParamSet( wlSkyPresetName, oldset ); - sky_mgr->savePreset( wlSkyPresetName ); - sky_mgr->loadPreset( wlSkyPresetName, true ); - //Then mix with the new - sky_mgr->SetMixTime(mSky, fade); - } - else - { - //Instant if fade is 0 - sky_mgr->mAnimator.mIsRunning = false; - sky_mgr->mAnimator.mUseLindenTime = false; - sky_mgr->removeParamSet( wlSkyPresetName, false ); - sky_mgr->addParamSet( wlSkyPresetName, *mSky ); - sky_mgr->savePreset( wlSkyPresetName ); - sky_mgr->loadPreset( wlSkyPresetName, true ); - } - - LLWorld::getInstance()->rebuildClouds(gAgent.getRegion()); - - mSky = NULL; - mWater = NULL; - mWaterNormal = NULL; -} - -// static -void WLSettingsManager::wlresetRegion() -{ - wlIgnoreRegion = false; - LLWorld::getInstance()->rebuildClouds(gAgent.getRegion()); -} - -// static -void WLSettingsManager::wlrestartIgnoreTimer() -{ - F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); - wlIgnoreTimer->start(); - wlIgnoreTimer->setTimerExpirySec( (time < 0) ? 0 : time ); -} - -// static -bool WLSettingsManager::wlignoreTimerHasExpired() -{ - return wlIgnoreTimer->hasExpired(); -} \ No newline at end of file diff --git a/linden/indra/newview/wlsettingsmanager.h b/linden/indra/newview/wlsettingsmanager.h deleted file mode 100644 index 5a0e9e7..0000000 --- a/linden/indra/newview/wlsettingsmanager.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file wlfloaterwindlightsend.h - * @brief WLFloaterWindLightSend class definition - * - * $LicenseInfo:firstyear=2007&license=viewergpl$ - * - * Copyright (c) 2007-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$ - */ - -/* - * Menu for adjusting the atmospheric settings of the world - */ - -#ifndef WINDLIGHTSETTINGSMANAGER_H -#define WINDLIGHTSETTINGSMANAGER_H - -#include -#include "llwlparamset.h" -#include "llwaterparamset.h" -#include "lluuid.h" - -class LLSD; -class LLTimer; -class LLUUID; -class LLWaterParamSet; -class LLWLParamSet; - - -/// Menuing system for all of windlight's functionality -class WLSettingsManager -{ -public: - - static LLTimer* wlIgnoreTimer; - static bool wlIgnoreRegion; - - // Called after the user has entered a new region, to reset the - // "ignore while in this region" state. - static void wlresetRegion(); - - static void Apply( LLWLParamSet* Sky, LLWaterParamSet* Water, LLUUID* WaterNormal ); - - // Callback when the user interacts with the notification. - static bool wlapplyCallback(const LLSD& notification, - const LLSD& response); - - static LLWaterParamSet* mWater; - static LLWLParamSet* mSky; - static LLUUID* mWaterNormal; - -private: - static void Apply(); - - // The name of the water preset where the region settings are stored. - static const std::string wlWaterPresetName; - - // The name of the sky preset where the region settings are stored. - static const std::string wlSkyPresetName; - - // Restart the timer for temporarily ignoring settings. - static void wlrestartIgnoreTimer(); - - // Returns true if the ignore timer has expired (i.e. new settings - // should not be ignored anymore). - static bool wlignoreTimerHasExpired(); -}; -#endif \ No newline at end of file -- cgit v1.1