PageRenderTime 645ms CodeModel.GetById 131ms app.highlight 396ms RepoModel.GetById 108ms app.codeStats 0ms

/indra/newview/llviewercontrol.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 750 lines | 630 code | 81 blank | 39 comment | 35 complexity | b36a878cb60ce0bfec42520a12534ada MD5 | raw file
  1/** 
  2 * @file llviewercontrol.cpp
  3 * @brief Viewer configuration
  4 * @author Richard Nelson
  5 *
  6 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#include "llviewerprecompiledheaders.h"
 29
 30#include "llviewercontrol.h"
 31
 32// Library includes
 33#include "llwindow.h"	// getGamma()
 34
 35// For Listeners
 36#include "llaudioengine.h"
 37#include "llagent.h"
 38#include "llagentcamera.h"
 39#include "llconsole.h"
 40#include "lldrawpoolbump.h"
 41#include "lldrawpoolterrain.h"
 42#include "llflexibleobject.h"
 43#include "llfeaturemanager.h"
 44#include "llviewershadermgr.h"
 45
 46#include "llsky.h"
 47#include "llvieweraudio.h"
 48#include "llviewermenu.h"
 49#include "llviewertexturelist.h"
 50#include "llviewerthrottle.h"
 51#include "llviewerwindow.h"
 52#include "llvoavatarself.h"
 53#include "llvoiceclient.h"
 54#include "llvosky.h"
 55#include "llvotree.h"
 56#include "llvovolume.h"
 57#include "llworld.h"
 58#include "pipeline.h"
 59#include "llviewerjoystick.h"
 60#include "llviewerobjectlist.h"
 61#include "llviewerparcelmgr.h"
 62#include "llparcel.h"
 63#include "llkeyboard.h"
 64#include "llerrorcontrol.h"
 65#include "llappviewer.h"
 66#include "llvosurfacepatch.h"
 67#include "llvowlsky.h"
 68#include "llrender.h"
 69#include "llnavigationbar.h"
 70#include "llfloatertools.h"
 71#include "llpaneloutfitsinventory.h"
 72#include "llpanellogin.h"
 73#include "llpaneltopinfobar.h"
 74#include "llupdaterservice.h"
 75
 76#ifdef TOGGLE_HACKED_GODLIKE_VIEWER
 77BOOL 				gHackGodmode = FALSE;
 78#endif
 79
 80
 81LLControlGroup gSavedSettings("Global");	// saved at end of session
 82LLControlGroup gSavedPerAccountSettings("PerAccount"); // saved at end of session
 83LLControlGroup gCrashSettings("CrashSettings");	// saved at end of session
 84LLControlGroup gWarningSettings("Warnings"); // persists ignored dialogs/warnings
 85
 86std::string gLastRunVersion;
 87
 88extern BOOL gResizeScreenTexture;
 89extern BOOL gDebugGL;
 90extern BOOL gAuditTexture;
 91////////////////////////////////////////////////////////////////////////////
 92// Listeners
 93
 94static bool handleRenderAvatarMouselookChanged(const LLSD& newvalue)
 95{
 96	LLVOAvatar::sVisibleInFirstPerson = newvalue.asBoolean();
 97	return true;
 98}
 99
100static bool handleRenderFarClipChanged(const LLSD& newvalue)
101{
102	F32 draw_distance = (F32) newvalue.asReal();
103	gAgentCamera.mDrawDistance = draw_distance;
104	LLWorld::getInstance()->setLandFarClip(draw_distance);
105	return true;
106}
107
108static bool handleTerrainDetailChanged(const LLSD& newvalue)
109{
110	LLDrawPoolTerrain::sDetailMode = newvalue.asInteger();
111	return true;
112}
113
114
115static bool handleSetShaderChanged(const LLSD& newvalue)
116{
117	// changing shader level may invalidate existing cached bump maps, as the shader type determines the format of the bump map it expects - clear and repopulate the bump cache
118	gBumpImageList.destroyGL();
119	gBumpImageList.restoreGL();
120
121	// else, leave terrain detail as is
122	LLViewerShaderMgr::instance()->setShaders();
123	return true;
124}
125
126static bool handleRenderPerfTestChanged(const LLSD& newvalue)
127{
128       bool status = !newvalue.asBoolean();
129       if (!status)
130       {
131               gPipeline.clearRenderTypeMask(LLPipeline::RENDER_TYPE_WL_SKY,
132                                                                         LLPipeline::RENDER_TYPE_GROUND,
133                                                                        LLPipeline::RENDER_TYPE_TERRAIN,
134                                                                         LLPipeline::RENDER_TYPE_GRASS,
135                                                                         LLPipeline::RENDER_TYPE_TREE,
136                                                                         LLPipeline::RENDER_TYPE_WATER,
137                                                                         LLPipeline::RENDER_TYPE_PASS_GRASS,
138                                                                         LLPipeline::RENDER_TYPE_HUD,
139                                                                         LLPipeline::RENDER_TYPE_CLOUDS,
140                                                                         LLPipeline::RENDER_TYPE_HUD_PARTICLES,
141                                                                         LLPipeline::END_RENDER_TYPES); 
142               gPipeline.setRenderDebugFeatureControl(LLPipeline::RENDER_DEBUG_FEATURE_UI, false);
143       }
144       else 
145       {
146               gPipeline.setRenderTypeMask(LLPipeline::RENDER_TYPE_WL_SKY,
147                                                                         LLPipeline::RENDER_TYPE_GROUND,
148                                                                         LLPipeline::RENDER_TYPE_TERRAIN,
149                                                                         LLPipeline::RENDER_TYPE_GRASS,
150                                                                         LLPipeline::RENDER_TYPE_TREE,
151                                                                         LLPipeline::RENDER_TYPE_WATER,
152                                                                         LLPipeline::RENDER_TYPE_PASS_GRASS,
153                                                                         LLPipeline::RENDER_TYPE_HUD,
154                                                                         LLPipeline::RENDER_TYPE_CLOUDS,
155                                                                         LLPipeline::RENDER_TYPE_HUD_PARTICLES,
156                                                                         LLPipeline::END_RENDER_TYPES);
157               gPipeline.setRenderDebugFeatureControl(LLPipeline::RENDER_DEBUG_FEATURE_UI, true);
158       }
159
160       return true;
161}
162
163bool handleRenderAvatarComplexityLimitChanged(const LLSD& newvalue)
164{
165	return true;
166}
167
168bool handleRenderTransparentWaterChanged(const LLSD& newvalue)
169{
170	LLWorld::getInstance()->updateWaterObjects();
171	return true;
172}
173
174static bool handleReleaseGLBufferChanged(const LLSD& newvalue)
175{
176	if (gPipeline.isInit())
177	{
178		gPipeline.releaseGLBuffers();
179		gPipeline.createGLBuffers();
180	}
181	return true;
182}
183
184static bool handleAnisotropicChanged(const LLSD& newvalue)
185{
186	LLImageGL::sGlobalUseAnisotropic = newvalue.asBoolean();
187	LLImageGL::dirtyTexOptions();
188	return true;
189}
190
191static bool handleVolumeLODChanged(const LLSD& newvalue)
192{
193	LLVOVolume::sLODFactor = (F32) newvalue.asReal();
194	LLVOVolume::sDistanceFactor = 1.f-LLVOVolume::sLODFactor * 0.1f;
195	return true;
196}
197
198static bool handleAvatarLODChanged(const LLSD& newvalue)
199{
200	LLVOAvatar::sLODFactor = (F32) newvalue.asReal();
201	return true;
202}
203
204static bool handleAvatarPhysicsLODChanged(const LLSD& newvalue)
205{
206	LLVOAvatar::sPhysicsLODFactor = (F32) newvalue.asReal();
207	return true;
208}
209
210static bool handleAvatarMaxVisibleChanged(const LLSD& newvalue)
211{
212	LLVOAvatar::sMaxVisible = (U32) newvalue.asInteger();
213	return true;
214}
215
216static bool handleTerrainLODChanged(const LLSD& newvalue)
217{
218		LLVOSurfacePatch::sLODFactor = (F32)newvalue.asReal();
219		//sqaure lod factor to get exponential range of [0,4] and keep
220		//a value of 1 in the middle of the detail slider for consistency
221		//with other detail sliders (see panel_preferences_graphics1.xml)
222		LLVOSurfacePatch::sLODFactor *= LLVOSurfacePatch::sLODFactor;
223		return true;
224}
225
226static bool handleTreeLODChanged(const LLSD& newvalue)
227{
228	LLVOTree::sTreeFactor = (F32) newvalue.asReal();
229	return true;
230}
231
232static bool handleFlexLODChanged(const LLSD& newvalue)
233{
234	LLVolumeImplFlexible::sUpdateFactor = (F32) newvalue.asReal();
235	return true;
236}
237
238static bool handleGammaChanged(const LLSD& newvalue)
239{
240	F32 gamma = (F32) newvalue.asReal();
241	if (gamma == 0.0f)
242	{
243		gamma = 1.0f; // restore normal gamma
244	}
245	if (gViewerWindow && gViewerWindow->getWindow() && gamma != gViewerWindow->getWindow()->getGamma())
246	{
247		// Only save it if it's changed
248		if (!gViewerWindow->getWindow()->setGamma(gamma))
249		{
250			llwarns << "setGamma failed!" << llendl;
251		}
252	}
253
254	return true;
255}
256
257const F32 MAX_USER_FOG_RATIO = 10.f;
258const F32 MIN_USER_FOG_RATIO = 0.5f;
259
260static bool handleFogRatioChanged(const LLSD& newvalue)
261{
262	F32 fog_ratio = llmax(MIN_USER_FOG_RATIO, llmin((F32) newvalue.asReal(), MAX_USER_FOG_RATIO));
263	gSky.setFogRatio(fog_ratio);
264	return true;
265}
266
267static bool handleMaxPartCountChanged(const LLSD& newvalue)
268{
269	LLViewerPartSim::setMaxPartCount(newvalue.asInteger());
270	return true;
271}
272
273static bool handleVideoMemoryChanged(const LLSD& newvalue)
274{
275	gTextureList.updateMaxResidentTexMem(newvalue.asInteger());
276	return true;
277}
278
279static bool handleChatFontSizeChanged(const LLSD& newvalue)
280{
281	if(gConsole)
282	{
283		gConsole->setFontSize(newvalue.asInteger());
284	}
285	return true;
286}
287
288static bool handleChatPersistTimeChanged(const LLSD& newvalue)
289{
290	if(gConsole)
291	{
292		gConsole->setLinePersistTime((F32) newvalue.asReal());
293	}
294	return true;
295}
296
297static bool handleConsoleMaxLinesChanged(const LLSD& newvalue)
298{
299	if(gConsole)
300	{
301		gConsole->setMaxLines(newvalue.asInteger());
302	}
303	return true;
304}
305
306static void handleAudioVolumeChanged(const LLSD& newvalue)
307{
308	audio_update_volume(true);
309}
310
311static bool handleJoystickChanged(const LLSD& newvalue)
312{
313	LLViewerJoystick::getInstance()->setCameraNeedsUpdate(TRUE);
314	return true;
315}
316
317static bool handleUseOcclusionChanged(const LLSD& newvalue)
318{
319	LLPipeline::sUseOcclusion = (newvalue.asBoolean() && gGLManager.mHasOcclusionQuery 
320		&& LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && !gUseWireframe) ? 2 : 0;
321	return true;
322}
323
324static bool handleUploadBakedTexOldChanged(const LLSD& newvalue)
325{
326	LLPipeline::sForceOldBakedUpload = newvalue.asBoolean();
327	return true;
328}
329
330
331static bool handleNumpadControlChanged(const LLSD& newvalue)
332{
333	if (gKeyboard)
334	{
335		gKeyboard->setNumpadDistinct(static_cast<LLKeyboard::e_numpad_distinct>(newvalue.asInteger()));
336	}
337	return true;
338}
339
340static bool handleWLSkyDetailChanged(const LLSD&)
341{
342	if (gSky.mVOWLSkyp.notNull())
343	{
344		gSky.mVOWLSkyp->updateGeometry(gSky.mVOWLSkyp->mDrawable);
345	}
346	return true;
347}
348
349static bool handleResetVertexBuffersChanged(const LLSD&)
350{
351	if (gPipeline.isInit())
352	{
353		gPipeline.resetVertexBuffers();
354	}
355	return true;
356}
357
358static bool handleRepartition(const LLSD&)
359{
360	if (gPipeline.isInit())
361	{
362		gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
363		gObjectList.repartitionObjects();
364	}
365	return true;
366}
367
368static bool handleRenderDynamicLODChanged(const LLSD& newvalue)
369{
370	LLPipeline::sDynamicLOD = newvalue.asBoolean();
371	return true;
372}
373
374static bool handleRenderLocalLightsChanged(const LLSD& newvalue)
375{
376	gPipeline.setLightingDetail(-1);
377	return true;
378}
379
380static bool handleRenderDeferredChanged(const LLSD& newvalue)
381{
382	LLRenderTarget::sUseFBO = newvalue.asBoolean();
383	if (gPipeline.isInit())
384	{
385		LLPipeline::refreshCachedSettings();
386		gPipeline.updateRenderDeferred();
387		gPipeline.releaseGLBuffers();
388		gPipeline.createGLBuffers();
389		gPipeline.resetVertexBuffers();
390		if (LLPipeline::sRenderDeferred == (BOOL)LLRenderTarget::sUseFBO)
391		{
392			LLViewerShaderMgr::instance()->setShaders();
393		}
394	}
395	return true;
396}
397
398static bool handleRenderUseImpostorsChanged(const LLSD& newvalue)
399{
400	LLVOAvatar::sUseImpostors = newvalue.asBoolean();
401	return true;
402}
403
404static bool handleAuditTextureChanged(const LLSD& newvalue)
405{
406	gAuditTexture = newvalue.asBoolean();
407	return true;
408}
409
410static bool handleRenderDebugGLChanged(const LLSD& newvalue)
411{
412	gDebugGL = newvalue.asBoolean() || gDebugSession;
413	gGL.clearErrors();
414	return true;
415}
416
417static bool handleRenderDebugPipelineChanged(const LLSD& newvalue)
418{
419	gDebugPipeline = newvalue.asBoolean();
420	return true;
421}
422
423static bool handleRenderResolutionDivisorChanged(const LLSD&)
424{
425	gResizeScreenTexture = TRUE;
426	return true;
427}
428
429static bool handleDebugViewsChanged(const LLSD& newvalue)
430{
431	LLView::sDebugRects = newvalue.asBoolean();
432	return true;
433}
434
435static bool handleLogFileChanged(const LLSD& newvalue)
436{
437	std::string log_filename = newvalue.asString();
438	LLFile::remove(log_filename);
439	LLError::logToFile(log_filename);
440	return true;
441}
442
443bool handleHideGroupTitleChanged(const LLSD& newvalue)
444{
445	gAgent.setHideGroupTitle(newvalue);
446	return true;
447}
448
449bool handleEffectColorChanged(const LLSD& newvalue)
450{
451	gAgent.setEffectColor(LLColor4(newvalue));
452	return true;
453}
454
455bool handleHighResSnapshotChanged(const LLSD& newvalue)
456{
457	// High Res Snapshot active, must uncheck RenderUIInSnapshot
458	if (newvalue.asBoolean())
459	{
460		gSavedSettings.setBOOL( "RenderUIInSnapshot", FALSE );
461	}
462	return true;
463}
464
465bool handleVoiceClientPrefsChanged(const LLSD& newvalue)
466{
467	LLVoiceClient::getInstance()->updateSettings();
468	return true;
469}
470
471bool handleVelocityInterpolate(const LLSD& newvalue)
472{
473	LLMessageSystem* msg = gMessageSystem;
474	if ( newvalue.asBoolean() )
475	{
476		msg->newMessageFast(_PREHASH_VelocityInterpolateOn);
477		msg->nextBlockFast(_PREHASH_AgentData);
478		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
479		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
480		gAgent.sendReliableMessage();
481		llinfos << "Velocity Interpolation On" << llendl;
482	}
483	else
484	{
485		msg->newMessageFast(_PREHASH_VelocityInterpolateOff);
486		msg->nextBlockFast(_PREHASH_AgentData);
487		msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
488		msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
489		gAgent.sendReliableMessage();
490		llinfos << "Velocity Interpolation Off" << llendl;
491	}
492	return true;
493}
494
495bool handleForceShowGrid(const LLSD& newvalue)
496{
497	LLPanelLogin::updateServer( );
498	return true;
499}
500
501bool toggle_agent_pause(const LLSD& newvalue)
502{
503	if ( newvalue.asBoolean() )
504	{
505		send_agent_pause();
506	}
507	else
508	{
509		send_agent_resume();
510	}
511	return true;
512}
513
514bool toggle_show_navigation_panel(const LLSD& newvalue)
515{
516	bool value = newvalue.asBoolean();
517
518	LLNavigationBar::getInstance()->setVisible(value);
519	gSavedSettings.setBOOL("ShowMiniLocationPanel", !value);
520
521	return true;
522}
523
524bool toggle_show_mini_location_panel(const LLSD& newvalue)
525{
526	bool value = newvalue.asBoolean();
527
528	LLPanelTopInfoBar::getInstance()->setVisible(value);
529	gSavedSettings.setBOOL("ShowNavbarNavigationPanel", !value);
530
531	return true;
532}
533
534bool toggle_show_object_render_cost(const LLSD& newvalue)
535{
536	LLFloaterTools::sShowObjectCost = newvalue.asBoolean();
537	return true;
538}
539
540void toggle_updater_service_active(const LLSD& new_value)
541{
542    if(new_value.asInteger())
543    {
544		LLUpdaterService update_service;
545		if(!update_service.isChecking()) update_service.startChecking();
546    }
547    else
548    {
549        LLUpdaterService().stopChecking();
550    }
551}
552
553////////////////////////////////////////////////////////////////////////////
554
555void settings_setup_listeners()
556{
557	gSavedSettings.getControl("FirstPersonAvatarVisible")->getSignal()->connect(boost::bind(&handleRenderAvatarMouselookChanged, _2));
558	gSavedSettings.getControl("RenderFarClip")->getSignal()->connect(boost::bind(&handleRenderFarClipChanged, _2));
559	gSavedSettings.getControl("RenderTerrainDetail")->getSignal()->connect(boost::bind(&handleTerrainDetailChanged, _2));
560	gSavedSettings.getControl("OctreeStaticObjectSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
561	gSavedSettings.getControl("OctreeDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
562	gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2));
563	gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
564	gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
565	gSavedSettings.getControl("RenderMaxTextureIndex")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
566	gSavedSettings.getControl("RenderUseTriStrips")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
567	gSavedSettings.getControl("RenderAvatarVP")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
568	gSavedSettings.getControl("VertexShaderEnable")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
569	gSavedSettings.getControl("RenderUIBuffer")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
570	gSavedSettings.getControl("RenderDepthOfField")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
571	gSavedSettings.getControl("RenderFSAASamples")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
572	gSavedSettings.getControl("RenderSpecularResX")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
573	gSavedSettings.getControl("RenderSpecularResY")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
574	gSavedSettings.getControl("RenderSpecularExponent")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
575	gSavedSettings.getControl("RenderAnisotropic")->getSignal()->connect(boost::bind(&handleAnisotropicChanged, _2));
576	gSavedSettings.getControl("RenderShadowResolutionScale")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
577	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
578	gSavedSettings.getControl("RenderGlow")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
579	gSavedSettings.getControl("RenderGlowResolutionPow")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
580	gSavedSettings.getControl("RenderAvatarCloth")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
581	gSavedSettings.getControl("WindLightUseAtmosShaders")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
582	gSavedSettings.getControl("RenderGammaFull")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
583	gSavedSettings.getControl("RenderAvatarMaxVisible")->getSignal()->connect(boost::bind(&handleAvatarMaxVisibleChanged, _2));
584	gSavedSettings.getControl("RenderAvatarComplexityLimit")->getSignal()->connect(boost::bind(&handleRenderAvatarComplexityLimitChanged, _2));
585	gSavedSettings.getControl("RenderVolumeLODFactor")->getSignal()->connect(boost::bind(&handleVolumeLODChanged, _2));
586	gSavedSettings.getControl("RenderAvatarLODFactor")->getSignal()->connect(boost::bind(&handleAvatarLODChanged, _2));
587	gSavedSettings.getControl("RenderAvatarPhysicsLODFactor")->getSignal()->connect(boost::bind(&handleAvatarPhysicsLODChanged, _2));
588	gSavedSettings.getControl("RenderTerrainLODFactor")->getSignal()->connect(boost::bind(&handleTerrainLODChanged, _2));
589	gSavedSettings.getControl("RenderTreeLODFactor")->getSignal()->connect(boost::bind(&handleTreeLODChanged, _2));
590	gSavedSettings.getControl("RenderFlexTimeFactor")->getSignal()->connect(boost::bind(&handleFlexLODChanged, _2));
591	gSavedSettings.getControl("RenderGamma")->getSignal()->connect(boost::bind(&handleGammaChanged, _2));
592	gSavedSettings.getControl("RenderFogRatio")->getSignal()->connect(boost::bind(&handleFogRatioChanged, _2));
593	gSavedSettings.getControl("RenderMaxPartCount")->getSignal()->connect(boost::bind(&handleMaxPartCountChanged, _2));
594	gSavedSettings.getControl("RenderDynamicLOD")->getSignal()->connect(boost::bind(&handleRenderDynamicLODChanged, _2));
595	gSavedSettings.getControl("RenderLocalLights")->getSignal()->connect(boost::bind(&handleRenderLocalLightsChanged, _2));
596	gSavedSettings.getControl("RenderDebugTextureBind")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
597	gSavedSettings.getControl("RenderAutoMaskAlphaDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
598	gSavedSettings.getControl("RenderAutoMaskAlphaNonDeferred")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
599	gSavedSettings.getControl("RenderObjectBump")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
600	gSavedSettings.getControl("RenderMaxVBOSize")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
601	gSavedSettings.getControl("RenderDeferredNoise")->getSignal()->connect(boost::bind(&handleReleaseGLBufferChanged, _2));
602	gSavedSettings.getControl("RenderUseImpostors")->getSignal()->connect(boost::bind(&handleRenderUseImpostorsChanged, _2));
603	gSavedSettings.getControl("RenderDebugGL")->getSignal()->connect(boost::bind(&handleRenderDebugGLChanged, _2));
604	gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2));
605	gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2));
606	gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleRenderDeferredChanged, _2));
607	gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
608	gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2));
609	gSavedSettings.getControl("RenderPerformanceTest")->getSignal()->connect(boost::bind(&handleRenderPerfTestChanged, _2));
610	gSavedSettings.getControl("TextureMemory")->getSignal()->connect(boost::bind(&handleVideoMemoryChanged, _2));
611	gSavedSettings.getControl("AuditTexture")->getSignal()->connect(boost::bind(&handleAuditTextureChanged, _2));
612	gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&handleChatFontSizeChanged, _2));
613	gSavedSettings.getControl("ChatPersistTime")->getSignal()->connect(boost::bind(&handleChatPersistTimeChanged, _2));
614	gSavedSettings.getControl("ConsoleMaxLines")->getSignal()->connect(boost::bind(&handleConsoleMaxLinesChanged, _2));
615	gSavedSettings.getControl("UploadBakedTexOld")->getSignal()->connect(boost::bind(&handleUploadBakedTexOldChanged, _2));
616	gSavedSettings.getControl("UseOcclusion")->getSignal()->connect(boost::bind(&handleUseOcclusionChanged, _2));
617	gSavedSettings.getControl("AudioLevelMaster")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
618	gSavedSettings.getControl("AudioLevelSFX")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
619	gSavedSettings.getControl("AudioLevelUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
620	gSavedSettings.getControl("AudioLevelAmbient")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
621	gSavedSettings.getControl("AudioLevelMusic")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
622	gSavedSettings.getControl("AudioLevelMedia")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
623	gSavedSettings.getControl("AudioLevelVoice")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
624	gSavedSettings.getControl("AudioLevelDoppler")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
625	gSavedSettings.getControl("AudioLevelRolloff")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
626	gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
627	gSavedSettings.getControl("MuteMusic")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
628	gSavedSettings.getControl("MuteMedia")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
629	gSavedSettings.getControl("MuteVoice")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
630	gSavedSettings.getControl("MuteAmbient")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
631	gSavedSettings.getControl("MuteUI")->getSignal()->connect(boost::bind(&handleAudioVolumeChanged, _2));
632	gSavedSettings.getControl("RenderVBOEnable")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
633	gSavedSettings.getControl("RenderUseVAO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
634	gSavedSettings.getControl("RenderVBOMappingDisable")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
635	gSavedSettings.getControl("RenderUseStreamVBO")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
636	gSavedSettings.getControl("RenderPreferStreamDraw")->getSignal()->connect(boost::bind(&handleResetVertexBuffersChanged, _2));
637	gSavedSettings.getControl("WLSkyDetail")->getSignal()->connect(boost::bind(&handleWLSkyDetailChanged, _2));
638	gSavedSettings.getControl("NumpadControl")->getSignal()->connect(boost::bind(&handleNumpadControlChanged, _2));
639	gSavedSettings.getControl("JoystickAxis0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
640	gSavedSettings.getControl("JoystickAxis1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
641	gSavedSettings.getControl("JoystickAxis2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
642	gSavedSettings.getControl("JoystickAxis3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
643	gSavedSettings.getControl("JoystickAxis4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
644	gSavedSettings.getControl("JoystickAxis5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
645	gSavedSettings.getControl("JoystickAxis6")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
646	gSavedSettings.getControl("FlycamAxisScale0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
647	gSavedSettings.getControl("FlycamAxisScale1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
648	gSavedSettings.getControl("FlycamAxisScale2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
649	gSavedSettings.getControl("FlycamAxisScale3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
650	gSavedSettings.getControl("FlycamAxisScale4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
651	gSavedSettings.getControl("FlycamAxisScale5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
652	gSavedSettings.getControl("FlycamAxisScale6")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
653	gSavedSettings.getControl("FlycamAxisDeadZone0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
654	gSavedSettings.getControl("FlycamAxisDeadZone1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
655	gSavedSettings.getControl("FlycamAxisDeadZone2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
656	gSavedSettings.getControl("FlycamAxisDeadZone3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
657	gSavedSettings.getControl("FlycamAxisDeadZone4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
658	gSavedSettings.getControl("FlycamAxisDeadZone5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
659	gSavedSettings.getControl("FlycamAxisDeadZone6")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
660	gSavedSettings.getControl("AvatarAxisScale0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
661	gSavedSettings.getControl("AvatarAxisScale1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
662	gSavedSettings.getControl("AvatarAxisScale2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
663	gSavedSettings.getControl("AvatarAxisScale3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
664	gSavedSettings.getControl("AvatarAxisScale4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
665	gSavedSettings.getControl("AvatarAxisScale5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
666	gSavedSettings.getControl("AvatarAxisDeadZone0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
667	gSavedSettings.getControl("AvatarAxisDeadZone1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
668	gSavedSettings.getControl("AvatarAxisDeadZone2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
669	gSavedSettings.getControl("AvatarAxisDeadZone3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
670	gSavedSettings.getControl("AvatarAxisDeadZone4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
671	gSavedSettings.getControl("AvatarAxisDeadZone5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
672	gSavedSettings.getControl("BuildAxisScale0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
673	gSavedSettings.getControl("BuildAxisScale1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
674	gSavedSettings.getControl("BuildAxisScale2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
675	gSavedSettings.getControl("BuildAxisScale3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
676	gSavedSettings.getControl("BuildAxisScale4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
677	gSavedSettings.getControl("BuildAxisScale5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
678	gSavedSettings.getControl("BuildAxisDeadZone0")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
679	gSavedSettings.getControl("BuildAxisDeadZone1")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
680	gSavedSettings.getControl("BuildAxisDeadZone2")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
681	gSavedSettings.getControl("BuildAxisDeadZone3")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
682	gSavedSettings.getControl("BuildAxisDeadZone4")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
683	gSavedSettings.getControl("BuildAxisDeadZone5")->getSignal()->connect(boost::bind(&handleJoystickChanged, _2));
684	gSavedSettings.getControl("DebugViews")->getSignal()->connect(boost::bind(&handleDebugViewsChanged, _2));
685	gSavedSettings.getControl("UserLogFile")->getSignal()->connect(boost::bind(&handleLogFileChanged, _2));
686	gSavedSettings.getControl("RenderHideGroupTitle")->getSignal()->connect(boost::bind(handleHideGroupTitleChanged, _2));
687	gSavedSettings.getControl("HighResSnapshot")->getSignal()->connect(boost::bind(handleHighResSnapshotChanged, _2));
688	gSavedSettings.getControl("EnableVoiceChat")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
689	gSavedSettings.getControl("PTTCurrentlyEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
690	gSavedSettings.getControl("PushToTalkButton")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
691	gSavedSettings.getControl("PushToTalkToggle")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
692	gSavedSettings.getControl("VoiceEarLocation")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
693	gSavedSettings.getControl("VoiceInputAudioDevice")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
694	gSavedSettings.getControl("VoiceOutputAudioDevice")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
695	gSavedSettings.getControl("AudioLevelMic")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));
696	gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _2));	
697	gSavedSettings.getControl("VelocityInterpolate")->getSignal()->connect(boost::bind(&handleVelocityInterpolate, _2));
698	gSavedSettings.getControl("QAMode")->getSignal()->connect(boost::bind(&show_debug_menus));
699	gSavedSettings.getControl("UseDebugMenus")->getSignal()->connect(boost::bind(&show_debug_menus));
700	gSavedSettings.getControl("AgentPause")->getSignal()->connect(boost::bind(&toggle_agent_pause, _2));
701	gSavedSettings.getControl("ShowNavbarNavigationPanel")->getSignal()->connect(boost::bind(&toggle_show_navigation_panel, _2));
702	gSavedSettings.getControl("ShowMiniLocationPanel")->getSignal()->connect(boost::bind(&toggle_show_mini_location_panel, _2));
703	gSavedSettings.getControl("ShowObjectRenderingCost")->getSignal()->connect(boost::bind(&toggle_show_object_render_cost, _2));
704	gSavedSettings.getControl("UpdaterServiceSetting")->getSignal()->connect(boost::bind(&toggle_updater_service_active, _2));
705	gSavedSettings.getControl("ForceShowGrid")->getSignal()->connect(boost::bind(&handleForceShowGrid, _2));
706	gSavedSettings.getControl("RenderTransparentWater")->getSignal()->connect(boost::bind(&handleRenderTransparentWaterChanged, _2));
707}
708
709#if TEST_CACHED_CONTROL
710
711#define DECL_LLCC(T, V) static LLCachedControl<T> mySetting_##T("TestCachedControl"#T, V)
712DECL_LLCC(U32, (U32)666);
713DECL_LLCC(S32, (S32)-666);
714DECL_LLCC(F32, (F32)-666.666);
715DECL_LLCC(bool, true);
716DECL_LLCC(BOOL, FALSE);
717static LLCachedControl<std::string> mySetting_string("TestCachedControlstring", "Default String Value");
718DECL_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
719DECL_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
720DECL_LLCC(LLRect, LLRect(0, 0, 100, 500));
721DECL_LLCC(LLColor4, LLColor4(0.0f, 0.5f, 1.0f));
722DECL_LLCC(LLColor3, LLColor3(1.0f, 0.f, 0.5f));
723DECL_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255));
724
725LLSD test_llsd = LLSD()["testing1"] = LLSD()["testing2"];
726DECL_LLCC(LLSD, test_llsd);
727
728static LLCachedControl<std::string> test_BrowserHomePage("BrowserHomePage", "hahahahahha", "Not the real comment");
729
730void test_cached_control()
731{
732#define do { TEST_LLCC(T, V) if((T)mySetting_##T != V) llerrs << "Fail "#T << llendl; } while(0)
733	TEST_LLCC(U32, 666);
734	TEST_LLCC(S32, (S32)-666);
735	TEST_LLCC(F32, (F32)-666.666);
736	TEST_LLCC(bool, true);
737	TEST_LLCC(BOOL, FALSE);
738	if((std::string)mySetting_string != "Default String Value") llerrs << "Fail string" << llendl;
739	TEST_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f));
740	TEST_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f));
741	TEST_LLCC(LLRect, LLRect(0, 0, 100, 500));
742	TEST_LLCC(LLColor4, LLColor4(0.0f, 0.5f, 1.0f));
743	TEST_LLCC(LLColor3, LLColor3(1.0f, 0.f, 0.5f));
744	TEST_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255));
745//There's no LLSD comparsion for LLCC yet. TEST_LLCC(LLSD, test_llsd); 
746
747	if((std::string)test_BrowserHomePage != "http://www.secondlife.com") llerrs << "Fail BrowserHomePage" << llendl;
748}
749#endif // TEST_CACHED_CONTROL
750