diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llprefsvoice.cpp | 292 |
1 files changed, 111 insertions, 181 deletions
diff --git a/linden/indra/newview/llprefsvoice.cpp b/linden/indra/newview/llprefsvoice.cpp index 6661f08..ae7c921 100644 --- a/linden/indra/newview/llprefsvoice.cpp +++ b/linden/indra/newview/llprefsvoice.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2003&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2003&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2003-2008, Linden Research, Inc. | 8 | * Copyright (c) 2003-2009, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -35,245 +35,175 @@ | |||
35 | #include "llprefsvoice.h" | 35 | #include "llprefsvoice.h" |
36 | 36 | ||
37 | #include "llcheckboxctrl.h" | 37 | #include "llcheckboxctrl.h" |
38 | #include "llcombobox.h" | 38 | #include "llfloatervoicedevicesettings.h" |
39 | 39 | #include "llfocusmgr.h" | |
40 | #include "llkeyboard.h" | ||
41 | #include "llmodaldialog.h" | ||
40 | #include "llviewercontrol.h" | 42 | #include "llviewercontrol.h" |
41 | #include "lluictrlfactory.h" | 43 | #include "lluictrlfactory.h" |
42 | 44 | ||
43 | #include "llmodaldialog.h" | ||
44 | #include "llkeyboard.h" | ||
45 | #include "llfocusmgr.h" | ||
46 | #include "llfloatervoicedevicesettings.h" | ||
47 | |||
48 | #include "llappviewer.h" | ||
49 | |||
50 | #include "llvoiceclient.h" | ||
51 | 45 | ||
52 | class LLVoiceHotkeySelectDialog : public LLModalDialog | 46 | class LLVoiceSetKeyDialog : public LLModalDialog |
53 | { | 47 | { |
54 | private: | ||
55 | LLPrefsVoiceLogic *mParent; | ||
56 | LLFloater *mOldFrontmost; | ||
57 | |||
58 | public: | 48 | public: |
59 | LLVoiceHotkeySelectDialog( LLPrefsVoiceLogic *parent ) | 49 | LLVoiceSetKeyDialog(LLPrefsVoice* parent); |
60 | : LLModalDialog( LLStringUtil::null, 240, 100 ), | 50 | ~LLVoiceSetKeyDialog(); |
61 | mParent( parent ) | ||
62 | { | ||
63 | mOldFrontmost = gFloaterView->getFrontmost(); | ||
64 | |||
65 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml"); | ||
66 | |||
67 | childSetAction("Cancel", LLVoiceHotkeySelectDialog::onCancel, this ); | ||
68 | childSetFocus("Cancel"); | ||
69 | } | ||
70 | |||
71 | /*virtual*/ void setFocus( BOOL b ) | ||
72 | { | ||
73 | LLFloater::setFocus(b); | ||
74 | |||
75 | // This forces keyboard processing to happen at the raw key level instead of going through handleUnicodeChar. | ||
76 | if (b) | ||
77 | { | ||
78 | gFocusMgr.setKeystrokesOnly(TRUE); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | static void onCancel( void* userdata ); | ||
83 | 51 | ||
84 | BOOL handleKeyHere(KEY key, MASK mask); | 52 | BOOL handleKeyHere(KEY key, MASK mask); |
85 | 53 | ||
54 | static void onCancel(void* user_data); | ||
55 | |||
56 | private: | ||
57 | LLPrefsVoice* mParent; | ||
86 | }; | 58 | }; |
87 | 59 | ||
88 | LLPrefsVoiceLogic::LLPrefsVoiceLogic(LLPanel* panelp) : | 60 | LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(LLPrefsVoice* parent) |
89 | mPanel(panelp) | 61 | : LLModalDialog(LLStringUtil::null, 240, 100), mParent(parent) |
90 | { | 62 | { |
91 | init(); | 63 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_select_key.xml"); |
64 | childSetAction("Cancel", onCancel, this); | ||
65 | childSetFocus("Cancel"); | ||
66 | |||
67 | gFocusMgr.setKeystrokesOnly(TRUE); | ||
92 | } | 68 | } |
93 | |||
94 | void LLPrefsVoiceLogic::init() | ||
95 | { | ||
96 | mEnableVoice = gSavedSettings.getBOOL("EnableVoiceChat"); | ||
97 | 69 | ||
98 | mVoiceCallsFriendsOnly = gSavedSettings.getBOOL("VoiceCallsFriendsOnly"); | 70 | LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog() |
99 | mModifier = gSavedSettings.getString("PushToTalkButton"); | 71 | { |
100 | mPushToTalkToggle = gSavedSettings.getBOOL("PushToTalkToggle"); | 72 | } |
101 | mEarLocation = gSavedSettings.getS32("VoiceEarLocation"); | ||
102 | 73 | ||
103 | LLUICtrl* ear_location = mPanel->getChild<LLUICtrl>("ear_location"); | 74 | BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask) |
104 | mCtrlEarLocation = ear_location->getSelectionInterface(); | 75 | { |
105 | if (mCtrlEarLocation) | 76 | BOOL result = TRUE; |
77 | |||
78 | if(key == 'Q' && mask == MASK_CONTROL) | ||
106 | { | 79 | { |
107 | mCtrlEarLocation->selectByValue(LLSD(gSavedSettings.getS32("VoiceEarLocation"))); | 80 | result = FALSE; |
81 | } | ||
82 | else | ||
83 | { | ||
84 | mParent->setKey(key); | ||
108 | } | 85 | } |
109 | mPanel->childSetCommitCallback("ear_location", onEarLocationCommit, this ); | ||
110 | |||
111 | mPanel->childSetAction("set_voice_hotkey_button", onClickSetKey, this); | ||
112 | mPanel->childSetAction("set_voice_middlemouse_button", onClickSetMiddleMouse, this); | ||
113 | 86 | ||
114 | refresh(); | 87 | close(); |
115 | mEatNextSetKeyClick = FALSE; | 88 | return result; |
116 | } | 89 | } |
117 | 90 | ||
118 | void LLPrefsVoiceLogic::refresh() | 91 | //static |
92 | void LLVoiceSetKeyDialog::onCancel(void* user_data) | ||
119 | { | 93 | { |
120 | BOOL voiceDisabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); | 94 | LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data; |
121 | mPanel->childSetVisible("voice_unavailable", voiceDisabled); | 95 | self->close(); |
122 | mPanel->childSetVisible("enable_voice_check", !voiceDisabled); | ||
123 | mPanel->childSetEnabled("enable_voice_check", !voiceDisabled); | ||
124 | |||
125 | bool enable = !voiceDisabled && gSavedSettings.getBOOL("EnableVoiceChat"); | ||
126 | |||
127 | mPanel->childSetEnabled("friends_only_check", enable); | ||
128 | mPanel->childSetEnabled("push_to_talk_check", enable); | ||
129 | mPanel->childSetEnabled("push_to_talk_label", enable); | ||
130 | mPanel->childSetEnabled("voice_call_friends_only_check", enable); | ||
131 | mPanel->childSetEnabled("push_to_talk_toggle_check", enable); | ||
132 | mPanel->childSetEnabled("ear_location", enable); | ||
133 | mPanel->childSetEnabled("set_voice_hotkey_button", enable); | ||
134 | mPanel->childSetEnabled("set_voice_middlemouse_button", enable); | ||
135 | } | 96 | } |
136 | 97 | ||
137 | void LLPrefsVoiceLogic::cancel() | 98 | //-------------------------------------------------------------------- |
138 | { | 99 | //LLPrefsVoice |
139 | gSavedSettings.setBOOL("EnableVoiceChat", mEnableVoice); | 100 | LLPrefsVoice::LLPrefsVoice() |
140 | gSavedSettings.setBOOL("VoiceCallsFriendsOnly", mVoiceCallsFriendsOnly); | 101 | : LLPanel(std::string("Voice Chat Panel")) |
141 | gSavedSettings.setString("PushToTalkButton", mModifier); | 102 | { |
142 | gSavedSettings.setBOOL("PushToTalkToggle", mPushToTalkToggle ); | 103 | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_voice.xml"); |
143 | gSavedSettings.setS32("VoiceEarLocation", mEarLocation); | ||
144 | } | 104 | } |
145 | 105 | ||
146 | void LLPrefsVoiceLogic::apply() | 106 | LLPrefsVoice::~LLPrefsVoice() |
147 | { | 107 | { |
148 | } | 108 | } |
149 | 109 | ||
150 | //static | 110 | BOOL LLPrefsVoice::postBuild() |
151 | void LLPrefsVoiceLogic::onEarLocationCommit(LLUICtrl* ctrl, void* user_data) | ||
152 | { | 111 | { |
153 | LLCtrlSelectionInterface* interfacep = ctrl->getSelectionInterface(); | 112 | childSetCommitCallback("enable_voice_check", onCommitEnableVoiceChat, this); |
154 | if (interfacep) | 113 | childSetAction("set_voice_hotkey_button", onClickSetKey, this); |
155 | { | 114 | childSetAction("set_voice_middlemouse_button", onClickSetMiddleMouse, this); |
156 | gSavedSettings.setS32("VoiceEarLocation", interfacep->getSelectedValue().asInteger()); | 115 | childSetAction("device_settings_btn", onClickVoiceDeviceSettings, NULL); |
157 | } | ||
158 | } | ||
159 | 116 | ||
160 | // static | 117 | BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice"); |
161 | void LLPrefsVoiceLogic::onClickSetKey(void* user_data) | 118 | childSetVisible("voice_unavailable", voice_disabled); |
162 | { | 119 | childSetVisible("enable_voice_check", !voice_disabled); |
163 | LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data; | 120 | childSetEnabled("enable_voice_check", !voice_disabled); |
164 | if(self->mEatNextSetKeyClick) | ||
165 | { | ||
166 | self->mEatNextSetKeyClick = false; | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | LLVoiceHotkeySelectDialog* dialog = new LLVoiceHotkeySelectDialog( self ); | ||
171 | dialog->startModal(); | ||
172 | // dialog will delete itself | ||
173 | } | ||
174 | } | ||
175 | 121 | ||
122 | bool enable = !voice_disabled && gSavedSettings.getBOOL("EnableVoiceChat"); | ||
123 | childSetValue("enable_voice_check", enable); | ||
124 | onCommitEnableVoiceChat(getChild<LLCheckBoxCtrl>("enable_voice_check"), this); | ||
176 | 125 | ||
177 | // static | 126 | childSetValue("modifier_combo", gSavedSettings.getString("PushToTalkButton")); |
178 | void LLPrefsVoiceLogic::onClickSetMiddleMouse(void* user_data) | 127 | childSetValue("voice_call_friends_only_check", gSavedSettings.getBOOL("VoiceCallsFriendsOnly")); |
179 | { | 128 | childSetValue("push_to_talk_toggle_check", gSavedSettings.getBOOL("PushToTalkToggle")); |
180 | // LLPrefsVoiceLogic* self=(LLPrefsVoiceLogic*)user_data; | 129 | childSetValue("ear_location", gSavedSettings.getS32("VoiceEarLocation")); |
181 | 130 | ||
182 | gSavedSettings.setString("PushToTalkButton", "MiddleMouse"); | 131 | return TRUE; |
183 | } | 132 | } |
184 | 133 | ||
185 | void LLPrefsVoiceLogic::setKey(KEY key, MASK mask) | 134 | void LLPrefsVoice::apply() |
186 | { | 135 | { |
187 | std::string keystring = LLKeyboard::stringFromKey(key); | 136 | gSavedSettings.setBOOL("EnableVoiceChat", childGetValue("enable_voice_check")); |
188 | gSavedSettings.setString("PushToTalkButton", keystring); | 137 | |
138 | gSavedSettings.setString("PushToTalkButton", childGetValue("modifier_combo")); | ||
139 | gSavedSettings.setBOOL("VoiceCallsFriendsOnly", childGetValue("voice_call_friends_only_check")); | ||
140 | gSavedSettings.setBOOL("PushToTalkToggle", childGetValue("push_to_talk_toggle_check")); | ||
141 | gSavedSettings.setS32("VoiceEarLocation", childGetValue("ear_location")); | ||
189 | 142 | ||
190 | if(key == ' ') | 143 | LLFloaterVoiceDeviceSettings* voice_device_settings = LLFloaterVoiceDeviceSettings::getInstance(); |
144 | if(voice_device_settings) | ||
191 | { | 145 | { |
192 | // This will cause the select dialog to immediately reopen. | 146 | voice_device_settings->apply(); |
193 | // Eat the next click event. | ||
194 | mEatNextSetKeyClick = TRUE; | ||
195 | } | 147 | } |
196 | } | 148 | } |
197 | 149 | ||
198 | void LLVoiceHotkeySelectDialog::onCancel( void* userdata ) | 150 | void LLPrefsVoice::cancel() |
199 | { | ||
200 | LLVoiceHotkeySelectDialog* self = (LLVoiceHotkeySelectDialog*) userdata; | ||
201 | self->close(); // destroys this object | ||
202 | self->mOldFrontmost->setFrontmost(TRUE); | ||
203 | } | ||
204 | |||
205 | BOOL LLVoiceHotkeySelectDialog::handleKeyHere(KEY key, MASK mask) | ||
206 | { | 151 | { |
207 | BOOL result = TRUE; | 152 | LLFloaterVoiceDeviceSettings* voice_device_settings = LLFloaterVoiceDeviceSettings::getInstance(); |
208 | 153 | if(voice_device_settings) | |
209 | // Suck up all keystokes except CTRL-Q. | ||
210 | BOOL is_quit = ('Q' == key) && (MASK_CONTROL == mask); | ||
211 | if(is_quit) | ||
212 | { | 154 | { |
213 | result = FALSE; | 155 | voice_device_settings->cancel(); |
214 | } | ||
215 | else | ||
216 | { | ||
217 | mParent->setKey(key, mask); | ||
218 | } | 156 | } |
219 | |||
220 | close(); // destroys this object | ||
221 | mOldFrontmost->setFrontmost(TRUE); | ||
222 | |||
223 | return result; | ||
224 | } | 157 | } |
225 | 158 | ||
226 | //--------------------------------------------------------------------------- | 159 | void LLPrefsVoice::setKey(KEY key) |
227 | |||
228 | |||
229 | LLPrefsVoice::LLPrefsVoice() | ||
230 | : LLPanel(std::string("Voice Chat Panel")) | ||
231 | { | ||
232 | LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_voice.xml"); | ||
233 | mLogic = new LLPrefsVoiceLogic(this); | ||
234 | childSetAction("device_settings_btn", onClickVoiceDeviceSettingsBtn, this); | ||
235 | |||
236 | // create floater immediately and keep it hidden | ||
237 | // since it stores preference state for audio devices | ||
238 | mVoiceDeviceSettings = LLFloaterVoiceDeviceSettings::getInstance(); | ||
239 | } | ||
240 | |||
241 | LLPrefsVoice::~LLPrefsVoice() | ||
242 | { | 160 | { |
243 | delete mLogic; | 161 | childSetValue("modifier_combo", LLKeyboard::stringFromKey(key)); |
244 | } | 162 | } |
245 | 163 | ||
246 | void LLPrefsVoice::draw() | 164 | //static |
165 | void LLPrefsVoice::onCommitEnableVoiceChat(LLUICtrl* ctrl, void* user_data) | ||
247 | { | 166 | { |
248 | bool enable = !gSavedSettings.getBOOL("CmdLineDisableVoice") | 167 | LLPrefsVoice* self = (LLPrefsVoice*)user_data; |
249 | && gSavedSettings.getBOOL("EnableVoiceChat"); | 168 | LLCheckBoxCtrl* enable_voice_chat = (LLCheckBoxCtrl*)ctrl; |
250 | childSetEnabled("device_settings_btn", enable); | 169 | |
170 | bool enable = enable_voice_chat->getValue(); | ||
251 | 171 | ||
252 | mLogic->refresh(); | 172 | self->childSetEnabled("modifier_combo", enable); |
253 | mVoiceDeviceSettings->refresh(); | 173 | self->childSetEnabled("friends_only_check", enable); |
254 | LLPanel::draw(); | 174 | self->childSetEnabled("push_to_talk_label", enable); |
175 | self->childSetEnabled("voice_call_friends_only_check", enable); | ||
176 | self->childSetEnabled("push_to_talk_toggle_check", enable); | ||
177 | self->childSetEnabled("ear_location", enable); | ||
178 | self->childSetEnabled("set_voice_hotkey_button", enable); | ||
179 | self->childSetEnabled("set_voice_middlemouse_button", enable); | ||
180 | self->childSetEnabled("device_settings_btn", enable); | ||
255 | } | 181 | } |
256 | 182 | ||
257 | void LLPrefsVoice::apply() | 183 | //static |
184 | void LLPrefsVoice::onClickSetKey(void* user_data) | ||
258 | { | 185 | { |
259 | mLogic->apply(); | 186 | LLPrefsVoice* self = (LLPrefsVoice*)user_data; |
260 | mVoiceDeviceSettings->apply(); | 187 | LLVoiceSetKeyDialog* dialog = new LLVoiceSetKeyDialog(self); |
188 | dialog->startModal(); | ||
261 | } | 189 | } |
262 | 190 | ||
263 | void LLPrefsVoice::cancel() | 191 | //static |
192 | void LLPrefsVoice::onClickSetMiddleMouse(void* user_data) | ||
264 | { | 193 | { |
265 | mLogic->cancel(); | 194 | LLPrefsVoice* self = (LLPrefsVoice*)user_data; |
266 | mVoiceDeviceSettings->cancel(); | 195 | self->childSetValue("modifier_combo", "MiddleMouse"); |
267 | } | 196 | } |
268 | 197 | ||
269 | //static | 198 | //static |
270 | void LLPrefsVoice::onClickVoiceDeviceSettingsBtn(void* user_data) | 199 | void LLPrefsVoice::onClickVoiceDeviceSettings(void* user_data) |
271 | { | 200 | { |
272 | LLPrefsVoice* prefs = (LLPrefsVoice*)user_data; | 201 | LLPrefsVoice* voice_prefs = (LLPrefsVoice*)user_data; |
273 | prefs->mVoiceDeviceSettings->open(); | 202 | LLFloaterVoiceDeviceSettings* device_settings_floater = LLFloaterVoiceDeviceSettings::showInstance(); |
274 | LLFloater* parent_floater = gFloaterView->getParentFloater(prefs); | 203 | LLFloater* parent_floater = gFloaterView->getParentFloater(voice_prefs); |
275 | if (parent_floater) | 204 | if(parent_floater) |
276 | { | 205 | { |
277 | parent_floater->addDependentFloater(prefs->mVoiceDeviceSettings, FALSE); | 206 | parent_floater->addDependentFloater(device_settings_floater, FALSE); |
278 | } | 207 | } |
279 | } | 208 | } |
209 | |||