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