PageRenderTime 29ms CodeModel.GetById 13ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llfloaterbeacons.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 131 lines | 88 code | 6 blank | 37 comment | 27 complexity | fa015dbef25a8a180bd9f774290c0028 MD5 | raw file
  1/** 
  2 * @file llfloaterbeacons.cpp
  3 * @brief Front-end to LLPipeline controls for highlighting various kinds of objects.
  4 * @author Coco
  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#include "llfloaterbeacons.h"
 30#include "llviewercontrol.h"
 31#include "lluictrlfactory.h"
 32#include "llcheckboxctrl.h"
 33#include "pipeline.h"
 34
 35
 36LLFloaterBeacons::LLFloaterBeacons(const LLSD& seed)
 37:	LLFloater(seed)
 38{
 39	// Initialize pipeline states from saved settings.
 40	// OK to do at floater constructor time because beacons do not display unless the floater is open
 41	// therefore it is OK to not initialize the pipeline state before needed.
 42	// Note also that we should replace those pipeline statics with direct lookup of the saved settings
 43	// eliminating the need to keep these states in sync.
 44	LLPipeline::setRenderScriptedTouchBeacons(gSavedSettings.getBOOL("scripttouchbeacon"));
 45	LLPipeline::setRenderScriptedBeacons(     gSavedSettings.getBOOL("scriptsbeacon"));
 46	LLPipeline::setRenderPhysicalBeacons(     gSavedSettings.getBOOL("physicalbeacon"));
 47	LLPipeline::setRenderSoundBeacons(        gSavedSettings.getBOOL("soundsbeacon"));
 48	LLPipeline::setRenderParticleBeacons(     gSavedSettings.getBOOL("particlesbeacon"));
 49	LLPipeline::setRenderHighlights(          gSavedSettings.getBOOL("renderhighlights"));
 50	LLPipeline::setRenderBeacons(             gSavedSettings.getBOOL("renderbeacons"));
 51	LLPipeline::setRenderMOAPBeacons(		  gSavedSettings.getBOOL("moapbeacon"));
 52	mCommitCallbackRegistrar.add("Beacons.UICheck",	boost::bind(&LLFloaterBeacons::onClickUICheck, this,_1));
 53}
 54
 55BOOL LLFloaterBeacons::postBuild()
 56{
 57	return TRUE;
 58}
 59
 60// Callback attached to each check box control to both affect their main purpose
 61// and to implement the couple screwy interdependency rules that some have.
 62
 63void LLFloaterBeacons::onClickUICheck(LLUICtrl *ctrl)
 64{
 65	LLCheckBoxCtrl *check = (LLCheckBoxCtrl *)ctrl;
 66	std::string name = check->getName();
 67	if(name == "touch_only")
 68	{
 69		LLPipeline::toggleRenderScriptedTouchBeacons(NULL);
 70		// Don't allow both to be ON at the same time. Toggle the other one off if both now on.
 71		if (
 72			LLPipeline::getRenderScriptedTouchBeacons(NULL) &&
 73			LLPipeline::getRenderScriptedBeacons(NULL) )
 74		{
 75			LLPipeline::setRenderScriptedBeacons(FALSE);
 76			getChild<LLCheckBoxCtrl>("scripted")->setControlValue(LLSD(FALSE));
 77			getChild<LLCheckBoxCtrl>("scripted")->setValue(FALSE);
 78			getChild<LLCheckBoxCtrl>("touch_only")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline
 79			getChild<LLCheckBoxCtrl>("touch_only")->setValue(TRUE);
 80		}
 81	}
 82	else if(name == "scripted")
 83	{
 84		LLPipeline::toggleRenderScriptedBeacons(NULL);
 85		// Don't allow both to be ON at the same time. Toggle the other one off if both now on.
 86		if (
 87			LLPipeline::getRenderScriptedTouchBeacons(NULL) &&
 88			LLPipeline::getRenderScriptedBeacons(NULL) )
 89		{
 90			LLPipeline::setRenderScriptedTouchBeacons(FALSE);
 91			getChild<LLCheckBoxCtrl>("touch_only")->setControlValue(LLSD(FALSE));
 92			getChild<LLCheckBoxCtrl>("touch_only")->setValue(FALSE);
 93			getChild<LLCheckBoxCtrl>("scripted")->setControlValue(LLSD(TRUE)); // just to be sure it's in sync with llpipeline
 94			getChild<LLCheckBoxCtrl>("scripted")->setValue(TRUE);
 95		}
 96	}
 97	else if(name == "physical")       LLPipeline::setRenderPhysicalBeacons(check->get());
 98	else if(name == "sounds")         LLPipeline::setRenderSoundBeacons(check->get());
 99	else if(name == "particles")      LLPipeline::setRenderParticleBeacons(check->get());
100	else if(name == "moapbeacon")     LLPipeline::setRenderMOAPBeacons(check->get());
101	else if(name == "highlights")
102	{
103		LLPipeline::toggleRenderHighlights(NULL);
104		// Don't allow both to be OFF at the same time. Toggle the other one on if both now off.
105		if (
106			!LLPipeline::getRenderBeacons(NULL) &&
107			!LLPipeline::getRenderHighlights(NULL) )
108		{
109			LLPipeline::setRenderBeacons(TRUE);
110			getChild<LLCheckBoxCtrl>("beacons")->setControlValue(LLSD(TRUE));
111			getChild<LLCheckBoxCtrl>("beacons")->setValue(TRUE);
112			getChild<LLCheckBoxCtrl>("highlights")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline
113			getChild<LLCheckBoxCtrl>("highlights")->setValue(FALSE); 
114		}
115	}
116	else if(name == "beacons")
117	{
118		LLPipeline::toggleRenderBeacons(NULL);
119		// Don't allow both to be OFF at the same time. Toggle the other one on if both now off.
120		if (
121			!LLPipeline::getRenderBeacons(NULL) &&
122			!LLPipeline::getRenderHighlights(NULL) )
123		{
124			LLPipeline::setRenderHighlights(TRUE);
125			getChild<LLCheckBoxCtrl>("highlights")->setControlValue(LLSD(TRUE));
126			getChild<LLCheckBoxCtrl>("highlights")->setValue(TRUE);
127			getChild<LLCheckBoxCtrl>("beacons")->setControlValue(LLSD(FALSE)); // just to be sure it's in sync with llpipeline
128			getChild<LLCheckBoxCtrl>("beacons")->setValue(FALSE); 
129		}
130	}
131}