diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/wlsettingsmanager.cpp | 249 |
1 files changed, 249 insertions, 0 deletions
diff --git a/linden/indra/newview/wlsettingsmanager.cpp b/linden/indra/newview/wlsettingsmanager.cpp new file mode 100644 index 0000000..78516df --- /dev/null +++ b/linden/indra/newview/wlsettingsmanager.cpp | |||
@@ -0,0 +1,249 @@ | |||
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 | |||
78 | #undef max | ||
79 | |||
80 | const std::string WLSettingsManager::wlWaterPresetName = "(Region settings)"; | ||
81 | const std::string WLSettingsManager::wlSkyPresetName = "(Region settings)"; | ||
82 | |||
83 | LLTimer* WLSettingsManager::wlIgnoreTimer = new LLTimer(); | ||
84 | bool WLSettingsManager::wlIgnoreRegion = false; | ||
85 | LLWaterParamSet* WLSettingsManager::mWater = NULL; | ||
86 | LLWLParamSet* WLSettingsManager::mSky = NULL; | ||
87 | LLUUID* WLSettingsManager::mWaterNormal = NULL; | ||
88 | |||
89 | void WLSettingsManager::Apply( LLWLParamSet* Sky, LLWaterParamSet* Water, LLUUID* WaterNormal ) | ||
90 | { | ||
91 | if( gSavedSettings.getU32("LightShareAllowed") <= WindlightMessage::LIGHTSHARE_NEVER ) | ||
92 | return; | ||
93 | |||
94 | std::string water = LLWaterParamManager::instance()->mCurParams.mName; | ||
95 | std::string sky = LLWLParamManager::instance()->mCurParams.mName; | ||
96 | |||
97 | // If they are using region settings already, or LightShare is | ||
98 | // always allowed, just apply the new settings, don't bother asking. | ||
99 | if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ALWAYS || | ||
100 | (sky == wlSkyPresetName && water == wlWaterPresetName) ) | ||
101 | { | ||
102 | mSky = Sky; | ||
103 | mWater = Water; | ||
104 | mWaterNormal = WaterNormal; | ||
105 | Apply(); | ||
106 | return; | ||
107 | } | ||
108 | |||
109 | if( !wlignoreTimerHasExpired() ) | ||
110 | { | ||
111 | // The user recently ignored a windlight message, so ignore | ||
112 | // this one too, and restart the timer. | ||
113 | wlrestartIgnoreTimer(); | ||
114 | return; | ||
115 | } | ||
116 | |||
117 | if(wlIgnoreRegion) | ||
118 | { | ||
119 | // We are ignoring new settings until user enters a new region. | ||
120 | return; | ||
121 | } | ||
122 | |||
123 | if( gSavedSettings.getU32("LightShareAllowed") == WindlightMessage::LIGHTSHARE_ASK && | ||
124 | mSky == NULL && mWater == NULL) | ||
125 | { | ||
126 | // No most recent, so store this and create notification | ||
127 | // asking the user whether to apply or not. | ||
128 | mSky = Sky; | ||
129 | mWater = Water; | ||
130 | mWaterNormal = WaterNormal; | ||
131 | LLNotifications::instance().add("ConfirmLightShare", LLSD(), LLSD(), | ||
132 | boost::bind(&wlapplyCallback, _1, _2)); | ||
133 | } | ||
134 | else | ||
135 | { | ||
136 | // No new notification (to avoid spamming the user, we do keep the saves from above) | ||
137 | mSky = Sky; | ||
138 | mWater = Water; | ||
139 | mWaterNormal = WaterNormal; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | // static | ||
144 | bool WLSettingsManager::wlapplyCallback(const LLSD& notification, | ||
145 | const LLSD& response) | ||
146 | { | ||
147 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
148 | |||
149 | switch(option) | ||
150 | { | ||
151 | case 0:{ | ||
152 | // "Apply" | ||
153 | Apply(); | ||
154 | break; | ||
155 | } | ||
156 | case 1:{ | ||
157 | // "Not Now", ignore until the region stops spamming | ||
158 | wlrestartIgnoreTimer(); | ||
159 | break; | ||
160 | } | ||
161 | case 2:{ | ||
162 | // "Ignore", ignore all until user leaves the region | ||
163 | wlIgnoreRegion = true; | ||
164 | break; | ||
165 | } | ||
166 | } | ||
167 | return false; | ||
168 | } | ||
169 | |||
170 | //static | ||
171 | void WLSettingsManager::Apply() | ||
172 | { | ||
173 | LLWaterParamManager* water_mgr = LLWaterParamManager::instance(); | ||
174 | LLWLParamManager* sky_mgr = LLWLParamManager::instance(); | ||
175 | |||
176 | F32 fade = 0; //Instant | ||
177 | bool error; | ||
178 | fade = mSky->getFloat("fade", error); | ||
179 | |||
180 | mWater->mName = wlWaterPresetName; | ||
181 | if(fade != 0) | ||
182 | { | ||
183 | LLWaterParamSet oldWset = water_mgr->mCurParams; | ||
184 | //This still needs done so that we update right, but load it to the old | ||
185 | water_mgr->removeParamSet( wlWaterPresetName, false ); | ||
186 | water_mgr->addParamSet( wlWaterPresetName, oldWset ); | ||
187 | water_mgr->savePreset( wlWaterPresetName ); | ||
188 | water_mgr->loadPreset( wlWaterPresetName, true ); | ||
189 | water_mgr->setNormalMapID( *mWaterNormal ); | ||
190 | //Then mix with the new | ||
191 | water_mgr->SetMixTime(mWater, fade); | ||
192 | } | ||
193 | else | ||
194 | { | ||
195 | //Instant if fade is 0 | ||
196 | water_mgr->removeParamSet( wlWaterPresetName, false ); | ||
197 | water_mgr->addParamSet( wlWaterPresetName, *mWater ); | ||
198 | water_mgr->savePreset( wlWaterPresetName ); | ||
199 | water_mgr->loadPreset( wlWaterPresetName, true ); | ||
200 | water_mgr->setNormalMapID( *mWaterNormal ); | ||
201 | } | ||
202 | |||
203 | mSky->mName = wlSkyPresetName; | ||
204 | if(fade != 0) | ||
205 | { | ||
206 | LLWLParamSet oldset = sky_mgr->mCurParams; | ||
207 | //This still needs done so that we update right, but load it to the old | ||
208 | sky_mgr->removeParamSet( wlSkyPresetName, true ); | ||
209 | sky_mgr->addParamSet( wlSkyPresetName, oldset ); | ||
210 | sky_mgr->savePreset( wlSkyPresetName ); | ||
211 | sky_mgr->loadPreset( wlSkyPresetName, true ); | ||
212 | //Then mix with the new | ||
213 | sky_mgr->SetMixTime(mSky, fade); | ||
214 | } | ||
215 | else | ||
216 | { | ||
217 | //Instant if fade is 0 | ||
218 | sky_mgr->mAnimator.mIsRunning = false; | ||
219 | sky_mgr->mAnimator.mUseLindenTime = false; | ||
220 | sky_mgr->removeParamSet( wlSkyPresetName, false ); | ||
221 | sky_mgr->addParamSet( wlSkyPresetName, *mSky ); | ||
222 | sky_mgr->savePreset( wlSkyPresetName ); | ||
223 | sky_mgr->loadPreset( wlSkyPresetName, true ); | ||
224 | } | ||
225 | |||
226 | mSky = NULL; | ||
227 | mWater = NULL; | ||
228 | mWaterNormal = NULL; | ||
229 | } | ||
230 | |||
231 | // static | ||
232 | void WLSettingsManager::wlresetRegion() | ||
233 | { | ||
234 | wlIgnoreRegion = false; | ||
235 | } | ||
236 | |||
237 | // static | ||
238 | void WLSettingsManager::wlrestartIgnoreTimer() | ||
239 | { | ||
240 | F32 time = gSavedSettings.getF32("LightShareIgnoreTimer"); | ||
241 | wlIgnoreTimer->start(); | ||
242 | wlIgnoreTimer->setTimerExpirySec( (time < 0) ? 0 : time ); | ||
243 | } | ||
244 | |||
245 | // static | ||
246 | bool WLSettingsManager::wlignoreTimerHasExpired() | ||
247 | { | ||
248 | return wlIgnoreTimer->hasExpired(); | ||
249 | } \ No newline at end of file | ||