aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/wlsettingsmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/wlsettingsmanager.cpp253
1 files changed, 253 insertions, 0 deletions
diff --git a/linden/indra/newview/wlsettingsmanager.cpp b/linden/indra/newview/wlsettingsmanager.cpp
new file mode 100644
index 0000000..853d14f
--- /dev/null
+++ b/linden/indra/newview/wlsettingsmanager.cpp
@@ -0,0 +1,253 @@
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