PageRenderTime 312ms CodeModel.GetById 137ms app.highlight 18ms RepoModel.GetById 154ms app.codeStats 0ms

/indra/newview/llpanellandaudio.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 203 lines | 117 code | 40 blank | 46 comment | 9 complexity | a728b0b8f8cbab0e1fff1b3d36a464c5 MD5 | raw file
  1/**
  2 * @file llpanellandaudio.cpp
  3 * @brief Allows configuration of "media" for a land parcel,
  4 *   for example movies, web pages, and audio.
  5 *
  6 * $LicenseInfo:firstyear=2007&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 "llpanellandaudio.h"
 31
 32// viewer includes
 33#include "llmimetypes.h"
 34#include "llviewerparcelmgr.h"
 35#include "llviewerregion.h"
 36#include "lluictrlfactory.h"
 37
 38// library includes
 39#include "llcheckboxctrl.h"
 40#include "llcombobox.h"
 41#include "llfloaterurlentry.h"
 42#include "llfocusmgr.h"
 43#include "lllineeditor.h"
 44#include "llparcel.h"
 45#include "lltextbox.h"
 46#include "llradiogroup.h"
 47#include "llspinctrl.h"
 48#include "llsdutil.h"
 49#include "lltexturectrl.h"
 50#include "roles_constants.h"
 51#include "llscrolllistctrl.h"
 52
 53// Values for the parcel voice settings radio group
 54enum
 55{
 56	kRadioVoiceChatEstate = 0,
 57	kRadioVoiceChatPrivate = 1,
 58	kRadioVoiceChatDisable = 2
 59};
 60
 61//---------------------------------------------------------------------------
 62// LLPanelLandAudio
 63//---------------------------------------------------------------------------
 64
 65LLPanelLandAudio::LLPanelLandAudio(LLParcelSelectionHandle& parcel)
 66:	LLPanel(/*std::string("land_media_panel")*/), mParcel(parcel)
 67{
 68}
 69
 70
 71// virtual
 72LLPanelLandAudio::~LLPanelLandAudio()
 73{
 74}
 75
 76
 77BOOL LLPanelLandAudio::postBuild()
 78{
 79	mCheckSoundLocal = getChild<LLCheckBoxCtrl>("check sound local");
 80	childSetCommitCallback("check sound local", onCommitAny, this);
 81
 82	mCheckParcelEnableVoice = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel");
 83	childSetCommitCallback("parcel_enable_voice_channel", onCommitAny, this);
 84
 85	// This one is always disabled so no need for a commit callback
 86	mCheckEstateDisabledVoice = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel_is_estate_disabled");
 87
 88	mCheckParcelVoiceLocal = getChild<LLCheckBoxCtrl>("parcel_enable_voice_channel_local");
 89	childSetCommitCallback("parcel_enable_voice_channel_local", onCommitAny, this);
 90
 91	mMusicURLEdit = getChild<LLLineEditor>("music_url");
 92	childSetCommitCallback("music_url", onCommitAny, this);
 93
 94	mCheckAVSoundAny = getChild<LLCheckBoxCtrl>("all av sound check");
 95	childSetCommitCallback("all av sound check", onCommitAny, this);
 96
 97	mCheckAVSoundGroup = getChild<LLCheckBoxCtrl>("group av sound check");
 98	childSetCommitCallback("group av sound check", onCommitAny, this);
 99
100	return TRUE;
101}
102
103
104// public
105void LLPanelLandAudio::refresh()
106{
107	LLParcel *parcel = mParcel->getParcel();
108
109	if (!parcel)
110	{
111		clearCtrls();
112	}
113	else
114	{
115		// something selected, hooray!
116
117		// Display options
118		BOOL can_change_media = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA);
119
120		mCheckSoundLocal->set( parcel->getSoundLocal() );
121		mCheckSoundLocal->setEnabled( can_change_media );
122
123		bool allow_voice = parcel->getParcelFlagAllowVoice();
124
125		LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion();
126		if (region && region->isVoiceEnabled())
127		{
128			mCheckEstateDisabledVoice->setVisible(false);
129
130			mCheckParcelEnableVoice->setVisible(true);
131			mCheckParcelEnableVoice->setEnabled( can_change_media );
132			mCheckParcelEnableVoice->set(allow_voice);
133
134			mCheckParcelVoiceLocal->setEnabled( can_change_media && allow_voice );
135		}
136		else
137		{
138			// Voice disabled at estate level, overrides parcel settings
139			// Replace the parcel voice checkbox with a disabled one
140			// labelled with an explanatory message
141			mCheckEstateDisabledVoice->setVisible(true);
142
143			mCheckParcelEnableVoice->setVisible(false);
144			mCheckParcelEnableVoice->setEnabled(false);
145			mCheckParcelVoiceLocal->setEnabled(false);
146		}
147
148		mCheckParcelEnableVoice->set(allow_voice);
149		mCheckParcelVoiceLocal->set(!parcel->getParcelFlagUseEstateVoiceChannel());
150
151		mMusicURLEdit->setText(parcel->getMusicURL());
152		mMusicURLEdit->setEnabled( can_change_media );
153
154		BOOL can_change_av_sounds = LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_OPTIONS) && parcel->getHaveNewParcelLimitData();
155		mCheckAVSoundAny->set(parcel->getAllowAnyAVSounds());
156		mCheckAVSoundAny->setEnabled(can_change_av_sounds);
157
158		mCheckAVSoundGroup->set(parcel->getAllowGroupAVSounds() || parcel->getAllowAnyAVSounds());	// On if "Everyone" is on
159		mCheckAVSoundGroup->setEnabled(can_change_av_sounds && !parcel->getAllowAnyAVSounds());		// Enabled if "Everyone" is off
160	}
161}
162// static
163void LLPanelLandAudio::onCommitAny(LLUICtrl*, void *userdata)
164{
165	LLPanelLandAudio *self = (LLPanelLandAudio *)userdata;
166
167	LLParcel* parcel = self->mParcel->getParcel();
168	if (!parcel)
169	{
170		return;
171	}
172
173	// Extract data from UI
174	BOOL sound_local		= self->mCheckSoundLocal->get();
175	std::string music_url	= self->mMusicURLEdit->getText();
176
177	BOOL voice_enabled = self->mCheckParcelEnableVoice->get();
178	BOOL voice_estate_chan = !self->mCheckParcelVoiceLocal->get();
179
180	BOOL any_av_sound		= self->mCheckAVSoundAny->get();
181	BOOL group_av_sound		= TRUE;		// If set to "Everyone" then group is checked as well
182	if (!any_av_sound)
183	{	// If "Everyone" is off, use the value from the checkbox
184		group_av_sound = self->mCheckAVSoundGroup->get();
185	}
186
187	// Remove leading/trailing whitespace (common when copying/pasting)
188	LLStringUtil::trim(music_url);
189
190	// Push data into current parcel
191	parcel->setParcelFlag(PF_ALLOW_VOICE_CHAT, voice_enabled);
192	parcel->setParcelFlag(PF_USE_ESTATE_VOICE_CHAN, voice_estate_chan);
193	parcel->setParcelFlag(PF_SOUND_LOCAL, sound_local);
194	parcel->setMusicURL(music_url);
195	parcel->setAllowAnyAVSounds(any_av_sound);
196	parcel->setAllowGroupAVSounds(group_av_sound);
197
198	// Send current parcel data upstream to server
199	LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel );
200
201	// Might have changed properties, so let's redraw!
202	self->refresh();
203}