PageRenderTime 56ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/indra/newview/llfloaterpreference.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 2053 lines | 1501 code | 317 blank | 235 comment | 230 complexity | 35f5f0ed35b6c50aad182a4d3e57f0d6 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /**
  2. * @file llfloaterpreference.cpp
  3. * @brief Global preferences with and without persistence.
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. /*
  27. * App-wide preferences. Note that these are not per-user,
  28. * because we need to load many preferences before we have
  29. * a login name.
  30. */
  31. #include "llviewerprecompiledheaders.h"
  32. #include "llfloaterpreference.h"
  33. #include "message.h"
  34. #include "llagent.h"
  35. #include "llavatarconstants.h"
  36. #include "llcheckboxctrl.h"
  37. #include "llcolorswatch.h"
  38. #include "llcombobox.h"
  39. #include "llcommandhandler.h"
  40. #include "lldirpicker.h"
  41. #include "lleventtimer.h"
  42. #include "llfeaturemanager.h"
  43. #include "llfocusmgr.h"
  44. //#include "llfirstuse.h"
  45. #include "llfloaterreg.h"
  46. #include "llfloaterabout.h"
  47. #include "llfloaterhardwaresettings.h"
  48. #include "llfloatersidepanelcontainer.h"
  49. #include "llimfloater.h"
  50. #include "llkeyboard.h"
  51. #include "llmodaldialog.h"
  52. #include "llnavigationbar.h"
  53. #include "llnearbychat.h"
  54. #include "llnotifications.h"
  55. #include "llnotificationsutil.h"
  56. #include "llnotificationtemplate.h"
  57. #include "llpanellogin.h"
  58. #include "llpanelvoicedevicesettings.h"
  59. #include "llradiogroup.h"
  60. #include "llsearchcombobox.h"
  61. #include "llsky.h"
  62. #include "llscrolllistctrl.h"
  63. #include "llscrolllistitem.h"
  64. #include "llsliderctrl.h"
  65. #include "lltabcontainer.h"
  66. #include "lltrans.h"
  67. #include "llviewercontrol.h"
  68. #include "llviewercamera.h"
  69. #include "llviewerwindow.h"
  70. #include "llviewermessage.h"
  71. #include "llviewershadermgr.h"
  72. #include "llviewerthrottle.h"
  73. #include "llvotree.h"
  74. #include "llvosky.h"
  75. // linden library includes
  76. #include "llavatarnamecache.h"
  77. #include "llerror.h"
  78. #include "llfontgl.h"
  79. #include "llrect.h"
  80. #include "llstring.h"
  81. // project includes
  82. #include "llbutton.h"
  83. #include "llflexibleobject.h"
  84. #include "lllineeditor.h"
  85. #include "llresmgr.h"
  86. #include "llspinctrl.h"
  87. #include "llstartup.h"
  88. #include "lltextbox.h"
  89. #include "llui.h"
  90. #include "llviewerobjectlist.h"
  91. #include "llvoavatar.h"
  92. #include "llvovolume.h"
  93. #include "llwindow.h"
  94. #include "llworld.h"
  95. #include "pipeline.h"
  96. #include "lluictrlfactory.h"
  97. #include "llviewermedia.h"
  98. #include "llpluginclassmedia.h"
  99. #include "llteleporthistorystorage.h"
  100. #include "llproxy.h"
  101. #include "lllogininstance.h" // to check if logged in yet
  102. #include "llsdserialize.h"
  103. const F32 MAX_USER_FAR_CLIP = 512.f;
  104. const F32 MIN_USER_FAR_CLIP = 64.f;
  105. const F32 BANDWIDTH_UPDATER_TIMEOUT = 0.5f;
  106. //control value for middle mouse as talk2push button
  107. const static std::string MIDDLE_MOUSE_CV = "MiddleMouse";
  108. class LLVoiceSetKeyDialog : public LLModalDialog
  109. {
  110. public:
  111. LLVoiceSetKeyDialog(const LLSD& key);
  112. ~LLVoiceSetKeyDialog();
  113. /*virtual*/ BOOL postBuild();
  114. void setParent(LLFloaterPreference* parent) { mParent = parent; }
  115. BOOL handleKeyHere(KEY key, MASK mask);
  116. static void onCancel(void* user_data);
  117. private:
  118. LLFloaterPreference* mParent;
  119. };
  120. LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
  121. : LLModalDialog(key),
  122. mParent(NULL)
  123. {
  124. }
  125. //virtual
  126. BOOL LLVoiceSetKeyDialog::postBuild()
  127. {
  128. childSetAction("Cancel", onCancel, this);
  129. getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
  130. gFocusMgr.setKeystrokesOnly(TRUE);
  131. return TRUE;
  132. }
  133. LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
  134. {
  135. }
  136. BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
  137. {
  138. BOOL result = TRUE;
  139. if (key == 'Q' && mask == MASK_CONTROL)
  140. {
  141. result = FALSE;
  142. }
  143. else if (mParent)
  144. {
  145. mParent->setKey(key);
  146. }
  147. closeFloater();
  148. return result;
  149. }
  150. //static
  151. void LLVoiceSetKeyDialog::onCancel(void* user_data)
  152. {
  153. LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
  154. self->closeFloater();
  155. }
  156. // global functions
  157. // helper functions for getting/freeing the web browser media
  158. // if creating/destroying these is too slow, we'll need to create
  159. // a static member and update all our static callbacks
  160. void handleNameTagOptionChanged(const LLSD& newvalue);
  161. void handleDisplayNamesOptionChanged(const LLSD& newvalue);
  162. bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response);
  163. bool callback_clear_cache(const LLSD& notification, const LLSD& response);
  164. //bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
  165. //bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
  166. void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
  167. bool callback_clear_cache(const LLSD& notification, const LLSD& response)
  168. {
  169. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  170. if ( option == 0 ) // YES
  171. {
  172. // flag client texture cache for clearing next time the client runs
  173. gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
  174. LLNotificationsUtil::add("CacheWillClear");
  175. }
  176. return false;
  177. }
  178. bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response)
  179. {
  180. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  181. if ( option == 0 ) // YES
  182. {
  183. // clean web
  184. LLViewerMedia::clearAllCaches();
  185. LLViewerMedia::clearAllCookies();
  186. // clean nav bar history
  187. LLNavigationBar::getInstance()->clearHistoryCache();
  188. // flag client texture cache for clearing next time the client runs
  189. gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
  190. LLNotificationsUtil::add("CacheWillClear");
  191. LLSearchHistory::getInstance()->clearHistory();
  192. LLSearchHistory::getInstance()->save();
  193. LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
  194. search_ctrl->clearHistory();
  195. LLTeleportHistoryStorage::getInstance()->purgeItems();
  196. LLTeleportHistoryStorage::getInstance()->save();
  197. }
  198. return false;
  199. }
  200. void handleNameTagOptionChanged(const LLSD& newvalue)
  201. {
  202. LLVOAvatar::invalidateNameTags();
  203. }
  204. void handleDisplayNamesOptionChanged(const LLSD& newvalue)
  205. {
  206. LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
  207. LLVOAvatar::invalidateNameTags();
  208. }
  209. /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
  210. {
  211. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  212. if (0 == option && floater )
  213. {
  214. if ( floater )
  215. {
  216. floater->setAllIgnored();
  217. // LLFirstUse::disableFirstUse();
  218. floater->buildPopupLists();
  219. }
  220. }
  221. return false;
  222. }
  223. bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
  224. {
  225. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  226. if ( 0 == option && floater )
  227. {
  228. if ( floater )
  229. {
  230. floater->resetAllIgnored();
  231. //LLFirstUse::resetFirstUse();
  232. floater->buildPopupLists();
  233. }
  234. }
  235. return false;
  236. }
  237. */
  238. void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
  239. {
  240. numerator = 0;
  241. denominator = 0;
  242. for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
  243. {
  244. if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
  245. {
  246. numerator = llround(decimal_val * test_denominator);
  247. denominator = llround(test_denominator);
  248. break;
  249. }
  250. }
  251. }
  252. // static
  253. std::string LLFloaterPreference::sSkin = "";
  254. //////////////////////////////////////////////
  255. // LLFloaterPreference
  256. LLFloaterPreference::LLFloaterPreference(const LLSD& key)
  257. : LLFloater(key),
  258. mGotPersonalInfo(false),
  259. mOriginalIMViaEmail(false),
  260. mLanguageChanged(false),
  261. mAvatarDataInitialized(false),
  262. mClickActionDirty(false)
  263. {
  264. //Build Floater is now Called from LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
  265. static bool registered_dialog = false;
  266. if (!registered_dialog)
  267. {
  268. LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
  269. registered_dialog = true;
  270. }
  271. mCommitCallbackRegistrar.add("Pref.Apply", boost::bind(&LLFloaterPreference::onBtnApply, this));
  272. mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreference::onBtnCancel, this));
  273. mCommitCallbackRegistrar.add("Pref.OK", boost::bind(&LLFloaterPreference::onBtnOK, this));
  274. mCommitCallbackRegistrar.add("Pref.ClearCache", boost::bind(&LLFloaterPreference::onClickClearCache, this));
  275. mCommitCallbackRegistrar.add("Pref.WebClearCache", boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
  276. mCommitCallbackRegistrar.add("Pref.SetCache", boost::bind(&LLFloaterPreference::onClickSetCache, this));
  277. mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this));
  278. mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
  279. mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this));
  280. mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this));
  281. mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
  282. mCommitCallbackRegistrar.add("Pref.SetSounds", boost::bind(&LLFloaterPreference::onClickSetSounds, this));
  283. // mCommitCallbackRegistrar.add("Pref.ClickSkipDialogs", boost::bind(&LLFloaterPreference::onClickSkipDialogs, this));
  284. // mCommitCallbackRegistrar.add("Pref.ClickResetDialogs", boost::bind(&LLFloaterPreference::onClickResetDialogs, this));
  285. mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
  286. mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this));
  287. mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this));
  288. mCommitCallbackRegistrar.add("Pref.HardwareSettings", boost::bind(&LLFloaterPreference::onOpenHardwareSettings, this));
  289. mCommitCallbackRegistrar.add("Pref.HardwareDefaults", boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
  290. mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
  291. mCommitCallbackRegistrar.add("Pref.WindowedMod", boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
  292. mCommitCallbackRegistrar.add("Pref.UpdateSliderText", boost::bind(&LLFloaterPreference::onUpdateSliderText,this, _1,_2));
  293. mCommitCallbackRegistrar.add("Pref.QualityPerformance", boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
  294. mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
  295. mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
  296. mCommitCallbackRegistrar.add("Pref.MaturitySettings", boost::bind(&LLFloaterPreference::onChangeMaturity, this));
  297. mCommitCallbackRegistrar.add("Pref.BlockList", boost::bind(&LLFloaterPreference::onClickBlockList, this));
  298. mCommitCallbackRegistrar.add("Pref.Proxy", boost::bind(&LLFloaterPreference::onClickProxySettings, this));
  299. mCommitCallbackRegistrar.add("Pref.TranslationSettings", boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
  300. sSkin = gSavedSettings.getString("SkinCurrent");
  301. mCommitCallbackRegistrar.add("Pref.ClickActionChange", boost::bind(&LLFloaterPreference::onClickActionChange, this));
  302. gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
  303. gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged, _2));
  304. gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged, _2));
  305. LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
  306. }
  307. void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type )
  308. {
  309. if ( APT_PROPERTIES == type )
  310. {
  311. const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
  312. if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
  313. {
  314. storeAvatarProperties( pAvatarData );
  315. processProfileProperties( pAvatarData );
  316. }
  317. }
  318. }
  319. void LLFloaterPreference::storeAvatarProperties( const LLAvatarData* pAvatarData )
  320. {
  321. if (LLStartUp::getStartupState() == STATE_STARTED)
  322. {
  323. mAvatarProperties.avatar_id = pAvatarData->avatar_id;
  324. mAvatarProperties.image_id = pAvatarData->image_id;
  325. mAvatarProperties.fl_image_id = pAvatarData->fl_image_id;
  326. mAvatarProperties.about_text = pAvatarData->about_text;
  327. mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
  328. mAvatarProperties.profile_url = pAvatarData->profile_url;
  329. mAvatarProperties.flags = pAvatarData->flags;
  330. mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
  331. mAvatarDataInitialized = true;
  332. }
  333. }
  334. void LLFloaterPreference::processProfileProperties(const LLAvatarData* pAvatarData )
  335. {
  336. getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );
  337. }
  338. void LLFloaterPreference::saveAvatarProperties( void )
  339. {
  340. const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
  341. if (allowPublish)
  342. {
  343. mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH;
  344. }
  345. //
  346. // NOTE: We really don't want to send the avatar properties unless we absolutely
  347. // need to so we can avoid the accidental profile reset bug, so, if we're
  348. // logged in, the avatar data has been initialized and we have a state change
  349. // for the "allow publish" flag, then set the flag to its new value and send
  350. // the properties update.
  351. //
  352. // NOTE: The only reason we can not remove this update altogether is because of the
  353. // "allow publish" flag, the last remaining profile setting in the viewer
  354. // that doesn't exist in the web profile.
  355. //
  356. if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
  357. {
  358. mAvatarProperties.allow_publish = allowPublish;
  359. LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
  360. }
  361. }
  362. BOOL LLFloaterPreference::postBuild()
  363. {
  364. gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2));
  365. gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLNearbyChat::processChatHistoryStyleUpdate, _2));
  366. gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2));
  367. gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLNearbyChat::processChatHistoryStyleUpdate, _2));
  368. gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
  369. gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
  370. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  371. if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
  372. tabcontainer->selectFirstTab();
  373. getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
  374. std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
  375. setCacheLocation(cache_location);
  376. getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
  377. // if floater is opened before login set default localized busy message
  378. if (LLStartUp::getStartupState() < STATE_STARTED)
  379. {
  380. gSavedPerAccountSettings.setString("BusyModeResponse", LLTrans::getString("BusyModeResponseDefault"));
  381. }
  382. return TRUE;
  383. }
  384. void LLFloaterPreference::onBusyResponseChanged()
  385. {
  386. // set "BusyResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
  387. if (LLTrans::getString("BusyModeResponseDefault") != getChild<LLUICtrl>("busy_response")->getValue().asString())
  388. {
  389. gSavedPerAccountSettings.setBOOL("BusyResponseChanged", TRUE );
  390. }
  391. else
  392. {
  393. gSavedPerAccountSettings.setBOOL("BusyResponseChanged", FALSE );
  394. }
  395. }
  396. LLFloaterPreference::~LLFloaterPreference()
  397. {
  398. // clean up user data
  399. LLComboBox* ctrl_window_size = getChild<LLComboBox>("windowsize combo");
  400. for (S32 i = 0; i < ctrl_window_size->getItemCount(); i++)
  401. {
  402. ctrl_window_size->setCurrentByIndex(i);
  403. }
  404. }
  405. void LLFloaterPreference::draw()
  406. {
  407. BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
  408. gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
  409. has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
  410. gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
  411. LLFloater::draw();
  412. }
  413. void LLFloaterPreference::saveSettings()
  414. {
  415. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  416. child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  417. child_list_t::const_iterator end = tabcontainer->getChildList()->end();
  418. for ( ; iter != end; ++iter)
  419. {
  420. LLView* view = *iter;
  421. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  422. if (panel)
  423. panel->saveSettings();
  424. }
  425. }
  426. void LLFloaterPreference::apply()
  427. {
  428. LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
  429. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  430. if (sSkin != gSavedSettings.getString("SkinCurrent"))
  431. {
  432. LLNotificationsUtil::add("ChangeSkin");
  433. refreshSkin(this);
  434. }
  435. // Call apply() on all panels that derive from LLPanelPreference
  436. for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  437. iter != tabcontainer->getChildList()->end(); ++iter)
  438. {
  439. LLView* view = *iter;
  440. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  441. if (panel)
  442. panel->apply();
  443. }
  444. // hardware menu apply
  445. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  446. if (hardware_settings)
  447. {
  448. hardware_settings->apply();
  449. }
  450. gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
  451. LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
  452. fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
  453. fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
  454. std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
  455. setCacheLocation(cache_location);
  456. LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
  457. if (hasChild("web_proxy_enabled") &&hasChild("web_proxy_editor") && hasChild("web_proxy_port"))
  458. {
  459. bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
  460. std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
  461. int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
  462. LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
  463. }
  464. // LLWString busy_response = utf8str_to_wstring(getChild<LLUICtrl>("busy_response")->getValue().asString());
  465. // LLWStringUtil::replaceTabsWithSpaces(busy_response, 4);
  466. gSavedSettings.setBOOL("PlainTextChatHistory", getChild<LLUICtrl>("plain_text_chat_history")->getValue().asBoolean());
  467. if (mGotPersonalInfo)
  468. {
  469. // gSavedSettings.setString("BusyModeResponse2", std::string(wstring_to_utf8str(busy_response)));
  470. bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
  471. bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();
  472. if ((new_im_via_email != mOriginalIMViaEmail)
  473. ||(new_hide_online != mOriginalHideOnlineStatus))
  474. {
  475. // This hack is because we are representing several different
  476. // possible strings with a single checkbox. Since most users
  477. // can only select between 2 values, we represent it as a
  478. // checkbox. This breaks down a little bit for liaisons, but
  479. // works out in the end.
  480. if (new_hide_online != mOriginalHideOnlineStatus)
  481. {
  482. if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
  483. else mDirectoryVisibility = VISIBILITY_DEFAULT;
  484. //Update showonline value, otherwise multiple applys won't work
  485. mOriginalHideOnlineStatus = new_hide_online;
  486. }
  487. gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
  488. }
  489. }
  490. saveAvatarProperties();
  491. if (mClickActionDirty)
  492. {
  493. updateClickActionSettings();
  494. mClickActionDirty = false;
  495. }
  496. }
  497. void LLFloaterPreference::cancel()
  498. {
  499. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  500. // Call cancel() on all panels that derive from LLPanelPreference
  501. for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  502. iter != tabcontainer->getChildList()->end(); ++iter)
  503. {
  504. LLView* view = *iter;
  505. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  506. if (panel)
  507. panel->cancel();
  508. }
  509. // hide joystick pref floater
  510. LLFloaterReg::hideInstance("pref_joystick");
  511. // hide translation settings floater
  512. LLFloaterReg::hideInstance("prefs_translation");
  513. // cancel hardware menu
  514. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  515. if (hardware_settings)
  516. {
  517. hardware_settings->cancel();
  518. }
  519. // reverts any changes to current skin
  520. gSavedSettings.setString("SkinCurrent", sSkin);
  521. if (mClickActionDirty)
  522. {
  523. updateClickActionControls();
  524. mClickActionDirty = false;
  525. }
  526. LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy");
  527. if (advanced_proxy_settings)
  528. {
  529. advanced_proxy_settings->cancel();
  530. }
  531. }
  532. void LLFloaterPreference::onOpen(const LLSD& key)
  533. {
  534. // this variable and if that follows it are used to properly handle busy mode response message
  535. static bool initialized = FALSE;
  536. // if user is logged in and we haven't initialized busy_response yet, do it
  537. if (!initialized && LLStartUp::getStartupState() == STATE_STARTED)
  538. {
  539. // Special approach is used for busy response localization, because "BusyModeResponse" is
  540. // in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized.
  541. // To keep track of whether busy response is default or changed by user additional setting BusyResponseChanged
  542. // was added into per account settings.
  543. // initialization should happen once,so setting variable to TRUE
  544. initialized = TRUE;
  545. // this connection is needed to properly set "BusyResponseChanged" setting when user makes changes in
  546. // busy response message.
  547. gSavedPerAccountSettings.getControl("BusyModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onBusyResponseChanged, this));
  548. }
  549. gAgent.sendAgentUserInfoRequest();
  550. /////////////////////////// From LLPanelGeneral //////////////////////////
  551. // if we have no agent, we can't let them choose anything
  552. // if we have an agent, then we only let them choose if they have a choice
  553. bool can_choose_maturity =
  554. gAgent.getID().notNull() &&
  555. (gAgent.isMature() || gAgent.isGodlike());
  556. LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
  557. LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() );
  558. if (can_choose_maturity)
  559. {
  560. // if they're not adult or a god, they shouldn't see the adult selection, so delete it
  561. if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery())
  562. {
  563. // we're going to remove the adult entry from the combo
  564. LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox");
  565. if (maturity_list)
  566. {
  567. maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
  568. }
  569. }
  570. getChildView("maturity_desired_combobox")->setVisible( true);
  571. getChildView("maturity_desired_textbox")->setVisible( false);
  572. }
  573. else
  574. {
  575. getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
  576. getChildView("maturity_desired_combobox")->setVisible( false);
  577. }
  578. // Forget previous language changes.
  579. mLanguageChanged = false;
  580. // Display selected maturity icons.
  581. onChangeMaturity();
  582. // Load (double-)click to walk/teleport settings.
  583. updateClickActionControls();
  584. // Enabled/disabled popups, might have been changed by user actions
  585. // while preferences floater was closed.
  586. buildPopupLists();
  587. LLPanelLogin::setAlwaysRefresh(true);
  588. refresh();
  589. // Make sure the current state of prefs are saved away when
  590. // when the floater is opened. That will make cancel do its
  591. // job
  592. saveSettings();
  593. }
  594. void LLFloaterPreference::onVertexShaderEnable()
  595. {
  596. refreshEnabledGraphics();
  597. }
  598. //static
  599. void LLFloaterPreference::initBusyResponse()
  600. {
  601. if (!gSavedPerAccountSettings.getBOOL("BusyResponseChanged"))
  602. {
  603. //LLTrans::getString("BusyModeResponseDefault") is used here for localization (EXT-5885)
  604. gSavedPerAccountSettings.setString("BusyModeResponse", LLTrans::getString("BusyModeResponseDefault"));
  605. }
  606. }
  607. void LLFloaterPreference::setHardwareDefaults()
  608. {
  609. LLFeatureManager::getInstance()->applyRecommendedSettings();
  610. refreshEnabledGraphics();
  611. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  612. child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  613. child_list_t::const_iterator end = tabcontainer->getChildList()->end();
  614. for ( ; iter != end; ++iter)
  615. {
  616. LLView* view = *iter;
  617. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  618. if (panel)
  619. panel->setHardwareDefaults();
  620. }
  621. }
  622. //virtual
  623. void LLFloaterPreference::onClose(bool app_quitting)
  624. {
  625. gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
  626. LLPanelLogin::setAlwaysRefresh(false);
  627. cancel();
  628. }
  629. void LLFloaterPreference::onOpenHardwareSettings()
  630. {
  631. LLFloaterReg::showInstance("prefs_hardware_settings");
  632. }
  633. // static
  634. void LLFloaterPreference::onBtnOK()
  635. {
  636. // commit any outstanding text entry
  637. if (hasFocus())
  638. {
  639. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  640. if (cur_focus && cur_focus->acceptsTextInput())
  641. {
  642. cur_focus->onCommit();
  643. }
  644. }
  645. if (canClose())
  646. {
  647. saveSettings();
  648. apply();
  649. closeFloater(false);
  650. LLUIColorTable::instance().saveUserSettings();
  651. gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
  652. }
  653. else
  654. {
  655. // Show beep, pop up dialog, etc.
  656. llinfos << "Can't close preferences!" << llendl;
  657. }
  658. LLPanelLogin::updateLocationCombo( false );
  659. }
  660. // static
  661. void LLFloaterPreference::onBtnApply( )
  662. {
  663. if (hasFocus())
  664. {
  665. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  666. if (cur_focus && cur_focus->acceptsTextInput())
  667. {
  668. cur_focus->onCommit();
  669. }
  670. }
  671. apply();
  672. saveSettings();
  673. LLPanelLogin::updateLocationCombo( false );
  674. }
  675. // static
  676. void LLFloaterPreference::onBtnCancel()
  677. {
  678. if (hasFocus())
  679. {
  680. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  681. if (cur_focus && cur_focus->acceptsTextInput())
  682. {
  683. cur_focus->onCommit();
  684. }
  685. refresh();
  686. }
  687. cancel();
  688. closeFloater();
  689. }
  690. // static
  691. void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email)
  692. {
  693. LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
  694. if (instance)
  695. {
  696. instance->setPersonalInfo(visibility, im_via_email, email);
  697. }
  698. }
  699. void LLFloaterPreference::refreshEnabledGraphics()
  700. {
  701. LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
  702. if (instance)
  703. {
  704. instance->refresh();
  705. //instance->refreshEnabledState();
  706. }
  707. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  708. if (hardware_settings)
  709. {
  710. hardware_settings->refreshEnabledState();
  711. }
  712. }
  713. void LLFloaterPreference::onClickClearCache()
  714. {
  715. LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
  716. }
  717. void LLFloaterPreference::onClickBrowserClearCache()
  718. {
  719. LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
  720. }
  721. // Called when user changes language via the combobox.
  722. void LLFloaterPreference::onLanguageChange()
  723. {
  724. // Let the user know that the change will only take effect after restart.
  725. // Do it only once so that we're not too irritating.
  726. if (!mLanguageChanged)
  727. {
  728. LLNotificationsUtil::add("ChangeLanguage");
  729. mLanguageChanged = true;
  730. }
  731. }
  732. void LLFloaterPreference::onNameTagOpacityChange(const LLSD& newvalue)
  733. {
  734. LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background");
  735. if (color_swatch)
  736. {
  737. LLColor4 new_color = color_swatch->get();
  738. color_swatch->set( new_color.setAlpha(newvalue.asReal()) );
  739. }
  740. }
  741. void LLFloaterPreference::onClickSetCache()
  742. {
  743. std::string cur_name(gSavedSettings.getString("CacheLocation"));
  744. // std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
  745. std::string proposed_name(cur_name);
  746. LLDirPicker& picker = LLDirPicker::instance();
  747. if (! picker.getDir(&proposed_name ) )
  748. {
  749. return; //Canceled!
  750. }
  751. std::string dir_name = picker.getDirName();
  752. if (!dir_name.empty() && dir_name != cur_name)
  753. {
  754. std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
  755. LLNotificationsUtil::add("CacheWillBeMoved");
  756. gSavedSettings.setString("NewCacheLocation", dir_name);
  757. gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
  758. }
  759. else
  760. {
  761. std::string cache_location = gDirUtilp->getCacheDir();
  762. gSavedSettings.setString("CacheLocation", cache_location);
  763. std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
  764. gSavedSettings.setString("CacheLocationTopFolder", top_folder);
  765. }
  766. }
  767. void LLFloaterPreference::onClickResetCache()
  768. {
  769. if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true))
  770. {
  771. // The cache location was already the default.
  772. return;
  773. }
  774. gSavedSettings.setString("NewCacheLocation", "");
  775. gSavedSettings.setString("NewCacheLocationTopFolder", "");
  776. LLNotificationsUtil::add("CacheWillBeMoved");
  777. std::string cache_location = gDirUtilp->getCacheDir(false);
  778. gSavedSettings.setString("CacheLocation", cache_location);
  779. std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
  780. gSavedSettings.setString("CacheLocationTopFolder", top_folder);
  781. }
  782. void LLFloaterPreference::onClickSkin(LLUICtrl* ctrl, const LLSD& userdata)
  783. {
  784. gSavedSettings.setString("SkinCurrent", userdata.asString());
  785. ctrl->setValue(userdata.asString());
  786. }
  787. void LLFloaterPreference::onSelectSkin()
  788. {
  789. std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
  790. gSavedSettings.setString("SkinCurrent", skin_selection);
  791. }
  792. void LLFloaterPreference::refreshSkin(void* data)
  793. {
  794. LLPanel*self = (LLPanel*)data;
  795. sSkin = gSavedSettings.getString("SkinCurrent");
  796. self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
  797. }
  798. void LLFloaterPreference::buildPopupLists()
  799. {
  800. LLScrollListCtrl& disabled_popups =
  801. getChildRef<LLScrollListCtrl>("disabled_popups");
  802. LLScrollListCtrl& enabled_popups =
  803. getChildRef<LLScrollListCtrl>("enabled_popups");
  804. disabled_popups.deleteAllItems();
  805. enabled_popups.deleteAllItems();
  806. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  807. iter != LLNotifications::instance().templatesEnd();
  808. ++iter)
  809. {
  810. LLNotificationTemplatePtr templatep = iter->second;
  811. LLNotificationFormPtr formp = templatep->mForm;
  812. LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
  813. if (ignore == LLNotificationForm::IGNORE_NO)
  814. continue;
  815. LLSD row;
  816. row["columns"][0]["value"] = formp->getIgnoreMessage();
  817. row["columns"][0]["font"] = "SANSSERIF_SMALL";
  818. row["columns"][0]["width"] = 400;
  819. LLScrollListItem* item = NULL;
  820. bool show_popup = !formp->getIgnored();
  821. if (!show_popup)
  822. {
  823. if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
  824. {
  825. LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
  826. if (!last_response.isUndefined())
  827. {
  828. for (LLSD::map_const_iterator it = last_response.beginMap();
  829. it != last_response.endMap();
  830. ++it)
  831. {
  832. if (it->second.asBoolean())
  833. {
  834. row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
  835. break;
  836. }
  837. }
  838. }
  839. row["columns"][1]["font"] = "SANSSERIF_SMALL";
  840. row["columns"][1]["width"] = 360;
  841. }
  842. item = disabled_popups.addElement(row);
  843. }
  844. else
  845. {
  846. item = enabled_popups.addElement(row);
  847. }
  848. if (item)
  849. {
  850. item->setUserdata((void*)&iter->first);
  851. }
  852. }
  853. }
  854. void LLFloaterPreference::refreshEnabledState()
  855. {
  856. LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
  857. LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio");
  858. // Reflections
  859. BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable")
  860. && gGLManager.mHasCubeMap
  861. && LLCubeMap::sUseCubeMaps;
  862. ctrl_reflections->setEnabled(reflections);
  863. // Bump & Shiny
  864. bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
  865. getChild<LLCheckBoxCtrl>("BumpShiny")->setEnabled(bumpshiny ? TRUE : FALSE);
  866. radio_reflection_detail->setEnabled(reflections);
  867. // Avatar Mode
  868. // Enable Avatar Shaders
  869. LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
  870. // Avatar Render Mode
  871. LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
  872. bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
  873. if (LLViewerShaderMgr::sInitialized)
  874. {
  875. S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
  876. avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
  877. }
  878. ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
  879. if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE ||
  880. gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
  881. {
  882. ctrl_avatar_cloth->setEnabled(false);
  883. }
  884. else
  885. {
  886. ctrl_avatar_cloth->setEnabled(true);
  887. }
  888. // Vertex Shaders
  889. // Global Shader Enable
  890. LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
  891. // radio set for terrain detail mode
  892. LLRadioGroup* mRadioTerrainDetail = getChild<LLRadioGroup>("TerrainDetailRadio"); // can be linked with control var
  893. ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
  894. BOOL shaders = ctrl_shader_enable->get();
  895. if (shaders)
  896. {
  897. mRadioTerrainDetail->setValue(1);
  898. mRadioTerrainDetail->setEnabled(FALSE);
  899. }
  900. else
  901. {
  902. mRadioTerrainDetail->setEnabled(TRUE);
  903. }
  904. // WindLight
  905. LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
  906. // *HACK just checks to see if we can use shaders...
  907. // maybe some cards that use shaders, but don't support windlight
  908. ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
  909. //Deferred/SSAO/Shadows
  910. LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
  911. BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
  912. shaders &&
  913. gGLManager.mHasFramebufferObject &&
  914. gSavedSettings.getBOOL("RenderAvatarVP") &&
  915. (ctrl_wind_light->get()) ? TRUE : FALSE;
  916. ctrl_deferred->setEnabled(enabled);
  917. LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
  918. LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
  919. LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
  920. enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
  921. ctrl_ssao->setEnabled(enabled);
  922. ctrl_dof->setEnabled(enabled);
  923. enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
  924. ctrl_shadow->setEnabled(enabled);
  925. // now turn off any features that are unavailable
  926. disableUnavailableSettings();
  927. getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
  928. }
  929. void LLFloaterPreference::disableUnavailableSettings()
  930. {
  931. LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
  932. LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
  933. LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
  934. LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
  935. LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
  936. LLCheckBoxCtrl* ctrl_avatar_impostors = getChild<LLCheckBoxCtrl>("AvatarImpostors");
  937. LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
  938. LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
  939. LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
  940. LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
  941. // if vertex shaders off, disable all shader related products
  942. if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
  943. {
  944. ctrl_shader_enable->setEnabled(FALSE);
  945. ctrl_shader_enable->setValue(FALSE);
  946. ctrl_wind_light->setEnabled(FALSE);
  947. ctrl_wind_light->setValue(FALSE);
  948. ctrl_reflections->setEnabled(FALSE);
  949. ctrl_reflections->setValue(0);
  950. ctrl_avatar_vp->setEnabled(FALSE);
  951. ctrl_avatar_vp->setValue(FALSE);
  952. ctrl_avatar_cloth->setEnabled(FALSE);
  953. ctrl_avatar_cloth->setValue(FALSE);
  954. ctrl_shadows->setEnabled(FALSE);
  955. ctrl_shadows->setValue(0);
  956. ctrl_ssao->setEnabled(FALSE);
  957. ctrl_ssao->setValue(FALSE);
  958. ctrl_dof->setEnabled(FALSE);
  959. ctrl_dof->setValue(FALSE);
  960. ctrl_deferred->setEnabled(FALSE);
  961. ctrl_deferred->setValue(FALSE);
  962. }
  963. // disabled windlight
  964. if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
  965. {
  966. ctrl_wind_light->setEnabled(FALSE);
  967. ctrl_wind_light->setValue(FALSE);
  968. //deferred needs windlight, disable deferred
  969. ctrl_shadows->setEnabled(FALSE);
  970. ctrl_shadows->setValue(0);
  971. ctrl_ssao->setEnabled(FALSE);
  972. ctrl_ssao->setValue(FALSE);
  973. ctrl_dof->setEnabled(FALSE);
  974. ctrl_dof->setValue(FALSE);
  975. ctrl_deferred->setEnabled(FALSE);
  976. ctrl_deferred->setValue(FALSE);
  977. }
  978. // disabled deferred
  979. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") ||
  980. !gGLManager.mHasFramebufferObject)
  981. {
  982. ctrl_shadows->setEnabled(FALSE);
  983. ctrl_shadows->setValue(0);
  984. ctrl_ssao->setEnabled(FALSE);
  985. ctrl_ssao->setValue(FALSE);
  986. ctrl_dof->setEnabled(FALSE);
  987. ctrl_dof->setValue(FALSE);
  988. ctrl_deferred->setEnabled(FALSE);
  989. ctrl_deferred->setValue(FALSE);
  990. }
  991. // disabled deferred SSAO
  992. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
  993. {
  994. ctrl_ssao->setEnabled(FALSE);
  995. ctrl_ssao->setValue(FALSE);
  996. }
  997. // disabled deferred shadows
  998. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
  999. {
  1000. ctrl_shadows->setEnabled(FALSE);
  1001. ctrl_shadows->setValue(0);
  1002. }
  1003. // disabled reflections
  1004. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
  1005. {
  1006. ctrl_reflections->setEnabled(FALSE);
  1007. ctrl_reflections->setValue(FALSE);
  1008. }
  1009. // disabled av
  1010. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
  1011. {
  1012. ctrl_avatar_vp->setEnabled(FALSE);
  1013. ctrl_avatar_vp->setValue(FALSE);
  1014. ctrl_avatar_cloth->setEnabled(FALSE);
  1015. ctrl_avatar_cloth->setValue(FALSE);
  1016. //deferred needs AvatarVP, disable deferred
  1017. ctrl_shadows->setEnabled(FALSE);
  1018. ctrl_shadows->setValue(0);
  1019. ctrl_ssao->setEnabled(FALSE);
  1020. ctrl_ssao->setValue(FALSE);
  1021. ctrl_dof->setEnabled(FALSE);
  1022. ctrl_dof->setValue(FALSE);
  1023. ctrl_deferred->setEnabled(FALSE);
  1024. ctrl_deferred->setValue(FALSE);
  1025. }
  1026. // disabled cloth
  1027. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
  1028. {
  1029. ctrl_avatar_cloth->setEnabled(FALSE);
  1030. ctrl_avatar_cloth->setValue(FALSE);
  1031. }
  1032. // disabled impostors
  1033. if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseImpostors"))
  1034. {
  1035. ctrl_avatar_impostors->setEnabled(FALSE);
  1036. ctrl_avatar_impostors->setValue(FALSE);
  1037. }
  1038. }
  1039. void LLFloaterPreference::refresh()
  1040. {
  1041. LLPanel::refresh();
  1042. // sliders and their text boxes
  1043. // mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
  1044. // slider text boxes
  1045. updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail", true), getChild<LLTextBox>("ObjectMeshDetailText", true));
  1046. updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail", true), getChild<LLTextBox>("FlexibleMeshDetailText", true));
  1047. updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail", true), getChild<LLTextBox>("TreeMeshDetailText", true));
  1048. updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail", true), getChild<LLTextBox>("AvatarMeshDetailText", true));
  1049. updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail", true), getChild<LLTextBox>("AvatarPhysicsDetailText", true));
  1050. updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail", true), getChild<LLTextBox>("TerrainMeshDetailText", true));
  1051. updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess", true), getChild<LLTextBox>("PostProcessText", true));
  1052. updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail", true), getChild<LLTextBox>("SkyMeshDetailText", true));
  1053. refreshEnabledState();
  1054. }
  1055. void LLFloaterPreference::onCommitWindowedMode()
  1056. {
  1057. refresh();
  1058. }
  1059. void LLFloaterPreference::onChangeQuality(const LLSD& data)
  1060. {
  1061. U32 level = (U32)(data.asReal());
  1062. LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
  1063. refreshEnabledGraphics();
  1064. refresh();
  1065. }
  1066. void LLFloaterPreference::onClickSetKey()
  1067. {
  1068. LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
  1069. if (dialog)
  1070. {
  1071. dialog->setParent(this);
  1072. }
  1073. }
  1074. void LLFloaterPreference::setKey(KEY key)
  1075. {
  1076. getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
  1077. // update the control right away since we no longer wait for apply
  1078. getChild<LLUICtrl>("modifier_combo")->onCommit();
  1079. }
  1080. void LLFloaterPreference::onClickSetMiddleMouse()
  1081. {
  1082. LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
  1083. // update the control right away since we no longer wait for apply
  1084. p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV);
  1085. //push2talk button "middle mouse" control value is in English, need to localize it for presentation
  1086. LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
  1087. if (advanced_preferences)
  1088. {
  1089. p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse"));
  1090. }
  1091. }
  1092. void LLFloaterPreference::onClickSetSounds()
  1093. {
  1094. // Disable Enable gesture sounds checkbox if the master sound is disabled
  1095. // or if sound effects are disabled.
  1096. getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
  1097. }
  1098. /*
  1099. void LLFloaterPreference::onClickSkipDialogs()
  1100. {
  1101. LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
  1102. }
  1103. void LLFloaterPreference::onClickResetDialogs()
  1104. {
  1105. LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
  1106. }
  1107. */
  1108. void LLFloaterPreference::onClickEnablePopup()
  1109. {
  1110. LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
  1111. std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
  1112. std::vector<LLScrollListItem*>::iterator itor;
  1113. for (itor = items.begin(); itor != items.end(); ++itor)
  1114. {
  1115. LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
  1116. //gSavedSettings.setWarning(templatep->mName, TRUE);
  1117. std::string notification_name = templatep->mName;
  1118. LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
  1119. }
  1120. buildPopupLists();
  1121. }
  1122. void LLFloaterPreference::onClickDisablePopup()
  1123. {
  1124. LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
  1125. std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
  1126. std::vector<LLScrollListItem*>::iterator itor;
  1127. for (itor = items.begin(); itor != items.end(); ++itor)
  1128. {
  1129. LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
  1130. templatep->mForm->setIgnored(true);
  1131. }
  1132. buildPopupLists();
  1133. }
  1134. void LLFloaterPreference::resetAllIgnored()
  1135. {
  1136. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  1137. iter != LLNotifications::instance().templatesEnd();
  1138. ++iter)
  1139. {
  1140. if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
  1141. {
  1142. iter->second->mForm->setIgnored(false);
  1143. }
  1144. }
  1145. }
  1146. void LLFloaterPreference::setAllIgnored()
  1147. {
  1148. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  1149. iter != LLNotifications::instance().templatesEnd();
  1150. ++iter)
  1151. {
  1152. if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
  1153. {
  1154. iter->second->mForm->setIgnored(true);
  1155. }
  1156. }
  1157. }
  1158. void LLFloaterPreference::onClickLogPath()
  1159. {
  1160. std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
  1161. LLDirPicker& picker = LLDirPicker::instance();
  1162. if (!picker.getDir(&proposed_name ) )
  1163. {
  1164. return; //Canceled!
  1165. }
  1166. gSavedPerAccountSettings.setString("InstantMessageLogPath", picker.getDirName());
  1167. }
  1168. void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email)
  1169. {
  1170. mGotPersonalInfo = true;
  1171. mOriginalIMViaEmail = im_via_email;
  1172. mDirectoryVisibility = visibility;
  1173. if (visibility == VISIBILITY_DEFAULT)
  1174. {
  1175. mOriginalHideOnlineStatus = false;
  1176. getChildView("online_visibility")->setEnabled(TRUE);
  1177. }
  1178. else if (visibility == VISIBILITY_HIDDEN)
  1179. {
  1180. mOriginalHideOnlineStatus = true;
  1181. getChildView("online_visibility")->setEnabled(TRUE);
  1182. }
  1183. else
  1184. {
  1185. mOriginalHideOnlineStatus = true;
  1186. }
  1187. getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE);
  1188. getChildView("include_im_in_chat_history")->setEnabled(TRUE);
  1189. getChildView("show_timestamps_check_im")->setEnabled(TRUE);
  1190. getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
  1191. getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus);
  1192. getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
  1193. getChildView("send_im_to_email")->setEnabled(TRUE);
  1194. getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email);
  1195. getChildView("plain_text_chat_history")->setEnabled(TRUE);
  1196. getChild<LLUICtrl>("plain_text_chat_history")->setValue(gSavedSettings.getBOOL("PlainTextChatHistory"));
  1197. getChildView("log_instant_messages")->setEnabled(TRUE);
  1198. // getChildView("log_chat")->setEnabled(TRUE);
  1199. // getChildView("busy_response")->setEnabled(TRUE);
  1200. // getChildView("log_instant_messages_timestamp")->setEnabled(TRUE);
  1201. // getChildView("log_chat_timestamp")->setEnabled(TRUE);
  1202. getChildView("log_chat_IM")->setEnabled(TRUE);
  1203. getChildView("log_date_timestamp")->setEnabled(TRUE);
  1204. // getChild<LLUICtrl>("busy_response")->setValue(gSavedSettings.getString("BusyModeResponse2"));
  1205. getChildView("favorites_on_login_check")->setEnabled(TRUE);
  1206. getChildView("log_nearby_chat")->setEnabled(TRUE);
  1207. getChildView("log_instant_messages")->setEnabled(TRUE);
  1208. getChildView("show_timestamps_check_im")->setEnabled(TRUE);
  1209. getChildView("log_path_string")->setEnabled(FALSE);// LineEditor becomes readonly in this case.
  1210. getChildView("log_path_button")->setEnabled(TRUE);
  1211. childEnable("logfile_name_datestamp");
  1212. std::string display_email(email);
  1213. getChild<LLUICtrl>("email_address")->setValue(display_email);
  1214. }
  1215. void LLFloaterPreference::onUpdateSliderText(LLUICtrl* ctrl, const LLSD& name)
  1216. {
  1217. std::string ctrl_name = name.asString();
  1218. if ((ctrl_name =="" )|| !hasChild(ctrl_name, true))
  1219. return;
  1220. LLTextBox* text_box = getChild<LLTextBox>(name.asString());
  1221. LLSliderCtrl* slider = dynamic_cast<LLSliderCtrl*>(ctrl);
  1222. updateSliderText(slider, text_box);
  1223. }
  1224. void LLFloaterPreference::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box)
  1225. {
  1226. if (text_box == NULL || ctrl== NULL)
  1227. return;
  1228. // get range and points when text should change
  1229. F32 value = (F32)ctrl->getValue().asReal();
  1230. F32 min = ctrl->getMinValue();
  1231. F32 max = ctrl->getMaxValue();
  1232. F32 range = max - min;
  1233. llassert(range > 0);
  1234. F32 midPoint = min + range / 3.0f;
  1235. F32 highPoint = min + (2.0f * range / 3.0f);
  1236. // choose the right text
  1237. if (value < midPoint)
  1238. {
  1239. text_box->setText(LLTrans::getString("GraphicsQualityLow"));
  1240. }
  1241. else if (value < highPoint)
  1242. {
  1243. text_box->setText(LLTrans::getString("GraphicsQualityMid"));
  1244. }
  1245. else
  1246. {
  1247. text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
  1248. }
  1249. }
  1250. void LLFloaterPreference::onChangeMaturity()
  1251. {
  1252. U8 sim_access = gSavedSettings.getU32("PreferredMaturity");
  1253. getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG
  1254. || sim_access == SIM_ACCESS_MATURE
  1255. || sim_access == SIM_ACCESS_ADULT)

Large files files are truncated, but you can click here to view the full file