/
LFDFrame.lua
1213 lines (1035 loc) · 40.7 KB
/
LFDFrame.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
EXPANSION_LEVEL = GetExpansionLevel(); --This doesn't change while logged in, so we just need to do it once.
LFD_MAX_REWARDS = 2;
NUM_LFD_CHOICE_BUTTONS = 15;
TYPEID_DUNGEON = 1;
TYPEID_HEROIC_DIFFICULTY = 5;
TYPEID_RANDOM_DUNGEON = 6;
NUM_LFD_MEMBERS = 5;
LFD_STATISTIC_CHANGE_TIME = 10; --In secs.
LFD_PROPOSAL_FAILED_CLOSE_TIME = 5;
LFD_NUM_ROLES = 3;
LFD_MAX_SHOWN_LEVEL_DIFF = 15;
local NUM_STATISTIC_TYPES = 1;
-------------------------------------
-----------LFD Frame--------------
-------------------------------------
--General functions
function LFDFrame_OnLoad(self)
self:RegisterEvent("LFG_PROPOSAL_UPDATE");
self:RegisterEvent("LFG_PROPOSAL_SHOW");
self:RegisterEvent("LFG_PROPOSAL_FAILED");
self:RegisterEvent("LFG_PROPOSAL_SUCCEEDED");
self:RegisterEvent("LFG_UPDATE");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("LFG_ROLE_CHECK_SHOW");
self:RegisterEvent("LFG_ROLE_CHECK_HIDE");
self:RegisterEvent("LFG_BOOT_PROPOSAL_UPDATE");
self:RegisterEvent("VOTE_KICK_REASON_NEEDED");
self:RegisterEvent("LFG_ROLE_UPDATE");
self:RegisterEvent("LFG_UPDATE_RANDOM_INFO");
self:RegisterEvent("LFG_OPEN_FROM_GOSSIP");
self:RegisterEvent("GOSSIP_CLOSED");
end
function LFDFrame_OnEvent(self, event, ...)
if ( event == "LFG_PROPOSAL_UPDATE" ) then
LFDDungeonReadyPopup_Update();
elseif ( event == "LFG_PROPOSAL_SHOW" ) then
LFDDungeonReadyPopup.closeIn = nil;
LFDDungeonReadyPopup:SetScript("OnUpdate", nil);
LFDDungeonReadyStatus_ResetReadyStates();
StaticPopupSpecial_Show(LFDDungeonReadyPopup);
LFDSearchStatus:Hide();
PlaySound("ReadyCheck");
elseif ( event == "LFG_PROPOSAL_FAILED" ) then
LFDDungeonReadyPopup_OnFail();
elseif ( event == "LFG_PROPOSAL_SUCCEEDED" ) then
LFGDebug("Proposal Hidden: Proposal succeeded.");
StaticPopupSpecial_Hide(LFDDungeonReadyPopup);
elseif ( event == "LFG_ROLE_CHECK_SHOW" ) then
StaticPopupSpecial_Show(LFDRoleCheckPopup);
LFDQueueFrameSpecificList_Update();
elseif ( event == "LFG_ROLE_CHECK_HIDE" ) then
StaticPopupSpecial_Hide(LFDRoleCheckPopup);
LFDQueueFrameSpecificList_Update();
elseif ( event == "LFG_BOOT_PROPOSAL_UPDATE" ) then
local voteInProgress, didVote, myVote, targetName, totalVotes, bootVotes, timeLeft, reason = GetLFGBootProposal();
if ( voteInProgress and not didVote and targetName ) then
StaticPopup_Show("VOTE_BOOT_PLAYER", targetName, reason);
else
StaticPopup_Hide("VOTE_BOOT_PLAYER");
end
elseif ( event == "VOTE_KICK_REASON_NEEDED" ) then
local targetName = ...;
StaticPopup_Show("VOTE_BOOT_REASON_REQUIRED", targetName, nil, targetName);
elseif ( event == "LFG_ROLE_UPDATE" ) then
LFG_UpdateRoleCheckboxes();
elseif ( event == "LFG_UPDATE_RANDOM_INFO" ) then
if ( not LFDQueueFrame.type or (type(LFDQueueFrame.type) == "number" and not IsLFGDungeonJoinable(LFDQueueFrame.type)) ) then
LFDQueueFrame.type = GetRandomDungeonBestChoice();
UIDropDownMenu_SetSelectedValue(LFDQueueFrameTypeDropDown, LFDQueueFrame.type);
end
--If we still don't have a value, we should go to specific.
if ( not LFDQueueFrame.type ) then
LFDQueueFrame.type = "specific";
UIDropDownMenu_SetSelectedValue(LFDQueueFrameTypeDropDown, LFDQueueFrame.type);
LFDQueueFrame_SetTypeSpecificDungeon();
elseif ( LFDQueueFrameRandom:IsShown() ) then
LFDQueueFrameRandom_UpdateFrame();
end
elseif ( event == "LFG_OPEN_FROM_GOSSIP" ) then
local dungeonID = ...;
LFDParentFrame.fromGossip = true;
ShowUIPanel(LFDParentFrame);
LFDQueueFrame_SetType(dungeonID);
elseif ( event == "GOSSIP_CLOSED" ) then
if ( LFDParentFrame.fromGossip ) then
HideUIPanel(LFDParentFrame);
end
end
LFDQueueFrame_UpdatePortrait();
end
function LFDFrame_OnShow(self)
LFDFrame_UpdateBackfill(true);
end
function LFDFrame_OnHide(self)
if ( self.fromGossip ) then
CloseGossip();
self.fromGossip = false;
end
end
function LFDQueueFrame_UpdatePortrait()
local mode, submode = GetLFGMode();
if ( mode == "queued" or mode == "rolecheck" ) then
EyeTemplate_StartAnimating(LFDParentFramePortrait);
else
EyeTemplate_StopAnimating(LFDParentFramePortrait);
end
end
--Backfill option
function LFDFrame_UpdateBackfill(forceUpdate)
if ( CanPartyLFGBackfill() ) then
local name, lfgID, typeID = GetPartyLFGBackfillInfo();
LFDQueueFramePartyBackfillDescription:SetFormattedText(LFG_OFFER_CONTINUE, HIGHLIGHT_FONT_COLOR_CODE..name.."|r");
local mode, subMode = GetLFGMode();
if ( (forceUpdate or not LFDQueueFrame:IsVisible()) and mode ~= "queued" ) then
LFDQueueFramePartyBackfill:Show();
end
else
LFDQueueFramePartyBackfill:Hide();
end
end
--Role-related functions
function LFDQueueFrame_SetRoles()
SetLFGRoles(LFDQueueFrameRoleButtonLeader.checkButton:GetChecked(),
LFDQueueFrameRoleButtonTank.checkButton:GetChecked(),
LFDQueueFrameRoleButtonHealer.checkButton:GetChecked(),
LFDQueueFrameRoleButtonDPS.checkButton:GetChecked());
end
function LFDFrameRoleCheckButton_OnClick(self)
LFDQueueFrame_SetRoles();
end
--Role-check popup functions
function LFDRoleCheckPopupAccept_OnClick()
PlaySound("igCharacterInfoTab");
local oldLeader = GetLFGRoles();
SetLFGRoles(oldLeader,
LFDRoleCheckPopupRoleButtonTank.checkButton:GetChecked(),
LFDRoleCheckPopupRoleButtonHealer.checkButton:GetChecked(),
LFDRoleCheckPopupRoleButtonDPS.checkButton:GetChecked());
if ( CompleteLFGRoleCheck(true) ) then
StaticPopupSpecial_Hide(LFDRoleCheckPopup);
end
end
function LFDRoleCheckPopupDecline_OnClick()
PlaySound("igCharacterInfoTab");
StaticPopupSpecial_Hide(LFDRoleCheckPopup);
CompleteLFGRoleCheck(false);
end
function LFDRoleCheckPopup_Update()
LFGDungeonList_Setup();
LFG_UpdateRoleCheckboxes();
local inProgress, slots, members = GetLFGRoleUpdate();
local displayName;
if ( slots == 1 ) then
local dungeonType, dungeonID = GetLFGRoleUpdateSlot(1);
if ( dungeonType == TYPEID_RANDOM_DUNGEON ) then
displayName = A_RANDOM_DUNGEON;
elseif ( dungeonType == TYPEID_HEROIC_DIFFICULTY ) then
displayName = format(HEROIC_PREFIX, select(LFG_RETURN_VALUES.name, GetLFGDungeonInfo(dungeonID)));
else
displayName = select(LFG_RETURN_VALUES.name, GetLFGDungeonInfo(dungeonID));
end
else
displayName = MULTIPLE_DUNGEONS;
end
displayName = NORMAL_FONT_COLOR_CODE..displayName.."|r";
LFDRoleCheckPopupDescriptionText:SetFormattedText(QUEUED_FOR, displayName);
LFDRoleCheckPopupDescription:SetWidth(LFDRoleCheckPopupDescriptionText:GetWidth()+10);
LFDRoleCheckPopupDescription:SetHeight(LFDRoleCheckPopupDescriptionText:GetHeight());
end
function LFDRoleCheckPopupDescription_OnEnter(self)
local inProgress, slots, members = GetLFGRoleUpdate();
if ( slots <= 1 ) then
return;
end
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:AddLine(QUEUED_FOR_SHORT);
for i=1, slots do
local dungeonType, dungeonID = GetLFGRoleUpdateSlot(i);
local displayName;
if ( dungeonType == TYPEID_HEROIC_DIFFICULTY ) then
displayName = format(HEROIC_PREFIX, LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.name]);
else
displayName = LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.name];
end
GameTooltip:AddLine(" "..displayName);
end
GameTooltip:Show();
end
function LFDFrameRoleCheckButton_OnEnter(self)
if ( self.checkButton:IsEnabled() == 1 ) then
self.checkButton:LockHighlight();
end
end
--List functions
function LFDQueueFrameSpecificListButton_SetDungeon(button, dungeonID, mode, submode)
local info = LFGGetDungeonInfoByID(dungeonID);
button.id = dungeonID;
if ( LFGIsIDHeader(dungeonID) ) then
local name = info[LFG_RETURN_VALUES.name];
button.instanceName:SetText(name);
button.instanceName:SetFontObject(QuestDifficulty_Header);
button.instanceName:SetPoint("RIGHT", button, "RIGHT", 0, 0);
button.level:Hide();
if ( info[LFG_RETURN_VALUES.typeID] == TYPEID_HEROIC_DIFFICULTY ) then
button.heroicIcon:Show();
button.instanceName:SetPoint("LEFT", button.heroicIcon, "RIGHT", 0, 1);
else
button.heroicIcon:Hide();
button.instanceName:SetPoint("LEFT", 40, 0);
end
button.expandOrCollapseButton:Show();
local isCollapsed = LFGCollapseList[dungeonID];
button.isCollapsed = isCollapsed;
if ( isCollapsed ) then
button.expandOrCollapseButton:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP");
else
button.expandOrCollapseButton:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP");
end
else
local name = info[LFG_RETURN_VALUES.name];
local minLevel, maxLevel = info[LFG_RETURN_VALUES.minLevel], info[LFG_RETURN_VALUES.maxLevel];
local minRecLevel, maxRecLevel = info[LFG_RETURN_VALUES.minRecLevel], info[LFG_RETURN_VALUES.maxRecLevel];
local recLevel = info[LFG_RETURN_VALUES.recLevel];
button.instanceName:SetText(name);
button.instanceName:SetPoint("RIGHT", button.level, "LEFT", -10, 0);
button.heroicIcon:Hide();
button.instanceName:SetPoint("LEFT", 40, 0);
if ( minLevel == maxLevel ) then
button.level:SetText(format(LFD_LEVEL_FORMAT_SINGLE, minLevel));
else
button.level:SetText(format(LFD_LEVEL_FORMAT_RANGE, minLevel, maxLevel));
end
button.level:Show();
local difficultyColor = GetQuestDifficultyColor(recLevel);
button.level:SetFontObject(difficultyColor.font);
if ( mode == "rolecheck" or mode == "queued" or mode == "listed" or not LFD_IsEmpowered()) then
button.instanceName:SetFontObject(QuestDifficulty_Header);
else
button.instanceName:SetFontObject(difficultyColor.font);
end
button.expandOrCollapseButton:Hide();
button.isCollapsed = false;
end
if ( LFGLockList[dungeonID] ) then
button.enableButton:Hide();
button.lockedIndicator:Show();
else
button.enableButton:Show();
button.lockedIndicator:Hide();
end
local enableState= LFGEnabledList;
if ( mode == "queued" or mode == "listed" ) then
enableState = LFGQueuedForList[dungeonID];
else
enableState = LFGEnabledList[dungeonID];
end
if ( enableState == 1 ) then --Some are checked, some aren't.
button.enableButton:SetCheckedTexture("Interface\\Buttons\\UI-MultiCheck-Up");
button.enableButton:SetDisabledCheckedTexture("Interface\\Buttons\\UI-MultiCheck-Disabled");
else
button.enableButton:SetCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check");
button.enableButton:SetDisabledCheckedTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled");
end
button.enableButton:SetChecked(enableState and enableState ~= 0);
if ( mode == "rolecheck" or mode == "queued" or mode == "listed" or not LFD_IsEmpowered() ) then
button.enableButton:Disable();
else
button.enableButton:Enable();
end
end
function LFDQueueFrameSpecificList_Update()
if ( LFGDungeonList_Setup() ) then
return; --Setup will update the list.
end
FauxScrollFrame_Update(LFDQueueFrameSpecificListScrollFrame, LFDGetNumDungeons(), NUM_LFD_CHOICE_BUTTONS, 16);
local offset = FauxScrollFrame_GetOffset(LFDQueueFrameSpecificListScrollFrame);
local areButtonsBig = not LFDQueueFrameSpecificListScrollFrame:IsShown();
local mode, subMode = GetLFGMode();
for i = 1, NUM_LFD_CHOICE_BUTTONS do
local button = _G["LFDQueueFrameSpecificListButton"..i];
local dungeonID = LFDDungeonList[i+offset];
if ( dungeonID ) then
button:Show();
if ( areButtonsBig ) then
button:SetWidth(315);
else
button:SetWidth(295);
end
LFDQueueFrameSpecificListButton_SetDungeon(button, dungeonID, mode, subMode);
else
button:Hide();
end
end
end
function LFDList_SetHeaderCollapsed(headerID, isCollapsed)
SetLFGHeaderCollapsed(headerID, isCollapsed);
LFGCollapseList[headerID] = isCollapsed;
for _, dungeonID in pairs(LFDDungeonList) do
if ( LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.groupID] == headerID ) then
LFGCollapseList[dungeonID] = isCollapsed;
end
end
for _, dungeonID in pairs(LFDHiddenByCollapseList) do
if ( LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.groupID] == headerID ) then
LFGCollapseList[dungeonID] = isCollapsed;
end
end
LFDQueueFrame_Update();
end
function LFDQueueFrame_QueueForInstanceIfEnabled(queueID)
if ( not LFGIsIDHeader(queueID) and LFGEnabledList[queueID] and not LFGLockList[queueID] ) then
local info = LFGGetDungeonInfoByID(queueID);
SetLFGDungeon(queueID);
return true;
end
return false;
end
function LFDQueueFrame_Join()
if ( LFDQueueFrame.type == "specific" ) then --Random queue
ClearAllLFGDungeons();
for _, queueID in pairs(LFDDungeonList) do
LFDQueueFrame_QueueForInstanceIfEnabled(queueID);
end
for _, queueID in pairs(LFDHiddenByCollapseList) do
LFDQueueFrame_QueueForInstanceIfEnabled(queueID);
end
JoinLFG();
else
ClearAllLFGDungeons();
SetLFGDungeon(LFDQueueFrame.type);
JoinLFG();
end
end
function LFDQueueFrameDungeonChoiceEnableButton_OnClick(self, button)
local parent = self:GetParent();
local dungeonID = parent.id;
local isChecked = self:GetChecked();
PlaySound(isChecked and "igMainMenuOptionCheckBoxOff" or "igMainMenuOptionCheckBoxOff");
if ( LFGIsIDHeader(dungeonID) ) then
LFDList_SetHeaderEnabled(dungeonID, isChecked);
else
LFDList_SetDungeonEnabled(dungeonID, isChecked);
LFGListUpdateHeaderEnabledAndLockedStates(LFDDungeonList, LFGEnabledList, LFGLockList, LFDHiddenByCollapseList);
end
LFDQueueFrameSpecificList_Update();
end
function LFDList_SetDungeonEnabled(dungeonID, isEnabled)
SetLFGDungeonEnabled(dungeonID, isEnabled);
LFGEnabledList[dungeonID] = not not isEnabled; --Change to true/false.
end
function LFDList_SetHeaderEnabled(headerID, isEnabled)
for _, dungeonID in pairs(LFDDungeonList) do
if ( LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.groupID] == headerID ) then
LFDList_SetDungeonEnabled(dungeonID, isEnabled);
end
end
for _, dungeonID in pairs(LFDHiddenByCollapseList) do
if ( LFGGetDungeonInfoByID(dungeonID)[LFG_RETURN_VALUES.groupID] == headerID ) then
LFDList_SetDungeonEnabled(dungeonID, isEnabled);
end
end
LFGEnabledList[headerID] = not not isEnabled; --Change to true/false.
end
function LFDQueueFrameDungeonListButton_OnEnter(self)
local dungeonID = self.id;
if ( self.lockedIndicator:IsShown() ) then
if ( LFGIsIDHeader(dungeonID) ) then
--GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
--GameTooltip:AddLine(YOU_MAY_NOT_QUEUE_FOR_CATEGORY, 1.0, 1.0, 1.0);
--GameTooltip:Show();
else
GameTooltip:SetOwner(self, "ANCHOR_TOP");
GameTooltip:AddLine(YOU_MAY_NOT_QUEUE_FOR_DUNGEON, 1.0, 1.0, 1.0);
for i=1, GetLFDLockPlayerCount() do
local playerName, lockedReason = GetLFDLockInfo(dungeonID, i);
if ( lockedReason ~= 0 ) then
local who;
if ( i == 1 ) then
who = "SELF_";
else
who = "OTHER_";
end
GameTooltip:AddLine(format(_G["INSTANCE_UNAVAILABLE_"..who..(LFG_INSTANCE_INVALID_CODES[lockedReason] or "OTHER")], playerName));
end
end
GameTooltip:Show();
end
end
end
function LFDQueueFrameExpandOrCollapseButton_OnClick(self, button)
local parent = self:GetParent();
LFDList_SetHeaderCollapsed(parent.id, not parent.isCollapsed);
end
--Ready popup functions
function LFDDungeonReadyPopup_OnFail()
PlaySound("LFG_Denied");
if ( LFDDungeonReadyDialog:IsShown() ) then
LFGDebug("Proposal Hidden: Proposal failed.");
StaticPopupSpecial_Hide(LFDDungeonReadyPopup);
elseif ( LFDDungeonReadyPopup:IsShown() ) then
LFDDungeonReadyPopup.closeIn = LFD_PROPOSAL_FAILED_CLOSE_TIME;
LFDDungeonReadyPopup:SetScript("OnUpdate", LFDDungeonReadyPopup_OnUpdate);
end
end
function LFDDungeonReadyPopup_OnUpdate(self, elapsed)
self.closeIn = self.closeIn - elapsed;
if ( self.closeIn < 0 ) then --We remove the OnUpdate and closeIn OnHide
LFGDebug("Proposal Hidden: Failure close timer expired.");
StaticPopupSpecial_Hide(LFDDungeonReadyPopup);
end
end
function LFDDungeonReadyPopup_Update()
local proposalExists, typeID, id, name, texture, role, hasResponded, totalEncounters, completedEncounters, numMembers, isLeader = GetLFGProposal();
if ( not proposalExists ) then
LFGDebug("Proposal Hidden: No proposal exists.");
StaticPopupSpecial_Hide(LFDDungeonReadyPopup);
return;
end
LFDDungeonReadyPopup.dungeonID = id;
if ( hasResponded ) then
LFDDungeonReadyStatus:Show();
LFDDungeonReadyDialog:Hide();
for i=1, numMembers do
LFDDungeonReadyStatus_UpdateIcon(_G["LFDDungeonReadyStatusPlayer"..i]);
end
for i=numMembers+1, NUM_LFD_MEMBERS do
_G["LFDDungeonReadyStatusPlayer"..i]:Hide();
end
if ( not LFDDungeonReadyPopup:IsShown() or StaticPopup_IsLastDisplayedFrame(LFDDungeonReadyPopup) ) then
LFDDungeonReadyPopup:SetHeight(LFDDungeonReadyStatus:GetHeight());
end
else
LFDDungeonReadyDialog:Show();
LFDDungeonReadyStatus:Hide();
local LFDDungeonReadyDialog = LFDDungeonReadyDialog; --Make a local copy.
if ( typeID == TYPEID_RANDOM_DUNGEON ) then
LFDDungeonReadyDialog.background:SetTexture("Interface\\LFGFrame\\UI-LFG-BACKGROUND-RANDOMDUNGEON");
LFDDungeonReadyDialog.label:SetText(RANDOM_DUNGEON_IS_READY);
LFDDungeonReadyDialog.instanceInfo:Hide();
if ( completedEncounters > 0 ) then
LFDDungeonReadyDialog.randomInProgress:Show();
LFDDungeonReadyPopup:SetHeight(223);
LFDDungeonReadyDialog.background:SetTexCoord(0, 1, 0, 1);
else
LFDDungeonReadyDialog.randomInProgress:Hide();
LFDDungeonReadyPopup:SetHeight(193);
LFDDungeonReadyDialog.background:SetTexCoord(0, 1, 0, 118/128);
end
else
LFDDungeonReadyDialog.randomInProgress:Hide();
LFDDungeonReadyPopup:SetHeight(223);
LFDDungeonReadyDialog.background:SetTexCoord(0, 1, 0, 1);
texture = "Interface\\LFGFrame\\UI-LFG-BACKGROUND-"..texture;
if ( not LFDDungeonReadyDialog.background:SetTexture(texture) ) then --We haven't added this texture yet. Default to the Deadmines.
LFDDungeonReadyDialog.background:SetTexture("Interface\\LFGFrame\\UI-LFG-BACKGROUND-Deadmines"); --DEBUG FIXME Default probably shouldn't be Deadmines
end
LFDDungeonReadyDialog.label:SetText(SPECIFIC_DUNGEON_IS_READY);
LFDDungeonReadyDialog_UpdateInstanceInfo(name, completedEncounters, totalEncounters);
LFDDungeonReadyDialog.instanceInfo:Show();
end
LFDDungeonReadyDialogRoleIconTexture:SetTexCoord(GetTexCoordsForRole(role));
LFDDungeonReadyDialogRoleLabel:SetText(_G[role]);
if ( isLeader ) then
LFDDungeonReadyDialogRoleIconLeaderIcon:Show();
else
LFDDungeonReadyDialogRoleIconLeaderIcon:Hide();
end
LFDDungeonReadyDialog_UpdateRewards(id);
end
end
function LFDDungeonReadyDialog_UpdateRewards(dungeonID)
local doneToday, moneyBase, moneyVar, experienceBase, experienceVar, numRewards = GetLFGDungeonRewards(dungeonID);
local numRandoms = 4 - GetNumPartyMembers();
local moneyAmount = moneyBase + moneyVar * numRandoms;
local experienceGained = experienceBase + experienceVar * numRandoms;
local rewardsOffset = 0;
if ( moneyAmount > 0 or experienceGained > 0 ) then --hasMiscReward ) then
LFDDungeonReadyDialogReward_SetMisc(LFDDungeonReadyDialogRewardsFrameReward1);
rewardsOffset = 1;
end
if ( moneyAmount == 0 and experienceGained == 0 and numRewards == 0 ) then
LFDDungeonReadyDialogRewardsFrameLabel:Hide();
else
LFDDungeonReadyDialogRewardsFrameLabel:Show();
end
for i = 1, numRewards do
local frameID = (i + rewardsOffset);
local frame = _G["LFDDungeonReadyDialogRewardsFrameReward"..frameID];
if ( not frame ) then
frame = CreateFrame("FRAME", "LFDDungeonReadyDialogRewardsFrameReward"..frameID, LFDDungeonReadyDialogRewardsFrame, LFDDungeonReadyRewardTemplate);
frame:SetID(frameID);
LFD_MAX_REWARDS = frameID;
end
LFDDungeonReadyDialogReward_SetReward(frame, dungeonID, i)
end
local usedButtons = numRewards + rewardsOffset;
--Hide the unused ones
for i = usedButtons + 1, LFD_MAX_REWARDS do
_G["LFDDungeonReadyDialogRewardsFrameReward"..i]:Hide();
end
if ( usedButtons > 0 ) then
--Set up positions
local positionPerIcon = 1/(2 * usedButtons) * LFDDungeonReadyDialogRewardsFrame:GetWidth();
local iconOffset = 2 * positionPerIcon - LFDDungeonReadyDialogRewardsFrameReward1:GetWidth();
LFDDungeonReadyDialogRewardsFrameReward1:SetPoint("CENTER", LFDDungeonReadyDialogRewardsFrame, "LEFT", positionPerIcon, 5);
for i = 2, usedButtons do
_G["LFDDungeonReadyDialogRewardsFrameReward"..i]:SetPoint("LEFT", "LFDDungeonReadyDialogRewardsFrameReward"..(i - 1), "RIGHT", iconOffset, 0);
end
end
end
function LFDDungeonReadyDialogReward_SetMisc(button)
SetPortraitToTexture(button.texture, "Interface\\Icons\\inv_misc_coin_02");
button.rewardID = 0;
button:Show();
end
function LFDDungeonReadyDialogReward_SetReward(button, dungeonID, rewardIndex)
local name, texturePath, quantity = GetLFGDungeonRewardInfo(dungeonID, rewardIndex);
if ( texturePath ) then --Otherwise, we may be waiting on the item data to come from the server.
SetPortraitToTexture(button.texture, texturePath);
end
button.rewardID = rewardIndex;
button:Show();
end
function LFDDungeonReadyDialogReward_OnEnter(self, dungeonID)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
if ( self.rewardID == 0 ) then
GameTooltip:AddLine(REWARD_ITEMS_ONLY);
local doneToday, moneyBase, moneyVar, experienceBase, experienceVar, numRewards = GetLFGDungeonRewards(LFDDungeonReadyPopup.dungeonID);
local numRandoms = 4 - GetNumPartyMembers();
local moneyAmount = moneyBase + moneyVar * numRandoms;
local experienceGained = experienceBase + experienceVar * numRandoms;
if ( experienceGained > 0 ) then
GameTooltip:AddLine(string.format(GAIN_EXPERIENCE, experienceGained));
end
if ( moneyAmount > 0 ) then
SetTooltipMoney(GameTooltip, moneyAmount, nil);
end
else
GameTooltip:SetLFGDungeonReward(LFDDungeonReadyPopup.dungeonID, self.rewardID);
end
GameTooltip:Show();
end
function LFDDungeonReadyDialog_UpdateInstanceInfo(name, completedEncounters, totalEncounters)
local instanceInfoFrame = LFDDungeonReadyDialogInstanceInfoFrame;
instanceInfoFrame.name:SetFontObject(GameFontNormalLarge);
instanceInfoFrame.name:SetText(name);
if ( instanceInfoFrame.name:GetWidth() + 20 > LFDDungeonReadyDialog:GetWidth() ) then
instanceInfoFrame.name:SetFontObject(GameFontNormal);
end
instanceInfoFrame.statusText:SetFormattedText(BOSSES_KILLED, completedEncounters, totalEncounters);
end
function LFDDungeonReadyDialogInstanceInfo_OnEnter(self)
local numBosses = select(8, GetLFGProposal());
local isHoliday = select(12, GetLFGProposal());
if ( numBosses == 0 or isHoliday) then
return;
end
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:AddLine(BOSSES)
for i=1, numBosses do
local bossName, texture, isKilled = GetLFGProposalEncounter(i);
if ( isKilled ) then
GameTooltip:AddDoubleLine(bossName, BOSS_DEAD, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b, RED_FONT_COLOR.r, RED_FONT_COLOR.g, RED_FONT_COLOR.b);
else
GameTooltip:AddDoubleLine(bossName, BOSS_ALIVE, GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b, GREEN_FONT_COLOR.r, GREEN_FONT_COLOR.g, GREEN_FONT_COLOR.b);
end
end
GameTooltip:Show();
end
function LFDDungeonReadyStatus_ResetReadyStates()
for i=1, NUM_LFD_MEMBERS do
local button = _G["LFDDungeonReadyStatusPlayer"..i];
button.readyStatus = "unknown";
end
end
function LFDDungeonReadyStatus_UpdateIcon(button)
local isLeader, role, level, responded, accepted, name, class = GetLFGProposalMember(button:GetID());
button.texture:SetTexCoord(GetTexCoordsForRole(role));
if ( not responded ) then
button.statusIcon:SetTexture(READY_CHECK_WAITING_TEXTURE);
elseif ( accepted ) then
if ( button.readyStatus ~= "accepted" ) then
button.readyStatus = "accepted";
PlaySound("LFG_RoleCheck");
end
button.statusIcon:SetTexture(READY_CHECK_READY_TEXTURE);
else
button.statusIcon:SetTexture(READY_CHECK_NOT_READY_TEXTURE);
end
button:Show();
end
function LFDQueueFrameTypeDropDown_SetUp(self)
UIDropDownMenu_SetWidth(self, 180);
UIDropDownMenu_Initialize(self, LFDQueueFrameTypeDropDown_Initialize);
UIDropDownMenu_SetSelectedValue(LFDQueueFrameTypeDropDown, LFDQueueFrame.type);
end
local function isRandomDungeonDisplayable(id)
local name, typeID, minLevel, maxLevel, _, _, _, expansionLevel = GetLFGDungeonInfo(id);
local myLevel = UnitLevel("player");
return myLevel >= minLevel and myLevel <= maxLevel and EXPANSION_LEVEL >= expansionLevel;
end
function LFDQueueFrameTypeDropDown_Initialize()
local info = UIDropDownMenu_CreateInfo();
info.text = SPECIFIC_DUNGEONS;
info.value = "specific";
info.func = LFDQueueFrameTypeDropDownButton_OnClick;
info.checked = LFDQueueFrame.type == info.value;
UIDropDownMenu_AddButton(info);
for i=1, GetNumRandomDungeons() do
local id, name = GetLFGRandomDungeonInfo(i);
local isAvailable = IsLFGDungeonJoinable(id);
if ( isRandomDungeonDisplayable(id) ) then
if ( isAvailable ) then
info.text = name;
info.value = id;
info.isTitle = nil;
info.func = LFDQueueFrameTypeDropDownButton_OnClick;
info.disabled = nil;
info.checked = (LFDQueueFrame.type == info.value);
info.tooltipWhileDisabled = nil;
info.tooltipOnButton = nil;
info.tooltipTitle = nil;
info.tooltipText = nil;
UIDropDownMenu_AddButton(info);
else
info.text = name;
info.value = id;
info.isTitle = nil;
info.func = nil;
info.disabled = 1;
info.checked = nil;
info.tooltipWhileDisabled = 1;
info.tooltipOnButton = 1;
info.tooltipTitle = YOU_MAY_NOT_QUEUE_FOR_THIS;
info.tooltipText = LFDConstructDeclinedMessage(id);
UIDropDownMenu_AddButton(info);
end
end
end
end
function LFDQueueFrameTypeDropDownButton_OnClick(self)
LFDQueueFrame_SetType(self.value);
end
function LFDQueueFrame_SetType(value) --"specific" for the list or the record id for a single dungeon
LFDQueueFrame.type = value;
UIDropDownMenu_SetSelectedValue(LFDQueueFrameTypeDropDown, value);
if ( value == "specific" ) then
LFDQueueFrame_SetTypeSpecificDungeon();
else
LFDQueueFrame_SetTypeRandomDungeon();
LFDQueueFrameRandom_UpdateFrame();
end
end
function LFDQueueFrame_SetTypeRandomDungeon()
LFDQueueFrameBackground:SetTexture("Interface\\LFGFrame\\UI-LFG-BACKGROUND-QUESTPAPER")
LFDQueueFrameSpecific:Hide();
LFDQueueFrameRandom:Show();
end
function LFDQueueFrame_SetTypeSpecificDungeon()
LFDQueueFrameBackground:SetTexture("Interface\\LFGFrame\\UI-LFG-BACKGROUND-DUNGEONWALL");
LFDQueueFrameRandom:Hide();
LFDQueueFrameSpecific:Show();
end
function LFDConstructDeclinedMessage(dungeonID)
local returnVal;
for i=1, GetLFDLockPlayerCount() do
local playerName, lockedReason = GetLFDLockInfo(dungeonID, i);
if ( lockedReason ~= 0 ) then
local who;
if ( i == 1 ) then
who = "SELF_";
else
who = "OTHER_";
end
if ( returnVal ) then
returnVal = returnVal.."\n"..format(_G["INSTANCE_UNAVAILABLE_"..who..(LFG_INSTANCE_INVALID_CODES[lockedReason] or "OTHER")], playerName);
else
returnVal = format(_G["INSTANCE_UNAVAILABLE_"..who..(LFG_INSTANCE_INVALID_CODES[lockedReason] or "OTHER")], playerName);
end
end
end
return returnVal;
end
--Random frame functions
NUM_LFD_RANDOM_REWARD_FRAMES = 1;
function LFDQueueFrameRandom_UpdateFrame()
local parentName = "LFDQueueFrameRandomScrollFrameChildFrame"
local parentFrame = _G[parentName];
local dungeonID = LFDQueueFrame.type;
if ( not dungeonID ) then --We haven't gotten info on available dungeons yet.
return;
end
local holiday;
local difficulty;
local dungeonDescription;
local textureFilename;
local dungeonName, _,_,_,_,_,_,_,_,textureFilename,difficulty,_,dungeonDescription, isHoliday = GetLFGDungeonInfo(dungeonID);
local isHeroic = difficulty > 0;
local doneToday, moneyBase, moneyVar, experienceBase, experienceVar, numRewards = GetLFGDungeonRewards(dungeonID);
local numRandoms = 4 - GetNumPartyMembers();
local moneyAmount = moneyBase + moneyVar * numRandoms;
local experienceGained = experienceBase + experienceVar * numRandoms;
local backgroundTexture;
if ( isHeroic ) then
backgroundTexture = "Interface\\LFGFrame\\UI-LFG-BACKGROUND-HEROIC";
elseif ( isHoliday ) then
backgroundTexture = "Interface\\LFGFrame\\UI-LFG-HOLIDAY-BACKGROUND-"..textureFilename;
else
backgroundTexture = "Interface\\LFGFrame\\UI-LFG-BACKGROUND-QUESTPAPER";
end
if ( not LFDQueueFrameBackground:SetTexture(backgroundTexture) ) then
LFDQueueFrameBackground:SetTexture("Interface\\LFGFrame\\UI-LFG-BACKGROUND-QUESTPAPER");
end
local lastFrame = parentFrame.rewardsLabel;
if ( isHoliday ) then
if ( doneToday ) then
parentFrame.rewardsDescription:SetText(LFD_HOLIDAY_REWARD_EXPLANATION2);
else
parentFrame.rewardsDescription:SetText(LFD_HOLIDAY_REWARD_EXPLANATION1);
end
parentFrame.title:SetText(dungeonName);
parentFrame.description:SetText(dungeonDescription);
else
if ( doneToday ) then
parentFrame.rewardsDescription:SetText(LFD_RANDOM_REWARD_EXPLANATION2);
else
parentFrame.rewardsDescription:SetText(LFD_RANDOM_REWARD_EXPLANATION1);
end
parentFrame.title:SetText(LFG_TYPE_RANDOM_DUNGEON);
parentFrame.description:SetText(LFD_RANDOM_EXPLANATION);
end
for i=1, numRewards do
local frame = _G[parentName.."Item"..i];
if ( not frame ) then
frame = CreateFrame("Button", parentName.."Item"..i, _G[parentName], "LFDRandomDungeonLootTemplate");
frame:SetID(i);
NUM_LFD_RANDOM_REWARD_FRAMES = i;
if ( mod(i, 2) == 0 ) then
frame:SetPoint("LEFT", parentName.."Item"..(i-1), "RIGHT", 0, 0);
else
frame:SetPoint("TOPLEFT", parentName.."Item"..(i-2), "BOTTOMLEFT", 0, -5);
end
end
local name, texture, numItems = GetLFGDungeonRewardInfo(dungeonID, i);
_G[parentName.."Item"..i.."Name"]:SetText(name);
SetItemButtonTexture(frame, texture);
SetItemButtonCount(frame, numItems);
frame:Show();
lastFrame = frame;
end
for i=numRewards+1, NUM_LFD_RANDOM_REWARD_FRAMES do
_G[parentName.."Item"..i]:Hide();
end
if ( numRewards > 0 or ((moneyVar == 0 and experienceVar == 0) and (moneyAmount > 0 or experienceGained > 0)) ) then
parentFrame.rewardsLabel:Show();
parentFrame.rewardsDescription:Show();
lastFrame = parentFrame.rewardsDescription;
else
parentFrame.rewardsLabel:Hide();
parentFrame.rewardsDescription:Hide();
end
if ( numRewards > 0 ) then
lastFrame = _G[parentName.."Item"..(numRewards - mod(numRewards+1, 2))];
end
if ( moneyVar > 0 or experienceVar > 0 ) then
parentFrame.pugDescription:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -5);
parentFrame.pugDescription:Show();
lastFrame = parentFrame.pugDescription;
else
parentFrame.pugDescription:Hide();
end
if ( moneyAmount > 0 ) then
MoneyFrame_Update(parentFrame.moneyFrame, moneyAmount);
parentFrame.moneyLabel:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 20, -10);
parentFrame.moneyLabel:Show();
parentFrame.moneyFrame:Show()
parentFrame.xpLabel:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -5);
lastFrame = parentFrame.moneyLabel;
else
parentFrame.moneyLabel:Hide();
parentFrame.moneyFrame:Hide();
end
if ( experienceGained > 0 ) then
parentFrame.xpAmount:SetText(experienceGained);
if ( lastFrame == parentFrame.moneyLabel ) then
parentFrame.xpLabel:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -5);
else
parentFrame.xpLabel:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 20, -10);
end
parentFrame.xpLabel:Show();
parentFrame.xpAmount:Show();
lastFrame = parentFrame.xpLabel;
else
parentFrame.xpLabel:Hide();
parentFrame.xpAmount:Hide();
end
parentFrame.spacer:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -10);
end
function LFDQueueFrameRandomCooldownFrame_OnLoad(self)
self:SetFrameLevel(11); --This value also needs to be set when SetParent is called in LFDQueueFrameRandomCooldownFrame_Update.
self:RegisterEvent("PLAYER_ENTERING_WORLD"); --For logging in/reloading ui
self:RegisterEvent("UNIT_AURA"); --The cooldown is still technically a debuff
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
end
function LFDQueueFrameRandomCooldownFrame_OnEvent(self, event, ...)
local arg1 = ...;
if ( event ~= "UNIT_AURA" or arg1 == "player" or strsub(arg1, 1, 5) == "party" ) then
LFDQueueFrameRandomCooldownFrame_Update();
end
end
function LFDQueueFrameRandomCooldownFrame_Update()
local cooldownFrame = LFDQueueFrameCooldownFrame;
local shouldShow = false;
local hasDeserter = false; --If we have deserter, we want to show this over the specific frame as well as the random frame.
local deserterExpiration = GetLFGDeserterExpiration();
local myExpireTime;
if ( deserterExpiration ) then
myExpireTime = deserterExpiration;
hasDeserter = true;
else
myExpireTime = GetLFGRandomCooldownExpiration();
end
cooldownFrame.myExpirationTime = myExpireTime;
for i = 1, GetNumPartyMembers() do
local nameLabel = _G["LFDQueueFrameCooldownFrameName"..i];
local statusLabel = _G["LFDQueueFrameCooldownFrameStatus"..i];
nameLabel:Show();
statusLabel:Show();
local _, classFilename = UnitClass("party"..i);
local classColor = classFilename and RAID_CLASS_COLORS[classFilename] or NORMAL_FONT_COLOR;
nameLabel:SetFormattedText("|cff%.2x%.2x%.2x%s|r", classColor.r * 255, classColor.g * 255, classColor.b * 255, UnitName("party"..i));
if ( UnitHasLFGDeserter("party"..i) ) then
statusLabel:SetFormattedText(RED_FONT_COLOR_CODE.."%s|r", DESERTER);
shouldShow = true;
hasDeserter = true;
elseif ( UnitHasLFGRandomCooldown("party"..i) ) then
statusLabel:SetFormattedText(RED_FONT_COLOR_CODE.."%s|r", ON_COOLDOWN);
shouldShow = true;
else
statusLabel:SetFormattedText(GREEN_FONT_COLOR_CODE.."%s|r", READY);
end
end
for i = GetNumPartyMembers() + 1, MAX_PARTY_MEMBERS do
local nameLabel = _G["LFDQueueFrameCooldownFrameName"..i];
local statusLabel = _G["LFDQueueFrameCooldownFrameStatus"..i];
nameLabel:Hide();
statusLabel:Hide();
end
if ( GetNumPartyMembers() == 0 ) then
cooldownFrame.description:SetPoint("TOP", 0, -85);
else
cooldownFrame.description:SetPoint("TOP", 0, -30);
end