aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-02 02:03:55 +1000
committerDavid Walter Seikel2012-04-02 02:03:55 +1000
commit121ed3da67037cd24d1928bec232b8deebf76e7f (patch)
tree8ac0ac3bcb11f5b463243061bd6d11afe7181907 /linden
parentMore automated whitespace cleanups. (diff)
downloadmeta-impy-121ed3da67037cd24d1928bec232b8deebf76e7f.zip
meta-impy-121ed3da67037cd24d1928bec232b8deebf76e7f.tar.gz
meta-impy-121ed3da67037cd24d1928bec232b8deebf76e7f.tar.bz2
meta-impy-121ed3da67037cd24d1928bec232b8deebf76e7f.tar.xz
Merge a bunch of duplicated Windlight sharing code.
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/newview/CMakeLists.txt2
-rw-r--r--linden/indra/newview/lightshare.cpp121
-rw-r--r--linden/indra/newview/lightshare.h65
-rw-r--r--linden/indra/newview/llviewergenericmessage.cpp4
-rwxr-xr-xlinden/indra/newview/llviewermessage.cpp7
-rw-r--r--linden/indra/newview/llwlparammanager.cpp64
-rw-r--r--linden/indra/newview/llwlparammanager.h9
-rw-r--r--linden/indra/newview/wlfloatermanager.cpp4
-rw-r--r--linden/indra/newview/wlretrievesettings.cpp1
-rw-r--r--linden/indra/newview/wlsettingsmanager.cpp253
-rw-r--r--linden/indra/newview/wlsettingsmanager.h90
11 files changed, 150 insertions, 470 deletions
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
506 wlfloatermanager.cpp 506 wlfloatermanager.cpp
507 wlfloaterwindlightsend.cpp 507 wlfloaterwindlightsend.cpp
508 wlretrievesettings.cpp 508 wlretrievesettings.cpp
509 wlsettingsmanager.cpp
510 ) 509 )
511 510
512set(VIEWER_BINARY_NAME "imprudence-bin" CACHE STRING 511set(VIEWER_BINARY_NAME "imprudence-bin" CACHE STRING
@@ -979,7 +978,6 @@ set(viewer_HEADER_FILES
979 wlfloatermanager.h 978 wlfloatermanager.h
980 wlfloaterwindlightsend.h 979 wlfloaterwindlightsend.h
981 wlretrievesettings.h 980 wlretrievesettings.h
982 wlsettingsmanager.h
983 ) 981 )
984 982
985source_group("CMake Rules" FILES ViewerInstall.cmake) 983source_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 @@
27 */ 27 */
28 28
29 29
30#include "lightshare.h"
31 30
32#include "linden_common.h" 31#include "linden_common.h"
33#include "llviewercontrol.h" 32#include "llviewercontrol.h"
@@ -38,21 +37,22 @@
38#include "message.h" 37#include "message.h"
39#include "meta7windlight.h" 38#include "meta7windlight.h"
40 39
40#include "lightshare.h"
41
42#include "llagent.h"
43#include "llworld.h"
41 44
42const std::string WindlightMessage::sWaterPresetName = "(Region settings)";
43const std::string WindlightMessage::sSkyPresetName = "(Region settings)";
44 45
45 46
46WindlightMessage* WindlightMessage::sMostRecent = NULL; 47LLWaterParamSet* LightShare::mWater = NULL;
47LLTimer* WindlightMessage::sIgnoreTimer = new LLTimer(); 48LLWLParamSet* LightShare::mSky = NULL;
48bool WindlightMessage::sIgnoreRegion = false; 49LLUUID* LightShare::mWaterNormal = NULL;
50LLTimer* LightShare::sIgnoreTimer = new LLTimer();
51bool LightShare::sIgnoreRegion = false;
49 52
50 53
51WindlightMessage::WindlightMessage( LLMessageSystem* msg ) : 54LightShare::LightShare( LLMessageSystem* msg ) :
52 mPacket(NULL), 55 mPacket(NULL),
53 mWater(NULL),
54 mSky(NULL),
55 mWaterNormal(NULL),
56 mIsValid(false) 56 mIsValid(false)
57{ 57{
58 std::string method; 58 std::string method;
@@ -93,7 +93,7 @@ WindlightMessage::WindlightMessage( LLMessageSystem* msg ) :
93} 93}
94 94
95 95
96WindlightMessage::~WindlightMessage() 96LightShare::~LightShare()
97{ 97{
98 delete mWater; 98 delete mWater;
99// delete mSky; 99// delete mSky;
@@ -102,12 +102,12 @@ WindlightMessage::~WindlightMessage()
102 102
103 103
104// static 104// static
105void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) 105void LightShare::processWindlight(LLMessageSystem* msg, void**)
106{ 106{
107 if( gSavedSettings.getU32("LightShareAllowed") <= LIGHTSHARE_NEVER ) 107 if( gSavedSettings.getU32("LightShareAllowed") <= LIGHTSHARE_NEVER )
108 return; 108 return;
109 109
110 WindlightMessage* wl = new WindlightMessage(msg); 110 LightShare* wl = new LightShare(msg);
111 111
112 if (!wl) 112 if (!wl)
113 return; 113 return;
@@ -118,16 +118,28 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**)
118 return; 118 return;
119 } 119 }
120 120
121 applyMaybe(wl->mWater, wl->mWaterNormal, wl->mSky);
122}
123
124
125//static
126void LightShare::applyMaybe(LLWaterParamSet* thisWater, LLUUID* thisWaterNormal, LLWLParamSet* thisSky)
127{
128 if( gSavedSettings.getU32("LightShareAllowed") <= LIGHTSHARE_NEVER )
129 return;
130
121 std::string water = LLWaterParamManager::instance()->mCurParams.mName; 131 std::string water = LLWaterParamManager::instance()->mCurParams.mName;
122 std::string sky = LLWLParamManager::instance()->mCurParams.mName; 132 std::string sky = LLWLParamManager::instance()->mCurParams.mName;
123 133
124 // If they are using region settings already, or LightShare is 134 // If they are using region settings already, or LightShare is
125 // always allowed, just apply the new settings, don't bother asking. 135 // always allowed, just apply the new settings, don't bother asking.
126 if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ALWAYS || 136 if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ALWAYS ||
127 (sky == sSkyPresetName && water == sWaterPresetName) ) 137 (sky == LLWLParamManager::sSkyPresetName && water == LLWLParamManager::sWaterPresetName) )
128 { 138 {
129 wl->apply(); 139 mSky = thisSky;
130 delete wl; 140 mWater = thisWater;
141 mWaterNormal = thisWaterNormal;
142 LLWLParamManager::apply(mWater, mWaterNormal, mSky);
131 return; 143 return;
132 } 144 }
133 145
@@ -136,41 +148,36 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**)
136 // The user recently ignored a windlight message, so ignore 148 // The user recently ignored a windlight message, so ignore
137 // this one too, and restart the timer. 149 // this one too, and restart the timer.
138 restartIgnoreTimer(); 150 restartIgnoreTimer();
139 delete wl;
140 return; 151 return;
141 } 152 }
142 153
143 if(sIgnoreRegion) 154 if(sIgnoreRegion)
144 { 155 {
145 // We are ignoring new settings until user enters a new region. 156 // We are ignoring new settings until user enters a new region.
146 delete wl;
147 return; 157 return;
148 } 158 }
149 159
150 if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ASK && 160 if( gSavedSettings.getU32("LightShareAllowed") == LIGHTSHARE_ASK && mSky == NULL && mWater == NULL)
151 sMostRecent == NULL )
152 { 161 {
153 // No most recent, so store this and create notification 162 // No most recent, so store this and create notification
154 // asking the user whether to apply or not. 163 // asking the user whether to apply or not.
155 sMostRecent = wl; 164 mSky = thisSky;
156 LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), 165 mWater = thisWater;
166 mWaterNormal = thisWaterNormal;
167 LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(),
157 boost::bind(&applyCallback, _1, _2)); 168 boost::bind(&applyCallback, _1, _2));
158 return;
159 } 169 }
160 else 170 else
161 { 171 {
162 // No new notification (to avoid spamming the user), just 172 // No new notification (to avoid spamming the user, we do keep the saves from above)
163 // store this as most recent. 173 mSky = thisSky;
164 delete sMostRecent; 174 mWater = thisWater;
165 sMostRecent = wl; 175 mWaterNormal = thisWaterNormal;
166 return;
167 } 176 }
168} 177}
169 178
170
171// static 179// static
172bool WindlightMessage::applyCallback(const LLSD& notification, 180bool LightShare::applyCallback(const LLSD& notification, const LLSD& response)
173 const LLSD& response)
174{ 181{
175 S32 option = LLNotification::getSelectedOption(notification, response); 182 S32 option = LLNotification::getSelectedOption(notification, response);
176 183
@@ -178,7 +185,8 @@ bool WindlightMessage::applyCallback(const LLSD& notification,
178 { 185 {
179 case 0:{ 186 case 0:{
180 // "Apply" 187 // "Apply"
181 sMostRecent->apply(); 188 LLWLParamManager::apply(mWater, mWaterNormal, mSky);
189
182 break; 190 break;
183 } 191 }
184 case 1:{ 192 case 1:{
@@ -193,22 +201,18 @@ bool WindlightMessage::applyCallback(const LLSD& notification,
193 } 201 }
194 } 202 }
195 203
196 delete sMostRecent;
197 sMostRecent = NULL;
198
199 return false; 204 return false;
200} 205}
201 206
202
203// static 207// static
204void WindlightMessage::resetRegion() 208void LightShare::resetRegion()
205{ 209{
206 sIgnoreRegion = false; 210 sIgnoreRegion = false;
211 LLWorld::getInstance()->rebuildClouds(gAgent.getRegion());
207} 212}
208 213
209
210// static 214// static
211void WindlightMessage::restartIgnoreTimer() 215void LightShare::restartIgnoreTimer()
212{ 216{
213 F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); 217 F32 time = gSavedSettings.getF32("LightShareIgnoreTimer");
214 sIgnoreTimer->start(); 218 sIgnoreTimer->start();
@@ -216,51 +220,24 @@ void WindlightMessage::restartIgnoreTimer()
216} 220}
217 221
218// static 222// static
219bool WindlightMessage::ignoreTimerHasExpired() 223bool LightShare::ignoreTimerHasExpired()
220{ 224{
221 return sIgnoreTimer->hasExpired(); 225 return sIgnoreTimer->hasExpired();
222} 226}
223 227
224 228bool LightShare::isValid()
225bool WindlightMessage::apply()
226{
227 LLWaterParamManager* water_mgr = LLWaterParamManager::instance();
228 LLWLParamManager* sky_mgr = LLWLParamManager::instance();
229
230 mWater->mName = sWaterPresetName;
231 water_mgr->removeParamSet( sWaterPresetName, false );
232 water_mgr->addParamSet( sWaterPresetName, *mWater );
233 water_mgr->savePreset( sWaterPresetName );
234 water_mgr->loadPreset( sWaterPresetName, true );
235 water_mgr->setNormalMapID( *mWaterNormal );
236
237 mSky->mName = sSkyPresetName;
238 sky_mgr->mAnimator.mIsRunning = false;
239 sky_mgr->mAnimator.mUseLindenTime = false;
240 sky_mgr->removeParamSet( sSkyPresetName, false );
241 sky_mgr->addParamSet( sSkyPresetName, *mSky );
242 sky_mgr->savePreset( sSkyPresetName );
243 sky_mgr->loadPreset( sSkyPresetName, true );
244
245 return true;
246}
247
248
249bool WindlightMessage::isValid()
250{ 229{
251 return mIsValid; 230 return mIsValid;
252} 231}
253 232
254 233void LightShare::process_packet( char* buf )
255void WindlightMessage::process_packet( char* buf )
256{ 234{
257 // *FIXME: Horrible idea, fragile, not byte-order or endian 235 // *FIXME: Horrible idea, fragile, not byte-order or endian
258 // safe, no validation, etc. etc. -Jacek 236 // safe, no validation, etc. etc. -Jacek
259 mPacket = (Meta7WindlightPacket*)buf; 237 mPacket = (Meta7WindlightPacket*)buf;
260} 238}
261 239
262 240void LightShare::process_water()
263void WindlightMessage::process_water()
264{ 241{
265 mWater->set("waterFogColor", 242 mWater->set("waterFogColor",
266 mPacket->waterColor.red / 256.f, 243 mPacket->waterColor.red / 256.f,
@@ -316,7 +293,7 @@ void WindlightMessage::process_water()
316} 293}
317 294
318 295
319void WindlightMessage::process_sky() 296void LightShare::process_sky()
320{ 297{
321 mSky->setSunAngle(F_TWO_PI * mPacket->sunMoonPosiiton); 298 mSky->setSunAngle(F_TWO_PI * mPacket->sunMoonPosiiton);
322 mSky->setEastAngle(F_TWO_PI * mPacket->eastAngle); 299 mSky->setEastAngle(F_TWO_PI * mPacket->eastAngle);
@@ -411,5 +388,3 @@ void WindlightMessage::process_sky()
411 388
412 mSky->setStarBrightness(mPacket->starBrightness); 389 mSky->setStarBrightness(mPacket->starBrightness);
413} 390}
414
415
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 @@
30#define LIGHTSHARE_H 30#define LIGHTSHARE_H
31 31
32#include <string> 32#include <string>
33#include "llwlparamset.h"
34#include "llwaterparamset.h"
35#include "lluuid.h"
33 36
34struct Meta7WindlightPacket; 37struct Meta7WindlightPacket;
35class LLMessageSystem;
36class LLSD;
37class LLTimer;
38class LLUUID;
39class LLWaterParamSet;
40class LLWLParamSet;
41 38
42 39
43// Encapsulates a "Windlight" (LightShare) message sent from the 40// Encapsulates a "Windlight" (LightShare) message sent from the
44// region, allowing the settings to be applied at a later time. 41// region, allowing the settings to be applied at a later time.
45// 42//
46class WindlightMessage 43class LightShare
47{ 44{
48 public: 45public:
49
50 // The meanings of the LightShareAllowed user setting. 46 // The meanings of the LightShareAllowed user setting.
51 enum LIGHTSHARE_ALLOWED 47 enum LIGHTSHARE_ALLOWED
52 { 48 {
@@ -55,61 +51,40 @@ class WindlightMessage
55 LIGHTSHARE_ALWAYS = 2, 51 LIGHTSHARE_ALWAYS = 2,
56 }; 52 };
57 53
58 // Constructs a new WindlightMessage instance from a GenericMessage 54 // Constructs a new LightShare instance from a GenericMessage
59 // with the "Windlight" method, such as those sent by a 55 // with the "Windlight" method, such as those sent by a
60 // Lightshare-enabled OpenSim region. 56 // Lightshare-enabled OpenSim region.
61 WindlightMessage( LLMessageSystem* msg ); 57 LightShare( LLMessageSystem* msg );
62
63 ~WindlightMessage();
64
65 // The name of the water preset where the region settings are stored.
66 static const std::string sWaterPresetName;
67 58
68 // The name of the sky preset where the region settings are stored. 59 ~LightShare();
69 static const std::string sSkyPresetName;
70 60
71 // Message handler for GenericMessage with the "Windlight" method. 61 // Message handler for GenericMessage with the "Windlight" method.
72 // Creates and applies a new WindlightMessage (or prompts user). 62 // Creates and applies a new LightShare (or prompts user).
73 static void processWindlight(LLMessageSystem* msg, void**); 63 static void processWindlight(LLMessageSystem* msg, void**);
74 64
75 // Callback when the user interacts with the notification. 65 static void applyMaybe(LLWaterParamSet* thisWater, LLUUID* thisVaterNormal, LLWLParamSet* thisSky);
76 static bool applyCallback(const LLSD& notification,
77 const LLSD& response);
78 66
79 // Called after the user has entered a new region, to reset the 67 // Called after the user has entered a new region, to reset the
80 // "ignore while in this region" state. 68 // "ignore while in this region" state.
81 static void resetRegion(); 69 static void resetRegion();
82 70
83 // Applies/activates the Windlight settings from the message.
84 bool apply();
85
86 // Returns true if the message contains valid Windlight settings. 71 // Returns true if the message contains valid Windlight settings.
87 // (But there's no real validation yet, so this is always true.) 72 // (But there's no real validation yet, so this is always true.)
88 bool isValid(); 73 bool isValid();
89 74
90 75private:
91 protected:
92
93 // Restart the timer for temporarily ignoring settings.
94 static void restartIgnoreTimer();
95
96 // Returns true if the ignore timer has expired (i.e. new settings
97 // should not be ignored anymore).
98 static bool ignoreTimerHasExpired();
99
100
101 private:
102
103 static WindlightMessage* sMostRecent;
104 static LLTimer* sIgnoreTimer; 76 static LLTimer* sIgnoreTimer;
105 static bool sIgnoreRegion; 77 static bool sIgnoreRegion;
106 78
107 Meta7WindlightPacket* mPacket; 79 Meta7WindlightPacket* mPacket;
108 LLWaterParamSet* mWater; 80 static LLWaterParamSet* mWater;
109 LLWLParamSet* mSky; 81 static LLWLParamSet* mSky;
110 LLUUID* mWaterNormal; 82 static LLUUID* mWaterNormal;
111 bool mIsValid; 83 bool mIsValid;
112 84
85 // Callback when the user interacts with the notification.
86 static bool applyCallback(const LLSD& notification, const LLSD& response);
87
113 // Converts the message's raw bytes into a Meta7WindlightPacket. 88 // Converts the message's raw bytes into a Meta7WindlightPacket.
114 void process_packet( char* buf ); 89 void process_packet( char* buf );
115 90
@@ -119,6 +94,12 @@ class WindlightMessage
119 // Constructs a LLWLParamSet from the Meta7WindlightPacket. 94 // Constructs a LLWLParamSet from the Meta7WindlightPacket.
120 void process_sky(); 95 void process_sky();
121 96
97 // Restart the timer for temporarily ignoring settings.
98 static void restartIgnoreTimer();
99
100 // Returns true if the ignore timer has expired (i.e. new settings
101 // should not be ignored anymore).
102 static bool ignoreTimerHasExpired();
122}; 103};
123 104
124#endif 105#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**)
87 87
88 // TODO: Use a proper dispatcher. 88 // TODO: Use a proper dispatcher.
89 if(method == "Windlight") 89 if(method == "Windlight")
90 { 90 {
91 WindlightMessage::processWindlight(msg, NULL); 91 LightShare::processWindlight(msg, NULL);
92 return; 92 return;
93 } 93 }
94 94
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 @@
152 152
153#include "hippogridmanager.h" 153#include "hippogridmanager.h"
154#include "hippolimits.h" 154#include "hippolimits.h"
155#include "wlsettingsmanager.h"
156 155
157#if LL_WINDOWS // For Windows specific error handler 156#if LL_WINDOWS // For Windows specific error handler
158#include "llwindebug.h" // For the invalid message handler 157#include "llwindebug.h" // For the invalid message handler
@@ -3548,8 +3547,7 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
3548// gViewerWindow->setShowProgress(TRUE); 3547// gViewerWindow->setShowProgress(TRUE);
3549 3548
3550 // Tell the LightShare handler that we have changed regions. 3549 // Tell the LightShare handler that we have changed regions.
3551 WindlightMessage::resetRegion(); 3550 LightShare::resetRegion();
3552 WLSettingsManager::wlresetRegion();
3553} 3551}
3554 3552
3555// stuff we have to do every time we get an AvatarInitComplete from a sim 3553// 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**)
3827 regionp->setSeedCapability(seedCap); 3825 regionp->setSeedCapability(seedCap);
3828 3826
3829 // Tell the LightShare handler that we have changed regions. 3827 // Tell the LightShare handler that we have changed regions.
3830 WindlightMessage::resetRegion(); 3828 LightShare::resetRegion();
3831 WLSettingsManager::wlresetRegion();
3832} 3829}
3833 3830
3834 3831
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 @@
33#include "llviewerprecompiledheaders.h" 33#include "llviewerprecompiledheaders.h"
34 34
35#include "llwlparammanager.h" 35#include "llwlparammanager.h"
36#include "llwaterparammanager.h"
36 37
37#include "pipeline.h" 38#include "pipeline.h"
38#include "llsky.h" 39#include "llsky.h"
@@ -60,6 +61,7 @@
60#include "llfloaterdaycycle.h" 61#include "llfloaterdaycycle.h"
61#include "llfloaterenvsettings.h" 62#include "llfloaterenvsettings.h"
62 63
64#include "llworld.h"
63 65
64// For notecard loading 66// For notecard loading
65#include "llvfile.h" 67#include "llvfile.h"
@@ -75,6 +77,9 @@
75 77
76#include "curl/curl.h" 78#include "curl/curl.h"
77 79
80const std::string LLWLParamManager::sWaterPresetName = "(Region settings)";
81const std::string LLWLParamManager::sSkyPresetName = "(Region settings)";
82
78LLWLParamManager * LLWLParamManager::sInstance = NULL; 83LLWLParamManager * LLWLParamManager::sInstance = NULL;
79std::vector<LLWLPresetsObserver*> LLWLParamManager::sObservers; 84std::vector<LLWLPresetsObserver*> LLWLParamManager::sObservers;
80LLFrameTimer wlSmoothTransitionTimer; 85LLFrameTimer wlSmoothTransitionTimer;
@@ -854,3 +859,62 @@ bool LLWLParamManager::isSettingsNotecard(std::string name)
854{ 859{
855 return (isSkySettingsNotecard(name) || isWaterSettingsNotecard(name)); 860 return (isSkySettingsNotecard(name) || isWaterSettingsNotecard(name));
856} 861}
862
863//static
864void LLWLParamManager::apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky)
865{
866 LLWaterParamManager* waterMgr = LLWaterParamManager::instance();
867 LLWLParamManager* skyMgr = LLWLParamManager::instance();
868
869 F32 fade = 0; //Instant
870 bool error;
871 fade = newSky->getFloat("fade", error);
872
873 newWater->mName = sWaterPresetName;
874 if(fade != 0 && waterMgr->mCurParams.mName == sWaterPresetName)//Load the settings forcefully the first time
875 {
876 LLWaterParamSet oldWset = waterMgr->mCurParams;
877 //This still needs done so that we update right, but load it to the old
878 waterMgr->removeParamSet( sWaterPresetName, false );
879 waterMgr->addParamSet( sWaterPresetName, oldWset );
880 waterMgr->savePreset( sWaterPresetName );
881 waterMgr->loadPreset( sWaterPresetName, true );
882 waterMgr->setNormalMapID( *newWaterNormal );
883 //Then mix with the new
884 waterMgr->SetMixTime(newWater, fade);
885 }
886 else
887 {
888 //Instant if fade is 0
889 waterMgr->removeParamSet( sWaterPresetName, false );
890 waterMgr->addParamSet( sWaterPresetName, *newWater );
891 waterMgr->savePreset( sWaterPresetName );
892 waterMgr->loadPreset( sWaterPresetName, true );
893 waterMgr->setNormalMapID( *newWaterNormal );
894 }
895
896 newSky->mName = sSkyPresetName;
897 if(fade != 0 && skyMgr->mCurParams.mName == sSkyPresetName)//Load the settings forcefully the first time
898 {
899 LLWLParamSet oldset = skyMgr->mCurParams;
900 //This still needs done so that we update right, but load it to the old
901 skyMgr->removeParamSet( sSkyPresetName, true );
902 skyMgr->addParamSet( sSkyPresetName, oldset );
903 skyMgr->savePreset( sSkyPresetName );
904 skyMgr->loadPreset( sSkyPresetName, true );
905 //Then mix with the new
906 skyMgr->SetMixTime(newSky, fade);
907 }
908 else
909 {
910 //Instant if fade is 0
911 skyMgr->mAnimator.mIsRunning = false;
912 skyMgr->mAnimator.mUseLindenTime = false;
913 skyMgr->removeParamSet( sSkyPresetName, false );
914 skyMgr->addParamSet( sSkyPresetName, *newSky );
915 skyMgr->savePreset( sSkyPresetName );
916 skyMgr->loadPreset( sSkyPresetName, true );
917 }
918
919 LLWorld::getInstance()->rebuildClouds(gAgent.getRegion());
920}
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 @@
36#include <vector> 36#include <vector>
37#include <map> 37#include <map>
38#include "llwlparamset.h" 38#include "llwlparamset.h"
39#include "llwaterparamset.h"
39#include "llwlanimator.h" 40#include "llwlanimator.h"
40#include "llwldaycycle.h" 41#include "llwldaycycle.h"
41#include "llviewercamera.h" 42#include "llviewercamera.h"
@@ -228,6 +229,8 @@ public:
228 static bool isSkySettingsNotecard(std::string name); 229 static bool isSkySettingsNotecard(std::string name);
229 static bool isSettingsNotecard(std::string name); 230 static bool isSettingsNotecard(std::string name);
230 231
232 static void apply(LLWaterParamSet * newWater, LLUUID *newWaterNormal, LLWLParamSet *newSky);
233
231public: 234public:
232 235
233 // helper variables 236 // helper variables
@@ -284,6 +287,12 @@ public:
284 // list of all the parameters, listed by name 287 // list of all the parameters, listed by name
285 std::map<std::string, LLWLParamSet> mParamList; 288 std::map<std::string, LLWLParamSet> mParamList;
286 289
290 // The name of the water preset where the region settings are stored.
291 static const std::string sWaterPresetName;
292
293 // The name of the sky preset where the region settings are stored.
294 static const std::string sSkyPresetName;
295
287private: 296private:
288 // our parameter manager singleton instance 297 // our parameter manager singleton instance
289 static LLWLParamManager * sInstance; 298 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 @@
70#include "llviewerparcelmgr.h" 70#include "llviewerparcelmgr.h"
71#include "llparcel.h" 71#include "llparcel.h"
72#include "wlretrievesettings.h" 72#include "wlretrievesettings.h"
73#include "wlsettingsmanager.h" 73#include "lightshare.h"
74#include "wlfloaterwindlightsend.h" 74#include "wlfloaterwindlightsend.h"
75 75
76#undef max 76#undef max
@@ -214,7 +214,7 @@ void WLFloaterManager::onShow(void* userData)
214 LLWaterParamSet* mWater = mgr->mWaterParamList[name]; 214 LLWaterParamSet* mWater = mgr->mWaterParamList[name];
215 LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name]; 215 LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name];
216 if(mSky != NULL && mWater != NULL && mWaterNormal != NULL) 216 if(mSky != NULL && mWater != NULL && mWaterNormal != NULL)
217 WLSettingsManager::Apply(mSky, mWater, mWaterNormal); 217 LightShare::applyMaybe(mWater, mWaterNormal, mSky);
218} 218}
219void WLFloaterManager::onSetToCurrent(void* userData) 219void WLFloaterManager::onSetToCurrent(void* userData)
220{ 220{
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 @@
67#include "hippolimits.h" 67#include "hippolimits.h"
68#include "wlfloaterwindlightsend.h" 68#include "wlfloaterwindlightsend.h"
69#include "llviewerregion.h" 69#include "llviewerregion.h"
70#include "wlsettingsmanager.h"
71#include "lightshare.h" 70#include "lightshare.h"
72 71
73#include "linden_common.h" 72#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 @@
1/**
2* @file wlfloaterwindlightsend.cpp
3* @brief WLFloaterWindLightSend class definition
4*
5* $LicenseInfo:firstyear=2007&license=viewergpl$
6*
7* Copyright (c) 2007-2009, Linden Research, Inc.
8*
9* Second Life Viewer Source Code
10* The source code in this file ("Source Code") is provided by Linden Lab
11* to you under the terms of the GNU General Public License, version 2.0
12* ("GPL"), unless you have obtained a separate licensing agreement
13* ("Other License"), formally executed by you and Linden Lab. Terms of
14* the GPL can be found in doc/GPL-license.txt in this distribution, or
15* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16*
17* There are special exceptions to the terms and conditions of the GPL as
18* it is applied to this Source Code. View the full text of the exception
19* in the file doc/FLOSS-exception.txt in this software distribution, or
20* online at
21* http://secondlifegrid.net/programs/open_source/licensing/flossexception
22*
23* By copying, modifying or distributing this software, you acknowledge
24* that you have read and understood your obligations described above,
25* and agree to abide by those obligations.
26*
27* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29* COMPLETENESS OR PERFORMANCE.
30* $/LicenseInfo$
31*/
32
33#include "llviewerprecompiledheaders.h"
34
35#include "llfloaterwindlight.h"
36
37#include "pipeline.h"
38#include "llsky.h"
39
40#include "llsliderctrl.h"
41#include "llmultislider.h"
42#include "llmultisliderctrl.h"
43#include "llspinctrl.h"
44#include "llcheckboxctrl.h"
45#include "lluictrlfactory.h"
46#include "llviewercamera.h"
47#include "llcombobox.h"
48#include "lllineeditor.h"
49#include "llfloaterdaycycle.h"
50#include "lltabcontainer.h"
51#include "llboost.h"
52
53#include "llagent.h"
54#include "llinventorymodel.h"
55#include "llviewerinventory.h"
56
57#include "v4math.h"
58#include "llviewerdisplay.h"
59#include "llviewercontrol.h"
60#include "llviewerwindow.h"
61#include "llsavedsettingsglue.h"
62
63#include "llwlparamset.h"
64#include "llwlparammanager.h"
65#include "llwaterparammanager.h"
66#include "llpostprocess.h"
67#include "hippolimits.h"
68#include "wlfloaterwindlightsend.h"
69#include "llviewerregion.h"
70#include "wlsettingsmanager.h"
71#include "lightshare.h"
72
73#include "linden_common.h"
74#include "llviewercontrol.h"
75#include "message.h"
76#include "meta7windlight.h"
77#include "llworld.h"
78
79#undef max
80
81const std::string WLSettingsManager::wlWaterPresetName = "(Region settings)";
82const std::string WLSettingsManager::wlSkyPresetName = "(Region settings)";
83
84LLTimer* WLSettingsManager::wlIgnoreTimer = new LLTimer();
85bool WLSettingsManager::wlIgnoreRegion = false;
86LLWaterParamSet* WLSettingsManager::mWater = NULL;
87LLWLParamSet* WLSettingsManager::mSky = NULL;
88LLUUID* WLSettingsManager::mWaterNormal = NULL;
89
90void WLSettingsManager::Apply( LLWLParamSet* Sky, LLWaterParamSet* Water, LLUUID* WaterNormal )
91{
92 if( gSavedSettings.getU32("LightShareAllowed") <= WindlightMessage::LIGHTSHARE_NEVER )
93 return;
94
95 std::string water = LLWaterParamManager::instance()->mCurParams.mName;
96 std::string sky = LLWLParamManager::instance()->mCurParams.mName;
97
98 // If they are using region settings already, or LightShare is
99 // always allowed, just apply the new settings, don't bother asking.
100 if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ALWAYS ||
101 (sky == wlSkyPresetName && water == wlWaterPresetName) )
102 {
103 mSky = Sky;
104 mWater = Water;
105 mWaterNormal = WaterNormal;
106 Apply();
107 return;
108 }
109
110 if( !wlignoreTimerHasExpired() )
111 {
112 // The user recently ignored a windlight message, so ignore
113 // this one too, and restart the timer.
114 wlrestartIgnoreTimer();
115 return;
116 }
117
118 if(wlIgnoreRegion)
119 {
120 // We are ignoring new settings until user enters a new region.
121 return;
122 }
123
124 if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ASK &&
125 mSky == NULL && mWater == NULL)
126 {
127 // No most recent, so store this and create notification
128 // asking the user whether to apply or not.
129 mSky = Sky;
130 mWater = Water;
131 mWaterNormal = WaterNormal;
132 LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(),
133 boost::bind(&wlapplyCallback, _1, _2));
134 }
135 else
136 {
137 // No new notification (to avoid spamming the user, we do keep the saves from above)
138 mSky = Sky;
139 mWater = Water;
140 mWaterNormal = WaterNormal;
141 }
142}
143
144// static
145bool WLSettingsManager::wlapplyCallback(const LLSD& notification,
146 const LLSD& response)
147{
148 S32 option = LLNotification::getSelectedOption(notification, response);
149
150 switch(option)
151 {
152 case 0:{
153 // "Apply"
154 Apply();
155 break;
156 }
157 case 1:{
158 // "Not Now", ignore until the region stops spamming
159 wlrestartIgnoreTimer();
160 break;
161 }
162 case 2:{
163 // "Ignore", ignore all until user leaves the region
164 wlIgnoreRegion = true;
165 break;
166 }
167 }
168 return false;
169}
170
171//static
172void WLSettingsManager::Apply()
173{
174 LLWaterParamManager* water_mgr = LLWaterParamManager::instance();
175 LLWLParamManager* sky_mgr = LLWLParamManager::instance();
176
177 F32 fade = 0; //Instant
178 bool error;
179 fade = mSky->getFloat("fade", error);
180
181 mWater->mName = wlWaterPresetName;
182 if(fade != 0 && water_mgr->mCurParams.mName == wlWaterPresetName)//Load the settings forcefully the first time
183 {
184 LLWaterParamSet oldWset = water_mgr->mCurParams;
185 //This still needs done so that we update right, but load it to the old
186 water_mgr->removeParamSet( wlWaterPresetName, false );
187 water_mgr->addParamSet( wlWaterPresetName, oldWset );
188 water_mgr->savePreset( wlWaterPresetName );
189 water_mgr->loadPreset( wlWaterPresetName, true );
190 water_mgr->setNormalMapID( *mWaterNormal );
191 //Then mix with the new
192 water_mgr->SetMixTime(mWater, fade);
193 }
194 else
195 {
196 //Instant if fade is 0
197 water_mgr->removeParamSet( wlWaterPresetName, false );
198 water_mgr->addParamSet( wlWaterPresetName, *mWater );
199 water_mgr->savePreset( wlWaterPresetName );
200 water_mgr->loadPreset( wlWaterPresetName, true );
201 water_mgr->setNormalMapID( *mWaterNormal );
202 }
203
204 mSky->mName = wlSkyPresetName;
205 if(fade != 0 && sky_mgr->mCurParams.mName == wlSkyPresetName)//Load the settings forcefully the first time
206 {
207 LLWLParamSet oldset = sky_mgr->mCurParams;
208 //This still needs done so that we update right, but load it to the old
209 sky_mgr->removeParamSet( wlSkyPresetName, true );
210 sky_mgr->addParamSet( wlSkyPresetName, oldset );
211 sky_mgr->savePreset( wlSkyPresetName );
212 sky_mgr->loadPreset( wlSkyPresetName, true );
213 //Then mix with the new
214 sky_mgr->SetMixTime(mSky, fade);
215 }
216 else
217 {
218 //Instant if fade is 0
219 sky_mgr->mAnimator.mIsRunning = false;
220 sky_mgr->mAnimator.mUseLindenTime = false;
221 sky_mgr->removeParamSet( wlSkyPresetName, false );
222 sky_mgr->addParamSet( wlSkyPresetName, *mSky );
223 sky_mgr->savePreset( wlSkyPresetName );
224 sky_mgr->loadPreset( wlSkyPresetName, true );
225 }
226
227 LLWorld::getInstance()->rebuildClouds(gAgent.getRegion());
228
229 mSky = NULL;
230 mWater = NULL;
231 mWaterNormal = NULL;
232}
233
234// static
235void WLSettingsManager::wlresetRegion()
236{
237 wlIgnoreRegion = false;
238 LLWorld::getInstance()->rebuildClouds(gAgent.getRegion());
239}
240
241// static
242void WLSettingsManager::wlrestartIgnoreTimer()
243{
244 F32 time = gSavedSettings.getF32("LightShareIgnoreTimer");
245 wlIgnoreTimer->start();
246 wlIgnoreTimer->setTimerExpirySec( (time < 0) ? 0 : time );
247}
248
249// static
250bool WLSettingsManager::wlignoreTimerHasExpired()
251{
252 return wlIgnoreTimer->hasExpired();
253} \ 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 @@
1/**
2 * @file wlfloaterwindlightsend.h
3 * @brief WLFloaterWindLightSend class definition
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33/*
34 * Menu for adjusting the atmospheric settings of the world
35 */
36
37#ifndef WINDLIGHTSETTINGSMANAGER_H
38#define WINDLIGHTSETTINGSMANAGER_H
39
40#include <string>
41#include "llwlparamset.h"
42#include "llwaterparamset.h"
43#include "lluuid.h"
44
45class LLSD;
46class LLTimer;
47class LLUUID;
48class LLWaterParamSet;
49class LLWLParamSet;
50
51
52/// Menuing system for all of windlight's functionality
53class WLSettingsManager
54{
55public:
56
57 static LLTimer* wlIgnoreTimer;
58 static bool wlIgnoreRegion;
59
60 // Called after the user has entered a new region, to reset the
61 // "ignore while in this region" state.
62 static void wlresetRegion();
63
64 static void Apply( LLWLParamSet* Sky, LLWaterParamSet* Water, LLUUID* WaterNormal );
65
66 // Callback when the user interacts with the notification.
67 static bool wlapplyCallback(const LLSD& notification,
68 const LLSD& response);
69
70 static LLWaterParamSet* mWater;
71 static LLWLParamSet* mSky;
72 static LLUUID* mWaterNormal;
73
74private:
75 static void Apply();
76
77 // The name of the water preset where the region settings are stored.
78 static const std::string wlWaterPresetName;
79
80 // The name of the sky preset where the region settings are stored.
81 static const std::string wlSkyPresetName;
82
83 // Restart the timer for temporarily ignoring settings.
84 static void wlrestartIgnoreTimer();
85
86 // Returns true if the ignore timer has expired (i.e. new settings
87 // should not be ignored anymore).
88 static bool wlignoreTimerHasExpired();
89};
90#endif \ No newline at end of file