llfloaterpreference.cpp
上传用户:king477883
上传日期:2021-03-01
资源大小:9553k
文件大小:45k
源码类别:

游戏引擎

开发平台:

C++ Builder

  1. /** 
  2.  * @file llfloaterpreference.cpp
  3.  * @brief Global preferences with and without persistence.
  4.  *
  5.  * $LicenseInfo:firstyear=2002&license=viewergpl$
  6.  * 
  7.  * Copyright (c) 2002-2010, Linden Research, Inc.
  8.  * 
  9.  * Second Life Viewer Source Code
  10.  * The source code in this file ("Source Code") is provided by Linden Lab
  11.  * to you under the terms of the GNU General Public License, version 2.0
  12.  * ("GPL"), unless you have obtained a separate licensing agreement
  13.  * ("Other License"), formally executed by you and Linden Lab.  Terms of
  14.  * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15.  * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16.  * 
  17.  * There are special exceptions to the terms and conditions of the GPL as
  18.  * it is applied to this Source Code. View the full text of the exception
  19.  * in the file doc/FLOSS-exception.txt in this software distribution, or
  20.  * online at
  21.  * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22.  * 
  23.  * By copying, modifying or distributing this software, you acknowledge
  24.  * that you have read and understood your obligations described above,
  25.  * and agree to abide by those obligations.
  26.  * 
  27.  * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28.  * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29.  * COMPLETENESS OR PERFORMANCE.
  30.  * $/LicenseInfo$
  31.  */
  32. /*
  33.  * App-wide preferences.  Note that these are not per-user,
  34.  * because we need to load many preferences before we have
  35.  * a login name.
  36.  */
  37. #include "llviewerprecompiledheaders.h"
  38. #include "llfloaterpreference.h"
  39. #include "message.h"
  40. #include "llagent.h"
  41. #include "llavatarconstants.h"
  42. #include "llcheckboxctrl.h"
  43. #include "llcolorswatch.h"
  44. #include "llcombobox.h"
  45. #include "llcommandhandler.h"
  46. #include "lldirpicker.h"
  47. #include "llfeaturemanager.h"
  48. #include "llfocusmgr.h"
  49. //#include "llfirstuse.h"
  50. #include "llfloaterreg.h"
  51. #include "llfloaterabout.h"
  52. #include "llfloaterhardwaresettings.h"
  53. #include "llfloatervoicedevicesettings.h"
  54. #include "llimfloater.h"
  55. #include "llkeyboard.h"
  56. #include "llmodaldialog.h"
  57. #include "llnavigationbar.h"
  58. #include "llnearbychat.h"
  59. #include "llnotifications.h"
  60. #include "llnotificationsutil.h"
  61. #include "llpanellogin.h"
  62. #include "llradiogroup.h"
  63. #include "llsearchcombobox.h"
  64. #include "llsky.h"
  65. #include "llscrolllistctrl.h"
  66. #include "llscrolllistitem.h"
  67. #include "llsliderctrl.h"
  68. #include "lltabcontainer.h"
  69. #include "lltrans.h"
  70. #include "llviewercontrol.h"
  71. #include "llviewercamera.h"
  72. #include "llviewerwindow.h"
  73. #include "llviewermessage.h"
  74. #include "llviewershadermgr.h"
  75. #include "llvotree.h"
  76. #include "llvosky.h"
  77. // linden library includes
  78. #include "llerror.h"
  79. #include "llfontgl.h"
  80. #include "llrect.h"
  81. #include "llstring.h"
  82. // project includes
  83. #include "llbutton.h"
  84. #include "llflexibleobject.h"
  85. #include "lllineeditor.h"
  86. #include "llresmgr.h"
  87. #include "llspinctrl.h"
  88. #include "llstartup.h"
  89. #include "lltextbox.h"
  90. #include "llui.h"
  91. #include "llviewerobjectlist.h"
  92. #include "llvoavatar.h"
  93. #include "llvovolume.h"
  94. #include "llwindow.h"
  95. #include "llworld.h"
  96. #include "pipeline.h"
  97. #include "lluictrlfactory.h"
  98. #include "llviewermedia.h"
  99. #include "llpluginclassmedia.h"
  100. #include "llteleporthistorystorage.h"
  101. const F32 MAX_USER_FAR_CLIP = 512.f;
  102. const F32 MIN_USER_FAR_CLIP = 64.f;
  103. class LLVoiceSetKeyDialog : public LLModalDialog
  104. {
  105. public:
  106. LLVoiceSetKeyDialog(const LLSD& key);
  107. ~LLVoiceSetKeyDialog();
  108. /*virtual*/ BOOL postBuild();
  109. void setParent(LLFloaterPreference* parent) { mParent = parent; }
  110. BOOL handleKeyHere(KEY key, MASK mask);
  111. static void onCancel(void* user_data);
  112. private:
  113. LLFloaterPreference* mParent;
  114. };
  115. LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
  116.   : LLModalDialog(key),
  117. mParent(NULL)
  118. {
  119. //  LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml", NULL);
  120. }
  121. //virtual
  122. BOOL LLVoiceSetKeyDialog::postBuild()
  123. {
  124. childSetAction("Cancel", onCancel, this);
  125. childSetFocus("Cancel");
  126. gFocusMgr.setKeystrokesOnly(TRUE);
  127. return TRUE;
  128. }
  129. LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
  130. {
  131. }
  132. BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
  133. {
  134. BOOL result = TRUE;
  135. if(key == 'Q' && mask == MASK_CONTROL)
  136. {
  137. result = FALSE;
  138. }
  139. else if (mParent)
  140. {
  141. mParent->setKey(key);
  142. }
  143. closeFloater();
  144. return result;
  145. }
  146. //static
  147. void LLVoiceSetKeyDialog::onCancel(void* user_data)
  148. {
  149. LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
  150. self->closeFloater();
  151. }
  152. // global functions 
  153. // helper functions for getting/freeing the web browser media
  154. // if creating/destroying these is too slow, we'll need to create
  155. // a static member and update all our static callbacks
  156. void handleNameTagOptionChanged(const LLSD& newvalue);
  157. viewer_media_t get_web_media();
  158. bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response);
  159. //bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
  160. //bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater);
  161. void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
  162. viewer_media_t get_web_media()
  163. {
  164. viewer_media_t media_source = LLViewerMedia::newMediaImpl(LLUUID::null);
  165. media_source->initializeMedia("text/html");
  166. return media_source;
  167. }
  168. bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response)
  169. {
  170. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  171. if ( option == 0 ) // YES
  172. {
  173. // clean web
  174. viewer_media_t media_source = get_web_media();
  175. if (media_source && media_source->hasMedia())
  176. media_source->getMediaPlugin()->clear_cache();
  177. // clean nav bar history
  178. LLNavigationBar::getInstance()->clearHistoryCache();
  179. // flag client texture cache for clearing next time the client runs
  180. gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
  181. LLNotificationsUtil::add("CacheWillClear");
  182. LLSearchHistory::getInstance()->clearHistory();
  183. LLSearchHistory::getInstance()->save();
  184. LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
  185. search_ctrl->clearHistory();
  186. LLTeleportHistoryStorage::getInstance()->purgeItems();
  187. LLTeleportHistoryStorage::getInstance()->save();
  188. }
  189. return false;
  190. }
  191. void handleNameTagOptionChanged(const LLSD& newvalue)
  192. {
  193. S32 name_tag_option = S32(newvalue);
  194. if(name_tag_option==2)
  195. {
  196. gSavedSettings.setBOOL("SmallAvatarNames", TRUE);
  197. }
  198. }
  199. /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
  200. {
  201. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  202. if (0 == option && floater )
  203. {
  204. if ( floater )
  205. {
  206. floater->setAllIgnored();
  207. // LLFirstUse::disableFirstUse();
  208. floater->buildPopupLists();
  209. }
  210. }
  211. return false;
  212. }
  213. bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
  214. {
  215. S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
  216. if ( 0 == option && floater )
  217. {
  218. if ( floater )
  219. {
  220. floater->resetAllIgnored();
  221. //LLFirstUse::resetFirstUse();
  222. floater->buildPopupLists();
  223. }
  224. }
  225. return false;
  226. }
  227. */
  228. void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
  229. {
  230. numerator = 0;
  231. denominator = 0;
  232. for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
  233. {
  234. if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
  235. {
  236. numerator = llround(decimal_val * test_denominator);
  237. denominator = llround(test_denominator);
  238. break;
  239. }
  240. }
  241. }
  242. // static
  243. std::string LLFloaterPreference::sSkin = "";
  244. //////////////////////////////////////////////
  245. // LLFloaterPreference
  246. LLFloaterPreference::LLFloaterPreference(const LLSD& key)
  247. : LLFloater(key),
  248. mGotPersonalInfo(false),
  249. mOriginalIMViaEmail(false)
  250. {
  251. //Build Floater is now Called from  LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
  252. static bool registered_dialog = false;
  253. if (!registered_dialog)
  254. {
  255. LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
  256. registered_dialog = true;
  257. }
  258. mCommitCallbackRegistrar.add("Pref.Apply", boost::bind(&LLFloaterPreference::onBtnApply, this));
  259. mCommitCallbackRegistrar.add("Pref.Cancel", boost::bind(&LLFloaterPreference::onBtnCancel, this));
  260. mCommitCallbackRegistrar.add("Pref.OK", boost::bind(&LLFloaterPreference::onBtnOK, this));
  261. // mCommitCallbackRegistrar.add("Pref.ClearCache", boost::bind(&LLFloaterPreference::onClickClearCache, this));
  262. mCommitCallbackRegistrar.add("Pref.WebClearCache", boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
  263. mCommitCallbackRegistrar.add("Pref.SetCache", boost::bind(&LLFloaterPreference::onClickSetCache, this));
  264. mCommitCallbackRegistrar.add("Pref.ResetCache", boost::bind(&LLFloaterPreference::onClickResetCache, this));
  265. mCommitCallbackRegistrar.add("Pref.ClickSkin", boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
  266. mCommitCallbackRegistrar.add("Pref.SelectSkin", boost::bind(&LLFloaterPreference::onSelectSkin, this));
  267. mCommitCallbackRegistrar.add("Pref.VoiceSetKey", boost::bind(&LLFloaterPreference::onClickSetKey, this));
  268. mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse", boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
  269. // mCommitCallbackRegistrar.add("Pref.ClickSkipDialogs", boost::bind(&LLFloaterPreference::onClickSkipDialogs, this));
  270. // mCommitCallbackRegistrar.add("Pref.ClickResetDialogs", boost::bind(&LLFloaterPreference::onClickResetDialogs, this));
  271. mCommitCallbackRegistrar.add("Pref.ClickEnablePopup", boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
  272. mCommitCallbackRegistrar.add("Pref.ClickDisablePopup", boost::bind(&LLFloaterPreference::onClickDisablePopup, this));
  273. mCommitCallbackRegistrar.add("Pref.LogPath", boost::bind(&LLFloaterPreference::onClickLogPath, this));
  274. mCommitCallbackRegistrar.add("Pref.HardwareSettings",       boost::bind(&LLFloaterPreference::onOpenHardwareSettings, this));
  275. mCommitCallbackRegistrar.add("Pref.HardwareDefaults",       boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
  276. mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",     boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
  277. mCommitCallbackRegistrar.add("Pref.WindowedMod",            boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
  278. mCommitCallbackRegistrar.add("Pref.UpdateSliderText",       boost::bind(&LLFloaterPreference::onUpdateSliderText,this, _1,_2));
  279. mCommitCallbackRegistrar.add("Pref.QualityPerformance",     boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
  280. mCommitCallbackRegistrar.add("Pref.applyUIColor", boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
  281. mCommitCallbackRegistrar.add("Pref.getUIColor", boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
  282. sSkin = gSavedSettings.getString("SkinCurrent");
  283. gSavedSettings.getControl("AvatarNameTagMode")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));
  284. }
  285. BOOL LLFloaterPreference::postBuild()
  286. {
  287. gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLIMFloater::processChatHistoryStyleUpdate, _2));
  288. gSavedSettings.getControl("PlainTextChatHistory")->getSignal()->connect(boost::bind(&LLNearbyChat::processChatHistoryStyleUpdate, _2));
  289. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  290. if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
  291. tabcontainer->selectFirstTab();
  292. S32 show_avatar_nametag_options = gSavedSettings.getS32("AvatarNameTagMode");
  293. handleNameTagOptionChanged(LLSD(show_avatar_nametag_options));
  294. std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
  295. childSetText("cache_location", cache_location);
  296. return TRUE;
  297. }
  298. LLFloaterPreference::~LLFloaterPreference()
  299. {
  300. // clean up user data
  301. LLComboBox* ctrl_window_size = getChild<LLComboBox>("windowsize combo");
  302. for (S32 i = 0; i < ctrl_window_size->getItemCount(); i++)
  303. {
  304. ctrl_window_size->setCurrentByIndex(i);
  305. }
  306. }
  307. void LLFloaterPreference::draw()
  308. {
  309. BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
  310. gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
  311. has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
  312. gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
  313. LLFloater::draw();
  314. }
  315. void LLFloaterPreference::saveSettings()
  316. {
  317. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  318. child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  319. child_list_t::const_iterator end = tabcontainer->getChildList()->end();
  320. for ( ; iter != end; ++iter)
  321. {
  322. LLView* view = *iter;
  323. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  324. if (panel)
  325. panel->saveSettings();
  326. }
  327. }
  328. void LLFloaterPreference::apply()
  329. {
  330. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  331. if (sSkin != gSavedSettings.getString("SkinCurrent"))
  332. {
  333. LLNotificationsUtil::add("ChangeSkin");
  334. refreshSkin(this);
  335. }
  336. // Call apply() on all panels that derive from LLPanelPreference
  337. for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  338.  iter != tabcontainer->getChildList()->end(); ++iter)
  339. {
  340. LLView* view = *iter;
  341. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  342. if (panel)
  343. panel->apply();
  344. }
  345. // hardware menu apply
  346. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  347. if (hardware_settings)
  348. {
  349. hardware_settings->apply();
  350. }
  351. LLFloaterVoiceDeviceSettings* voice_device_settings = LLFloaterReg::findTypedInstance<LLFloaterVoiceDeviceSettings>("pref_voicedevicesettings");
  352. if(voice_device_settings)
  353. {
  354. voice_device_settings->apply();
  355. }
  356. gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
  357. LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
  358. fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
  359. fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
  360. std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
  361. childSetText("cache_location", cache_location);
  362. viewer_media_t media_source = get_web_media();
  363. if (media_source && media_source->hasMedia())
  364. {
  365. media_source->getMediaPlugin()->enable_cookies(childGetValue("cookies_enabled"));
  366. if(hasChild("web_proxy_enabled") &&hasChild("web_proxy_editor") && hasChild("web_proxy_port"))
  367. {
  368. bool proxy_enable = childGetValue("web_proxy_enabled");
  369. std::string proxy_address = childGetValue("web_proxy_editor");
  370. int proxy_port = childGetValue("web_proxy_port");
  371. media_source->getMediaPlugin()->proxy_setup(proxy_enable, proxy_address, proxy_port);
  372. }
  373. }
  374. // LLWString busy_response = utf8str_to_wstring(getChild<LLUICtrl>("busy_response")->getValue().asString());
  375. // LLWStringUtil::replaceTabsWithSpaces(busy_response, 4);
  376. gSavedSettings.setBOOL("PlainTextChatHistory", childGetValue("plain_text_chat_history").asBoolean());
  377. if(mGotPersonalInfo)
  378. // gSavedSettings.setString("BusyModeResponse2", std::string(wstring_to_utf8str(busy_response)));
  379. bool new_im_via_email = childGetValue("send_im_to_email").asBoolean();
  380. bool new_hide_online = childGetValue("online_visibility").asBoolean();
  381. if((new_im_via_email != mOriginalIMViaEmail)
  382. ||(new_hide_online != mOriginalHideOnlineStatus))
  383. {
  384. // This hack is because we are representing several different   
  385. // possible strings with a single checkbox. Since most users   
  386. // can only select between 2 values, we represent it as a   
  387. // checkbox. This breaks down a little bit for liaisons, but   
  388. // works out in the end.   
  389. if(new_hide_online != mOriginalHideOnlineStatus)   
  390. {   
  391. if(new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
  392. else mDirectoryVisibility = VISIBILITY_DEFAULT;
  393.  //Update showonline value, otherwise multiple applys won't work
  394. mOriginalHideOnlineStatus = new_hide_online;
  395. }   
  396. gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
  397. }
  398. }
  399. applyResolution();
  400. }
  401. void LLFloaterPreference::cancel()
  402. {
  403. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  404. // Call cancel() on all panels that derive from LLPanelPreference
  405. for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  406. iter != tabcontainer->getChildList()->end(); ++iter)
  407. {
  408. LLView* view = *iter;
  409. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  410. if (panel)
  411. panel->cancel();
  412. }
  413. // hide joystick pref floater
  414. LLFloaterReg::hideInstance("pref_joystick");
  415. // cancel hardware menu
  416. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  417. if (hardware_settings)
  418. {
  419. hardware_settings->cancel();
  420. }
  421. // reverts any changes to current skin
  422. gSavedSettings.setString("SkinCurrent", sSkin);
  423. LLFloaterVoiceDeviceSettings* voice_device_settings = LLFloaterReg::findTypedInstance<LLFloaterVoiceDeviceSettings>("pref_voicedevicesettings");
  424. if (voice_device_settings)
  425. {
  426. voice_device_settings ->cancel();
  427. }
  428. LLFloaterReg::hideInstance("pref_voicedevicesettings");
  429. }
  430. void LLFloaterPreference::onOpen(const LLSD& key)
  431. {
  432. gAgent.sendAgentUserInfoRequest();
  433. /////////////////////////// From LLPanelGeneral //////////////////////////
  434. // if we have no agent, we can't let them choose anything
  435. // if we have an agent, then we only let them choose if they have a choice
  436. bool can_choose_maturity =
  437. gAgent.getID().notNull() &&
  438. (gAgent.isMature() || gAgent.isGodlike());
  439. LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
  440. if (can_choose_maturity)
  441. {
  442. // if they're not adult or a god, they shouldn't see the adult selection, so delete it
  443. if (!gAgent.isAdult() && !gAgent.isGodlike())
  444. {
  445. // we're going to remove the adult entry from the combo. This obviously depends
  446. // on the order of items in the XML file, but there doesn't seem to be a reasonable
  447. // way to depend on the field in XML called 'name'.
  448. maturity_combo->remove(0);
  449. }
  450. childSetVisible("maturity_desired_combobox", true);
  451. childSetVisible("maturity_desired_textbox", false);
  452. }
  453. else
  454. {
  455. childSetText("maturity_desired_textbox",  maturity_combo->getSelectedItemLabel());
  456. childSetVisible("maturity_desired_combobox", false);
  457. }
  458. // Enabled/disabled popups, might have been changed by user actions
  459. // while preferences floater was closed.
  460. buildPopupLists();
  461. LLPanelLogin::setAlwaysRefresh(true);
  462. refresh();
  463. // Make sure the current state of prefs are saved away when
  464. // when the floater is opened.  That will make cancel do its
  465. // job
  466. saveSettings();
  467. }
  468. void LLFloaterPreference::onVertexShaderEnable()
  469. {
  470. refreshEnabledGraphics();
  471. }
  472. void LLFloaterPreference::setHardwareDefaults()
  473. {
  474. LLFeatureManager::getInstance()->applyRecommendedSettings();
  475. refreshEnabledGraphics();
  476. LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
  477. child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
  478. child_list_t::const_iterator end = tabcontainer->getChildList()->end();
  479. for ( ; iter != end; ++iter)
  480. {
  481. LLView* view = *iter;
  482. LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
  483. if (panel)
  484. panel->setHardwareDefaults();
  485. }
  486. }
  487. //virtual
  488. void LLFloaterPreference::onClose(bool app_quitting)
  489. {
  490. gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
  491. LLPanelLogin::setAlwaysRefresh(false);
  492. cancel();
  493. }
  494. void LLFloaterPreference::onOpenHardwareSettings()
  495. {
  496. LLFloaterReg::showInstance("prefs_hardware_settings");
  497. }
  498. // static 
  499. void LLFloaterPreference::onBtnOK()
  500. {
  501. // commit any outstanding text entry
  502. if (hasFocus())
  503. {
  504. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  505. if (cur_focus && cur_focus->acceptsTextInput())
  506. {
  507. cur_focus->onCommit();
  508. }
  509. }
  510. if (canClose())
  511. {
  512. saveSettings();
  513. apply();
  514. closeFloater(false);
  515. LLUIColorTable::instance().saveUserSettings();
  516. gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
  517. std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
  518. // save all settings, even if equals defaults
  519. gCrashSettings.saveToFile(crash_settings_filename, FALSE);
  520. }
  521. else
  522. {
  523. // Show beep, pop up dialog, etc.
  524. llinfos << "Can't close preferences!" << llendl;
  525. }
  526. LLPanelLogin::refreshLocation( false );
  527. }
  528. // static 
  529. void LLFloaterPreference::onBtnApply( )
  530. {
  531. if (hasFocus())
  532. {
  533. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  534. if (cur_focus && cur_focus->acceptsTextInput())
  535. {
  536. cur_focus->onCommit();
  537. }
  538. }
  539. apply();
  540. saveSettings();
  541. LLPanelLogin::refreshLocation( false );
  542. }
  543. // static 
  544. void LLFloaterPreference::onBtnCancel()
  545. {
  546. if (hasFocus())
  547. {
  548. LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
  549. if (cur_focus && cur_focus->acceptsTextInput())
  550. {
  551. cur_focus->onCommit();
  552. }
  553. refresh();
  554. }
  555. cancel();
  556. closeFloater();
  557. }
  558. // static 
  559. void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email)
  560. {
  561. LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
  562. if(instance)
  563. {
  564. instance->setPersonalInfo(visibility, im_via_email, email);
  565. }
  566. }
  567. void LLFloaterPreference::refreshEnabledGraphics()
  568. {
  569. LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
  570. if(instance)
  571. {
  572. instance->refresh();
  573. //instance->refreshEnabledState();
  574. }
  575. LLFloaterHardwareSettings* hardware_settings = LLFloaterReg::getTypedInstance<LLFloaterHardwareSettings>("prefs_hardware_settings");
  576. if (hardware_settings)
  577. {
  578. hardware_settings->refreshEnabledState();
  579. }
  580. }
  581. void LLFloaterPreference::onClickBrowserClearCache()
  582. {
  583. LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
  584. }
  585. void LLFloaterPreference::onClickSetCache()
  586. {
  587. std::string cur_name(gSavedSettings.getString("CacheLocation"));
  588. // std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
  589. std::string proposed_name(cur_name);
  590. LLDirPicker& picker = LLDirPicker::instance();
  591. if (! picker.getDir(&proposed_name ) )
  592. {
  593. return; //Canceled!
  594. }
  595. std::string dir_name = picker.getDirName();
  596. if (!dir_name.empty() && dir_name != cur_name)
  597. {
  598. std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
  599. LLNotificationsUtil::add("CacheWillBeMoved");
  600. gSavedSettings.setString("NewCacheLocation", dir_name);
  601. gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
  602. }
  603. else
  604. {
  605. std::string cache_location = gDirUtilp->getCacheDir();
  606. gSavedSettings.setString("CacheLocation", cache_location);
  607. std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
  608. gSavedSettings.setString("CacheLocationTopFolder", top_folder);
  609. }
  610. }
  611. void LLFloaterPreference::onClickResetCache()
  612. {
  613. if (!gSavedSettings.getString("CacheLocation").empty())
  614. {
  615. gSavedSettings.setString("NewCacheLocation", "");
  616. gSavedSettings.setString("NewCacheLocationTopFolder", "");
  617. }
  618. LLNotificationsUtil::add("CacheWillBeMoved");
  619. std::string cache_location = gDirUtilp->getCacheDir(true);
  620. gSavedSettings.setString("CacheLocation", cache_location);
  621. std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
  622. gSavedSettings.setString("CacheLocationTopFolder", top_folder);
  623. }
  624. void LLFloaterPreference::onClickSkin(LLUICtrl* ctrl, const LLSD& userdata)
  625. {
  626. gSavedSettings.setString("SkinCurrent", userdata.asString());
  627. ctrl->setValue(userdata.asString());
  628. }
  629. void LLFloaterPreference::onSelectSkin()
  630. {
  631. std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
  632. gSavedSettings.setString("SkinCurrent", skin_selection);
  633. }
  634. void LLFloaterPreference::refreshSkin(void* data)
  635. {
  636. LLPanel*self = (LLPanel*)data;
  637. sSkin = gSavedSettings.getString("SkinCurrent");
  638. self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
  639. }
  640. void LLFloaterPreference::buildPopupLists()
  641. {
  642. LLScrollListCtrl& disabled_popups =
  643. getChildRef<LLScrollListCtrl>("disabled_popups");
  644. LLScrollListCtrl& enabled_popups =
  645. getChildRef<LLScrollListCtrl>("enabled_popups");
  646. disabled_popups.deleteAllItems();
  647. enabled_popups.deleteAllItems();
  648. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  649.  iter != LLNotifications::instance().templatesEnd();
  650.  ++iter)
  651. {
  652. LLNotificationTemplatePtr templatep = iter->second;
  653. LLNotificationFormPtr formp = templatep->mForm;
  654. LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
  655. if (ignore == LLNotificationForm::IGNORE_NO)
  656. continue;
  657. LLSD row;
  658. row["columns"][0]["value"] = formp->getIgnoreMessage();
  659. row["columns"][0]["font"] = "SANSSERIF_SMALL";
  660. row["columns"][0]["width"] = 400;
  661. LLScrollListItem* item = NULL;
  662. bool show_popup = LLUI::sSettingGroups["ignores"]->getBOOL(templatep->mName);
  663. if (!show_popup)
  664. {
  665. if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
  666. {
  667. LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
  668. if (!last_response.isUndefined())
  669. {
  670. for (LLSD::map_const_iterator it = last_response.beginMap();
  671.  it != last_response.endMap();
  672.  ++it)
  673. {
  674. if (it->second.asBoolean())
  675. {
  676. row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
  677. break;
  678. }
  679. }
  680. }
  681. row["columns"][1]["font"] = "SANSSERIF_SMALL";
  682. row["columns"][1]["width"] = 360;
  683. }
  684. item = disabled_popups.addElement(row,
  685.   ADD_SORTED);
  686. }
  687. else
  688. {
  689. item = enabled_popups.addElement(row,
  690.  ADD_SORTED);
  691. }
  692. if (item)
  693. {
  694. item->setUserdata((void*)&iter->first);
  695. }
  696. }
  697. }
  698. void LLFloaterPreference::refreshEnabledState()
  699. {
  700. LLCheckBoxCtrl* ctrl_reflections = getChild<LLCheckBoxCtrl>("Reflections");
  701. LLRadioGroup* radio_reflection_detail = getChild<LLRadioGroup>("ReflectionDetailRadio");
  702. // Reflections
  703. BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") 
  704. && gGLManager.mHasCubeMap
  705. && LLCubeMap::sUseCubeMaps;
  706. ctrl_reflections->setEnabled(reflections);
  707. // Bump & Shiny
  708. bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
  709. getChild<LLCheckBoxCtrl>("BumpShiny")->setEnabled(bumpshiny ? TRUE : FALSE);
  710. radio_reflection_detail->setEnabled(ctrl_reflections->get() && reflections);
  711. // Avatar Mode
  712. // Enable Avatar Shaders
  713. LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
  714. // Avatar Render Mode
  715. LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
  716. S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
  717. ctrl_avatar_vp->setEnabled((max_avatar_shader > 0) ? TRUE : FALSE);
  718. if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || 
  719. gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
  720. {
  721. ctrl_avatar_cloth->setEnabled(false);
  722. else
  723. {
  724. ctrl_avatar_cloth->setEnabled(true);
  725. }
  726. // Vertex Shaders
  727. // Global Shader Enable
  728. LLCheckBoxCtrl* ctrl_shader_enable   = getChild<LLCheckBoxCtrl>("BasicShaders");
  729. // radio set for terrain detail mode
  730. LLRadioGroup*   mRadioTerrainDetail = getChild<LLRadioGroup>("TerrainDetailRadio");   // can be linked with control var
  731. ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
  732. BOOL shaders = ctrl_shader_enable->get();
  733. if (shaders)
  734. {
  735. mRadioTerrainDetail->setValue(1);
  736. mRadioTerrainDetail->setEnabled(FALSE);
  737. }
  738. else
  739. {
  740. mRadioTerrainDetail->setEnabled(TRUE);
  741. }
  742. // WindLight
  743. LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
  744. // *HACK just checks to see if we can use shaders... 
  745. // maybe some cards that use shaders, but don't support windlight
  746. ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
  747. // now turn off any features that are unavailable
  748. disableUnavailableSettings();
  749. }
  750. void LLFloaterPreference::disableUnavailableSettings()
  751. {
  752. LLCheckBoxCtrl* ctrl_reflections   = getChild<LLCheckBoxCtrl>("Reflections");
  753. LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
  754. LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
  755. LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
  756. LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
  757. LLCheckBoxCtrl* ctrl_avatar_impostors = getChild<LLCheckBoxCtrl>("AvatarImpostors");
  758. // if vertex shaders off, disable all shader related products
  759. if(!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
  760. {
  761. ctrl_shader_enable->setEnabled(FALSE);
  762. ctrl_shader_enable->setValue(FALSE);
  763. ctrl_wind_light->setEnabled(FALSE);
  764. ctrl_wind_light->setValue(FALSE);
  765. ctrl_reflections->setEnabled(FALSE);
  766. ctrl_reflections->setValue(FALSE);
  767. ctrl_avatar_vp->setEnabled(FALSE);
  768. ctrl_avatar_vp->setValue(FALSE);
  769. ctrl_avatar_cloth->setEnabled(FALSE);
  770. ctrl_avatar_cloth->setValue(FALSE);
  771. }
  772. // disabled windlight
  773. if(!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
  774. {
  775. ctrl_wind_light->setEnabled(FALSE);
  776. ctrl_wind_light->setValue(FALSE);
  777. }
  778. // disabled reflections
  779. if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderWaterReflections"))
  780. {
  781. ctrl_reflections->setEnabled(FALSE);
  782. ctrl_reflections->setValue(FALSE);
  783. }
  784. // disabled av
  785. if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
  786. {
  787. ctrl_avatar_vp->setEnabled(FALSE);
  788. ctrl_avatar_vp->setValue(FALSE);
  789. ctrl_avatar_cloth->setEnabled(FALSE);
  790. ctrl_avatar_cloth->setValue(FALSE);
  791. }
  792. // disabled cloth
  793. if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
  794. {
  795. ctrl_avatar_cloth->setEnabled(FALSE);
  796. ctrl_avatar_cloth->setValue(FALSE);
  797. }
  798. // disabled impostors
  799. if(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseImpostors"))
  800. {
  801. ctrl_avatar_impostors->setEnabled(FALSE);
  802. ctrl_avatar_impostors->setValue(FALSE);
  803. }
  804. }
  805. void LLFloaterPreference::refresh()
  806. {
  807. LLPanel::refresh();
  808. // sliders and their text boxes
  809. // mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
  810. // slider text boxes
  811. updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail", true), getChild<LLTextBox>("ObjectMeshDetailText", true));
  812. updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail", true), getChild<LLTextBox>("FlexibleMeshDetailText", true));
  813. updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail", true), getChild<LLTextBox>("TreeMeshDetailText", true));
  814. updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail", true), getChild<LLTextBox>("AvatarMeshDetailText", true));
  815. updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail", true), getChild<LLTextBox>("TerrainMeshDetailText", true));
  816. updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess", true), getChild<LLTextBox>("PostProcessText", true));
  817. updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail", true), getChild<LLTextBox>("SkyMeshDetailText", true));
  818. refreshEnabledState();
  819. }
  820. void LLFloaterPreference::onCommitWindowedMode()
  821. {
  822. refresh();
  823. }
  824. void LLFloaterPreference::onChangeQuality(const LLSD& data)
  825. {
  826. U32 level = (U32)(data.asReal());
  827. LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
  828. refreshEnabledGraphics();
  829. refresh();
  830. }
  831. // static
  832. // DEV-24146 -  needs to be removed at a later date. jan-2009
  833. void LLFloaterPreference::cleanupBadSetting()
  834. {
  835. if (gSavedPerAccountSettings.getString("BusyModeResponse2") == "|TOKEN COPY BusyModeResponse|")
  836. {
  837. llwarns << "cleaning old BusyModeResponse" << llendl;
  838. gSavedPerAccountSettings.setString("BusyModeResponse2", gSavedPerAccountSettings.getText("BusyModeResponse"));
  839. }
  840. }
  841. void LLFloaterPreference::onClickSetKey()
  842. {
  843. LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
  844. if (dialog)
  845. {
  846. dialog->setParent(this);
  847. }
  848. }
  849. void LLFloaterPreference::setKey(KEY key)
  850. {
  851. childSetValue("modifier_combo", LLKeyboard::stringFromKey(key));
  852. // update the control right away since we no longer wait for apply
  853. getChild<LLUICtrl>("modifier_combo")->onCommit();
  854. }
  855. void LLFloaterPreference::onClickSetMiddleMouse()
  856. {
  857. childSetValue("modifier_combo", "MiddleMouse");
  858. // update the control right away since we no longer wait for apply
  859. getChild<LLUICtrl>("modifier_combo")->onCommit();
  860. }
  861. /*
  862. void LLFloaterPreference::onClickSkipDialogs()
  863. {
  864. LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
  865. }
  866. void LLFloaterPreference::onClickResetDialogs()
  867. {
  868. LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
  869. }
  870.  */
  871. void LLFloaterPreference::onClickEnablePopup()
  872. {
  873. LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
  874. std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
  875. std::vector<LLScrollListItem*>::iterator itor;
  876. for (itor = items.begin(); itor != items.end(); ++itor)
  877. {
  878. LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
  879. //gSavedSettings.setWarning(templatep->mName, TRUE);
  880. std::string notification_name = templatep->mName;
  881. LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
  882. }
  883. buildPopupLists();
  884. }
  885. void LLFloaterPreference::onClickDisablePopup()
  886. {
  887. LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
  888. std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
  889. std::vector<LLScrollListItem*>::iterator itor;
  890. for (itor = items.begin(); itor != items.end(); ++itor)
  891. {
  892. LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
  893. //gSavedSettings.setWarning(templatep->mName, TRUE);
  894. std::string notification_name = templatep->mName;
  895. LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, FALSE);
  896. }
  897. buildPopupLists();
  898. }
  899. void LLFloaterPreference::resetAllIgnored()
  900. {
  901. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  902.  iter != LLNotifications::instance().templatesEnd();
  903.  ++iter)
  904. {
  905. if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
  906. {
  907. LLUI::sSettingGroups["ignores"]->setBOOL(iter->first, TRUE);
  908. }
  909. }
  910. }
  911. void LLFloaterPreference::setAllIgnored()
  912. {
  913. for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
  914.  iter != LLNotifications::instance().templatesEnd();
  915.  ++iter)
  916. {
  917. if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
  918. {
  919. LLUI::sSettingGroups["ignores"]->setBOOL(iter->first, FALSE);
  920. }
  921. }
  922. }
  923. void LLFloaterPreference::onClickLogPath()
  924. {
  925. std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));  
  926. LLDirPicker& picker = LLDirPicker::instance();
  927. if (!picker.getDir(&proposed_name ) )
  928. {
  929. return; //Canceled!
  930. }
  931. std::string chat_log_dir = picker.getDirName();
  932. std::string chat_log_top_folder= gDirUtilp->getBaseFileName(chat_log_dir);
  933. gSavedPerAccountSettings.setString("InstantMessageLogPath",chat_log_dir);
  934. gSavedPerAccountSettings.setString("InstantMessageLogFolder",chat_log_top_folder);
  935. }
  936. void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email)
  937. {
  938. mGotPersonalInfo = true;
  939. mOriginalIMViaEmail = im_via_email;
  940. mDirectoryVisibility = visibility;
  941. if(visibility == VISIBILITY_DEFAULT)
  942. {
  943. mOriginalHideOnlineStatus = false;
  944. childEnable("online_visibility");   
  945. }
  946. else if(visibility == VISIBILITY_HIDDEN)
  947. {
  948. mOriginalHideOnlineStatus = true;
  949. childEnable("online_visibility");   
  950. }
  951. else
  952. {
  953. mOriginalHideOnlineStatus = true;
  954. }
  955. childEnable("include_im_in_chat_history");
  956. childEnable("show_timestamps_check_im");
  957. childEnable("friends_online_notify_checkbox");
  958. childSetValue("online_visibility", mOriginalHideOnlineStatus);   
  959. childSetLabelArg("online_visibility", "[DIR_VIS]", mDirectoryVisibility);
  960. childEnable("send_im_to_email");
  961. childSetValue("send_im_to_email", im_via_email);
  962. childEnable("plain_text_chat_history");
  963. childSetValue("plain_text_chat_history", gSavedSettings.getBOOL("PlainTextChatHistory"));
  964. childEnable("log_instant_messages");
  965. // childEnable("log_chat");
  966. // childEnable("busy_response");
  967. // childEnable("log_instant_messages_timestamp");
  968. // childEnable("log_chat_timestamp");
  969. childEnable("log_chat_IM");
  970. childEnable("log_date_timestamp");
  971. // childSetText("busy_response", gSavedSettings.getString("BusyModeResponse2"));
  972. childEnable("log_nearby_chat");
  973. childEnable("log_instant_messages");
  974. childEnable("show_timestamps_check_im");
  975. childDisable("log_path_string");// LineEditor becomes readonly in this case.
  976. childEnable("log_path_button");
  977. std::string display_email(email);
  978. childSetText("email_address",display_email);
  979. }
  980. void LLFloaterPreference::onUpdateSliderText(LLUICtrl* ctrl, const LLSD& name)
  981. {
  982. std::string ctrl_name = name.asString();
  983. if((ctrl_name =="" )|| !hasChild(ctrl_name, true))
  984. return;
  985. LLTextBox* text_box = getChild<LLTextBox>(name.asString());
  986. LLSliderCtrl* slider = dynamic_cast<LLSliderCtrl*>(ctrl);
  987. updateSliderText(slider, text_box);
  988. }
  989. void LLFloaterPreference::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box)
  990. {
  991. if(text_box == NULL || ctrl== NULL)
  992. return;
  993. // get range and points when text should change
  994. F32 value = (F32)ctrl->getValue().asReal();
  995. F32 min = ctrl->getMinValue();
  996. F32 max = ctrl->getMaxValue();
  997. F32 range = max - min;
  998. llassert(range > 0);
  999. F32 midPoint = min + range / 3.0f;
  1000. F32 highPoint = min + (2.0f * range / 3.0f);
  1001. // choose the right text
  1002. if(value < midPoint)
  1003. {
  1004. text_box->setText(LLTrans::getString("GraphicsQualityLow"));
  1005. else if (value < highPoint)
  1006. {
  1007. text_box->setText(LLTrans::getString("GraphicsQualityMid"));
  1008. }
  1009. else
  1010. {
  1011. text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
  1012. }
  1013. }
  1014. void LLFloaterPreference::applyResolution()
  1015. {
  1016. gGL.flush();
  1017. // Screen resolution
  1018. S32 num_resolutions;
  1019. LLWindow::LLWindowResolution* supported_resolutions = 
  1020. gViewerWindow->getWindow()->getSupportedResolutions(num_resolutions);
  1021. S32 resIndex = getChild<LLComboBox>("fullscreen combo")->getCurrentIndex();
  1022. if (resIndex == -1)
  1023. {
  1024. // use highest resolution if nothing selected
  1025. resIndex = num_resolutions - 1;
  1026. }
  1027. gSavedSettings.setS32("FullScreenWidth", supported_resolutions[resIndex].mWidth);
  1028. gSavedSettings.setS32("FullScreenHeight", supported_resolutions[resIndex].mHeight);
  1029. gViewerWindow->requestResolutionUpdate(gSavedSettings.getBOOL("WindowFullScreen"));
  1030. send_agent_update(TRUE);
  1031. // Update enable/disable
  1032. refresh();
  1033. }
  1034. void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param)
  1035. {
  1036. LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
  1037. }
  1038. void LLFloaterPreference::getUIColor(LLUICtrl* ctrl, const LLSD& param)
  1039. {
  1040. LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
  1041. color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
  1042. }
  1043. //----------------------------------------------------------------------------
  1044. static LLRegisterPanelClassWrapper<LLPanelPreference> t_places("panel_preference");
  1045. LLPanelPreference::LLPanelPreference()
  1046. : LLPanel()
  1047. {
  1048. mCommitCallbackRegistrar.add("Pref.setControlFalse", boost::bind(&LLPanelPreference::setControlFalse,this, _2));
  1049. }
  1050. //virtual
  1051. BOOL LLPanelPreference::postBuild()
  1052. {
  1053. ////////////////////// PanelVoice ///////////////////
  1054. if(hasChild("voice_unavailable"))
  1055. {
  1056. BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
  1057. childSetVisible("voice_unavailable", voice_disabled);
  1058. childSetVisible("enable_voice_check", !voice_disabled);
  1059. }
  1060. //////////////////////PanelSkins ///////////////////
  1061. if (hasChild("skin_selection"))
  1062. {
  1063. LLFloaterPreference::refreshSkin(this);
  1064. // if skin is set to a skin that no longer exists (silver) set back to default
  1065. if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
  1066. {
  1067. gSavedSettings.setString("SkinCurrent", "default");
  1068. LLFloaterPreference::refreshSkin(this);
  1069. }
  1070. }
  1071. if(hasChild("online_visibility") && hasChild("send_im_to_email"))
  1072. {
  1073. childSetText("email_address",getString("log_in_to_change") );
  1074. // childSetText("busy_response", getString("log_in_to_change"));
  1075. }
  1076. //////////////////////PanelPrivacy ///////////////////
  1077. if (hasChild("media_enabled"))
  1078. {
  1079. bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
  1080. getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
  1081. getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
  1082. getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
  1083. }
  1084. if (hasChild("music_enabled"))
  1085. {
  1086. getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
  1087. }
  1088. apply();
  1089. return true;
  1090. }
  1091. void LLPanelPreference::apply()
  1092. {
  1093. // no-op
  1094. }
  1095. void LLPanelPreference::saveSettings()
  1096. {
  1097. // Save the value of all controls in the hierarchy
  1098. mSavedValues.clear();
  1099. std::list<LLView*> view_stack;
  1100. view_stack.push_back(this);
  1101. while(!view_stack.empty())
  1102. {
  1103. // Process view on top of the stack
  1104. LLView* curview = view_stack.front();
  1105. view_stack.pop_front();
  1106. LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
  1107. if (color_swatch)
  1108. {
  1109. mSavedColors[color_swatch->getName()] = color_swatch->get();
  1110. }
  1111. else
  1112. {
  1113. LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
  1114. if (ctrl)
  1115. {
  1116. LLControlVariable* control = ctrl->getControlVariable();
  1117. if (control)
  1118. {
  1119. mSavedValues[control] = control->getValue();
  1120. }
  1121. }
  1122. }
  1123. // Push children onto the end of the work stack
  1124. for (child_list_t::const_iterator iter = curview->getChildList()->begin();
  1125.  iter != curview->getChildList()->end(); ++iter)
  1126. {
  1127. view_stack.push_back(*iter);
  1128. }
  1129. }
  1130. }
  1131. void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& value)
  1132. {
  1133. if (checkbox && checkbox->getValue())
  1134. {
  1135. LLNotificationsUtil::add("FriendsAndGroupsOnly");
  1136. }
  1137. }
  1138. void LLPanelPreference::cancel()
  1139. {
  1140. for (control_values_map_t::iterator iter =  mSavedValues.begin();
  1141.  iter !=  mSavedValues.end(); ++iter)
  1142. {
  1143. LLControlVariable* control = iter->first;
  1144. LLSD ctrl_value = iter->second;
  1145. control->set(ctrl_value);
  1146. }
  1147. for (string_color_map_t::iterator iter = mSavedColors.begin();
  1148.  iter != mSavedColors.end(); ++iter)
  1149. {
  1150. LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
  1151. if(color_swatch)
  1152. {
  1153. color_swatch->set(iter->second);
  1154. color_swatch->onCommit();
  1155. }
  1156. }
  1157. }
  1158. void LLPanelPreference::setControlFalse(const LLSD& user_data)
  1159. {
  1160. std::string control_name = user_data.asString();
  1161. LLControlVariable* control = findControl(control_name);
  1162. if (control)
  1163. control->set(LLSD(FALSE));
  1164. }
  1165. static LLRegisterPanelClassWrapper<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
  1166. BOOL LLPanelPreferenceGraphics::postBuild()
  1167. {
  1168. return LLPanelPreference::postBuild();
  1169. }
  1170. void LLPanelPreferenceGraphics::draw()
  1171. {
  1172. LLPanelPreference::draw();
  1173. LLButton* button_apply = findChild<LLButton>("Apply");
  1174. if(button_apply && button_apply->getVisible())
  1175. {
  1176. bool enable = hasDirtyChilds();
  1177. button_apply->setEnabled(enable);
  1178. }
  1179. }
  1180. bool LLPanelPreferenceGraphics::hasDirtyChilds()
  1181. {
  1182. std::list<LLView*> view_stack;
  1183. view_stack.push_back(this);
  1184. while(!view_stack.empty())
  1185. {
  1186. // Process view on top of the stack
  1187. LLView* curview = view_stack.front();
  1188. view_stack.pop_front();
  1189. LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
  1190. if (ctrl)
  1191. {
  1192. if(ctrl->isDirty())
  1193. return true;
  1194. }
  1195. // Push children onto the end of the work stack
  1196. for (child_list_t::const_iterator iter = curview->getChildList()->begin();
  1197.  iter != curview->getChildList()->end(); ++iter)
  1198. {
  1199. view_stack.push_back(*iter);
  1200. }
  1201. }
  1202. return false;
  1203. }
  1204. void LLPanelPreferenceGraphics::resetDirtyChilds()
  1205. {
  1206. std::list<LLView*> view_stack;
  1207. view_stack.push_back(this);
  1208. while(!view_stack.empty())
  1209. {
  1210. // Process view on top of the stack
  1211. LLView* curview = view_stack.front();
  1212. view_stack.pop_front();
  1213. LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
  1214. if (ctrl)
  1215. {
  1216. ctrl->resetDirty();
  1217. }
  1218. // Push children onto the end of the work stack
  1219. for (child_list_t::const_iterator iter = curview->getChildList()->begin();
  1220.  iter != curview->getChildList()->end(); ++iter)
  1221. {
  1222. view_stack.push_back(*iter);
  1223. }
  1224. }
  1225. }
  1226. void LLPanelPreferenceGraphics::apply()
  1227. {
  1228. resetDirtyChilds();
  1229. LLPanelPreference::apply();
  1230. }
  1231. void LLPanelPreferenceGraphics::cancel()
  1232. {
  1233. resetDirtyChilds();
  1234. LLPanelPreference::cancel();
  1235. }
  1236. void LLPanelPreferenceGraphics::saveSettings()
  1237. {
  1238. resetDirtyChilds();
  1239. LLPanelPreference::saveSettings();
  1240. }
  1241. void LLPanelPreferenceGraphics::setHardwareDefaults()
  1242. {
  1243. resetDirtyChilds();
  1244. LLPanelPreference::setHardwareDefaults();
  1245. }