-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.lua
More file actions
1201 lines (1191 loc) · 43.8 KB
/
util.lua
File metadata and controls
1201 lines (1191 loc) · 43.8 KB
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
--[[--
by ALA
CREDIT shagu/pfQuest(MIT LICENSE) @ https://github.com/shagu
--]]--
local __addon, __private = ...;
local MT = __private.MT;
local CT = __private.CT;
local VT = __private.VT;
local DT = __private.DT;
--> variables
local pcall = pcall;
local type = type;
local select = select;
local next = next;
local strsplit, strmatch, gsub, format = string.split, string.match, string.gsub, string.format;
local tonumber = tonumber;
local GetItemInfoInstant = GetItemInfoInstant;
local UnitGUID = UnitGUID;
local UnitIsPlayer = UnitIsPlayer;
local GetFactionInfoByID = GetFactionInfoByID;
local IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown = IsShiftKeyDown, IsControlKeyDown, IsAltKeyDown;
local GetQuestTagInfo = GetQuestTagInfo;
local GetQuestLogTitle = GetQuestLogTitle;
local GetQuestLogSelection = GetQuestLogSelection;
local GetItemCount = GetItemCount;
local GetMouseFocus = GetMouseFocus or VT._comptb.GetMouseFocus;
local IsModifiedClick = IsModifiedClick;
local Ambiguate = Ambiguate;
local GetNumActiveQuests = C_GossipInfo.GetNumActiveQuests;
local GetActiveQuests = C_GossipInfo.GetActiveQuests;
local SelectActiveQuest = C_GossipInfo.SelectActiveQuest;
local GetNumAvailableQuests = C_GossipInfo.GetNumAvailableQuests;
local GetAvailableQuests = C_GossipInfo.GetAvailableQuests;
local SelectAvailableQuest = C_GossipInfo.SelectAvailableQuest;
local GetActiveTitle = GetActiveTitle;
local GetAvailableTitle = GetAvailableTitle;
local AcceptQuest = AcceptQuest;
local IsQuestCompletable = IsQuestCompletable;
local CompleteQuest = CompleteQuest;
local GetNumQuestChoices = GetNumQuestChoices;
local GetQuestReward = GetQuestReward;
local ConfirmAcceptQuest = ConfirmAcceptQuest;
local GetQuestLogIndexByID = GetQuestLogIndexByID;
local GetQuestLogIsAutoComplete = GetQuestLogIsAutoComplete;
local ShowQuestComplete = ShowQuestComplete;
local StaticPopup_Hide = StaticPopup_Hide;
local CreateFrame = CreateFrame;
local ChatEdit_GetActiveWindow = ChatEdit_GetActiveWindow;
local ChatEdit_InsertLink = ChatEdit_InsertLink;
local ChatFrame_AddMessageEventFilter = ChatFrame_AddMessageEventFilter;
local UIParent = UIParent;
local GameTooltip = GameTooltip;
local ItemRefTooltip = ItemRefTooltip;
local WorldMapFrame = WorldMapFrame;
local ChatFrame2 = ChatFrame2;
local QuestFrame = QuestFrame;
local QuestLogFrame = QuestLogFrame;
local QuestLogListScrollFrame = QuestLogListScrollFrame;
local QuestLogDetailScrollChildFrame = QuestLogDetailScrollChildFrame;
local QuestLogDescriptionTitle = QuestLogDescriptionTitle or QuestInfoDescriptionHeader;
local RAID_CLASS_COLORS = RAID_CLASS_COLORS;
local CLASS_ICON_TCOORDS = CLASS_ICON_TCOORDS;
local _G = _G;
-->
local DataAgent = DT.DB;
local l10n = CT.l10n;
local EventAgent = VT.EventAgent;
local __MAIN_META = VT.MAIN_META;
local __MAIN_OBJ_LOOKUP = VT.MAIN_OBJ_LOOKUP;
local __MAIN_QUESTS_COMPLETED = VT.MAIN_QUESTS_COMPLETED;
local __COMM_META = VT.COMM_META;
local TIP_IMG_S_NORMAL = CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_S_NORMAL];
local IMG_TAG_CPL = "|T" .. CT.TEXTUREPATH .. "TAG_CPL" .. ":0|t";
local IMG_TAG_PRG = "|T" .. CT.TEXTUREPATH .. "TAG_PRG" .. ":0|t";
local IMG_TAG_UNCPL = "|T" .. CT.TEXTUREPATH .. "TAG_UNCPL" .. ":0|t";
-->
MT.BuildEnv("util");
--> UTIL
local quest_auto_inverse_modifier = IsShiftKeyDown;
--> methods
local function GetLevelTag(quest, info, modifier, colored)
local lvl_str = "[";
local tag = GetQuestTagInfo(quest);
if tag ~= nil then
tag = l10n.ui.QUEST_TAG[tag];
end
local min = info.min;
local lvl = info.lvl;
if lvl <= 0 then
lvl = min;
end
if colored ~= false then
if lvl >= VT.QuestLvRed then
lvl_str = lvl_str .. "|cffff0000" .. (tag ~= nil and (lvl .. tag) or lvl) .. "|r";
elseif lvl >= VT.QuestLvOrange then
lvl_str = lvl_str .. "|cffff7f7f" .. (tag ~= nil and (lvl .. tag) or lvl) .. "|r";
elseif lvl >= VT.QuestLvYellow then
lvl_str = lvl_str .. "|cffffff00" .. (tag ~= nil and (lvl .. tag) or lvl) .. "|r";
elseif lvl >= VT.QuestLvGreen then
lvl_str = lvl_str .. "|cff7fbf3f" .. (tag ~= nil and (lvl .. tag) or lvl) .. "|r";
else
lvl_str = lvl_str .. "|cff7f7f7f" .. (tag ~= nil and (lvl .. tag) or lvl) .. "|r";
end
if modifier then
lvl_str = lvl_str .. "/";
local diff = min - VT.PlayerLevel;
if diff > 0 then
if diff > 1 then
lvl_str = lvl_str .. "|cffff3f3f" .. min .. "|r";
else
lvl_str = lvl_str .. "|cffff0f0f" .. min .. "|r";
end
else
if min >= VT.QuestLvRed then
lvl_str = lvl_str .. "|cffff0000" .. min .. "|r";
elseif min >= VT.QuestLvOrange then
lvl_str = lvl_str .. "|cffff7f7f" .. min .. "|r";
elseif min >= VT.QuestLvYellow then
lvl_str = lvl_str .. "|cffffff00" .. min .. "|r";
elseif min >= VT.QuestLvGreen then
lvl_str = lvl_str .. "|cff7fbf3f" .. min .. "|r";
else
lvl_str = lvl_str .. "|cff7f7f7f" .. min .. "|r";
end
end
end
else
if lvl >= VT.QuestLvRed then
lvl_str = lvl_str .. (tag ~= nil and (lvl .. tag) or lvl);
elseif lvl >= VT.QuestLvOrange then
lvl_str = lvl_str .. (tag ~= nil and (lvl .. tag) or lvl);
elseif lvl >= VT.QuestLvYellow then
lvl_str = lvl_str .. (tag ~= nil and (lvl .. tag) or lvl);
elseif lvl >= VT.QuestLvGreen then
lvl_str = lvl_str .. (tag ~= nil and (lvl .. tag) or lvl);
else
lvl_str = lvl_str .. (tag ~= nil and (lvl .. tag) or lvl);
end
if modifier then
lvl_str = lvl_str .. "/";
local diff = min - VT.PlayerLevel;
if diff > 0 then
if diff > 1 then
lvl_str = lvl_str .. min;
else
lvl_str = lvl_str .. min;
end
else
if min >= VT.QuestLvRed then
lvl_str = lvl_str .. min;
elseif min >= VT.QuestLvOrange then
lvl_str = lvl_str .. min;
elseif min >= VT.QuestLvYellow then
lvl_str = lvl_str .. min;
elseif min >= VT.QuestLvGreen then
lvl_str = lvl_str .. min;
else
lvl_str = lvl_str .. min;
end
end
end
end
lvl_str = lvl_str .. "]";
return lvl_str;
end
local function GetPlayerTag(name, class)
if class == nil then
return " > " .. name;
else
local color = RAID_CLASS_COLORS[class];
local coord = CLASS_ICON_TCOORDS[class];
return format(" > |TInterface\\TargetingFrame\\UI-Classes-Circles:0:0:0:0:256:256:%d:%d:%d:%d|t |cff%.2x%.2x%.2x%s|r",
coord[1] * 255, coord[2] * 255, coord[3] * 255, coord[4] * 255,
color.r * 255, color.g * 255, color.b * 255, name
);
end
end
-->
-->
--> performance board
-- display
local function Create()
local frame = CreateFrame("FRAME", nil, UIParent);
frame:SetSize(256, 512);
frame:SetPoint("CENTER");
end
--> events and hooks
local function TooltipSetQuestTip(tip, uuid, META)
local modifier = IsShiftKeyDown();
local refs = uuid[4];
if next(refs) ~= nil then
META = META or __MAIN_META;
for quest, ref in next, refs do
local meta = META[quest];
local info = DataAgent.quest[quest];
local color = CT.IMG_LIST[MT.GetQuestStartTexture(info)];
--[[
local lvl_str = "|cff000000**|r[ ";
local lvl = info.lvl;
local min = info.min;
lvl_str = lvl_str .. l10n.ui.TIP_QUEST_LVL;
if lvl >= VT.QuestLvRed then
lvl_str = lvl_str .. "|cffff0000" .. lvl .. "|r ";
elseif lvl >= VT.QuestLvOrange then
lvl_str = lvl_str .. "|cffff7f7f" .. lvl .. "|r ";
elseif lvl >= VT.QuestLvYellow then
lvl_str = lvl_str .. "|cffffff00" .. lvl .. "|r ";
elseif lvl >= VT.QuestLvGreen then
lvl_str = lvl_str .. "|cff7fbf3f" .. lvl .. "|r ";
else
lvl_str = lvl_str .. "|cff7f7f7f" .. lvl .. "|r ";
end
lvl_str = lvl_str .. l10n.ui.TIP_QUEST_MIN;
if min >= VT.QuestLvRed then
lvl_str = lvl_str .. "|cffff0000" .. min .. "|r ]|cff000000**|r";
elseif min >= VT.QuestLvOrange then
lvl_str = lvl_str .. "|cffff7f7f" .. min .. "|r ]|cff000000**|r";
elseif min >= VT.QuestLvYellow then
lvl_str = lvl_str .. "|cffffff00" .. min .. "|r ]|cff000000**|r";
elseif min >= VT.QuestLvGreen then
lvl_str = lvl_str .. "|cff7fbf3f" .. min .. "|r ]|cff000000**|r";
else
lvl_str = lvl_str .. "|cff7f7f7f" .. min .. "|r ]|cff000000**|r";
end
if meta ~= nil then
if line == 'start' then
tip:AddLine(TIP_IMG_S_NORMAL .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
if modifier then
local loc = l10n.quest[quest];
if loc ~= nil and loc[3] ~= nil then
for _, text in next, loc[3] do
tip:AddLine("|cff000000**|r" .. text, 1.0, 0.75, 0.0);
end
end
end
elseif line == 'end' then
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
end
if modifier then
local loc = l10n.quest[quest];
if loc ~= nil and loc[3] ~= nil then
for _, text in next, loc[3] do
tip:AddLine("|cff000000**|r" .. text, 1.0, 0.75, 0.0);
end
end
end
elseif line == 'event' then
tip:AddLine(TIP_IMG_S_NORMAL .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
for index = 1, #meta do
local meta_line = meta[index];
if meta_line[2] == 'event' or meta_line[2] == 'log' then
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
end
else
tip:AddLine(TIP_IMG_S_NORMAL .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
if line > 0 then
local meta_line = meta[line];
if meta_line ~= nil then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
end
else
line = - line;
local meta_line = meta[line];
if meta_line ~= nil then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
end
end
end
else
local loc = l10n.quest[quest];
if loc ~= nil then
tip:AddLine(TIP_IMG_S_NORMAL .. loc[1] .. "(" .. quest .. ")", color[2], color[3], color[4]);
if modifier and loc[3] then
for _, text in next, loc[3] do
tip:AddLine("|cff000000**|r" .. text, 1.0, 0.75, 0.0);
end
end
else
tip:AddLine(TIP_IMG_S_NORMAL .. "quest:" .. quest, color[2], color[3], color[4]);
end
tip:AddLine(lvl_str, 1.0, 1.0, 1.0);
end
--]]
local lvl_str = GetLevelTag(quest, info, modifier);
if meta ~= nil then
if VT.SETTING.show_id_in_tooltip then
if ref['end'] then
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. lvl_str .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. lvl_str .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
end
else
tip:AddLine(TIP_IMG_S_NORMAL .. lvl_str .. meta.title .. "(" .. quest .. ")", color[2], color[3], color[4]);
end
else
if ref['end'] then
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. lvl_str .. meta.title, color[2], color[3], color[4]);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. lvl_str .. meta.title, color[2], color[3], color[4]);
end
else
tip:AddLine(TIP_IMG_S_NORMAL .. lvl_str .. meta.title, color[2], color[3], color[4]);
end
end
for line, _ in next, ref do
if line == 'start' or line == 'end' then
if modifier then
local loc = l10n.quest[quest];
if loc ~= nil and loc[3] ~= nil then
for _, text in next, loc[3] do
tip:AddLine("|cff000000**|r" .. text, 1.0, 0.75, 0.0);
end
end
end
elseif line == 'extra' then
else
if line > 0 then
local meta_line = meta[line];
if meta_line ~= nil then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
end
else
line = - line;
local meta_line = meta[line];
if meta_line ~= nil then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
end
end
end
end
else
local loc = l10n.quest[quest];
if loc ~= nil and loc[1] ~= nil then
if VT.SETTING.show_id_in_tooltip then
tip:AddLine(TIP_IMG_S_NORMAL .. lvl_str .. loc[1] .. "(" .. quest .. ")", color[2], color[3], color[4]);
else
tip:AddLine(TIP_IMG_S_NORMAL .. lvl_str .. loc[1], color[2], color[3], color[4]);
end
if modifier and loc[3] then
for _, text in next, loc[3] do
tip:AddLine("|cff000000**|r" .. text, 1.0, 0.75, 0.0);
end
end
else
tip:AddLine(TIP_IMG_S_NORMAL .. lvl_str .. "quest:" .. quest, color[2], color[3], color[4]);
end
end
end
end
end
local function OnTooltipSetUnit(tip)
tip.__TextLeft1Text = nil;
if VT.SETTING.objective_tooltip_info then
local _, unit = tip:GetUnit();
if unit and not UnitIsPlayer(unit) then
local GUID = UnitGUID(unit);
if GUID ~= nil then
-- local _, _, _id = strfind(GUID, "Creature%-0%-%d+%-%d+%-%d+%-(%d+)%-%x+");
local _type, _, _, _, _, _id = strsplit("-", GUID);
if (_type == "Creature" or _type == "Vehicle") and _id ~= nil then
_id = tonumber(_id);
if _id ~= nil then
local reshow = false;
local uuid = MT.CoreGetUUID('unit', _id);
if uuid ~= nil then
TooltipSetQuestTip(tip, uuid);
reshow = true;
end
for name, val in next, VT.COMM_GROUP_MEMBERS do
local meta_table = __COMM_META[name];
if meta_table ~= nil then
local uuid = MT.CommGetUUID(name, 'unit', _id);
if uuid ~= nil and next(uuid[4]) ~= nil then
local info = VT.COMM_GROUP_MEMBERS_INFO[name];
tip:AddLine(GetPlayerTag(name, info ~= nil and info[4]));
TooltipSetQuestTip(tip, uuid, meta_table);
reshow = true;
end
end
end
if reshow then
tip:Show();
end
end
end
end
end
end
end
local function OnTooltipSetItem(tip)
tip.__TextLeft1Text = nil;
if VT.SETTING.objective_tooltip_info then
local name, link = tip:GetItem();
if link ~= nil then
local id = GetItemInfoInstant(link);
if id ~= nil then
local QUESTS = DataAgent.item_related_quest[id];
if QUESTS ~= nil and QUESTS[1] ~= nil then
local reshow = false;
local modifier = IsShiftKeyDown();
for _, quest in next, QUESTS do
local meta = __MAIN_META[quest];
if meta ~= nil then
local qinfo = DataAgent.quest[quest];
local color = CT.IMG_LIST[MT.GetQuestStartTexture(qinfo)];
local lvl_str = GetLevelTag(quest, qinfo, modifier);
if modifier then
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. IMG_TAG_PRG .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. IMG_TAG_PRG .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
end
else
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
end
end
for index = 1, #meta do
local meta_line = meta[index];
if meta_line[2] == 'item' and meta_line[3] == id then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
break;
end
end
reshow = true;
end
end
if modifier then
for _, quest in next, QUESTS do
if __MAIN_META[quest] == nil and DataAgent.avl_quest_hash[quest] ~= nil then
local qinfo = DataAgent.quest[quest];
local color = CT.IMG_LIST[MT.GetQuestStartTexture(qinfo)];
local lvl_str = GetLevelTag(quest, qinfo, true);
local loc = l10n.quest[quest];
if loc ~= nil then
if VT.SETTING.show_id_in_tooltip then
if __MAIN_QUESTS_COMPLETED[quest] ~= nil then
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_CPL .. lvl_str .. loc[1] .. "(" .. quest .. ")", color[2], color[3], color[4]);
else
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_UNCPL .. lvl_str .. loc[1] .. "(" .. quest .. ")", color[2], color[3], color[4]);
end
else
if __MAIN_QUESTS_COMPLETED[quest] ~= nil then
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_CPL .. lvl_str .. loc[1], color[2], color[3], color[4]);
else
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_UNCPL .. lvl_str .. loc[1], color[2], color[3], color[4]);
end
end
else
if __MAIN_QUESTS_COMPLETED[quest] ~= nil then
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_CPL .. lvl_str .. "quest:" .. quest, color[2], color[3], color[4]);
else
tip:AddLine(TIP_IMG_S_NORMAL .. IMG_TAG_UNCPL .. lvl_str .. "quest:" .. quest, color[2], color[3], color[4]);
end
end
reshow = true;
end
end
end
for name, val in next, VT.COMM_GROUP_MEMBERS do
local meta_table = __COMM_META[name];
if meta_table ~= nil then
local first_line_of_partner = true;
for _, quest in next, QUESTS do
local meta = meta_table[quest];
if meta ~= nil then
if first_line_of_partner then
first_line_of_partner = false;
local info = VT.COMM_GROUP_MEMBERS_INFO[name];
tip:AddLine(GetPlayerTag(name, info ~= nil and info[4]));
end
local qinfo = DataAgent.quest[quest];
local color = CT.IMG_LIST[MT.GetQuestStartTexture(qinfo)];
local lvl_str = GetLevelTag(quest, qinfo, modifier);
if meta.completed == 1 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_COMPLETED] .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
elseif meta.completed == 0 then
tip:AddLine(CT.TIP_IMG_LIST[CT.IMG_INDEX.IMG_E_UNCOMPLETED] .. lvl_str .. meta.title, 1.0, 0.9, 0.0);
end
for index = 1, #meta do
local meta_line = meta[index];
if meta_line[2] == 'item' and meta_line[3] == id then
if meta_line[5] then
tip:AddLine("|cff000000**|r" .. meta_line[4], 0.5, 1.0, 0.0);
else
tip:AddLine("|cff000000**|r" .. meta_line[4], 1.0, 0.5, 0.0);
end
break;
end
end
end
end
end
end
if reshow then
tip:Show();
end
end
end
end
end
end
-- object
local updateTimer = 0.0;
local function TooltipOnUpdate(tip, elasped)
if VT.SETTING.objective_tooltip_info and tip:GetOwner() == UIParent then
if updateTimer <= 0.0 then
updateTimer = 0.1;
if tip:GetUnit() == nil and tip:GetItem() == nil then
tip.__TextLeft1 = tip.__TextLeft1 or _G[tip:GetName() .. "TextLeft1"];
local text = tip.__TextLeft1:GetText();
if text ~= nil and text ~= tip.__TextLeft1Text then
local reshow = false;
local map = MT.GetPlayerZone();
local oids = __MAIN_OBJ_LOOKUP[map] ~= nil and __MAIN_OBJ_LOOKUP[map][text] or __MAIN_OBJ_LOOKUP["*"][text];
text = "|cffffffff" .. text .. "|r";
tip.__TextLeft1:SetText(text);
tip.__TextLeft1Text = text;
if oids ~= nil and #oids > 0 then
local oid = oids[1];
if #oids > 1 then
local continent, x, y = MT.GetUnitPosition('player');
local mindist2 = 4294967295;
for i = 1, #oids do
local id = oids[i];
local info = DataAgent.object[id];
if info ~= nil and info.wcoords ~= nil then
for j = 1, #info.wcoords do
local coords = info.wcoords[j];
if coords[3] == continent then
local dist2 = (coords[1] - x) * (coords[1] - x) + (coords[2] - y) * (coords[2] - y);
if dist2 < mindist2 then
oid = oids[i];
mindist2 = dist2;
end
end
end
end
end
end
local uuid = MT.CoreGetUUID('object', oid);
if uuid ~= nil then
TooltipSetQuestTip(tip, uuid);
reshow = true;
end
for name, val in next, VT.COMM_GROUP_MEMBERS do
local meta_table = __COMM_META[name];
if meta_table ~= nil then
local uuid = MT.CommGetUUID(name, 'object', oid);
if uuid ~= nil and next(uuid[4]) ~= nil then
local info = VT.COMM_GROUP_MEMBERS_INFO[name];
tip:AddLine(GetPlayerTag(name, info ~= nil and info[4]));
TooltipSetQuestTip(tip, uuid, meta_table);
reshow = true;
end
end
end
end
if reshow then
tip:Show();
end
end
end
else
updateTimer = updateTimer - elasped;
end
end
end
function EventAgent.MODIFIER_STATE_CHANGED()
local focus = GetMouseFocus();
if focus ~= nil and focus.__PIN_TAG ~= nil then
MT.Pin_OnEnter(focus);
elseif GameTooltip:IsShown() then
end
end
function MT.TooltipSetInfo(tip, type, id)
if type == 'event' then
tip:AddLine(l10n.ui.TIP_WAYPOINT, 0.0, 1.0, 0.0);
elseif type == 'extra' then
else
local _loc = l10n[type];
if _loc ~= nil then
if VT.SETTING.show_id_in_tooltip then
if type == 'unit' then
local info = DataAgent.unit[id];
if info ~= nil then
if VT.IsUnitFacFriend[info.fac] then
tip:AddLine(_loc[id] .. "(" .. id .. ")", 0.0, 1.0, 0.0);
else
local facId = info.facId;
if facId ~= nil then
local _, _, standing_rank, _, _, val = GetFactionInfoByID(facId);
if standing_rank == nil then
tip:AddLine(_loc[id] .. "(" .. id .. ")", 1.0, 0.0, 0.0);
elseif standing_rank == 4 then
tip:AddLine(_loc[id] .. "(" .. id .. ")", 1.0, 1.0, 0.0);
elseif standing_rank < 4 then
tip:AddLine(_loc[id] .. "(" .. id .. ")", 1.0, (standing_rank - 1) * 0.25, 0.0);
else
tip:AddLine(_loc[id] .. "(" .. id .. ")", 0.5 - (standing_rank - 4) * 0.125, 1.0, 0.0);
end
else
tip:AddLine(_loc[id] .. "(" .. id .. ")", 1.0, 0.0, 0.0);
end
end
end
else
tip:AddLine(_loc[id] .. "(" .. id .. ")", 1.0, 1.0, 1.0);
end
else
if type == 'unit' then
local info = DataAgent.unit[id];
if info ~= nil then
if VT.IsUnitFacFriend[info.fac] then
tip:AddLine(_loc[id], 0.0, 1.0, 0.0);
else
local facId = info.facId;
if facId ~= nil then
local _, _, standing_rank, _, _, val = GetFactionInfoByID(facId);
if standing_rank == nil then
tip:AddLine(_loc[id], 1.0, 0.0, 0.0);
elseif standing_rank == 4 then
tip:AddLine(_loc[id], 1.0, 1.0, 0.0);
elseif standing_rank < 4 then
tip:AddLine(_loc[id], 1.0, (standing_rank - 1) * 0.25, 0.0);
else
tip:AddLine(_loc[id], 0.5 - (standing_rank - 4) * 0.125, 1.0, 0.0);
end
else
tip:AddLine(_loc[id], 1.0, 0.0, 0.0);
end
end
end
else
tip:AddLine(_loc[id], 1.0, 1.0, 1.0);
end
end
end
end
local uuid = MT.CoreGetUUID(type, id);
if uuid ~= nil then
TooltipSetQuestTip(tip, uuid);
end
for name, val in next, VT.COMM_GROUP_MEMBERS do
local meta_table = __COMM_META[name];
if meta_table ~= nil then
local uuid = MT.CommGetUUID(name, type, id);
if uuid ~= nil and next(uuid[4]) ~= nil then
local info = VT.COMM_GROUP_MEMBERS_INFO[name];
tip:AddLine(GetPlayerTag(name, info ~= nil and info[4]));
TooltipSetQuestTip(tip, uuid, meta_table);
end
end
end
end
function MT.ShowInfoLines(self)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
local info_lines = self.info_lines;
if info_lines then
for index = 1, #info_lines do
GameTooltip:AddLine(info_lines[index]);
end
end
GameTooltip:Show();
end
function MT.OnLeave(self)
if GameTooltip:IsOwned(self) then
GameTooltip:Hide();
end
end
local function drop_handler_send(_, _, quest)
local info = DataAgent.quest[quest];
local loc = l10n.quest[quest];
local lvl = info.lvl;
if lvl <= 0 then
lvl = info.min;
end
local activeWindow = ChatEdit_GetActiveWindow();
if activeWindow ~= nil then
activeWindow:Insert("[[" .. lvl .. "] " .. (loc ~= nil and loc[1] or "Quest: " .. quest) .. " (" .. quest .. ")]");
end
-- ChatEdit_InsertLink("[[" .. lvl .. "] " .. (loc ~= nil and loc[1] or "Quest: " .. quest) .. " (" .. quest .. ")]");
end
local function drop_handler_toggle(_, _, quest)
MT.MapPermanentlyToggleQuestNodes(quest);
end
local function GetQuestTitle(quest, modifier)
local info = DataAgent.quest[quest];
local color = CT.IMG_LIST[MT.GetQuestStartTexture(info)];
local lvl_str = GetLevelTag(quest, info, modifier);
local loc = l10n.quest[quest];
return lvl_str .. "|c" .. color[5] .. (loc ~= nil and (loc[1] .. "(" .. quest .. ")") or "quest: " .. quest) .. "|r";
end
function MT.NodeOnModifiedClick(node, uuid)
local refs = uuid[4];
if ChatEdit_GetActiveWindow() then
local data = { handler = drop_handler_send, num = 0, };
for quest, val in next, refs do
data.num = data.num + 1;
data[data.num] = {
text = l10n.ui.pin_menu_send_quest .. GetQuestTitle(quest, true);
param = quest,
};
end
VT.__menulib.ShowMenu(node, "BOTTOMLEFT", data);
return true;
else
for quest, val in next, refs do
if val["start"] ~= nil then
local data = { handler = drop_handler_toggle, num = 0, };
for quest, val in next, refs do
if val["start"] ~= nil then
if VT.QUEST_PREMANENTLY_BLOCKED[quest] then
data.num = data.num + 1;
data[data.num] = {
text = l10n.ui.pin_menu_show_quest .. GetQuestTitle(quest, true);
param = quest,
};
else
data.num = data.num + 1;
data[data.num] = {
text = l10n.ui.pin_menu_hide_quest .. GetQuestTitle(quest, true);
param = quest,
};
end
end
end
VT.__menulib.ShowMenu(node, "BOTTOMLEFT", data);
return true;
end
end
end
end
--> Auto Accept and Turnin
function EventAgent.GOSSIP_SHOW()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_complete ~= modstate then
local quests = GetActiveQuests();
for i = 1, GetNumActiveQuests() do
local quest = quests[i];
-- local title, level, isTrivial, isComplete, isLegendary, isIgnored = select(i * 6 - 5, GetActiveQuests());
if quest.title and quest.isComplete then
return SelectActiveQuest(quest.questID);
end
end
end
if not VT.SETTING.auto_accept ~= modstate then
local quests = GetAvailableQuests();
for i = 1, GetNumAvailableQuests() do
local quest = quests[i];
-- local title, level, isTrivial, isDaily, isRepeatable, isLegendary, isIgnored = select(i * 7 - 6, GetAvailableQuests());
if quest.title then
return SelectAvailableQuest(quest.questID);
end
end
end
-- if VT.SETTING.auto_accept then
-- for i = 1, GetNumAvailableQuests() do
-- local titleText, level, isTrivial, frequency, isRepeatable, isLegendary, isIgnored = GetAvailableQuests(i);
-- if title then
-- return SelectAvailableQuest(i);
-- end
-- end
-- end
end
function EventAgent.QUEST_GREETING()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_complete ~= modstate then
for i = 1, GetNumActiveQuests() do
local title, isComplete = GetActiveTitle(i);
if title and isComplete then
return SelectActiveQuest(i);
end
end
end
if not VT.SETTING.auto_accept ~= modstate then
for i = 1, GetNumAvailableQuests() do
local title, isComplete = GetAvailableTitle(i);
if title then
return SelectAvailableQuest(i);
end
end
end
end
function EventAgent.QUEST_DETAIL()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_accept ~= modstate then
AcceptQuest();
QuestFrame:Hide();
end
end
function EventAgent.QUEST_PROGRESS()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_complete ~= modstate then
if IsQuestCompletable() then
CompleteQuest();
end
end
end
function EventAgent.QUEST_COMPLETE()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_complete ~= modstate then
local _NumChoices = GetNumQuestChoices();
if _NumChoices <= 1 then
GetQuestReward(_NumChoices);
end
end
end
function EventAgent.QUEST_ACCEPT_CONFIRM()
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_accept ~= modstate then
ConfirmAcceptQuest() ;
StaticPopup_Hide("QUEST_ACCEPT");
end
end
function EventAgent.QUEST_AUTOCOMPLETE(id)
local modstate = not quest_auto_inverse_modifier();
if not VT.SETTING.auto_complete ~= modstate then
local index = GetQuestLogIndexByID(id);
if GetQuestLogIsAutoComplete(index) then
ShowQuestComplete(index);
end
end
end
local function SetQuestAutoInverseModifier(modifier)
if modifier == "SHIFT" then
quest_auto_inverse_modifier = IsShiftKeyDown;
elseif modifier == "CTRL" then
quest_auto_inverse_modifier = IsControlKeyDown;
elseif modifier == "ALT" then
quest_auto_inverse_modifier = IsAltKeyDown;
end
end
--> DBIcon
local function CreateDBIcon()
local LibStub = _G.LibStub;
if LibStub ~= nil then
local LDI = LibStub("LibDBIcon-1.0", true);
if LDI then
local D = nil;
LDI:Register(
"CodexLite",
{
icon = [[interface\icons\inv_misc_book_09]],
OnClick = function(self, button)
if button == "LeftButton" then
if VT.SettingUI:IsShown() then
VT.SettingUI:Hide();
else
VT.SettingUI:Show();
end
else
VT.SETTING.show_minimappin = not VT.SETTING.show_minimappin;
MT.MapToggleMinimapPin(VT.SETTING.show_minimappin);
D:SetShown(not VT.SETTING.show_minimappin);
end
end,
text = "CodexLite",
OnTooltipShow = function(tt)
tt:AddLine("CodexLite");
tt:Show();
end,
},
VT.SVAR.minimap
);
LDI:Show(__addon);
if VT.SETTING.show_db_icon then
LDI:Show(__addon);
else
LDI:Hide(__addon);
end
local Icon = LDI:GetMinimapButton(__addon);
if Icon ~= nil then
D = Icon:CreateTexture(nil, "OVERLAY");
D:SetAllPoints(Icon.icon);
D:SetTexture(CT.TEXTUREPATH .. "close");
D:SetShown(not VT.SETTING.show_minimappin);
end
end
end
end
--> WorldMapPin Toggle
local function CreateWorldMapPinSwitch()
local Switch = CreateFrame('BUTTON', nil, WorldMapFrame, "UIPanelButtonTemplate");
Switch:SetSize(30, 30);
Switch:SetText("CL");
Switch:SetPoint("TOPRIGHT", WorldMapFrame, "TOPRIGHT", -100, -30);
Switch:RegisterForClicks("AnyUp");
Switch:SetScript("OnClick", function(self, button)
if button == "LeftButton" then
if VT.SettingUI:IsShown() then
VT.SettingUI:Hide();
else
VT.SettingUI:Show();
end
else
VT.SETTING.show_worldmappin = not VT.SETTING.show_worldmappin;
MT.MapToggleWorldMapPin(VT.SETTING.show_worldmappin);
Switch.D:SetShown(not VT.SETTING.show_worldmappin);
end
end);
local D = Switch:CreateTexture(nil, "OVERLAY");
D:SetSize(20, 20);
D:SetPoint("CENTER");
D:SetTexture(CT.TEXTUREPATH .. "close");
D:SetShown(not VT.SETTING.show_worldmappin);
Switch.D = D;
VT.__autostyle:AddReskinObject(Switch);
end
-->
--> Chat
--
local function SendFilterRep(id, level, title)
return "[[" .. gsub(level, "[^0-9]", "") .. "] " .. title .. " (" .. id .. ")]";
end
local function SendFilter(msg)
--"|Hcdxl:([0-9]+)|h|c[0-9a-f]+%[%[(.+)%](.+)%]|r|h"
return gsub(msg, "|Hcdxl:([0-9]+)|h|c[0-9a-f]+%[%[(.-)%](.-)%(.-%)%]|r|h", SendFilterRep);
end
local __SendChatMessage = nil;
local function CdxlSendChatMessage(text, ...)
__SendChatMessage(SendFilter(text), ...);
end
local __BNSendWhisper = nil;
local function CdxlBNSendWhisper(presenceID, text, ...)
__BNSendWhisper(presenceID, SendFilter(text), ...);
end
local __BNSendConversationMessage = nil;
local function CdxlBNSendConversationMessage(target, text, ...)
__BNSendConversationMessage(target, SendFilter(text), ...);
end
local function ChatFilterReplacer(body, id)
local quest = tonumber(id);
local info = DataAgent.quest[quest];
local loc = l10n.quest[quest];
if info ~= nil and loc ~= nil then
local color = CT.IMG_LIST[MT.GetQuestStartTexture(info)];
return "|Hcdxl:" .. id .. "|h|c" .. color[5] .. "[" .. GetLevelTag(quest, info, false, false) .. (loc ~= nil and loc[1] .. "(" .. id .. ")" or "Quest: " .. id) .. "]|r|h";
end
return body;
end
local function ChatFilter(ChatFrame, event, arg1, ...)
if ChatFrame ~= ChatFrame2 then
return false, gsub(arg1, "(%[%[[0-9]+%] .- %(([0-9]+)%)%])", ChatFilterReplacer), ...;
end
return false, arg1, ...;
end
local ItemRefTooltip = ItemRefTooltip;
local _ItemRefTooltip_SetHyperlink = ItemRefTooltip.SetHyperlink;
function ItemRefTooltip:SetHyperlink(link, ...)
local id = strmatch(link, "cdxl:(%d+)");
if id ~= nil then
id = tonumber(id);
if id ~= nil then
local meta = __MAIN_META[id];
local info = DataAgent.quest[id];
if meta ~= nil then
ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE");