forked from wowgaming/3.3.5-interface-files
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChannelFrame.lua
1262 lines (1136 loc) · 41.2 KB
/
ChannelFrame.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
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MAX_CHANNEL_BUTTONS = 20;
MAX_DISPLAY_CHANNEL_BUTTONS = 16;
MAX_CHANNEL_MEMBER_BUTTONS = 22;
CHANNEL_ROSTER_HEIGHT = 15;
CHANNEL_FRAME_SCROLLBAR_OFFSET = 25;
CHANNEL_TITLE_WIDTH = 135;
CHANNEL_TITLE_OFFSET= 10;
CHANNEL_HEADER_OFFSET = 5;
CHAT_CHANNEL_TABBING = {};
CHAT_CHANNEL_TABBING[1] = "ChannelFrameDaughterFrameChannelPassword";
CHAT_CHANNEL_TABBING[2] = "ChannelFrameDaughterFrameChannelName";
local rosterFrame;
function ChannelFrame_OnLoad(self)
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
self:RegisterEvent("PARTY_LEADER_CHANGED");
self:RegisterEvent("RAID_ROSTER_UPDATE");
self:RegisterEvent("CHANNEL_UI_UPDATE");
self:RegisterEvent("MUTELIST_UPDATE");
self:RegisterEvent("IGNORELIST_UPDATE");
self:RegisterEvent("CHANNEL_FLAGS_UPDATED");
self:RegisterEvent("CHANNEL_VOICE_UPDATE");
self:RegisterEvent("CHANNEL_COUNT_UPDATE");
self:RegisterEvent("CHANNEL_ROSTER_UPDATE");
FauxScrollFrame_SetOffset(ChannelRosterScrollFrame, 0);
ChannelFrame_Update();
end
function ChannelFrame_OnEvent(self, event, ...)
local arg1, arg2, arg3 = ...;
if ( event == "PLAYER_ENTERING_WORLD" or event == "CHANNEL_UI_UPDATE" or event == "PARTY_MEMBERS_CHANGED" or event == "PARTY_LEADER_CHANGED" or event == "RAID_ROSTER_UPDATE" ) then
ChannelFrame_Update();
elseif ( event == "CHANNEL_FLAGS_UPDATED" ) then
if ( arg1 == ChannelListDropDown.clicked ) then
ChannelList_ShowDropdown(arg1);
end
elseif ( event == "CHANNEL_VOICE_UPDATE" ) then
ChannelList_UpdateVoice(arg1, arg2, arg3);
elseif ( event == "CHANNEL_COUNT_UPDATE" ) then
ChannelList_CountUpdate(arg1, arg2);
elseif ( event == "CHANNEL_ROSTER_UPDATE" ) then
ChannelRoster_Update(arg1);
elseif ( event == "MUTELIST_UPDATE" or event == "IGNORELIST_UPDATE" ) then
ChannelRoster_Update(GetSelectedDisplayChannel());
end
end
function ChannelFrame_Update()
local id = GetSelectedDisplayChannel();
if ( not id ) then
id = GetActiveVoiceChannel();
end
ChannelList_Update();
ChannelList_UpdateHighlight(id);
ChannelRoster_Update(id);
--ChannelFrame_UpdateJoin();
end
function ChannelFrame_OnUpdate(self, elapsed)
if ( not ChannelFrame.updating ) then
return;
else
ChannelRoster_Update(ChannelFrame.updating);
ChannelFrame.updating = nil;
end
end
function ChannelFrame_UpdateJoin()
local id = GetSelectedDisplayChannel();
if ( id ) then
local name, header, collapsed, channelNumber, count, active, category, voiceEnabled, voiceActive = GetChannelDisplayInfo(id);
if ( category == "CHANNEL_CATEGORY_WORLD" and not active ) then
ChannelFrameJoinButton:Enable();
end
else
ChannelFrameJoinButton:Disable();
end
end
function ChannelFrame_New_OnClick()
if ( ChannelFrameDaughterFrame:IsShown() ) then
ChannelFrameDaughterFrame:Hide();
else
ChannelFrameDaughterFrameChannelNameLabel:SetText(CHANNEL_CHANNEL_NAME);
ChannelFrameDaughterFrameChannelPasswordLabel:SetText(PASSWORD);
ChannelFrameDaughterFrameChannelPasswordOptional:Show();
ChannelFrameDaughterFrameName:SetText(CHANNEL_NEW_CHANNEL);
--ChannelFrameDaughterFrameVoiceChat:SetChecked(1);
--ChannelFrameDaughterFrameVoiceChat:Show();
ChannelFrameDaughterFrame:Show();
PlaySound("UChatScrollButton");
end
end
function ChannelFrame_Join_OnClick()
if ( ChannelFrameDaughterFrame:IsShown() ) then
ChannelFrameDaughterFrame:Hide();
else
local selected = GetSelectedDisplayChannel();
local button;
if ( selected ) then
button = _G["ChannelButton"..selected];
end
if ( button and button.global ) then
JoinPermanentChannel(button.channel, nil, nil, 1);
else
ChannelFrameDaughterFrameChannelNameLabel:SetText(CHANNEL_CHANNEL_NAME);
ChannelFrameDaughterFrameChannelPasswordLabel:SetText(PASSWORD);
ChannelFrameDaughterFrameChannelPasswordOptional:Show();
ChannelFrameDaughterFrameName:SetText(CHANNEL_JOIN_CHANNEL);
--ChannelFrameDaughterFrameVoiceChat:Hide();
ChannelFrameDaughterFrame:Show();
end
end
end
function ChannelFrameDaughterFrame_Okay()
local name = ChannelFrameDaughterFrameChannelName:GetText();
local password = ChannelFrameDaughterFrameChannelPassword:GetText();
local zoneChannel, channelName = JoinPermanentChannel(name, password, DEFAULT_CHAT_FRAME:GetID(), 1);
if ( not zoneChannel ) then
local info = ChatTypeInfo["CHANNEL"];
DEFAULT_CHAT_FRAME:AddMessage(CHAT_INVALID_NAME_NOTICE, info.r, info.g, info.b, info.id);
ChannelFrameDaughterFrame:Hide();
return;
end
if ( channelName ) then
name = channelName;
end
local i = 1;
while ( DEFAULT_CHAT_FRAME.channelList[i] ) do
i = i + 1;
end
DEFAULT_CHAT_FRAME.channelList[i] = name;
DEFAULT_CHAT_FRAME.zoneChannelList[i] = zoneChannel;
-- Clear Out Values
ChannelFrameDaughterFrame:Hide();
end
function ChannelFrameDaughterFrame_Cancel(self)
self:GetParent():Hide();
end
function ChannelFrameDaughterFrame_OnHide()
ChannelFrameDaughterFrameChannelName:SetText("");
ChannelFrameDaughterFrameChannelPassword:SetText("");
PlaySound("UChatScrollButton");
end
--[ Channel List Functions ]--
function ChannelList_Update()
-- Scroll Bar Handling --
local frameHeight = ChannelListScrollChildFrame:GetHeight();
local button, buttonName, buttonLines, buttonCollapsed, buttonSpeaker, hideVoice;
local name, header, collapsed, channelNumber, active, count, category, voiceEnabled, voiceActive;
local channelCount = GetNumDisplayChannels();
for i=1, MAX_CHANNEL_BUTTONS, 1 do
button = _G["ChannelButton"..i];
buttonName = _G["ChannelButton"..i.."Text"];
buttonLines = _G["ChannelButton"..i.."NormalTexture"];
buttonCollapsed = _G["ChannelButton"..i.."Collapsed"];
buttonSpeaker = _G["ChannelButton"..i.."SpeakerFrame"];
if ( i <= channelCount) then
name, header, collapsed, channelNumber, count, active, category, voiceEnabled, voiceActive = GetChannelDisplayInfo(i);
if ( IsVoiceChatEnabled() ) then
ChannelList_UpdateVoice(i, voiceEnabled, voiceActive);
else
ChannelList_UpdateVoice(i, nil, nil);
end
button.header = header;
button.collapsed = collapsed;
if ( header ) then
if ( button.channel ) then
button.channel = nil;
button.active = nil;
local point, rTo, rPoint, x, y = buttonName:GetPoint();
buttonName:SetPoint(point, rTo, rPoint, CHANNEL_HEADER_OFFSET, y);
buttonName:SetWidth(CHANNEL_TITLE_WIDTH + buttonSpeaker:GetWidth());
end
-- Set the collapsed Status
if ( collapsed ) then
buttonCollapsed:SetText("+");
else
buttonCollapsed:SetText("-");
end
-- Hide collapsed Status if there are no sub channels
if ( count ) then
buttonCollapsed:Show();
button:Enable();
else
buttonCollapsed:Hide();
button:Disable();
end
buttonLines:SetAlpha(1.0);
buttonName:SetText(NORMAL_FONT_COLOR_CODE..name..FONT_COLOR_CODE_CLOSE);
else
local point, rTo, rPoint, x, y = buttonName:GetPoint();
if ( not button.channel ) then
buttonName:SetPoint(point, rTo, rPoint, CHANNEL_TITLE_OFFSET, y);
buttonName:SetWidth(CHANNEL_TITLE_WIDTH - buttonSpeaker:GetWidth());
end
if ( not channelNumber ) then
channelNumber = "";
else
channelNumber = channelNumber..". ";
end
if ( active ) then
if ( count and category == "CHANNEL_CATEGORY_GROUP" ) then
buttonName:SetText(HIGHLIGHT_FONT_COLOR_CODE..channelNumber..name.." ("..count..")"..FONT_COLOR_CODE_CLOSE);
else
buttonName:SetText(HIGHLIGHT_FONT_COLOR_CODE..channelNumber..name..FONT_COLOR_CODE_CLOSE);
end
button:Enable();
else
buttonName:SetText(GRAY_FONT_COLOR_CODE..channelNumber..name..FONT_COLOR_CODE_CLOSE);
button:Disable();
end
if ( category == "CHANNEL_CATEGORY_WORLD" ) then
button.global = 1;
button.group = nil;
button.custom = nil;
elseif ( category == "CHANNEL_CATEGORY_GROUP" ) then
button.group = 1;
button.global = nil;
button.custom = nil;
elseif ( category == "CHANNEL_CATEGORY_CUSTOM" ) then
button.custom = 1;
button.group = nil;
button.global = nil;
else
button.custom = nil;
button.group = nil;
button.global = nil;
end
buttonCollapsed:Hide();
button.channel = name;
button.active = active;
buttonLines:SetAlpha(0.5);
channelNumber = nil;
end
button:Show();
else
-- button.channel = nil;
button:Hide();
button.voiceEnabled = nil;
button.voiceActive = nil;
-- Scroll Bar Handling --
frameHeight = frameHeight - button:GetHeight();
end
end
-- Scroll Bar Handling --
ChannelListScrollChildFrame:SetHeight(frameHeight);
if ((ChannelListScrollFrameScrollBarScrollUpButton:IsEnabled() == 0) and (ChannelListScrollFrameScrollBarScrollDownButton:IsEnabled() == 0) ) then
ChannelListScrollFrame.scrolling = nil;
else
ChannelListScrollFrame.scrolling = 1;
end
ChannelList_SetScroll();
end
function ChannelList_CountUpdate(id, count)
local button = _G["ChannelButton"..id];
local name, header, collapsed, channelNumber, count, active, category, voiceEnabled, voiceActive = GetChannelDisplayInfo(id);
if ( category == "CHANNEL_CATEGORY_GROUP" ) then
if ( count ) then
button:SetText(HIGHLIGHT_FONT_COLOR_CODE..channelNumber..". "..name.." ("..count..")"..FONT_COLOR_CODE_CLOSE);
end
end
if ( id == GetSelectedDisplayChannel() ) then
ChannelRoster_Update(id);
end
end
function ChannelList_SetScroll()
local buttonWidth = 130;
if ( not ChannelListScrollFrame.scrolling ) then
ChannelMemberButton1:SetPoint("TOPLEFT", ChannelFrame, "TOPLEFT", 186, -75);
ChannelRoster:SetPoint("TOPLEFT", ChannelFrame, "TOP", 121, -79);
ChannelListScrollFrameScrollBar:Hide();
ChannelListScrollFrameTop:Hide();
ChannelListScrollFrameBottom:Hide();
buttonWidth = buttonWidth + 10;
else
ChannelMemberButton1:SetPoint("TOPLEFT", ChannelFrame, "TOPLEFT", 206, -75);
ChannelRoster:SetPoint("TOPLEFT", ChannelFrame, "TOP", 97, -77);
ChannelListScrollFrameScrollBar:Show();
ChannelListScrollFrameTop:Show();
ChannelListScrollFrameBottom:Show();
buttonWidth = buttonWidth - 10;
end
end
function ChannelRoster_SetScroll()
local buttonWidth = 145;
if ( not ChannelRosterScrollFrame.scrolling ) then
ChannelRosterScrollFrameScrollBar:Hide();
ChannelRosterScrollFrameTop:Hide();
ChannelRosterScrollFrameBottom:Hide();
buttonWidth = buttonWidth + 10;
else
ChannelRosterScrollFrameScrollBar:Show();
ChannelRosterScrollFrameTop:Show();
ChannelRosterScrollFrameBottom:Show();
buttonWidth = buttonWidth - 10;
end
for i=1, MAX_CHANNEL_MEMBER_BUTTONS do
_G["ChannelMemberButton"..i]:SetWidth(buttonWidth);
end
end
function ChannelList_UpdateVoice(id, enabled, active)
local speaker = _G["ChannelButton"..id.."SpeakerFrame"];
local speakerIcon = _G["ChannelButton"..id.."SpeakerFrameOn"];
local speakerFlash = _G["ChannelButton"..id.."SpeakerFrameFlash"];
local button = _G["ChannelButton" .. id];
if ( enabled ) then
button.voiceEnabled = true;
if ( active ) then
button.voiceActive = true;
ChannelFrame_Desaturate(speakerIcon, nil, 1, 1, 1, 0.75);
ChannelFrame_Desaturate(speakerFlash, nil, 1, 1, 1, 0.75);
else
button.voiceActive = nil;
ChannelFrame_Desaturate(speakerIcon, 1, nil, nil, nil, 0.5);
ChannelFrame_Desaturate(speakerFlash, 1, nil, nil, nil, 0.5);
end
speaker:Show()
speaker:SetFrameLevel(speaker:GetFrameLevel()+5);
speakerFlash:Show();
else
button.voiceEnabled = nil;
button.voiceActive = nil;
speaker:Hide();
end
end
function ChannelList_OnClick(self, button)
local id = self:GetID();
PlaySound("igMainMenuOptionCheckBoxOn");
ChannelListDropDown.clicked = nil;
if ( button == "LeftButton" ) then
HideDropDownMenu(1);
if ( self.header ) then
if ( self.collapsed ) then
ExpandChannelHeader(id);
else
CollapseChannelHeader(id);
end
else
ChannelList_UpdateHighlight(id);
if ( self.active ) then
ChannelFrame.updating = id;
SetSelectedDisplayChannel(id);
ChannelRoster_Update(id);
else
ChannelRoster_Update(0);
end
end
elseif ( button == "RightButton" ) then
if ( self.channel ) then
FauxScrollFrame_SetOffset(ChannelRosterScrollFrame, 0);
if ( self.global ) then
ChannelList_UpdateHighlight(id);
ChannelList_ShowDropdown(id);
end
if ( self.active ) then
ChannelFrame.updating = id;
GetNumChannelMembers(id);
ChannelList_UpdateHighlight(id);
ChannelListDropDown.clicked = id;
ChannelList_ShowDropdown(id);
end
end
end
end
function ChannelList_UpdateHighlight(id)
local button;
local channelCount = GetNumDisplayChannels();
for i=1, MAX_CHANNEL_BUTTONS, 1 do
button = _G["ChannelButton"..i];
if ( i <= channelCount ) then
if ( i == id ) then
button:LockHighlight();
else
button:UnlockHighlight();
end
end
end
end
local function ChannelListDropDown_StripSelf (self, func1, arg1)
func1(arg1);
end
--[ DropDown Functions ]--
function ChannelListDropDown_Initialize()
local count = 0;
local info;
if ( not ChannelListDropDown.global ) then
if ( IsVoiceChatEnabled() ) then
-- Enable Voice Chat option if Voice Chat is enabled.
if ( not ChannelListDropDown.voice and IsDisplayChannelOwner() ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_VOICE_ON;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = DisplayChannelVoiceOn;
info.arg2 = ChannelListDropDown.id;
UIDropDownMenu_AddButton(info);
count = count + 1;
end
-- Voice Chat option if Voice Chat is enabled.
if ( ChannelListDropDown.voice and not ChannelListDropDown.voiceActive ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_VOICE;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = SetActiveVoiceChannel;
info.arg2 = ChannelListDropDown.id;
UIDropDownMenu_AddButton(info);
count = count + 1;
--[[ Disable Voice Chat option if Voice Chat is enabled and not a group channel.
if ( not ChannelListDropDown.group and IsDisplayChannelOwner() ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_VOICE_OFF;
info.notCheckable = 1;
info.func = SetActiveVoiceChannel;
info.arg1 = ChannelListDropDown.id;
UIDropDownMenu_AddButton(info);
count = count + 1;
end]]--
end
end
-- SET PASSWORD if it is a custom Channel and is owner
if ( ChannelListDropDown.custom and IsDisplayChannelOwner() ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_PASSWORD;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = ChannelListDropDown_SetPassword;
info.arg2 = ChannelListDropDown.channelName;
UIDropDownMenu_AddButton(info);
count = count + 1;
end
-- INVITE if it is a custom Channel and is owner
if ( ChannelListDropDown.custom and IsDisplayChannelModerator() ) then
info = UIDropDownMenu_CreateInfo();
info.text = PARTY_INVITE;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = ChannelListDropDown_Invite;
info.arg2 = ChannelListDropDown.channelName;
UIDropDownMenu_AddButton(info);
count = count + 1;
end
end
-- JOIN if it is a Global Channel
if ( ChannelListDropDown.global and not ChannelListDropDown.active ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_JOIN;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = JoinPermanentChannel;
info.arg2 = ChannelListDropDown.channelName;
UIDropDownMenu_AddButton(info);
count = count + 1;
end
-- LEAVE Channel if not a group channel
if ( not ChannelListDropDown.group and ChannelListDropDown.active ) then
info = UIDropDownMenu_CreateInfo();
info.text = CHAT_LEAVE;
info.notCheckable = 1;
info.func = ChannelListDropDown_StripSelf
info.arg1 = LeaveChannelByName;
info.arg2 = ChannelListDropDown.channelName;
UIDropDownMenu_AddButton(info);
count = count + 1;
end
if ( count > 0 ) then
info = UIDropDownMenu_CreateInfo();
info.text = CANCEL;
info.notCheckable = 1;
info.func = ChannelListDropDown_HideDropDown;
UIDropDownMenu_AddButton(info);
end
end
function ChannelListDropDown_HideDropDown(self)
self:GetParent():Hide();
end
function ChannelListDropDown_SetPassword(name)
local dialog = StaticPopup_Show("CHANNEL_PASSWORD", name);
if ( dialog ) then
dialog.data = name;
end
end
function ChannelListDropDown_Invite(name)
local dialog = StaticPopup_Show("CHANNEL_INVITE", name);
if ( dialog ) then
dialog.data = name;
end
end
function ChannelList_ShowDropdown(id)
local name, header, collapsed, channelNumber, count, active, category, voice, voiceActive;
name, header, collapsed, channelNumber, count, active, category, voice, voiceActive = GetChannelDisplayInfo(id);
HideDropDownMenu(1);
local button = _G["ChannelButton"..id];
ChannelListDropDown.global = button.global;
ChannelListDropDown.group = button.group;
ChannelListDropDown.custom = button.custom;
ChannelListDropDown.initialize = ChannelListDropDown_Initialize;
ChannelListDropDown.displayMode = "MENU";
ChannelListDropDown.id = id;
ChannelListDropDown.voice = voice;
ChannelListDropDown.voiceActive = voiceActive;
ChannelListDropDown.active = active;
ChannelListDropDown.channelName = name;
ToggleDropDownMenu(1, nil, ChannelListDropDown, "cursor");
end
function ChannelListButton_OnDragStart (button)
local name, index, spoof = ChannelPulloutRoster_GetActiveSession()
if ( ( button and button.channel and button.voiceEnabled ) and ( not spoof and name == button.channel ) ) then
CHANNELPULLOUT_OPTIONS.displayActive = true;
elseif ( button.channel and button.voiceEnabled ) then
CHANNELPULLOUT_OPTIONS.displayActive = nil;
CHANNELPULLOUT_OPTIONS.name = button.channel;
CHANNELPULLOUT_OPTIONS.session = ChannelPulloutRoster_GetSessionIDByName(button.channel);
else
return;
end
if ( not ChannelPullout:IsShown() ) then
ChannelPullout_ToggleDisplay();
end
ChannelPulloutRoster_OnEvent(rosterFrame or ChannelPulloutRoster);
ChannelPulloutTab:StartMoving();
ChannelPulloutTab:ClearAllPoints();
local x, y = GetCursorPosition();
x, y = x / UIParent:GetScale(), y / UIParent:GetScale();
ChannelPulloutTab:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x, y)
ChannelPulloutTab.dragging = true;
end
function ChannelListButton_OnDragStop (button)
ChannelPulloutTab:StopMovingOrSizing();
ChannelPulloutTab.dragging = nil;
end
--[ Channel Roster Functions ]--
function ChannelRoster_Update(id)
if ( (not id) or (type(id) ~= "number") ) then
id = GetSelectedDisplayChannel();
end
if ( not id ) then
id = 0;
end
local channel, header, collapsed, channelNumber, count, active, category = GetChannelDisplayInfo(id);
local button, buttonName, buttonRank, buttonRankTexture, buttonVoice, buttonVoiceMuted, newWidth, nameWidth;
if ( count ) then
if ( category == "CHANNEL_CATEGORY_GROUP" ) then
ChannelRosterChannelCount:SetText("("..count..")");
else
ChannelRosterChannelCount:SetText("");
end
-- ScrollFrame stuff
if ( count > MAX_CHANNEL_MEMBER_BUTTONS ) then
ChannelRosterScrollFrame.scrolling = 1;
else
ChannelRosterScrollFrame.scrolling = nil;
end
if ( channel ) then
ChannelRosterHiddenText:SetText(channel);
ChannelRosterChannelName:SetText(channel);
--Set the width of the title bar.
nameWidth = ChannelRosterHiddenText:GetWidth();
if ( ChannelListScrollFrame.scrolling ) then
newWidth = CHANNEL_TITLE_WIDTH - CHANNEL_FRAME_SCROLLBAR_OFFSET;
else
newWidth = CHANNEL_TITLE_WIDTH;
end
if ( nameWidth > newWidth) then
nameWidth = newWidth;
end
ChannelRosterChannelName:SetHeight(13);
ChannelRosterChannelName:SetWidth(nameWidth);
end
else
ChannelRosterScrollFrame.scrolling = nil;
ChannelRosterChannelName:SetText("");
ChannelRosterChannelCount:SetText("");
count = 0;
end
local rosterOffset = FauxScrollFrame_GetOffset(ChannelRosterScrollFrame);
local name, owner, moderator, muted, active, enabled;
local rosterIndex;
for i=1, MAX_CHANNEL_MEMBER_BUTTONS do
rosterIndex = rosterOffset + i;
button = _G["ChannelMemberButton"..i];
if ( rosterIndex <= count ) then
buttonName = _G["ChannelMemberButton"..i.."Name"];
buttonRank = _G["ChannelMemberButton"..i.."Rank"];
buttonRankTexture = _G["ChannelMemberButton"..i.."RankTexture"];
buttonVoice = _G["ChannelMemberButton"..i.."SpeakerFrame"];
buttonVoiceMuted = _G["ChannelMemberButton"..i.."SpeakerFrameMuted"];
name, owner, moderator, muted, active, enabled = GetChannelRosterInfo(id, rosterIndex);
buttonName:SetText(name);
button.name = name;
if ( owner or moderator ) then
-- Sets the Leader/Assistant Icon
if ( owner ) then
buttonRankTexture:SetTexture("Interface\\GroupFrame\\UI-Group-LeaderIcon");
elseif ( moderator ) then
buttonRankTexture:SetTexture("Interface\\GroupFrame\\UI-Group-AssistantIcon");
end
buttonRank:Show();
else
buttonRank:Hide();
end
if ( IsVoiceChatEnabled() ) then
ChannelRoster_UpdateVoice(i, enabled, active, muted);
else
ChannelRoster_UpdateVoice(i, nil, nil, nil);
end
button:SetID(rosterIndex);
button:Show();
else
button:Hide();
end
end
ChannelRoster_SetScroll();
FauxScrollFrame_Update(ChannelRosterScrollFrame, count, MAX_CHANNEL_MEMBER_BUTTONS, CHANNEL_ROSTER_HEIGHT );
end
function ChannelRoster_UpdateVoice(id, enabled, active, muted)
local speaker = _G["ChannelMemberButton"..id.."SpeakerFrame"];
local speakerIcon = _G["ChannelMemberButton"..id.."SpeakerFrameOn"];
local speakerFlash = _G["ChannelMemberButton"..id.."SpeakerFrameFlash"];
local speakerMuted = _G["ChannelMemberButton"..id.."SpeakerFrameMuted"];
if ( enabled ) then
if ( active ) then
ChannelFrame_Desaturate(speakerIcon, nil, 1, 1, 1, 0.75);
ChannelFrame_Desaturate(speakerFlash, nil, 1, 1, 1, 0.75);
else
ChannelFrame_Desaturate(speakerIcon, 1, nil, nil, nil, 0.25);
ChannelFrame_Desaturate(speakerFlash, 1, nil, nil, nil, 0.25);
end
if ( muted ) then
speakerMuted:Show();
else
speakerMuted:Hide();
end
speaker:Show()
speakerFlash:Show();
else
speaker:Hide();
end
end
function ChannelRoster_OnClick(self, button)
if ( button == "RightButton" ) then
ChannelRosterFrame_ShowDropdown(self:GetID());
end
end
--[ DropDown Functions ]--
function ChannelRosterDropDown_Initialize()
UnitPopup_ShowMenu(UIDROPDOWNMENU_OPEN_MENU, "CHAT_ROSTER", nil, ChannelRosterDropDown.name);
end
function ChannelRosterFrame_ShowDropdown(id)
HideDropDownMenu(1);
local channelID = GetSelectedDisplayChannel();
local channelName, header, collapsed, channelNumber, count, active, category;
local name, owner, moderator, muted, voiceEnabled;
channelName, header, collapsed, channelNumber, count, active, category = GetChannelDisplayInfo(channelID);
name, owner, moderator, muted, voiceEnabled = GetChannelRosterInfo(channelID, id);
ChannelRosterDropDown.initialize = ChannelRosterDropDown_Initialize;
ChannelRosterDropDown.displayMode = "MENU";
ChannelRosterDropDown.name = name;
ChannelRosterDropDown.owner = owner;
ChannelRosterDropDown.moderator = moderator;
ChannelRosterDropDown.channelName = channelName;
ChannelRosterDropDown.category = category;
ToggleDropDownMenu(1, nil, ChannelRosterDropDown, "cursor");
end
--[ Utility Functions ]--
function ChannelFrame_Desaturate(texture, desaturate, r, g, b, a)
local shaderSupported = texture:SetDesaturated(desaturate);
if ( not desaturate ) then
r = 1.0;
g = 1.0;
b = 1.0;
elseif ( not r and not shaderSupported ) then
r = 0.5;
g = 0.5;
b = 0.5;
end
texture:SetVertexColor(r, g, b);
if ( a ) then
texture:SetAlpha(a);
end
end
--[[ Functions for the Channel Pullout window ]]--
CHANNELPULLOUT_TAB_SHOW_DELAY = 0.2;
CHANNELPULLOUT_TAB_FADE_TIME = 0.15;
DEFAULT_CHANNELPULLOUT_TAB_ALPHA = 0.75;
DEFAULT_CHANNELPULLOUT_ALPHA = 1;
CHANNELPULLOUT_OPTIONS = {};
CHANNELPULLOUT_MINSIZE = 5;
CHANNELPULLOUT_MAXSIZE = 25;
CHANNELPULLOUT_ROSTERFRAME_OFFSETY = 4;
CHANNELPULLOUT_ROSTERPARENT_YPADDING = 14;
CHANNELPULLOUT_FADEFRAMES = { "ChannelPulloutBackground", "ChannelPulloutCloseButton", "ChannelPulloutRosterScroll" };
function ChannelPullout_OnLoad (self)
self:RegisterEvent("VARIABLES_LOADED");
self:SetScript("OnEvent", ChannelPullout_OnEvent);
RegisterForSave("CHANNELPULLOUT_OPTIONS");
end
function ChannelPullout_OnEvent (self)
if ( CHANNELPULLOUT_OPTIONS.display ) then
self:Show();
end
end
function ChannelPullout_OnUpdate (self, elapsed)
local ChannelPulloutTab = ChannelPulloutTab;
if ( self:IsMouseOver(45, -10, -5, 5) ) then
local xPos, yPos = GetCursorPosition();
-- If mouse is hovering don't show the tab until the elapsed time reaches the tab show delay
if ( self.hover ) then
if ( (self.oldX == xPos and self.oldy == yPos) ) then
self.hoverTime = self.hoverTime + elapsed;
else
self.hoverTime = 0;
self.oldX = xPos;
self.oldy = yPos;
end
if ( self.hoverTime > CHANNELPULLOUT_TAB_SHOW_DELAY or ChannelPulloutTab.dragging ) then
-- If the tab's alpha is less than the current default, then fade it in
if ( not self.hasBeenFaded and (ChannelPulloutTab.oldAlpha and ChannelPulloutTab.oldAlpha < DEFAULT_CHANNELPULLOUT_TAB_ALPHA) ) then
UIFrameFadeIn(ChannelPulloutTab, CHANNELPULLOUT_TAB_FADE_TIME, ChannelPulloutTab.oldAlpha, DEFAULT_CHANNELPULLOUT_TAB_ALPHA);
local frame;
for _, name in next, CHANNELPULLOUT_FADEFRAMES do
frame = _G[name];
if ( frame:IsShown() ) then
UIFrameFadeIn(frame, CHANNELPULLOUT_TAB_FADE_TIME, self.oldAlpha, DEFAULT_CHANNELPULLOUT_ALPHA);
end
end
-- Set the fact that the chatFrame has been faded so we don't try to fade it again
self.hasBeenFaded = 1;
end
end
else
-- Start hovering counter
self.hover = 1;
self.hoverTime = 0;
self.hasBeenFaded = nil;
CURSOR_OLD_X, CURSOR_OLD_Y = GetCursorPosition();
-- Remember the oldAlpha so we can return to it later
if ( not ChannelPulloutTab.oldAlpha ) then
ChannelPulloutTab.oldAlpha = ChannelPulloutTab:GetAlpha();
end
self.oldAlpha = ChannelPulloutBackground:GetAlpha();
end
else
-- If the tab's alpha was less than the current default, then fade it back out to the oldAlpha
if ( self.hasBeenFaded and ChannelPulloutTab.oldAlpha and ChannelPulloutTab.oldAlpha < DEFAULT_CHANNELPULLOUT_TAB_ALPHA ) then
UIFrameFadeOut(ChannelPulloutTab, CHANNELPULLOUT_TAB_FADE_TIME, DEFAULT_CHANNELPULLOUT_TAB_ALPHA, ChannelPulloutTab.oldAlpha);
local frame;
for _, name in next, CHANNELPULLOUT_FADEFRAMES do
frame = _G[name];
if ( frame:IsShown() ) then
UIFrameFadeOut(frame, CHANNELPULLOUT_TAB_FADE_TIME, DEFAULT_CHANNELPULLOUT_ALPHA, self.oldAlpha);
end
end
self.hover = nil;
self.hasBeenFaded = nil;
end
self.hoverTime = 0;
end
end
function ChannelPullout_ShowOpacity ()
OpacityFrame:ClearAllPoints();
OpacityFrame:SetPoint("TOPRIGHT", "ChannelPullout", "TOPLEFT", 0, 7);
OpacityFrame.opacityFunc = ChannelPullout_SetOpacity;
OpacityFrame.saveOpacityFunc = ChannelPullout_SaveOpacity;
OpacityFrame:Show();
OpacityFrameSlider:SetValue(CHANNELPULLOUT_OPTIONS.opacity or 0);
end
function ChannelPullout_SetOpacity(value)
local alpha = 1.0 - (value or OpacityFrameSlider:GetValue());
ChannelPulloutBackground:SetAlpha(alpha);
ChannelPulloutCloseButton:SetAlpha(alpha);
end
function ChannelPullout_SaveOpacity()
CHANNELPULLOUT_OPTIONS.opacity = OpacityFrameSlider:GetValue();
OpacityFrame.saveOpacityFunc = nil;
end
function ChannelPullout_ToggleDisplay ()
if ( ChannelPullout:IsShown() ) then
ChannelPullout:Hide();
ChannelPulloutTab:Hide();
CHANNELPULLOUT_OPTIONS.display = nil;
else
ChannelPullout:Show();
ChannelPulloutTab:Show();
CHANNELPULLOUT_OPTIONS.display = true;
end
end
function ChannelPulloutTab_OnClick (tab, button)
if ( button == "RightButton" ) then
ToggleDropDownMenu(1, nil, ChannelPulloutTabDropDown, tab:GetName(), 0, 0);
return;
end
CloseDropDownMenus();
if ( tab:GetButtonState() == "PUSHED" ) then
tab:StopMovingOrSizing();
elseif ( CHANNELPULLOUT_OPTIONS.locked ) then
return;
else
tab:StartMoving();
end
ValidateFramePosition(tab);
end
function ChannelPulloutTab_ReanchorLeft ()
-- Make sure that we're always anchoring the left side of the tab, otherwise resizing the tab moves the roster
local point = { ChannelPulloutTab:GetPoint() };
if ( string.match(point[1], "RIGHT") ) then
point[1] = string.gsub(point[1], "RIGHT", "LEFT");
point[4] = point[4] - ChannelPulloutTab:GetWidth();
ChannelPulloutTab:ClearAllPoints();
ChannelPulloutTab:SetPoint(unpack(point));
end
end
function ChannelPulloutTab_UpdateText (text)
ChannelPulloutTab_ReanchorLeft();
ChannelPulloutTabText:SetText(text or CHANNEL_ROSTER);
PanelTemplates_TabResize(ChannelPulloutTab, 0);
end
function ChannelPulloutTabDropDown_Initialize ()
local checked, name, index;
local info = UIDropDownMenu_CreateInfo();
if ( not rosterFrame ) then
return;
end
info.text = CHANNELS;
info.notCheckable = true;
info.isTitle = true;
UIDropDownMenu_AddButton(info, 1);
info = UIDropDownMenu_CreateInfo();
info.text = DISPLAY_ACTIVE_CHANNEL;
info.func = function ()
CHANNELPULLOUT_OPTIONS.displayActive = not CHANNELPULLOUT_OPTIONS.displayActive;
CHANNELPULLOUT_OPTIONS.name = nil;
CHANNELPULLOUT_OPTIONS.session = nil;
ChannelPulloutRoster_OnEvent(rosterFrame);
end
info.checked = CHANNELPULLOUT_OPTIONS.displayActive;
UIDropDownMenu_AddButton(info, 1);
for i = 1, GetNumVoiceSessions() do
name = GetVoiceSessionInfo(i);
info.text = name;
info.func = function (self)
CHANNELPULLOUT_OPTIONS.name = self.value;
CHANNELPULLOUT_OPTIONS.displayActive = nil;
ChannelPulloutRoster_OnEvent(rosterFrame);
end
info.checked = ( function () if ( ( not CHANNELPULLOUT_OPTIONS.displayActive ) and CHANNELPULLOUT_OPTIONS.name == name ) then return true end return false end )();
UIDropDownMenu_AddButton(info, 1);
end
info.checked = nil;
info.text = DISPLAY_OPTIONS;
info.notCheckable = true;
info.isTitle = true;
UIDropDownMenu_AddButton(info, 1);
info = UIDropDownMenu_CreateInfo();
info.text = LOCK_CHANNELPULLOUT_LABEL;
info.func = function() CHANNELPULLOUT_OPTIONS.locked = not CHANNELPULLOUT_OPTIONS.locked end;
info.checked = CHANNELPULLOUT_OPTIONS.locked
UIDropDownMenu_AddButton(info, 1);
info.text = CHANNELPULLOUT_OPACITY_LABEL;
info.func = ChannelPullout_ShowOpacity;
info.checked = nil;
UIDropDownMenu_AddButton(info, 1);
end
function ChannelPulloutRoster_OnLoad (self)
self:RegisterEvent("VARIABLES_LOADED")
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("VOICE_SESSIONS_UPDATE");
self:RegisterEvent("CHANNEL_ROSTER_UPDATE");
self:RegisterEvent("VOICE_CHANNEL_STATUS_UPDATE");
self:SetScript("OnEvent", ChannelPulloutRoster_OnEvent);
self.members = {};
self.scroll = _G[self:GetName() .. "Scroll"];
if ( self.scroll ) then
self.upBtn = _G[self.scroll:GetName() .. "UpBtn"];
self.downBtn = _G[self.scroll:GetName() .. "DownBtn"];
self.topBtn = _G[self.scroll:GetName() .. "TopBtn"];
self.bottomBtn = _G[self.scroll:GetName() .. "BottomBtn"];
end
end
function ChannelPulloutRoster_OnEvent (rosterFrame, event, ...)
ChannelPulloutRoster_GetSessionInfo(rosterFrame)
ChannelPulloutRoster_Populate(rosterFrame, "ChannelPulloutRosterButtonTemplate", #rosterFrame.members)
ChannelPulloutRoster_Update(rosterFrame);
ChannelPulloutRoster_UpdateScrollControls(rosterFrame);
ChannelPullout_SetOpacity(CHANNELPULLOUT_OPTIONS.opacity or 0);
if ( CHANNELPULLOUT_OPTIONS.display and not ChannelPullout:IsShown() ) then
ChannelPullout_ToggleDisplay();
end
end
function ChannelPulloutRoster_GetActiveSession ()
local name, active;
for i = 1, GetNumVoiceSessions() do
name, active = GetVoiceSessionInfo(i);
if ( active ) then
return name, i;
end
end
name = GetVoiceSessionInfo(1);
if ( name ) then
return name, 1, true;
end
return false;
end
function ChannelPulloutRoster_GetSessionIDByName (name)
for i = 1, GetNumVoiceSessions() do
if ( GetVoiceSessionInfo(i) == name ) then
return i;
end
end
return nil;
end
function ChannelPulloutRoster_GetSessionInfo (roster)
rosterFrame = roster or rosterFrame;
local index, name;