aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/wlfloatermanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/wlfloatermanager.cpp281
1 files changed, 281 insertions, 0 deletions
diff --git a/linden/indra/newview/wlfloatermanager.cpp b/linden/indra/newview/wlfloatermanager.cpp
new file mode 100644
index 0000000..1946807
--- /dev/null
+++ b/linden/indra/newview/wlfloatermanager.cpp
@@ -0,0 +1,281 @@
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 "wlfloatermanager.h"
69#include "llviewerregion.h"
70#include "llviewerparcelmgr.h"
71#include "llparcel.h"
72#include "wlretrievesettings.h"
73#include "wlsettingsmanager.h"
74#include "wlfloaterwindlightsend.h"
75
76#undef max
77WLFloaterManager* WLFloaterManager::sWindLight;
78std::map<std::string, LLWLParamSet*> WLFloaterManager::mWLParamList;
79std::map<std::string, LLWaterParamSet*> WLFloaterManager::mWaterParamList;
80std::map<std::string, LLUUID*> WLFloaterManager::mWaterNormalParamList;
81std::map<std::string, LLSD> WLFloaterManager::mMinAltParamList;
82std::map<std::string, LLSD> WLFloaterManager::mMaxAltParamList;
83std::map<std::string, LLSD> WLFloaterManager::mFadeParamList;
84
85WLFloaterManager::WLFloaterManager() : LLFloater(std::string("windlight manager floater"))
86{
87 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_manager.xml");
88
89 // load it up
90 initCallbacks();
91}
92
93WLFloaterManager::~WLFloaterManager()
94{
95}
96
97void WLFloaterManager::initCallbacks(void) {
98
99 // help buttons
100 childSetAction("this_parcel", onGetThisParcel, this);
101 childSetAction("all_parcels", onGetAllParcels, this);
102 childSetAction("this_region", onGetThisRegion, this);
103 childSetAction("show", onShow, this);
104 childSetAction("set_to_current", onSetToCurrent, this);
105 childSetAction("remove", onRemove, this);
106}
107
108void WLFloaterManager::onClickHelp(void* data)
109{
110 LLFloaterWindLight* self = LLFloaterWindLight::instance();
111
112 const std::string xml_alert = *(std::string*)data;
113 LLNotifications::instance().add(self->contextualNotification(xml_alert));
114}
115
116void WLFloaterManager::initHelpBtn(const std::string& name, const std::string& xml_alert)
117{
118 childSetAction(name, onClickHelp, new std::string(xml_alert));
119}
120
121// static
122WLFloaterManager* WLFloaterManager::instance()
123{
124 if (!sWindLight)
125 {
126 sWindLight = new WLFloaterManager();
127 sWindLight->open();
128 sWindLight->setFocus(TRUE);
129 }
130 return sWindLight;
131}
132
133void WLFloaterManager::show()
134{
135 if (!sWindLight)
136 {
137 WLFloaterManager::instance();
138 }
139 else
140 {
141 if (sWindLight->getVisible())
142 {
143 sWindLight->close();
144 }
145 else
146 {
147 sWindLight->open();
148 }
149 }
150}
151
152bool WLFloaterManager::isOpen()
153{
154 if (sWindLight != NULL) {
155 return true;
156 }
157 return false;
158}
159
160// virtual
161void WLFloaterManager::onClose(bool app_quitting)
162{
163 if (sWindLight)
164 {
165 sWindLight->setVisible(FALSE);
166 }
167}
168
169void WLFloaterManager::onGetThisRegion(void* userData)
170{
171 LLSD body;
172
173 //Send the update CAPS to the server
174 std::string url = gAgent.getRegion()->getCapability("RetrieveWindLightSettings");
175 if (!url.empty())
176 {
177 body["RegionID"] = gAgent.getRegion()->getRegionID();
178 LLHTTPClient::post(url, body, new retrieveWindlightSettings(body));
179 }
180}
181
182void WLFloaterManager::onGetThisParcel(void* userData)
183{
184 LLSD body;
185
186 //Send the update CAPS to the server
187 std::string url = gAgent.getRegion()->getCapability("RetrieveWindLightSettings");
188 if (!url.empty())
189 {
190 body["ParcelID"] = LLViewerParcelMgr::getInstance()->getAgentParcel()->getLocalID();
191 LLHTTPClient::post(url, body, new retrieveWindlightSettings(body));
192 }
193}
194void WLFloaterManager::onGetAllParcels(void* userData)
195{
196 LLSD body;
197
198 //Send the update CAPS to the server
199 std::string url = gAgent.getRegion()->getCapability("RetrieveWindLightSettings");
200 if (!url.empty())
201 {
202 body["ParcelID"] = -1;
203 LLHTTPClient::post(url, body, new retrieveWindlightSettings(body));
204 }
205}
206
207void WLFloaterManager::onShow(void* userData)
208{
209 WLFloaterManager* mgr = WLFloaterManager::instance();
210 LLComboBox* comboBox = mgr->getChild<LLComboBox>("WLSettingsCombo");
211 std::string name = comboBox->getSelectedItemLabel();
212 //Set the new settings up
213 LLWLParamSet* mSky = mgr->mWLParamList[name];
214 LLWaterParamSet* mWater = mgr->mWaterParamList[name];
215 LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name];
216 if(mSky != NULL && mWater != NULL && mWaterNormal != NULL)
217 WLSettingsManager::Apply(mSky, mWater, mWaterNormal);
218}
219void WLFloaterManager::onSetToCurrent(void* userData)
220{
221 WLFloaterManager* mgr = WLFloaterManager::instance();
222 LLComboBox* comboBox = mgr->getChild<LLComboBox>("WLSettingsCombo");
223 std::string name = comboBox->getSelectedItemLabel();
224
225 LLWLParamSet* mSky = mgr->mWLParamList[name];
226 LLWaterParamSet* mWater = mgr->mWaterParamList[name];
227 LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name];
228 LLSD fade = mgr->mFadeParamList[name];
229 LLSD minAlt = mgr->mMinAltParamList[name];
230 LLSD maxAlt = mgr->mMaxAltParamList[name];
231
232 int type = 1;
233 if(name == "(Region Settings)")
234 {
235 type = 0;
236 }
237
238 if(mSky != NULL && mWater != NULL && mWaterNormal != NULL)
239 WLFloaterWindLightSend::SendSettings(false, type, NULL, *mSky, *mWater, fade, minAlt, maxAlt, *mWaterNormal);
240}
241void WLFloaterManager::onRemove(void* userData)
242{
243 WLFloaterManager* mgr = WLFloaterManager::instance();
244 LLComboBox* comboBox = mgr->getChild<LLComboBox>("WLSettingsCombo");
245 std::string name = comboBox->getSelectedItemLabel();
246
247 LLWLParamSet* mSky = mgr->mWLParamList[name];
248 LLWaterParamSet* mWater = mgr->mWaterParamList[name];
249 LLUUID* mWaterNormal = mgr->mWaterNormalParamList[name];
250 LLSD fade = mgr->mFadeParamList[name];
251 LLSD minAlt = mgr->mMinAltParamList[name];
252 LLSD maxAlt = mgr->mMaxAltParamList[name];
253
254 int type = 1;
255 if(name == "(Region Settings)")
256 {
257 type = 0;
258 }
259
260 if(mSky != NULL && mWater != NULL && mWaterNormal != NULL)
261 WLFloaterWindLightSend::SendSettings(true, type, false, *mSky, *mWater, fade, minAlt, maxAlt, *mWaterNormal);
262}
263
264
265//static
266void WLFloaterManager::UpdateFloater()
267{
268 WLFloaterManager* mgr = WLFloaterManager::instance();
269 LLComboBox* comboBox = mgr->getChild<LLComboBox>("WLSettingsCombo");
270 comboBox->clear();
271 comboBox->removeall();
272 std::map<std::string, LLWLParamSet*>::iterator mIt =
273 WLFloaterManager::instance()->mWLParamList.begin();
274 for(; mIt != WLFloaterManager::instance()->mWLParamList.end(); mIt++)
275 {
276 comboBox->add(mIt->first);
277 }
278 //Reorder them
279 comboBox->sortByName();
280}
281