-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathAudioOptionsPanels.lua
823 lines (708 loc) · 28 KB
/
AudioOptionsPanels.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
-- if you change something here you probably want to change the glue version too
local VOICE_OPTIONS_BINDING_SUCCESS_FADE = 3;
local VOICE_OPTIONS_BINDING_FAIL_FADE = 6;
-- [[ Generic Audio Options Panel ]] --
function AudioOptionsPanel_CheckButton_OnClick (checkButton)
local setting = "0";
if ( checkButton:GetChecked() ) then
if ( not checkButton.invert ) then
setting = "1"
end
elseif ( checkButton.invert ) then
setting = "1"
end
local prevValue = checkButton:GetValue();
checkButton:SetValue(setting);
if ( checkButton.restart and prevValue ~= setting ) then
AudioOptionsFrame_AudioRestart();
end
if ( checkButton.dependentControls ) then
if ( checkButton:GetChecked() ) then
for _, control in next, checkButton.dependentControls do
control:Enable();
end
else
for _, control in next, checkButton.dependentControls do
control:Disable();
end
end
end
if ( checkButton.setFunc ) then
checkButton.setFunc(setting);
end
end
local function AudioOptionsPanel_Okay (self)
for _, control in next, self.controls do
if ( control.value and control:GetValue() ~= control.value ) then
if ( control.restart ) then
AudioOptionsFrame.audioRestart = true;
end
control:SetValue(control.value);
end
end
MiniMapVoiceChat_Update();
end
local function AudioOptionsPanel_Cancel (self)
for _, control in next, self.controls do
if ( control.oldValue ) then
if ( control.value and control.value ~= control.oldValue ) then
if ( control.restart ) then
AudioOptionsFrame.audioRestart = true;
end
control:SetValue(control.oldValue);
end
elseif ( control.value ) then
if ( control:GetValue() ~= control.value ) then
if ( control.restart ) then
AudioOptionsFrame.audioRestart = true;
end
control:SetValue(control.value);
end
end
end
end
local function AudioOptionsPanel_Default (self)
for _, control in next, self.controls do
if ( control.defaultValue and control.value ~= control.defaultValue ) then
if ( control.restart ) then
AudioOptionsFrame.audioRestart = true;
end
control:SetValue(control.defaultValue);
control.value = control.defaultValue;
end
end
MiniMapVoiceChat_Update();
end
local function AudioOptionsPanel_Refresh (self)
for _, control in next, self.controls do
BlizzardOptionsPanel_RefreshControl(control);
-- record values so we can cancel back to this state
control.oldValue = control.value;
end
end
-- [[ Sound Options Panel ]] --
SoundPanelOptions = {
Sound_EnableErrorSpeech = { text = "ENABLE_ERROR_SPEECH" },
Sound_EnableMusic = { text = "ENABLE_MUSIC" },
Sound_EnableAmbience = { text = "ENABLE_AMBIENCE" },
Sound_EnableSFX = { text = "ENABLE_SOUNDFX" },
Sound_EnableAllSound = { text = "ENABLE_SOUND" },
Sound_ListenerAtCharacter = { text = "ENABLE_SOUND_AT_CHARACTER" },
Sound_EnableEmoteSounds = { text = "ENABLE_EMOTE_SOUNDS" },
Sound_EnablePetSounds = { text = "ENABLE_PET_SOUNDS" },
Sound_ZoneMusicNoDelay = { text = "ENABLE_MUSIC_LOOPING" },
Sound_EnableSoundWhenGameIsInBG = { text = "ENABLE_BGSOUND" },
Sound_EnableReverb = { text = "ENABLE_REVERB" },
Sound_EnableHardware = { text = "ENABLE_HARDWARE" },
Sound_EnableSoftwareHRTF = { text = "ENABLE_SOFTWARE_HRTF" },
Sound_EnableDSPEffects = { text = "ENABLE_DSP_EFFECTS" },
Sound_SFXVolume = { text = "SOUND_VOLUME", minValue = 0, maxValue = 1, valueStep = 0.1, },
Sound_MusicVolume = { text = "MUSIC_VOLUME", minValue = 0, maxValue = 1, valueStep = 0.1, },
Sound_AmbienceVolume = { text = "AMBIENCE_VOLUME", minValue = 0, maxValue = 1, valueStep = 0.1, },
Sound_MasterVolume = { text = "MASTER_VOLUME", minValue = 0, maxValue = 1, valueStep = SOUND_MASTERVOLUME_STEP, },
Sound_NumChannels = { text = "SOUND_CHANNELS", minValue = 32, maxValue = 64, valueStep = 32, },
Sound_OutputQuality = { text = "SOUND_QUALITY", minValue = 0, maxValue = 2, valueStep = 1 },
}
function AudioOptionsSoundPanel_OnLoad (self)
self.name = SOUND_LABEL;
self.options = SoundPanelOptions;
BlizzardOptionsPanel_OnLoad(self, AudioOptionsPanel_Okay, AudioOptionsPanel_Cancel, AudioOptionsPanel_Default, AudioOptionsPanel_Refresh);
OptionsFrame_AddCategory(AudioOptionsFrame, self);
end
function AudioOptionsSoundPanelHardwareDropDown_OnLoad (self)
self.cvar = "Sound_OutputDriverIndex";
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
local deviceName = Sound_GameSystem_GetOutputDriverNameByIndex(selectedDriverIndex);
self.defaultValue = BlizzardOptionsPanel_GetCVarDefaultSafe(self.cvar);
self.value = selectedDriverIndex;
self.newValue = selectedDriverIndex;
self.restart = true;
UIDropDownMenu_SetWidth(self, 136);
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsSoundPanelHardwareDropDown_Initialize);
self.SetValue =
function (self, value)
self.value = value;
BlizzardOptionsPanel_SetCVarSafe(self.cvar, value);
end
self.GetValue =
function (self)
return BlizzardOptionsPanel_GetCVarSafe(self.cvar);
end
self.RefreshValue =
function (self)
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
local deviceName = Sound_GameSystem_GetOutputDriverNameByIndex(selectedDriverIndex);
self.value = selectedDriverIndex;
self.newValue = selectedDriverIndex;
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsSoundPanelHardwareDropDown_Initialize);
end
end
function AudioOptionsSoundPanelHardwareDropDown_Initialize(self)
local selectedValue = UIDropDownMenu_GetSelectedValue(self);
local num = Sound_GameSystem_GetNumOutputDrivers();
local info = UIDropDownMenu_CreateInfo();
for index=0,num-1,1 do
info.text = Sound_GameSystem_GetOutputDriverNameByIndex(index);
info.value = index;
info.checked = nil;
if (selectedValue and index == selectedValue) then
UIDropDownMenu_SetText(self, info.text);
info.checked = 1;
else
info.checked = nil;
end
info.func = AudioOptionsSoundPanelHardwareDropDown_OnClick;
UIDropDownMenu_AddButton(info);
end
end
function AudioOptionsSoundPanelHardwareDropDown_OnClick(self)
local value = self.value;
local dropdown = AudioOptionsSoundPanelHardwareDropDown;
UIDropDownMenu_SetSelectedValue(dropdown, value);
local prevValue = dropdown:GetValue();
dropdown:SetValue(value);
if ( dropdown.restart and prevValue ~= value ) then
AudioOptionsFrame_AudioRestart();
end
end
-- [[ Voice Options Panel ]] --
VoicePanelOptions = {
EnableVoiceChat = { text = "ENABLE_VOICECHAT" },
EnableMicrophone = { text = "ENABLE_MICROPHONE" },
OutboundChatVolume = { text = "VOICE_INPUT_VOLUME", minValue = 0.25, maxValue = 2.5, valueStep = 0.05 },
InboundChatVolume = { text = "VOICE_OUTPUT_VOLUME", minValue = 0, maxValue = 1, valueStep = 0.01 },
ChatSoundVolume = { text = "", minValue = 0, maxValue = 1, valueStep = 0.01, tooltip = OPTION_TOOLTIP_VOICE_SOUND },
ChatMusicVolume = { text = "", minValue = 0, maxValue = 1, valueStep = 0.01, tooltip = OPTION_TOOLTIP_VOICE_MUSIC },
ChatAmbienceVolume = { text = "", minValue = 0, maxValue = 1, valueStep = 0.01, tooltip = OPTION_TOOLTIP_VOICE_AMBIENCE },
PushToTalkSound = { text = "PUSHTOTALK_SOUND_TEXT" },
VoiceActivationSensitivity = { text = "VOICE_ACTIVATION_SENSITIVITY", minValue = 0, maxValue = 1, valueStep = 0.02 },
}
local AudioOptionsVoicePanelDisableList =
{
AudioOptionsVoicePanelChatMode1Label = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelAudioLabel = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelAudioDescription = HIGHLIGHT_FONT_COLOR,
AudioOptionsVoicePanelAudioOff = HIGHLIGHT_FONT_COLOR,
AudioOptionsVoicePanelAudioNormal = HIGHLIGHT_FONT_COLOR,
AudioOptionsVoicePanelSpeakerVolumeLabel = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelSoundFadeLabel = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelMusicFadeLabel = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelAmbienceFadeLabel = NORMAL_FONT_COLOR,
};
local AudioOptionsVoicePanelFrameMicrophoneList =
{
AudioOptionsVoicePanelMicrophoneVolumeLabel = NORMAL_FONT_COLOR,
AudioOptionsVoicePanelMicTestText = NORMAL_FONT_COLOR,
PlayLoopbackSoundButtonTexture = NORMAL_FONT_COLOR,
RecordLoopbackSoundButtonTexture = RED_FONT_COLOR,
};
function AudioOptionsVoicePanel_Refresh (self)
AudioOptionsPanel_Refresh(self);
AudioOptionsVoicePanelEnableVoice_UpdateControls(GetCVar(AudioOptionsVoicePanelEnableVoice.cvar));
AudioOptionsVoicePanelBindingType_Update(GetCVar(AudioOptionsVoicePanelChatModeDropDown.cvar));
AudioOptionsVoicePanelKeyBindingButton_Refresh();
AudioOptionsVoicePanelKeyBindingButton_SetTooltip();
end
function AudioOptionsVoicePanel_OnLoad (self)
self.name = VOICE_LABEL;
self.options = VoicePanelOptions;
BlizzardOptionsPanel_OnLoad(self, AudioOptionsPanel_Okay, AudioOptionsPanel_Cancel, AudioOptionsPanel_Default, AudioOptionsVoicePanel_Refresh);
self:SetScript("OnEvent", AudioOptionsVoicePanel_OnEvent);
end
function AudioOptionsVoicePanel_OnEvent (self, event, ...)
if ( event == "PLAYER_ENTERING_WORLD" ) then
if ( IsVoiceChatAllowedByServer() ) then
OptionsFrame_AddCategory(AudioOptionsFrame, self);
BlizzardOptionsPanel_OnEvent(self, event, ...);
end
self:UnregisterEvent(event);
end
end
function AudioOptionsVoicePanel_OnShow (self)
VoiceChatTalkers:SetAlpha(1);
VoiceChatTalkers.optionsLock = true;
end
function AudioOptionsVoicePanel_OnHide (self)
AudioOptionsVoicePanelKeyBindingButton_CancelBinding();
VoiceChatTalkers.optionsLock = nil;
if ( VoiceChatTalkers_CanHide() ) then
VoiceChatTalkers_FadeOut();
end
end
function AudioOptionsVoicePanelEnableVoice_UpdateControls (value)
local voiceChatEnabled = value == "1";
if ( VoiceIsDisabledByClient() ) then
--Comsat is disabled either because the computer is way old (No SSE) or another copy of WoW is running.
BlizzardOptionsPanel_SetCVarSafe("EnableVoiceChat", 0);
voiceChatEnabled = false;
AudioOptionsVoicePanelEnableVoice:Hide();
AudioOptionsVoicePanelDisabledMessage:Show();
elseif ( not AudioOptionsVoicePanelEnableVoice:IsShown() ) then
--Pretty certain this won't be changing dynamically, but better safe than sorry.
AudioOptionsVoicePanelEnableVoice:Show();
AudioOptionsVoicePanelDisabledMessage:Hide();
end
if ( voiceChatEnabled ) then
UIDropDownMenu_EnableDropDown(AudioOptionsVoicePanelOutputDeviceDropDown);
UIDropDownMenu_EnableDropDown(AudioOptionsVoicePanelChatModeDropDown);
AudioOptionsVoicePanelChatMode1KeyBindingButton:Enable();
for index, value in pairs(AudioOptionsVoicePanelDisableList) do
_G[index]:SetVertexColor(value.r, value.g, value.b);
end
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelVoiceActivateSlider);
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelSpeakerVolume);
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelSoundFade);
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelMusicFade);
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelAmbienceFade);
AudioOptionsVoicePanelEnableMicrophone:Enable();
AudioOptionsVoicePanelPushToTalkSound:Enable();
AudioOptionsVoicePanelEnableMicrophone_UpdateControls(AudioOptionsVoicePanelEnableMicrophone:GetChecked());
if ( ChannelPullout:IsShown() ) then
ChannelPullout_ToggleDisplay();
end
else
UIDropDownMenu_DisableDropDown(AudioOptionsVoicePanelOutputDeviceDropDown);
UIDropDownMenu_DisableDropDown(AudioOptionsVoicePanelChatModeDropDown);
AudioOptionsVoicePanelChatMode1KeyBindingButton:Disable();
for index, value in pairs(AudioOptionsVoicePanelDisableList) do
_G[index]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
end
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelVoiceActivateSlider);
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelSpeakerVolume);
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelSoundFade);
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelMusicFade);
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelAmbienceFade);
AudioOptionsVoicePanelEnableMicrophone:Disable();
AudioOptionsVoicePanelPushToTalkSound:Disable();
AudioOptionsVoicePanelEnableMicrophone_UpdateControls(AudioOptionsVoicePanelEnableMicrophone:GetChecked());
if ( ChannelPullout:IsShown() ) then
ChannelPullout_ToggleDisplay();
end
end
end
function AudioOptionsVoicePanel_DisableMicrophoneControls ()
UIDropDownMenu_DisableDropDown(AudioOptionsVoicePanelInputDeviceDropDown);
RecordLoopbackSoundButton:Disable();
PlayLoopbackSoundButton:Disable();
VoiceChat_StopRecordingLoopbackSound();
VoiceChat_StopPlayingLoopbackSound();
for index in pairs(AudioOptionsVoicePanelFrameMicrophoneList) do
_G[index]:SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
end
BlizzardOptionsPanel_Slider_Disable(AudioOptionsVoicePanelMicrophoneVolume);
end
function AudioOptionsVoicePanel_EnableMicrophoneControls ()
UIDropDownMenu_EnableDropDown(AudioOptionsVoicePanelInputDeviceDropDown);
RecordLoopbackSoundButton:Enable();
PlayLoopbackSoundButton:Enable();
for index, value in pairs(AudioOptionsVoicePanelFrameMicrophoneList) do
_G[index]:SetVertexColor(value.r, value.g, value.b);
end
BlizzardOptionsPanel_Slider_Enable(AudioOptionsVoicePanelMicrophoneVolume);
end
function AudioOptionsVoicePanelEnableMicrophone_UpdateControls (value)
if ( not AudioOptionsVoicePanelEnableVoice:GetChecked() or
not value or value == "0" or
VoiceIsDisabledByClient() ) then
--If VoiceChat is disabled, the microphone controls should be too.
AudioOptionsVoicePanel_DisableMicrophoneControls();
else
AudioOptionsVoicePanel_EnableMicrophoneControls();
end
end
function AudioOptionsVoicePanelBindingType_Update (value)
local mode = tonumber(value) + 1;
if ( mode == 1 ) then
AudioOptionsVoicePanelChatMode1:Show();
AudioOptionsVoicePanelChatMode2:Hide();
else
AudioOptionsVoicePanelChatMode1:Hide();
AudioOptionsVoicePanelChatMode2:Show();
end
end
function AudioOptionsVoicePanelKeyBindingButton_Refresh ()
PUSH_TO_TALK_BUTTON = BlizzardOptionsPanel_GetCVarSafe("PushToTalkButton");
local bindingText = GetBindingText(PUSH_TO_TALK_BUTTON, "KEY_");
AudioOptionsVoicePanelChatMode1KeyBindingButtonHiddenText:SetText(bindingText);
AudioOptionsVoicePanelChatMode1KeyBindingButton:SetText(bindingText);
end
function AudioOptionsVoicePanelKeyBindingButton_SetTooltip ()
local textWidth = AudioOptionsVoicePanelChatMode1KeyBindingButtonHiddenText:GetWidth();
if ( textWidth > 135 ) then
AudioOptionsVoicePanelChatMode1KeyBindingButton.tooltip = AudioOptionsVoicePanelChatMode1KeyBindingButtonHiddenText:GetText();
else
AudioOptionsVoicePanelChatMode1KeyBindingButton.tooltip = nil;
end
end
function AudioOptionsVoicePanelKeyBindingButton_OnEnter (self)
if ( self.tooltip ) then
GameTooltip:SetOwner(self);
GameTooltip:SetText(self.tooltip);
GameTooltip:Show();
end
end
function AudioOptionsVoicePanelKeyBindingButton_OnKeyUp (self, key)
if ( self.buttonPressed ) then
AudioOptionsVoicePanelKeyBindingButton_BindButton(self);
end
end
function AudioOptionsVoicePanelKeyBindingButton_OnKeyDown (self, key)
if ( GetBindingFromClick(key) == "SCREENSHOT" ) then
RunBinding("SCREENSHOT");
return;
end
if ( self.buttonPressed ) then
if ( key == "UNKNOWN" ) then
return;
end
if ( key == "LSHIFT" or key == "RSHIFT" or key == "LCTRL" or key == "RCTRL" or key == "LALT" or key == "RALT" ) then
if ( PUSH_TO_TALK_MODIFIER == "" ) then
PUSH_TO_TALK_MODIFIER = key;
else
PUSH_TO_TALK_MODIFIER = PUSH_TO_TALK_MODIFIER.."-"..key;
end
return;
elseif ( PUSH_TO_TALK_BUTTON ~= "" ) then
AudioOptionsVoicePanelBindingOutputText:SetText(ERROR_CANNOT_BIND);
AudioOptionsVoicePanelBindingOutputTextConflict:SetText("");
AudioOptionsVoicePanelBindingOutput:SetAlpha(1.0);
AudioOptionsVoicePanelBindingOutput.fade = VOICE_OPTIONS_BINDING_FAIL_FADE;
self:UnlockHighlight();
self.buttonPressed = nil;
return;
end
if ( PUSH_TO_TALK_MODIFIER == "" ) then
PUSH_TO_TALK_BUTTON = key;
else
PUSH_TO_TALK_BUTTON = PUSH_TO_TALK_MODIFIER.."-"..key;
end
end
end
function AudioOptionsVoicePanelKeyBindingButton_CancelBinding ()
local self = AudioOptionsVoicePanelChatMode1KeyBindingButton;
self:UnlockHighlight();
self.buttonPressed = nil;
AudioOptionsVoicePanelBindingOutputText:SetText("");
AudioOptionsVoicePanelBindingOutputTextConflict:SetText("");
self:SetScript("OnKeyDown", nil);
self:SetScript("OnKeyUp", nil);
AudioOptionsVoicePanelBindingOutput:SetAlpha(1.0)
AudioOptionsVoicePanelBindingOutput.fade = 0;
UIFrameFadeIn(AudioOptionsVoicePanelBindingOutput, 0);
PUSH_TO_TALK_BUTTON = "";
PUSH_TO_TALK_MODIFIER = "";
end
function AudioOptionsVoicePanelKeyBindingButton_OnClick (self, button)
if ( button == "UNKNOWN" ) then
return;
end
if ( not IsShiftKeyDown() and not IsControlKeyDown() and not IsAltKeyDown() ) then
if ( button == "LeftButton" or button == "RightButton" ) then
if ( self.buttonPressed ) then
AudioOptionsVoicePanelKeyBindingButton_CancelBinding(self);
else
self:LockHighlight();
self.buttonPressed = 1;
AudioOptionsVoicePanelBindingOutputText:SetText(CAN_BIND_PTT);
self:SetScript("OnKeyDown", AudioOptionsVoicePanelKeyBindingButton_OnKeyDown);
self:SetScript("OnKeyUp", AudioOptionsVoicePanelKeyBindingButton_OnKeyUp);
AudioOptionsVoicePanelBindingOutput:SetAlpha(1.0)
AudioOptionsVoicePanelBindingOutput.fade = 0;
UIFrameFadeIn(AudioOptionsVoicePanelBindingOutput, 0);
AudioOptionsVoicePanelBindingOutputTextConflict:SetText("");
PUSH_TO_TALK_BUTTON = "";
PUSH_TO_TALK_MODIFIER = "";
end
return;
end
end
if ( self.buttonPressed ) then
if ( PUSH_TO_TALK_BUTTON ~= "" ) then
AudioOptionsVoicePanelBindingOutputText:SetText(ERROR_CANNOT_BIND);
AudioOptionsVoicePanelBindingOutput:SetAlpha(1.0);
AudioOptionsVoicePanelBindingOutput.fade = VOICE_OPTIONS_BINDING_FAIL_FADE;
AudioOptionsVoicePanelBindingOutputText:SetVertexColor(1, 1, 1);
AudioOptionsVoicePanelBindingOutputTextConflict:SetText("");
self:UnlockHighlight();
self.buttonPressed = nil;
return;
end
if ( PUSH_TO_TALK_MODIFIER == "" ) then
PUSH_TO_TALK_BUTTON = button;
else
PUSH_TO_TALK_BUTTON = PUSH_TO_TALK_MODIFIER.."-"..button;
end
AudioOptionsVoicePanelKeyBindingButton_BindButton(self);
end
end
function AudioOptionsVoicePanelKeyBindingButton_BindButton (self)
if ( PUSH_TO_TALK_BUTTON == "" and PUSH_TO_TALK_MODIFIER ~= "" ) then
PUSH_TO_TALK_BUTTON = PUSH_TO_TALK_MODIFIER;
end
if ( PUSH_TO_TALK_BUTTON ~= "" ) then
BlizzardOptionsPanel_SetCVarSafe("PushToTalkButton", PUSH_TO_TALK_BUTTON);
local bindingText = GetBindingText(PUSH_TO_TALK_BUTTON, "KEY_");
self:SetText(bindingText);
AudioOptionsVoicePanelChatMode1KeyBindingButtonHiddenText:SetText(bindingText);
self:UnlockHighlight();
self.buttonPressed = nil;
local currentbinding = GetBindingByKey(PUSH_TO_TALK_BUTTON);
if ( currentbinding ) then
UIErrorsFrame:AddMessage(format(ALREADY_BOUND, GetBindingText(currentbinding, "BINDING_NAME_")), 1.0, 1.0, 0.0, 1.0);
AudioOptionsVoicePanelBindingOutputTextConflict:SetText(format(ALREADY_BOUND, GetBindingText(currentbinding, "BINDING_NAME_")));
else
AudioOptionsVoicePanelBindingOutputTextConflict:SetText("");
end
AudioOptionsVoicePanelBindingOutputText:SetText(PTT_BOUND);
AudioOptionsVoicePanelBindingOutput:SetAlpha(1.0);
AudioOptionsVoicePanelBindingOutput.fade = VOICE_OPTIONS_BINDING_SUCCESS_FADE;
self:SetScript("OnKeyDown", nil);
self:SetScript("OnKeyUp", nil);
end
AudioOptionsVoicePanelKeyBindingButton_SetTooltip();
if ( GameTooltip:GetOwner() == self ) then
AudioOptionsVoicePanelKeyBindingButton_OnEnter(self);
end
end
function AudioOptionsVoicePanelBindingOutput_OnUpdate(self, elapsed)
if ( self.fade and self.fade > 0 ) then
self:SetAlpha(self.fade);
self.fade = self.fade - elapsed;
if ( self.fade < 0 ) then
self.fade = 0;
self:SetAlpha(0);
end
end
end
function AudioOptionsVoicePanel_SetOutputDevice(deviceIndex)
VoiceSelectOutputDevice(VoiceEnumerateOutputDevices(deviceIndex));
end
function AudioOptionsVoicePanel_SetInputDevice(deviceIndex)
VoiceSelectCaptureDevice(VoiceEnumerateCaptureDevices(deviceIndex));
end
function AudioOptionsVoicePanelInputDeviceDropDown_OnLoad (self)
UIDropDownMenu_SetWidth(self, 140);
self.cvar = "Sound_VoiceChatInputDriverIndex";
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.defaultValue = BlizzardOptionsPanel_GetCVarDefaultSafe(self.cvar);
self.value = selectedDriverIndex;
self.nextValue = selectedDriverIndex;
self.restart = true;
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelInputDeviceDropDown_Initialize);
self.SetValue =
function (self, value)
self.value = value;
AudioOptionsVoicePanel_SetInputDevice(value);
BlizzardOptionsPanel_SetCVarSafe(self.cvar, value);
end
self.GetValue =
function (self)
return BlizzardOptionsPanel_GetCVarSafe(self.cvar);
end
self.RefreshValue =
function (self)
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.value = selectedDriverIndex;
self.newValue = selectedDriverIndex;
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelInputDeviceDropDown_Initialize);
end
end
function AudioOptionsVoicePanelInputDeviceDropDown_Initialize(self)
local selectedValue = UIDropDownMenu_GetSelectedValue(self);
local num = Sound_ChatSystem_GetNumInputDrivers();
local info = UIDropDownMenu_CreateInfo();
for index=0,num-1,1 do
info.text = Sound_ChatSystem_GetInputDriverNameByIndex(index);
info.value = index;
if (selectedValue and index == selectedValue) then
info.checked = 1;
UIDropDownMenu_SetText(self, info.text);
else
info.checked = nil;
end
info.func = AudioOptionsVoicePanelInputDeviceDropDown_OnClick;
UIDropDownMenu_AddButton(info);
end
end
function AudioOptionsVoicePanelInputDeviceDropDown_OnClick(self)
local value = self.value;
local dropdown = AudioOptionsVoicePanelInputDeviceDropDown;
UIDropDownMenu_SetSelectedValue(dropdown, value);
dropdown:SetValue(value);
end
--==============================
--
-- Record Loopback functions
--
--==============================
function RecordLoopbackSoundButton_OnUpdate (self)
if ( self.clicked ) then
if ( not AudioOptionsVoicePanelEnableVoice:GetChecked() or
not AudioOptionsVoicePanelEnableMicrophone:GetChecked() ) then
-- NOTE: add VoiceIsDisabledByClient() if turning voice on and off ever happens dynamically
RecordLoopbackSoundButton:Disable();
RecordLoopbackSoundButtonTexture:SetVertexColor(0.5, 0.5, 0.5);
else
local isRecording = VoiceChat_IsRecordingLoopbackSound();
if ( isRecording == 0 ) then
RecordLoopbackSoundButton:Enable();
RecordLoopbackSoundButtonTexture:SetVertexColor(1, 0, 0);
self.clicked = nil;
else
RecordLoopbackSoundButton:Disable();
RecordLoopbackSoundButtonTexture:SetVertexColor(0.5, 0.5, 0.5);
end
end
end
end
--==============================
--
-- VU Meter functions
--
--==============================
function LoopbackVUMeter_OnLoad (self)
self:SetMinMaxValues(0, 100);
self:SetValue(0);
end
function LoopbackVUMeter_OnUpdate (self, elapsed)
local isRecording = VoiceChat_IsRecordingLoopbackSound();
local isPlaying = VoiceChat_IsPlayingLoopbackSound();
if ( isRecording == 0 and isPlaying == 0 ) then
self:SetValue(0);
else
local volume = VoiceChat_GetCurrentMicrophoneSignalLevel();
self:SetValue(volume);
end
end
function AudioOptionsVoicePanelChatModeDropDown_OnLoad (self)
UIDropDownMenu_SetWidth(self, 140);
self.cvar = "VoiceChatMode";
local voiceChatMode = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.tooltip = _G["OPTION_TOOLTIP_VOICE_TYPE"..(voiceChatMode+1)];
self.defaultValue = BlizzardOptionsPanel_GetCVarDefaultSafe(self.cvar);
self.value = voiceChatMode;
self.newValue = voiceChatMode;
self.restart = true;
UIDropDownMenu_SetSelectedValue(self, voiceChatMode);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelChatModeDropDown_Initialize);
self.SetValue =
function (self, value)
self.value = value;
BlizzardOptionsPanel_SetCVarSafe(self.cvar, value);
AudioOptionsVoicePanelBindingType_Update(value);
SetSelfMuteState();
end
self.GetValue =
function (self)
return BlizzardOptionsPanel_GetCVarSafe(self.cvar);
end
self.RefreshValue =
function (self)
local voiceChatMode = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.tooltip = _G["OPTION_TOOLTIP_VOICE_TYPE"..(voiceChatMode+1)];
self.value = voiceChatMode;
self.newValue = voiceChatMode;
UIDropDownMenu_SetSelectedValue(self, voiceChatMode);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelChatModeDropDown_Initialize);
end
end
function AudioOptionsVoicePanelChatModeDropDown_Initialize(self)
local selectedValue = UIDropDownMenu_GetSelectedValue(self);
local info = UIDropDownMenu_CreateInfo();
info.text = PUSH_TO_TALK;
info.func = AudioOptionsVoicePanelChatModeDropDown_OnClick;
info.value = 0;
if ( info.value == selectedValue ) then
info.checked = 1;
UIDropDownMenu_SetText(self, info.text);
else
info.checked = nil;
end
info.tooltipTitle = PUSH_TO_TALK;
info.tooltipText = OPTION_TOOLTIP_VOICE_TYPE1;
UIDropDownMenu_AddButton(info);
info.text = VOICE_ACTIVATED;
info.func = AudioOptionsVoicePanelChatModeDropDown_OnClick;
info.value = 1;
if ( info.value == selectedValue ) then
info.checked = 1;
UIDropDownMenu_SetText(self, info.text);
else
info.checked = nil;
end
info.tooltipTitle = VOICE_ACTIVATED;
info.tooltipText = OPTION_TOOLTIP_VOICE_TYPE2;
UIDropDownMenu_AddButton(info);
end
function AudioOptionsVoicePanelChatModeDropDown_OnClick(self)
local value = self.value;
local dropdown = AudioOptionsVoicePanelChatModeDropDown;
UIDropDownMenu_SetSelectedValue(dropdown, value);
dropdown.tooltip = _G["OPTION_TOOLTIP_VOICE_TYPE"..(value+1)];
dropdown:SetValue(value);
end
function AudioOptionsVoicePanelOutputDeviceDropDown_OnLoad (self)
UIDropDownMenu_SetWidth(self, 140);
self.cvar = "Sound_VoiceChatOutputDriverIndex";
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.defaultValue = BlizzardOptionsPanel_GetCVarDefaultSafe(self.cvar);
self.value = selectedDriverIndex;
self.nextValue = selectedDriverIndex;
self.restart = true;
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelOutputDeviceDropDown_Initialize);
self.SetValue =
function (self, value)
self.value = value;
AudioOptionsVoicePanel_SetOutputDevice(value);
BlizzardOptionsPanel_SetCVarSafe("Sound_VoiceChatOutputDriverIndex", value);
end
self.GetValue =
function (self)
return BlizzardOptionsPanel_GetCVarSafe(self.cvar);
end
self.RefreshValue =
function (self)
local selectedDriverIndex = BlizzardOptionsPanel_GetCVarSafe(self.cvar);
self.value = selectedDriverIndex;
self.nextValue = selectedDriverIndex;
UIDropDownMenu_SetSelectedValue(self, selectedDriverIndex);
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelOutputDeviceDropDown_Initialize);
end
end
function AudioOptionsVoicePanelOutputDeviceDropDown_Initialize(self)
local selectedValue = UIDropDownMenu_GetSelectedValue(self);
local num = Sound_ChatSystem_GetNumOutputDrivers();
local info = UIDropDownMenu_CreateInfo();
if ( num == 0 ) then
UIDropDownMenu_SetText(self, "");
else
for index=0,num-1,1 do
info.text = Sound_ChatSystem_GetOutputDriverNameByIndex(index);
info.value = index;
if (selectedValue and index == selectedValue) then
info.checked = 1;
UIDropDownMenu_SetText(self, info.text);
else
info.checked = nil;
end
info.func = AudioOptionsVoicePanelOutputDeviceDropDown_OnClick;
UIDropDownMenu_AddButton(info);
end
end
end
function AudioOptionsVoicePanelOutputDeviceDropDown_OnClick(self)
local value = self.value;
local dropdown = AudioOptionsVoicePanelOutputDeviceDropDown;
UIDropDownMenu_SetSelectedValue(dropdown, value);
dropdown:SetValue(value);
end
function AudioOptionsVoicePanelOutputDeviceDropDown_OnEvent(self, event, ...)
if ( event == "VOICE_CHAT_ENABLED_UPDATE" ) then
UIDropDownMenu_Initialize(self, AudioOptionsVoicePanelOutputDeviceDropDown_Initialize);
end
end