aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatervoicedevicesettings.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llfloatervoicedevicesettings.cpp (renamed from linden/indra/newview/llfloatervoicewizard.cpp)254
1 files changed, 39 insertions, 215 deletions
diff --git a/linden/indra/newview/llfloatervoicewizard.cpp b/linden/indra/newview/llfloatervoicedevicesettings.cpp
index 94063a0..c7b9562 100644
--- a/linden/indra/newview/llfloatervoicewizard.cpp
+++ b/linden/indra/newview/llfloatervoicedevicesettings.cpp
@@ -1,7 +1,7 @@
1/** 1/**
2 * @file llfloatervoicewizard.cpp 2 * @file llfloatervoicedevicesettings.cpp
3 * @author Richard Nelson 3 * @author Richard Nelson
4 * @brief Voice communication set-up wizard 4 * @brief Voice communication set-up
5 * 5 *
6 * $LicenseInfo:firstyear=2007&license=viewergpl$ 6 * $LicenseInfo:firstyear=2007&license=viewergpl$
7 * 7 *
@@ -32,8 +32,9 @@
32 32
33#include "llviewerprecompiledheaders.h" 33#include "llviewerprecompiledheaders.h"
34 34
35#include "llfloatervoicewizard.h" 35#include "llfloatervoicedevicesettings.h"
36 36
37// Viewer includes
37#include "llagent.h" 38#include "llagent.h"
38#include "llbutton.h" 39#include "llbutton.h"
39#include "llcombobox.h" 40#include "llcombobox.h"
@@ -42,184 +43,14 @@
42#include "llprefsvoice.h" 43#include "llprefsvoice.h"
43#include "llsliderctrl.h" 44#include "llsliderctrl.h"
44#include "llviewercontrol.h" 45#include "llviewercontrol.h"
45#include "llvieweruictrlfactory.h"
46#include "llvoiceclient.h" 46#include "llvoiceclient.h"
47#include "llimpanel.h" 47#include "llimpanel.h"
48 48
49LLFloaterVoiceWizard::LLFloaterVoiceWizard(const LLSD& seed) : LLFloater("floater_voice_wizard"), mDevicePanel(NULL) 49// Library includes (after viewer)
50{ 50#include "lluictrlfactory.h"
51 mFactoryMap["device_settings"] = LLCallbackMap(createPanelDeviceSettings, this);
52 // do not automatically open singleton floaters (as result of getInstance())
53 BOOL no_open = FALSE;
54 gUICtrlFactory->buildFloater(this, "floater_voice_wizard.xml", &mFactoryMap, no_open);
55
56 mLogic = new LLPrefsVoiceLogic(this);
57 center();
58}
59
60LLFloaterVoiceWizard::~LLFloaterVoiceWizard()
61{
62 delete mLogic;
63 mLogic = NULL;
64}
65
66BOOL LLFloaterVoiceWizard::postBuild()
67{
68 childSetAction("next_btn", onClickNext, this);
69 childSetAction("back_btn", onClickBack, this);
70 childSetAction("ok_btn", onClickOK, this);
71 childSetAction("cancel_btn", onClickCancel, this);
72
73 childSetCommitCallback("voice_enable", onCommitVoiceEnable, this);
74
75 return TRUE;
76}
77
78void LLFloaterVoiceWizard::draw()
79{
80 mLogic->refresh();
81 if (mDevicePanel)
82 {
83 mDevicePanel->refresh();
84 }
85
86 LLTabContainer* tabs = LLUICtrlFactory::getTabContainerByName(this, "wizard_tabs");
87
88 if (tabs)
89 {
90 // if on first tab, disable back button, etc
91 if (tabs->getCurrentPanelIndex() == 0)
92 {
93 if (gSavedSettings.getBOOL("EnableVoiceChat"))
94 {
95 childSetEnabled("next_btn", TRUE);
96 setDefaultBtn(gUICtrlFactory->getButtonByName(this, "next_btn"));
97 }
98 else
99 {
100 childSetEnabled("next_btn", FALSE);
101 setDefaultBtn(gUICtrlFactory->getButtonByName(this, "ok_btn"));
102 }
103 childSetEnabled("back_btn", FALSE);
104 }
105 else
106 {
107 // if on any tab but the last, enable the next button
108 if (tabs->getCurrentPanelIndex() < tabs->getTabCount() - 1)
109 {
110 childSetEnabled("next_btn", TRUE);
111 setDefaultBtn(gUICtrlFactory->getButtonByName(this, "next_btn"));
112 }
113 else
114 {
115 childSetEnabled("next_btn", FALSE);
116 setDefaultBtn(gUICtrlFactory->getButtonByName(this, "ok_btn"));
117 }
118 childSetEnabled("back_btn", TRUE);
119 }
120 }
121
122 // because we can simultaneously change voice settings from the preferences UI
123 // we need to stay in sync
124 childSetValue("voice_enable", gSavedSettings.getBOOL("EnableVoiceChat") ? "1" : "0");
125
126 // show appropriate text on first tab
127 childSetVisible("voice_intro_text3", !gSavedSettings.getBOOL("EnableVoiceChat"));
128 childSetVisible("voice_intro_text4", gSavedSettings.getBOOL("EnableVoiceChat"));
129 51
130 LLFloater::draw();
131}
132 52
133void LLFloaterVoiceWizard::onOpen() 53LLPanelVoiceDeviceSettings::LLPanelVoiceDeviceSettings()
134{
135 LLFloaterDeviceSettings::hideInstance();
136
137 if(mDevicePanel)
138 {
139 mDevicePanel->onOpen();
140 }
141
142 LLFloater::onOpen();
143}
144
145void LLFloaterVoiceWizard::onClose(bool app_quitting)
146{
147 if(mDevicePanel)
148 {
149 mDevicePanel->onClose(app_quitting);
150 }
151
152 LLFloater::onClose(app_quitting);
153}
154
155
156// static
157void LLFloaterVoiceWizard::onClickNext(void *user_data)
158{
159 LLTabContainer* tabs = LLUICtrlFactory::getTabContainerByName((LLFloater*)user_data, "wizard_tabs");
160 if (tabs)
161 {
162 tabs->selectNextTab();
163 }
164}
165
166// static
167void LLFloaterVoiceWizard::onClickBack(void *user_data)
168{
169 LLTabContainer* tabs = LLUICtrlFactory::getTabContainerByName((LLFloater*)user_data, "wizard_tabs");
170 if (tabs)
171 {
172 tabs->selectPrevTab();
173 }
174}
175
176// static
177void LLFloaterVoiceWizard::onClickOK(void *user_data)
178{
179 LLFloaterVoiceWizard* self = (LLFloaterVoiceWizard*)user_data;
180
181 // propagate tuning mic volume to actual mic volume
182 self->mLogic->apply();
183 if (self->mDevicePanel)
184 {
185 self->mDevicePanel->apply();
186 }
187 self->close();
188}
189
190// static
191void LLFloaterVoiceWizard::onClickCancel(void *user_data)
192{
193 LLFloaterVoiceWizard* self = (LLFloaterVoiceWizard*)user_data;
194
195 self->mLogic->cancel();
196 if (self->mDevicePanel)
197 {
198 self->mDevicePanel->cancel();
199 }
200 self->close();
201}
202
203// static
204void LLFloaterVoiceWizard::onCommitVoiceEnable(LLUICtrl* ctrl, void* user_data)
205{
206 gSavedSettings.setBOOL("EnableVoiceChat", ctrl->getValue().asInteger());
207}
208
209// static
210void* LLFloaterVoiceWizard::createPanelDeviceSettings(void* user_data)
211{
212 LLFloaterVoiceWizard* floaterp = (LLFloaterVoiceWizard*)user_data;
213 floaterp->mDevicePanel = new LLPanelDeviceSettings();
214 return floaterp->mDevicePanel;
215}
216
217
218//
219// LLPanelDeviceSettings
220//
221
222LLPanelDeviceSettings::LLPanelDeviceSettings()
223{ 54{
224 mCtrlInputDevices = NULL; 55 mCtrlInputDevices = NULL;
225 mCtrlOutputDevices = NULL; 56 mCtrlOutputDevices = NULL;
@@ -235,18 +66,15 @@ LLPanelDeviceSettings::LLPanelDeviceSettings()
235 //gVoiceClient->refreshDeviceLists(); 66 //gVoiceClient->refreshDeviceLists();
236} 67}
237 68
238LLPanelDeviceSettings::~LLPanelDeviceSettings() 69LLPanelVoiceDeviceSettings::~LLPanelVoiceDeviceSettings()
239{ 70{
240} 71}
241 72
242BOOL LLPanelDeviceSettings::postBuild() 73BOOL LLPanelVoiceDeviceSettings::postBuild()
243{ 74{
244 LLSlider* volume_slider = gUICtrlFactory->getSliderBarByName(this, "mic_volume_slider"); 75 LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
245 if (volume_slider) 76 // set mic volume tuning slider based on last mic volume setting
246 { 77 volume_slider->setValue(mMicVolume);
247 // set mic volume tuning slider based on last mic volume setting
248 volume_slider->setValue(mMicVolume);
249 }
250 78
251 childSetCommitCallback("voice_input_device", onCommitInputDevice, this); 79 childSetCommitCallback("voice_input_device", onCommitInputDevice, this);
252 childSetCommitCallback("voice_output_device", onCommitOutputDevice, this); 80 childSetCommitCallback("voice_output_device", onCommitOutputDevice, this);
@@ -254,7 +82,7 @@ BOOL LLPanelDeviceSettings::postBuild()
254 return TRUE; 82 return TRUE;
255} 83}
256 84
257void LLPanelDeviceSettings::draw() 85void LLPanelVoiceDeviceSettings::draw()
258{ 86{
259 // let user know that volume indicator is not yet available 87 // let user know that volume indicator is not yet available
260 childSetVisible("wait_text", !gVoiceClient->inTuningMode()); 88 childSetVisible("wait_text", !gVoiceClient->inTuningMode());
@@ -278,7 +106,7 @@ void LLPanelDeviceSettings::draw()
278 for(S32 power_bar_idx = 0; power_bar_idx < 5; power_bar_idx++) 106 for(S32 power_bar_idx = 0; power_bar_idx < 5; power_bar_idx++)
279 { 107 {
280 LLString view_name = llformat("%s%d", "bar", power_bar_idx); 108 LLString view_name = llformat("%s%d", "bar", power_bar_idx);
281 LLView* bar_view = getChildByName(view_name, TRUE); 109 LLView* bar_view = getChild<LLView>(view_name);
282 if (bar_view) 110 if (bar_view)
283 { 111 {
284 if (power_bar_idx < discrete_power) 112 if (power_bar_idx < discrete_power)
@@ -292,7 +120,7 @@ void LLPanelDeviceSettings::draw()
292 } 120 }
293} 121}
294 122
295void LLPanelDeviceSettings::apply() 123void LLPanelVoiceDeviceSettings::apply()
296{ 124{
297 std::string s; 125 std::string s;
298 if(mCtrlInputDevices) 126 if(mCtrlInputDevices)
@@ -311,7 +139,7 @@ void LLPanelDeviceSettings::apply()
311 gSavedSettings.setF32("AudioLevelMic", mMicVolume); 139 gSavedSettings.setF32("AudioLevelMic", mMicVolume);
312} 140}
313 141
314void LLPanelDeviceSettings::cancel() 142void LLPanelVoiceDeviceSettings::cancel()
315{ 143{
316 gSavedSettings.setString("VoiceInputAudioDevice", mInputDevice); 144 gSavedSettings.setString("VoiceInputAudioDevice", mInputDevice);
317 gSavedSettings.setString("VoiceOutputAudioDevice", mOutputDevice); 145 gSavedSettings.setString("VoiceOutputAudioDevice", mOutputDevice);
@@ -323,20 +151,17 @@ void LLPanelDeviceSettings::cancel()
323 mCtrlOutputDevices->setSimple(mOutputDevice); 151 mCtrlOutputDevices->setSimple(mOutputDevice);
324} 152}
325 153
326void LLPanelDeviceSettings::refresh() 154void LLPanelVoiceDeviceSettings::refresh()
327{ 155{
328 //grab current volume 156 //grab current volume
329 LLSlider* volume_slider = gUICtrlFactory->getSliderBarByName(this, "mic_volume_slider"); 157 LLSlider* volume_slider = getChild<LLSlider>("mic_volume_slider");
330 if (volume_slider) 158 // set mic volume tuning slider based on last mic volume setting
331 { 159 mMicVolume = (F32)volume_slider->getValue().asReal();
332 // set mic volume tuning slider based on last mic volume setting 160 gVoiceClient->tuningSetMicVolume(mMicVolume);
333 mMicVolume = (F32)volume_slider->getValue().asReal();
334 gVoiceClient->tuningSetMicVolume(mMicVolume);
335 }
336 161
337 // Fill in popup menus 162 // Fill in popup menus
338 mCtrlInputDevices = LLUICtrlFactory::getComboBoxByName(this, "voice_input_device"); 163 mCtrlInputDevices = getChild<LLComboBox>("voice_input_device");
339 mCtrlOutputDevices = LLUICtrlFactory::getComboBoxByName(this, "voice_output_device"); 164 mCtrlOutputDevices = getChild<LLComboBox>("voice_output_device");
340 165
341 if(!gVoiceClient->deviceSettingsAvailable()) 166 if(!gVoiceClient->deviceSettingsAvailable())
342 { 167 {
@@ -398,7 +223,7 @@ void LLPanelDeviceSettings::refresh()
398 } 223 }
399} 224}
400 225
401void LLPanelDeviceSettings::onOpen() 226void LLPanelVoiceDeviceSettings::onOpen()
402{ 227{
403 mInputDevice = gSavedSettings.getString("VoiceInputAudioDevice"); 228 mInputDevice = gSavedSettings.getString("VoiceInputAudioDevice");
404 mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice"); 229 mOutputDevice = gSavedSettings.getString("VoiceOutputAudioDevice");
@@ -413,40 +238,39 @@ void LLPanelDeviceSettings::onOpen()
413 LLVoiceChannel::suspend(); 238 LLVoiceChannel::suspend();
414} 239}
415 240
416void LLPanelDeviceSettings::onClose(bool app_quitting) 241void LLPanelVoiceDeviceSettings::onClose(bool app_quitting)
417{ 242{
418 gVoiceClient->tuningStop(); 243 gVoiceClient->tuningStop();
419 LLVoiceChannel::resume(); 244 LLVoiceChannel::resume();
420} 245}
421 246
422// static 247// static
423void LLPanelDeviceSettings::onCommitInputDevice(LLUICtrl* ctrl, void* user_data) 248void LLPanelVoiceDeviceSettings::onCommitInputDevice(LLUICtrl* ctrl, void* user_data)
424{ 249{
425 gSavedSettings.setString("VoiceInputAudioDevice", ctrl->getValue().asString()); 250 gSavedSettings.setString("VoiceInputAudioDevice", ctrl->getValue().asString());
426} 251}
427 252
428// static 253// static
429void LLPanelDeviceSettings::onCommitOutputDevice(LLUICtrl* ctrl, void* user_data) 254void LLPanelVoiceDeviceSettings::onCommitOutputDevice(LLUICtrl* ctrl, void* user_data)
430{ 255{
431 gSavedSettings.setString("VoiceOutputAudioDevice", ctrl->getValue().asString()); 256 gSavedSettings.setString("VoiceOutputAudioDevice", ctrl->getValue().asString());
432} 257}
433 258
434// 259//
435// LLFloaterDeviceSettings 260// LLFloaterVoiceDeviceSettings
436// 261//
437 262
438LLFloaterDeviceSettings::LLFloaterDeviceSettings(const LLSD& seed) : LLFloater("floater_device_settings"), mDevicePanel(NULL) 263LLFloaterVoiceDeviceSettings::LLFloaterVoiceDeviceSettings(const LLSD& seed) : LLFloater("floater_device_settings"), mDevicePanel(NULL)
439{ 264{
440 mFactoryMap["device_settings"] = LLCallbackMap(createPanelDeviceSettings, this); 265 mFactoryMap["device_settings"] = LLCallbackMap(createPanelVoiceDeviceSettings, this);
441 // do not automatically open singleton floaters (as result of getInstance()) 266 // do not automatically open singleton floaters (as result of getInstance())
442 BOOL no_open = FALSE; 267 BOOL no_open = FALSE;
443 gUICtrlFactory->buildFloater(this, "floater_device_settings.xml", &mFactoryMap, no_open); 268 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_device_settings.xml", &mFactoryMap, no_open);
444 center(); 269 center();
445} 270}
446 271
447void LLFloaterDeviceSettings::onOpen() 272void LLFloaterVoiceDeviceSettings::onOpen()
448{ 273{
449 LLFloaterVoiceWizard::hideInstance();
450 if(mDevicePanel) 274 if(mDevicePanel)
451 { 275 {
452 mDevicePanel->onOpen(); 276 mDevicePanel->onOpen();
@@ -455,7 +279,7 @@ void LLFloaterDeviceSettings::onOpen()
455 LLFloater::onOpen(); 279 LLFloater::onOpen();
456} 280}
457 281
458void LLFloaterDeviceSettings::onClose(bool app_quitting) 282void LLFloaterVoiceDeviceSettings::onClose(bool app_quitting)
459{ 283{
460 if(mDevicePanel) 284 if(mDevicePanel)
461 { 285 {
@@ -465,7 +289,7 @@ void LLFloaterDeviceSettings::onClose(bool app_quitting)
465 setVisible(FALSE); 289 setVisible(FALSE);
466} 290}
467 291
468void LLFloaterDeviceSettings::apply() 292void LLFloaterVoiceDeviceSettings::apply()
469{ 293{
470 if (mDevicePanel) 294 if (mDevicePanel)
471 { 295 {
@@ -473,7 +297,7 @@ void LLFloaterDeviceSettings::apply()
473 } 297 }
474} 298}
475 299
476void LLFloaterDeviceSettings::cancel() 300void LLFloaterVoiceDeviceSettings::cancel()
477{ 301{
478 if (mDevicePanel) 302 if (mDevicePanel)
479 { 303 {
@@ -481,7 +305,7 @@ void LLFloaterDeviceSettings::cancel()
481 } 305 }
482} 306}
483 307
484void LLFloaterDeviceSettings::draw() 308void LLFloaterVoiceDeviceSettings::draw()
485{ 309{
486 if (mDevicePanel) 310 if (mDevicePanel)
487 { 311 {
@@ -491,9 +315,9 @@ void LLFloaterDeviceSettings::draw()
491} 315}
492 316
493// static 317// static
494void* LLFloaterDeviceSettings::createPanelDeviceSettings(void* user_data) 318void* LLFloaterVoiceDeviceSettings::createPanelVoiceDeviceSettings(void* user_data)
495{ 319{
496 LLFloaterDeviceSettings* floaterp = (LLFloaterDeviceSettings*)user_data; 320 LLFloaterVoiceDeviceSettings* floaterp = (LLFloaterVoiceDeviceSettings*)user_data;
497 floaterp->mDevicePanel = new LLPanelDeviceSettings(); 321 floaterp->mDevicePanel = new LLPanelVoiceDeviceSettings();
498 return floaterp->mDevicePanel; 322 return floaterp->mDevicePanel;
499} 323}