123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514 |
- /**
- * @file llprefsmedia.cpp
- * @brief Media preference implementation
- *
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #include "llviewerprecompiledheaders.h"
- #include "llprefsmedia.h"
- #include "llaudioengine.h"
- #include "llcheckboxctrl.h"
- #include "lluictrlfactory.h"
- #include "llpanelaudiovolume.h"
- #include "llviewercontrol.h"
- class LLPrefsMediaImpl : public LLPanel
- {
- public:
- LLPrefsMediaImpl();
- ~LLPrefsMediaImpl() override {}
- void refresh() override;
- void draw() override;
- void apply() { refreshValues(); }
- void cancel();
- private:
- void refreshValues();
- static void* createVolumePanel(void* user_data);
- static void onTabChanged(void* data, bool from_click);
- static void onCommitCheckBoxFilter(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxAudio(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxMedia(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxMediaHUD(LLUICtrl* ctrl, void* user_data);
- static void onCommitCheckBoxSharedMedia(LLUICtrl* ctrl, void* user_data);
- static void onCommitChecIncomingIMSession(LLUICtrl* ctrl, void* user_data);
- private:
- LLTabContainer* mTabContainer;
- F32 mVolume;
- F32 mSounds;
- F32 mAmbient;
- F32 mMusic;
- F32 mMedia;
- F32 mVoice;
- F32 mUI;
- F32 mWind;
- F32 mDoppler;
- F32 mRolloff;
- F32 mHealthReductionThreshold;
- F32 mMoneyChangeThreshold;
- U32 mMediaAutoZoom;
- bool mMuteAudio;
- bool mMuteSounds;
- bool mMuteUI;
- bool mMuteAmbient;
- bool mMuteWind;
- bool mMuteMusic;
- bool mMuteMedia;
- bool mMuteVoice;
- bool mMuteWhenMinimized;
- bool mEnableGestureSounds;
- bool mEnableAttachmentSounds;
- bool mNeighborSimsSounds;
- bool mUISndAlertEnable;
- bool mUISndBadKeystrokeEnable;
- bool mUISndClickEnable;
- bool mUISndClickReleaseEnable;
- bool mUISndInvalidOpEnable;
- bool mUISndMoneyChangeDownEnable;
- bool mUISndMoneyChangeUpEnable;
- bool mUISndNewIncomingIMSessionEnable;
- bool mUISndNewIncomingPlayForGroup;
- bool mUISndObjectCreateEnable;
- bool mUISndObjectDeleteEnable;
- bool mUISndObjectRezInEnable;
- bool mUISndObjectRezOutEnable;
- bool mUISndPieMenuAppearEnable;
- bool mUISndPieMenuHideEnable;
- bool mUISndPieMenuSliceHighlightEnable;
- bool mUISndSnapshotEnable;
- bool mUISndStartIMEnable;
- bool mUISndTeleportOutEnable;
- bool mUISndTypingEnable;
- bool mUISndWindowCloseEnable;
- bool mUISndWindowOpenEnable;
- bool mUISndHealthReductionFEnable;
- bool mUISndHealthReductionMEnable;
- bool mEnableCollisionSounds;
- bool mMediaEnableFilter;
- bool mMediaLookupIP;
- bool mStreamingMusic;
- bool mNotifyStreamChanges;
- bool mStreamingMedia;
- bool mParcelMediaAutoPlay;
- bool mMediaOnAPrimUI;
- bool mPrimMediaMaster;
- bool mMediaShowOnOthers;
- bool mMediaShowWithinParcel;
- bool mMediaShowOutsideParcel;
- bool mRunningFMOD;
- bool mFirstRun;
- };
- //static
- void* LLPrefsMediaImpl::createVolumePanel(void* user_data)
- {
- LLPanelAudioVolume* panel = new LLPanelAudioVolume();
- return panel;
- }
- LLPrefsMediaImpl::LLPrefsMediaImpl()
- : mFirstRun(true)
- {
- mFactoryMap["Volume Panel"] = LLCallbackMap(createVolumePanel, NULL);
- LLUICtrlFactory::getInstance()->buildPanel(this,
- "panel_preferences_media.xml",
- &getFactoryMap());
- mTabContainer = getChild<LLTabContainer>("Audio and Media");
- LLPanel* tab = mTabContainer->getChild<LLPanel>("Audio");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- tab = mTabContainer->getChild<LLPanel>("Media");
- mTabContainer->setTabChangeCallback(tab, onTabChanged);
- mTabContainer->setTabUserData(tab, this);
- childSetCommitCallback("media_enable_filter", onCommitCheckBoxFilter, this);
- childSetCommitCallback("streaming_music", onCommitCheckBoxAudio, this);
- childSetCommitCallback("streaming_video", onCommitCheckBoxMedia, this);
- childSetCommitCallback("media_hud", onCommitCheckBoxMediaHUD, this);
- childSetCommitCallback("shared_media", onCommitCheckBoxSharedMedia, this);
- childSetCommitCallback("enable_UISndNewIncomingIMSessionEnable",
- onCommitChecIncomingIMSession, this);
- refresh();
- }
- void LLPrefsMediaImpl::draw()
- {
- if (mFirstRun)
- {
- mFirstRun = false;
- mTabContainer->selectTab(gSavedSettings.getS32("LastMediaPrefTab"));
- }
- LLPanel::draw();
- }
- void LLPrefsMediaImpl::refreshValues()
- {
- mVolume = gSavedSettings.getF32("AudioLevelMaster");
- mMuteAudio = gSavedSettings.getBool("MuteAudio");
- mUI = gSavedSettings.getF32("AudioLevelUI");
- mMuteUI = gSavedSettings.getBool("MuteUI");
- mSounds = gSavedSettings.getF32("AudioLevelSFX");
- mMuteSounds = gSavedSettings.getBool("MuteSounds");
- mAmbient = gSavedSettings.getF32("AudioLevelAmbient");
- mMuteAmbient = gSavedSettings.getBool("MuteAmbient");
- mWind = gSavedSettings.getF32("AudioLevelWind");
- mMuteWind = gSavedSettings.getBool("DisableWindAudio");
- mMusic = gSavedSettings.getF32("AudioLevelMusic");
- mMuteMusic = gSavedSettings.getBool("MuteMusic");
- mMedia = gSavedSettings.getF32("AudioLevelMedia");
- mMuteMedia = gSavedSettings.getBool("MuteMedia");
- mVoice = gSavedSettings.getF32("AudioLevelVoice");
- mMuteVoice = gSavedSettings.getBool("MuteVoice");
- mMediaAutoZoom = gSavedSettings.getU32("MediaAutoZoom");
- mMuteWhenMinimized = gSavedSettings.getBool("MuteWhenMinimized");
- mEnableGestureSounds = gSavedSettings.getBool("EnableGestureSounds");
- mEnableAttachmentSounds = gSavedSettings.getBool("EnableAttachmentSounds");
- mNeighborSimsSounds = gSavedSettings.getBool("NeighborSimsSounds");
- mDoppler = gSavedSettings.getF32("AudioLevelDoppler");
- mRolloff = gSavedSettings.getF32("AudioLevelRolloff");
- mMoneyChangeThreshold = gSavedSettings.getF32("UISndMoneyChangeThreshold");
- mHealthReductionThreshold =
- gSavedSettings.getF32("UISndHealthReductionThreshold");
- mMediaEnableFilter = gSavedSettings.getBool("MediaEnableFilter");
- mMediaLookupIP = gSavedSettings.getBool("MediaLookupIP");
- mStreamingMusic = gSavedSettings.getBool("EnableStreamingMusic");
- mNotifyStreamChanges = gSavedSettings.getBool("NotifyStreamChanges");
- mStreamingMedia = gSavedSettings.getBool("EnableStreamingMedia");
- mMediaOnAPrimUI = gSavedSettings.getBool("MediaOnAPrimUI");
- mParcelMediaAutoPlay = gSavedSettings.getBool("ParcelMediaAutoPlayEnable");
- mPrimMediaMaster = gSavedSettings.getBool("PrimMediaMasterEnabled");
- mMediaShowOnOthers = gSavedSettings.getBool("MediaShowOnOthers");
- mMediaShowWithinParcel = gSavedSettings.getBool("MediaShowWithinParcel");
- mMediaShowOutsideParcel = gSavedSettings.getBool("MediaShowOutsideParcel");
- mUISndAlertEnable = gSavedSettings.getBool("UISndAlertEnable");
- mUISndBadKeystrokeEnable =
- gSavedSettings.getBool("UISndBadKeystrokeEnable");
- mUISndClickEnable = gSavedSettings.getBool("UISndClickEnable");
- mUISndClickReleaseEnable =
- gSavedSettings.getBool("UISndClickReleaseEnable");
- mUISndInvalidOpEnable = gSavedSettings.getBool("UISndInvalidOpEnable");
- mUISndMoneyChangeDownEnable =
- gSavedSettings.getBool("UISndMoneyChangeDownEnable");
- mUISndMoneyChangeUpEnable =
- gSavedSettings.getBool("UISndMoneyChangeUpEnable");
- mUISndNewIncomingIMSessionEnable =
- gSavedSettings.getBool("UISndNewIncomingIMSessionEnable");
- mUISndNewIncomingPlayForGroup =
- gSavedSettings.getBool("UISndNewIncomingPlayForGroup");
- mUISndObjectCreateEnable =
- gSavedSettings.getBool("UISndObjectCreateEnable");
- mUISndObjectDeleteEnable =
- gSavedSettings.getBool("UISndObjectDeleteEnable");
- mUISndObjectRezInEnable = gSavedSettings.getBool("UISndObjectRezInEnable");
- mUISndObjectRezOutEnable =
- gSavedSettings.getBool("UISndObjectRezOutEnable");
- mUISndPieMenuAppearEnable =
- gSavedSettings.getBool("UISndPieMenuAppearEnable");
- mUISndPieMenuHideEnable = gSavedSettings.getBool("UISndPieMenuHideEnable");
- mUISndPieMenuSliceHighlightEnable =
- gSavedSettings.getBool("UISndPieMenuSliceHighlightEnable");
- mUISndSnapshotEnable = gSavedSettings.getBool("UISndSnapshotEnable");
- mUISndStartIMEnable = gSavedSettings.getBool("UISndStartIMEnable");
- mUISndTeleportOutEnable = gSavedSettings.getBool("UISndTeleportOutEnable");
- mUISndTypingEnable = gSavedSettings.getBool("UISndTypingEnable");
- mUISndWindowCloseEnable = gSavedSettings.getBool("UISndWindowCloseEnable");
- mUISndWindowOpenEnable = gSavedSettings.getBool("UISndWindowOpenEnable");
- mUISndHealthReductionFEnable =
- gSavedSettings.getBool("UISndHealthReductionFEnable");
- mUISndHealthReductionMEnable =
- gSavedSettings.getBool("UISndHealthReductionMEnable");
- mEnableCollisionSounds = gSavedSettings.getBool("EnableCollisionSounds");
- }
- void LLPrefsMediaImpl::refresh()
- {
- refreshValues();
- // Disable sub-settings check boxes when needed
- #if LL_FMOD
- mRunningFMOD = gAudiop && gAudiop->getDriverName(false) == "FMODStudio";
- #else
- mRunningFMOD = false;
- #endif
- childSetEnabled("notify_stream_changes",
- mRunningFMOD && mStreamingMusic);
- if (!mRunningFMOD)
- {
- gSavedSettings.setBool("NotifyStreamChanges", false);
- }
- childSetEnabled("media_hud", mStreamingMedia);
- childSetEnabled("text_box_zoom", mStreamingMedia && mMediaOnAPrimUI);
- childSetEnabled("auto_zoom", mStreamingMedia && mMediaOnAPrimUI);
- childSetEnabled("auto_streaming_video", mStreamingMedia);
- childSetEnabled("shared_media", mStreamingMedia);
- childSetEnabled("within_parcel", mStreamingMedia);
- childSetEnabled("outside_parcel", mStreamingMedia);
- if (!mStreamingMedia)
- {
- gSavedSettings.setBool("ParcelMediaAutoPlayEnable", false);
- mParcelMediaAutoPlay = false;
- }
- childSetEnabled("media_lookup_ip", mMediaEnableFilter);
- bool shared_media = mStreamingMedia && mPrimMediaMaster;
- childSetEnabled("on_others", shared_media);
- childSetEnabled("within_parcel", shared_media);
- childSetEnabled("outside_parcel", shared_media);
- childSetEnabled("enable_UISndNewIncomingPlayForGroup",
- mUISndNewIncomingIMSessionEnable);
- if (!mUISndNewIncomingIMSessionEnable)
- {
- gSavedSettings.setBool("UISndNewIncomingPlayForGroup", false);
- }
- }
- void LLPrefsMediaImpl::cancel()
- {
- gSavedSettings.setF32("AudioLevelMaster", mVolume);
- gSavedSettings.setBool("MuteAudio", mMuteAudio);
- gSavedSettings.setF32("AudioLevelUI", mUI);
- gSavedSettings.setBool("MuteUI", mMuteUI);
- gSavedSettings.setF32("AudioLevelSFX", mSounds);
- gSavedSettings.setBool("MuteSounds", mMuteSounds);
- gSavedSettings.setF32("AudioLevelAmbient", mAmbient);
- gSavedSettings.setBool("MuteAmbient", mMuteAmbient);
- gSavedSettings.setF32("AudioLevelWind", mWind);
- gSavedSettings.setBool("DisableWindAudio", mMuteWind);
- gSavedSettings.setF32("AudioLevelMusic", mMusic);
- gSavedSettings.setBool("MuteMusic", mMuteMusic);
- gSavedSettings.setF32("AudioLevelMedia", mMedia);
- gSavedSettings.setBool("MuteMedia", mMuteMedia);
- gSavedSettings.setF32("AudioLevelVoice", mVoice);
- gSavedSettings.setBool("MuteVoice", mMuteVoice);
- gSavedSettings.setBool("MuteWhenMinimized", mMuteWhenMinimized);
- gSavedSettings.setBool("EnableGestureSounds", mEnableGestureSounds);
- gSavedSettings.setBool("EnableAttachmentSounds", mEnableAttachmentSounds);
- gSavedSettings.setBool("NeighborSimsSounds", mNeighborSimsSounds);
- gSavedSettings.setF32("AudioLevelDoppler", mDoppler);
- gSavedSettings.setF32("AudioLevelRolloff", mRolloff);
- gSavedSettings.setF32("UISndMoneyChangeThreshold", mMoneyChangeThreshold);
- gSavedSettings.setF32("UISndHealthReductionThreshold",
- mHealthReductionThreshold);
- gSavedSettings.setBool("MediaEnableFilter", mMediaEnableFilter);
- gSavedSettings.setBool("MediaLookupIP", mMediaLookupIP);
- gSavedSettings.setBool("EnableStreamingMusic", mStreamingMusic);
- gSavedSettings.setBool("NotifyStreamChanges", mNotifyStreamChanges);
- gSavedSettings.setBool("EnableStreamingMedia", mStreamingMedia);
- gSavedSettings.setBool("MediaOnAPrimUI", mMediaOnAPrimUI);
- gSavedSettings.setU32("MediaAutoZoom", mMediaAutoZoom);
- gSavedSettings.setBool("ParcelMediaAutoPlayEnable", mParcelMediaAutoPlay);
- gSavedSettings.setBool("PrimMediaMasterEnabled", mPrimMediaMaster);
- gSavedSettings.setBool("MediaShowOnOthers", mMediaShowOnOthers);
- gSavedSettings.setBool("MediaShowWithinParcel", mMediaShowWithinParcel);
- gSavedSettings.setBool("MediaShowOutsideParcel", mMediaShowOutsideParcel);
- gSavedSettings.setBool("UISndAlertEnable", mUISndAlertEnable);
- gSavedSettings.setBool("UISndBadKeystrokeEnable",
- mUISndBadKeystrokeEnable);
- gSavedSettings.setBool("UISndClickEnable", mUISndClickEnable);
- gSavedSettings.setBool("UISndClickReleaseEnable",
- mUISndClickReleaseEnable);
- gSavedSettings.setBool("UISndInvalidOpEnable", mUISndInvalidOpEnable);
- gSavedSettings.setBool("UISndMoneyChangeDownEnable",
- mUISndMoneyChangeDownEnable);
- gSavedSettings.setBool("UISndMoneyChangeUpEnable",
- mUISndMoneyChangeUpEnable);
- gSavedSettings.setBool("UISndNewIncomingIMSessionEnable",
- mUISndNewIncomingIMSessionEnable);
- gSavedSettings.setBool("UISndNewIncomingPlayForGroup",
- mUISndNewIncomingPlayForGroup);
- gSavedSettings.setBool("UISndObjectCreateEnable",
- mUISndObjectCreateEnable);
- gSavedSettings.setBool("UISndObjectDeleteEnable",
- mUISndObjectDeleteEnable);
- gSavedSettings.setBool("UISndObjectRezInEnable", mUISndObjectRezInEnable);
- gSavedSettings.setBool("UISndObjectRezOutEnable",
- mUISndObjectRezOutEnable);
- gSavedSettings.setBool("UISndPieMenuAppearEnable",
- mUISndPieMenuAppearEnable);
- gSavedSettings.setBool("UISndPieMenuHideEnable", mUISndPieMenuHideEnable);
- gSavedSettings.setBool("UISndPieMenuSliceHighlightEnable",
- mUISndPieMenuSliceHighlightEnable);
- gSavedSettings.setBool("UISndSnapshotEnable", mUISndSnapshotEnable);
- gSavedSettings.setBool("UISndStartIMEnable", mUISndStartIMEnable);
- gSavedSettings.setBool("UISndTeleportOutEnable", mUISndTeleportOutEnable);
- gSavedSettings.setBool("UISndTypingEnable", mUISndTypingEnable);
- gSavedSettings.setBool("UISndWindowCloseEnable", mUISndWindowCloseEnable);
- gSavedSettings.setBool("UISndWindowOpenEnable", mUISndWindowOpenEnable);
- gSavedSettings.setBool("UISndHealthReductionFEnable",
- mUISndHealthReductionFEnable);
- gSavedSettings.setBool("UISndHealthReductionMEnable",
- mUISndHealthReductionMEnable);
- gSavedSettings.setBool("EnableCollisionSounds", mEnableCollisionSounds);
- }
- //static
- void LLPrefsMediaImpl::onTabChanged(void* data, bool from_click)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)data;
- if (self && self->mTabContainer)
- {
- gSavedSettings.setS32("LastMediaPrefTab",
- self->mTabContainer->getCurrentPanelIndex());
- }
- }
- //static
- void LLPrefsMediaImpl::onCommitCheckBoxMedia(LLUICtrl* ctrl, void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- bool enabled = check->get();
- if (!enabled)
- {
- gSavedSettings.setBool("ParcelMediaAutoPlayEnable", false);
- }
- self->refresh();
- }
- //static
- void LLPrefsMediaImpl::onCommitCheckBoxMediaHUD(LLUICtrl* ctrl,
- void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (self && check)
- {
- self->refresh();
- bool enable = check->get();
- self->childSetEnabled("text_box_zoom", enable);
- self->childSetEnabled("auto_zoom", enable);
- }
- }
- //static
- void LLPrefsMediaImpl::onCommitCheckBoxSharedMedia(LLUICtrl* ctrl,
- void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (self && check)
- {
- bool enable = check->get();
- self->childSetEnabled("on_others", enable);
- self->childSetEnabled("within_parcel", enable);
- self->childSetEnabled("outside_parcel", enable);
- }
- }
- //static
- void LLPrefsMediaImpl::onCommitChecIncomingIMSession(LLUICtrl* ctrl,
- void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (self && check)
- {
- bool enable = check->get();
- gSavedSettings.setBool("UISndNewIncomingPlayForGroup", enable);
- self->childSetEnabled("enable_UISndNewIncomingPlayForGroup", enable);
- }
- }
- //static
- void LLPrefsMediaImpl::onCommitCheckBoxAudio(LLUICtrl* ctrl, void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (!self || !check) return;
- self->childSetEnabled("notify_stream_changes",
- self->mRunningFMOD && check->get());
- }
- //static
- void LLPrefsMediaImpl::onCommitCheckBoxFilter(LLUICtrl* ctrl, void* user_data)
- {
- LLPrefsMediaImpl* self = (LLPrefsMediaImpl*)user_data;
- LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
- if (self && check)
- {
- self->childSetEnabled("media_lookup_ip", check->get());
- }
- }
- //---------------------------------------------------------------------------
- LLPrefsMedia::LLPrefsMedia()
- : impl(* new LLPrefsMediaImpl())
- {
- }
- LLPrefsMedia::~LLPrefsMedia()
- {
- delete &impl;
- }
- void LLPrefsMedia::apply()
- {
- impl.apply();
- }
- void LLPrefsMedia::cancel()
- {
- impl.cancel();
- }
- LLPanel* LLPrefsMedia::getPanel()
- {
- return &impl;
- }
|