Annotation of /trunk/indra/newview/llprefschat.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llprefschat.cpp | ||
| 3 : | * @author James Cook, Richard Nelson | ||
| 4 : | * @brief Chat preferences panel | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2003&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | mjm | 137 | * Copyright (c) 2003-2010, Linden Research, Inc. |
| 9 : | mjm | 135 | * |
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at | ||
| 22 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 23 : | * | ||
| 24 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 25 : | * that you have read and understood your obligations described above, | ||
| 26 : | * and agree to abide by those obligations. | ||
| 27 : | * | ||
| 28 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 29 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 30 : | * COMPLETENESS OR PERFORMANCE. | ||
| 31 : | * $/LicenseInfo$ | ||
| 32 : | */ | ||
| 33 : | |||
| 34 : | #include "llviewerprecompiledheaders.h" | ||
| 35 : | |||
| 36 : | #include "llprefschat.h" | ||
| 37 : | #include "lltexteditor.h" | ||
| 38 : | #include "llviewercontrol.h" | ||
| 39 : | #include "lluictrlfactory.h" | ||
| 40 : | #include "llcolorswatch.h" | ||
| 41 : | #include "llradiogroup.h" | ||
| 42 : | #include "llstylemap.h" | ||
| 43 : | |||
| 44 : | class LLPrefsChatImpl : public LLPanel | ||
| 45 : | { | ||
| 46 : | public: | ||
| 47 : | LLPrefsChatImpl(); | ||
| 48 : | /*virtual*/ ~LLPrefsChatImpl(){}; | ||
| 49 : | |||
| 50 : | void apply(); | ||
| 51 : | void cancel(); | ||
| 52 : | |||
| 53 : | private: | ||
| 54 : | void refreshValues(); | ||
| 55 : | S32 mChatSize; | ||
| 56 : | F32 mChatPersist; | ||
| 57 : | S32 mChatMaxLines; | ||
| 58 : | LLColor4 mSystemChatColor; | ||
| 59 : | LLColor4 mUserChatColor; | ||
| 60 : | LLColor4 mAgentChatColor; | ||
| 61 : | LLColor4 mIMChatColor; | ||
| 62 : | LLColor4 mObjectChatColor; | ||
| 63 : | LLColor4 mOwnerSayChatColor; | ||
| 64 : | LLColor4 mBGChatColor; | ||
| 65 : | LLColor4 mScriptErrorColor; | ||
| 66 : | LLColor4 mHTMLLinkColor; | ||
| 67 : | BOOL mChatFullWidth; | ||
| 68 : | BOOL mCloseChatOnReturn; | ||
| 69 : | BOOL mArrowKeysMoveAvatar; | ||
| 70 : | BOOL mShowTimestamps; | ||
| 71 : | BOOL mPlayTypingAnim; | ||
| 72 : | BOOL mChatBubbles; | ||
| 73 : | BOOL mScriptErrorAsChat; | ||
| 74 : | F32 mConsoleOpacity; | ||
| 75 : | F32 mBubbleOpacity; | ||
| 76 : | }; | ||
| 77 : | |||
| 78 : | |||
| 79 : | LLPrefsChatImpl::LLPrefsChatImpl() | ||
| 80 : | : LLPanel(std::string("Chat Panel")) | ||
| 81 : | { | ||
| 82 : | refreshValues(); // initialize member data from saved settings | ||
| 83 : | |||
| 84 : | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_chat.xml"); | ||
| 85 : | |||
| 86 : | getChild<LLRadioGroup>("chat_font_size")->setSelectedIndex(gSavedSettings.getS32("ChatFontSize")); | ||
| 87 : | childSetValue("fade_chat_time", gSavedSettings.getF32("ChatPersistTime")); | ||
| 88 : | childSetValue("max_chat_count", gSavedSettings.getS32("ConsoleMaxLines")); | ||
| 89 : | |||
| 90 : | getChild<LLColorSwatchCtrl>("system")->set(gSavedSettings.getColor4("SystemChatColor")); | ||
| 91 : | getChild<LLColorSwatchCtrl>("user")->set(gSavedSettings.getColor4("UserChatColor")); | ||
| 92 : | getChild<LLColorSwatchCtrl>("agent")->set(gSavedSettings.getColor4("AgentChatColor")); | ||
| 93 : | getChild<LLColorSwatchCtrl>("im")->set(gSavedSettings.getColor4("IMChatColor")); | ||
| 94 : | getChild<LLColorSwatchCtrl>("script_error")->set(gSavedSettings.getColor4("ScriptErrorColor")); | ||
| 95 : | getChild<LLColorSwatchCtrl>("objects")->set(gSavedSettings.getColor4("ObjectChatColor")); | ||
| 96 : | getChild<LLColorSwatchCtrl>("owner")->set(gSavedSettings.getColor4("llOwnerSayChatColor")); | ||
| 97 : | getChild<LLColorSwatchCtrl>("background")->set(gSavedSettings.getColor4("BackgroundChatColor")); | ||
| 98 : | getChild<LLColorSwatchCtrl>("links")->set(gSavedSettings.getColor4("HTMLLinkColor")); | ||
| 99 : | |||
| 100 : | childSetValue("arrow_keys_move_avatar_check", gSavedSettings.getBOOL("ArrowKeysMoveAvatar")); | ||
| 101 : | childSetValue("show_timestamps_check", gSavedSettings.getBOOL("ChatShowTimestamps")); | ||
| 102 : | childSetValue("script_errors_as_chat", gSavedSettings.getBOOL("ScriptErrorsAsChat")); | ||
| 103 : | |||
| 104 : | childSetValue("bubble_text_chat", gSavedSettings.getBOOL("UseChatBubbles")); | ||
| 105 : | childSetValue("chat_full_width_check", gSavedSettings.getBOOL("ChatFullWidth")); | ||
| 106 : | childSetValue("close_chat_on_return_check", gSavedSettings.getBOOL("CloseChatOnReturn")); | ||
| 107 : | childSetValue("play_typing_animation", gSavedSettings.getBOOL("PlayTypingAnim")); | ||
| 108 : | childSetValue("console_opacity", gSavedSettings.getF32("ConsoleBackgroundOpacity")); | ||
| 109 : | childSetValue("bubble_chat_opacity", gSavedSettings.getF32("ChatBubbleOpacity")); | ||
| 110 : | } | ||
| 111 : | |||
| 112 : | void LLPrefsChatImpl::refreshValues() | ||
| 113 : | { | ||
| 114 : | //set values | ||
| 115 : | mChatSize = gSavedSettings.getS32("ChatFontSize"); | ||
| 116 : | mChatPersist = gSavedSettings.getF32("ChatPersistTime"); | ||
| 117 : | mChatMaxLines = gSavedSettings.getS32("ConsoleMaxLines"); | ||
| 118 : | mSystemChatColor = gSavedSettings.getColor4("SystemChatColor"); | ||
| 119 : | mUserChatColor = gSavedSettings.getColor4("UserChatColor"); | ||
| 120 : | mAgentChatColor = gSavedSettings.getColor4("AgentChatColor"); | ||
| 121 : | mIMChatColor = gSavedSettings.getColor4("IMChatColor"); | ||
| 122 : | mObjectChatColor = gSavedSettings.getColor4("ObjectChatColor"); | ||
| 123 : | mOwnerSayChatColor = gSavedSettings.getColor4("llOwnerSayChatColor"); | ||
| 124 : | mBGChatColor = gSavedSettings.getColor4("BackgroundChatColor"); | ||
| 125 : | mScriptErrorColor = gSavedSettings.getColor4("ScriptErrorColor"); | ||
| 126 : | mHTMLLinkColor = gSavedSettings.getColor4("HTMLLinkColor"); | ||
| 127 : | mArrowKeysMoveAvatar = gSavedSettings.getBOOL("ArrowKeysMoveAvatar"); | ||
| 128 : | mShowTimestamps = gSavedSettings.getBOOL("ChatShowTimestamps"); | ||
| 129 : | mScriptErrorAsChat = gSavedSettings.getBOOL("ScriptErrorsAsChat"); | ||
| 130 : | mChatBubbles = gSavedSettings.getBOOL("UseChatBubbles"); | ||
| 131 : | mChatFullWidth = gSavedSettings.getBOOL("ChatFullWidth"); | ||
| 132 : | mCloseChatOnReturn = gSavedSettings.getBOOL("CloseChatOnReturn"); | ||
| 133 : | mPlayTypingAnim = gSavedSettings.getBOOL("PlayTypingAnim"); | ||
| 134 : | mConsoleOpacity = gSavedSettings.getF32("ConsoleBackgroundOpacity"); | ||
| 135 : | mBubbleOpacity = gSavedSettings.getF32("ChatBubbleOpacity"); | ||
| 136 : | } | ||
| 137 : | |||
| 138 : | void LLPrefsChatImpl::cancel() | ||
| 139 : | { | ||
| 140 : | gSavedSettings.setS32("ChatFontSize", mChatSize); | ||
| 141 : | gSavedSettings.setF32("ChatPersistTime", mChatPersist); | ||
| 142 : | gSavedSettings.setS32("ConsoleMaxLines", mChatMaxLines); | ||
| 143 : | gSavedSettings.setColor4("SystemChatColor", mSystemChatColor); | ||
| 144 : | gSavedSettings.setColor4("UserChatColor", mUserChatColor); | ||
| 145 : | gSavedSettings.setColor4("AgentChatColor", mAgentChatColor); | ||
| 146 : | gSavedSettings.setColor4("IMChatColor", mIMChatColor); | ||
| 147 : | gSavedSettings.setColor4("ObjectChatColor", mObjectChatColor); | ||
| 148 : | gSavedSettings.setColor4("llOwnerSayChatColor", mOwnerSayChatColor); | ||
| 149 : | gSavedSettings.setColor4("BackgroundChatColor", mBGChatColor); | ||
| 150 : | gSavedSettings.setColor4("ScriptErrorColor", mScriptErrorColor); | ||
| 151 : | gSavedSettings.setColor4("HTMLLinkColor", mHTMLLinkColor); | ||
| 152 : | gSavedSettings.setBOOL("ArrowKeysMoveAvatar", mArrowKeysMoveAvatar); | ||
| 153 : | gSavedSettings.setBOOL("ChatShowTimestamps", mShowTimestamps); | ||
| 154 : | gSavedSettings.setBOOL("ScriptErrorsAsChat", mScriptErrorAsChat); | ||
| 155 : | gSavedSettings.setBOOL("UseChatBubbles", mChatBubbles); | ||
| 156 : | gSavedSettings.setBOOL("ChatFullWidth", mChatFullWidth); | ||
| 157 : | gSavedSettings.setBOOL("CloseChatOnReturn", mCloseChatOnReturn); | ||
| 158 : | gSavedSettings.setBOOL("PlayTypingAnim", mPlayTypingAnim); | ||
| 159 : | gSavedSettings.setF32("ConsoleBackgroundOpacity", mConsoleOpacity); | ||
| 160 : | gSavedSettings.setF32("ChatBubbleOpacity", mBubbleOpacity); | ||
| 161 : | } | ||
| 162 : | |||
| 163 : | void LLPrefsChatImpl::apply() | ||
| 164 : | { | ||
| 165 : | gSavedSettings.setS32("ChatFontSize", getChild<LLRadioGroup>("chat_font_size")->getSelectedIndex()); | ||
| 166 : | gSavedSettings.setF32("ChatPersistTime", childGetValue("fade_chat_time").asReal()); | ||
| 167 : | gSavedSettings.setS32("ConsoleMaxLines", childGetValue("max_chat_count")); | ||
| 168 : | |||
| 169 : | gSavedSettings.setColor4("SystemChatColor", childGetValue("system")); | ||
| 170 : | gSavedSettings.setColor4("UserChatColor", childGetValue("user")); | ||
| 171 : | gSavedSettings.setColor4("AgentChatColor", childGetValue("agent")); | ||
| 172 : | gSavedSettings.setColor4("IMChatColor", childGetValue("im")); | ||
| 173 : | gSavedSettings.setColor4("ScriptErrorColor", childGetValue("script_error")); | ||
| 174 : | gSavedSettings.setColor4("ObjectChatColor", childGetValue("objects")); | ||
| 175 : | gSavedSettings.setColor4("llOwnerSayChatColor", childGetValue("owner")); | ||
| 176 : | gSavedSettings.setColor4("BackgroundChatColor", childGetValue("background")); | ||
| 177 : | |||
| 178 : | gSavedSettings.setColor4("HTMLLinkColor", childGetValue("links")); | ||
| 179 : | LLTextEditor::setLinkColor(childGetValue("links")); | ||
| 180 : | |||
| 181 : | gSavedSettings.setBOOL("ArrowKeysMoveAvatar", childGetValue("arrow_keys_move_avatar_check")); | ||
| 182 : | gSavedSettings.setBOOL("ChatShowTimestamps", childGetValue("show_timestamps_check")); | ||
| 183 : | gSavedSettings.setBOOL("ScriptErrorsAsChat", childGetValue("script_errors_as_chat")); | ||
| 184 : | gSavedSettings.setBOOL("UseChatBubbles", childGetValue("bubble_text_chat")); | ||
| 185 : | gSavedSettings.setBOOL("ChatFullWidth", childGetValue("chat_full_width_check")); | ||
| 186 : | gSavedSettings.setBOOL("CloseChatOnReturn", childGetValue("close_chat_on_return_check")); | ||
| 187 : | gSavedSettings.setBOOL("PlayTypingAnim", childGetValue("play_typing_animation")); | ||
| 188 : | |||
| 189 : | gSavedSettings.setF32("ConsoleBackgroundOpacity", childGetValue("console_opacity").asReal()); | ||
| 190 : | gSavedSettings.setF32("ChatBubbleOpacity", childGetValue("bubble_chat_opacity").asReal()); | ||
| 191 : | |||
| 192 : | refreshValues(); // member values become the official values and cancel becomes a no-op. | ||
| 193 : | } | ||
| 194 : | |||
| 195 : | //--------------------------------------------------------------------------- | ||
| 196 : | |||
| 197 : | LLPrefsChat::LLPrefsChat() | ||
| 198 : | : impl( * new LLPrefsChatImpl() ) | ||
| 199 : | { } | ||
| 200 : | |||
| 201 : | LLPrefsChat::~LLPrefsChat() | ||
| 202 : | { | ||
| 203 : | delete &impl; | ||
| 204 : | } | ||
| 205 : | |||
| 206 : | void LLPrefsChat::apply() | ||
| 207 : | { | ||
| 208 : | impl.apply(); | ||
| 209 : | LLStyleMap::instance().update(); | ||
| 210 : | } | ||
| 211 : | |||
| 212 : | void LLPrefsChat::cancel() | ||
| 213 : | { | ||
| 214 : | impl.cancel(); | ||
| 215 : | } | ||
| 216 : | |||
| 217 : | LLPanel* LLPrefsChat::getPanel() | ||
| 218 : | { | ||
| 219 : | return &impl; | ||
| 220 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

