-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore.lua
1785 lines (1619 loc) · 58.9 KB
/
Core.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
local addonName, MTI = ...;
MoreTooltipInfo = MTI
MoreTooltipInfo.Data = {}
local _G = _G
local ACD = LibStub("AceConfigDialog-3.0")
local ACR = LibStub("AceConfigRegistry-3.0")
local IUI = LibStub("LibItemUpgradeInfo-1.0")
local AGUI= LibStub("AceGUI-3.0")
local DBC = HeroDBC.DBC
local cfg
local profiles
local dbDefaults = {
char = {},
profiles = {},
}
local charDefaults = {
enableSpellID = true,
enableSpellRPPM = true,
enableSpellGCD = true,
enableSpellTalentID = true,
enableItemID = true,
enableItemSpellID = true,
enableItemRPPM = true,
enableItemBonusID = true,
enableItemGemID = true,
enableItemEnchantID = true,
enableItemEnchantSpellID = true,
enableItemEnchantSpellRPPM = true,
enableBaseItemDPS = true,
enablePersonnalItemDPS = true,
enableLegendaryItemDPS = true,
enableBaseTalentDPS = true,
enableBestTalentDPS = true,
enableTalentDPSOnUI = true,
enableSoulbindID = true,
enableSoulbindBaseDPS = true,
enableSoulbindBestDPS = true,
enableSoulbindDPSOnUI = true,
enableConduitID = true,
enableConduitSpellID = true,
enableConduitRank = true,
enableConduitDPS = true,
enableConduitDPSOnUI = true,
enableNPCID = true,
enableTextureID = false,
}
local profileDefaults = {
trinket = {},
soulbind={},
conduit={},
legendary={},
talent={}
}
local UIElements={
mainframe,
mainGroup,
scroll1,
tableLabel={},
spacerTable={},
detailsGroup,
scroll2,
titleLabel,
renameButton,
deleteButton,
importButton,
typeDropdown,
enablecheckbox,
useOnUIChechbox,
colorpicker,
talentStrings={},
conduitStrings={},
soulbindStrings={}
}
local UIParameters={
--Consts
OFFSET_ITEM_ID = 1,
OFFSET_ENCHANT_ID = 2,
OFFSET_GEM_ID_1 = 3,
OFFSET_GEM_ID_2 = 4,
OFFSET_GEM_ID_3 = 5,
OFFSET_GEM_ID_4 = 6,
OFFSET_SUFFIX_ID = 7,
OFFSET_FLAGS = 11,
OFFSET_BONUS_ID = 13,
MAX_TALENT_ROW = 7,
MAX_TALENT_PER_ROW = 3,
MAX_SOULBIND_ROW = 7,
MAX_SOULBIND_PER_ROW = 3,
detailsLoaded=false,
detailsDrawn=false,
mainframeCreated=false,
currentProfile="",
currentType="trinket",
currentTypeIndex=1,
currentClassID=0,
currentSpecID=0,
availableOption = {
[1] = "trinket",
[2] = "talent",
[3] = "conduit",
[4] = "soulbind",
[5] = "legendary"
},
talentOnUILoaded=false,
conduitOnUILoaded=false,
soulbindOnUILoaded=false,
}
local f = CreateFrame("Frame")
f:SetScript("OnEvent", function(self, event, ...)
return self[event] and self[event](self, event, ...)
end)
f:RegisterEvent("ADDON_LOADED")
-- Command UI
SLASH_MORETOOLTIPINFOSLASH1 = "/mti"
SlashCmdList["MORETOOLTIPINFOSLASH"] = function (arg)
if UIParameters.mainframeCreated and UIElements.mainframe:IsShown() then
UIElements.mainframe:Hide()
else
OpenProfileUI()
UIParameters.mainframeCreated = true
end
end
function MoreTooltipInfo.TooltipLine(tooltip, info, infoType, textColor)
local found = false
-- Check if we already added to this tooltip. Happens on the talent frame
for i = 1,15 do
local frame = _G[tooltip:GetName() .. "TextLeft" .. i]
local text
if frame then text = frame:GetText() end
if text and text == infoType then
found = true
break
end
end
if not found then
local color = "ffffffff"
if textColor ~= nil then color = textColor end
tooltip:AddDoubleLine(infoType, "|c" .. color .. info)
tooltip:Show()
end
end
function MoreTooltipInfo.FormatSpace(number)
local formatted = number
local k
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2')
if (k == 0) then
return formatted
end
end
end
function MoreTooltipInfo.GetSpecID()
-- Spec Info
local globalSpecID
local specId = GetSpecialization()
if specId then
globalSpecID = GetSpecializationInfo(specId)
end
return tonumber(globalSpecID)
end
function MoreTooltipInfo.GetRace()
-- Race info
local _, playerRace = UnitRace('player')
return tonumber(playerRace)
end
function MoreTooltipInfo.GetClassID()
-- Class info
local _, _, playerRace = UnitClass('player')
return tonumber(playerRace)
end
function MoreTooltipInfo.GetHastePct()
return GetHaste()
end
function MoreTooltipInfo.GetCritPct()
return GetCritChance()
end
function MoreTooltipInfo.GetItemSplit(itemLink)
local itemString = string.match(itemLink, "item:([%-?%d:]+)")
local itemSplit = {}
-- Split data into a table
for _, v in ipairs({strsplit(":", itemString)}) do
if v == "" then
itemSplit[#itemSplit + 1] = 0
else
itemSplit[#itemSplit + 1] = tonumber(v)
end
end
return itemSplit
end
function MoreTooltipInfo.GetIDFromLink(linktype,Link)
local xString = string.match(Link, linktype .. ":([%-?%d:]+)")
local xSplit = {}
if not xString then
return nil
end
-- Split data into a table
for v in string.gmatch(xString, "(%d*:?)") do
if v == ":" then
xSplit[#xSplit + 1] = 0
else
xSplit[#xSplit + 1] = string.gsub(v, ':', '')
end
end
return tonumber(xSplit[1])
end
function MoreTooltipInfo.GetItemBonusID(itemSplit)
local bonuses = {}
for index=1, itemSplit[UIParameters.OFFSET_BONUS_ID] do
bonuses[#bonuses + 1] = itemSplit[UIParameters.OFFSET_BONUS_ID + index]
end
if #bonuses > 0 then
return table.concat(bonuses, '/')
end
end
function MoreTooltipInfo.GetGemItemID(itemLink, index)
local _, gemLink = GetItemGem(itemLink, index)
if gemLink ~= nil then
local itemIdStr = string.match(gemLink, "item:(%d+)")
if itemIdStr ~= nil then
return tonumber(itemIdStr)
end
end
return 0
end
function MoreTooltipInfo.GetGemBonuses(itemLink, index)
local bonuses = {}
local _, gemLink = GetItemGem(itemLink, index)
if gemLink ~= nil then
local gemSplit = MoreTooltipInfo.GetItemSplit(gemLink)
for index=1, gemSplit[UIParameters.OFFSET_BONUS_ID] do
bonuses[#bonuses + 1] = gemSplit[UIParameters.OFFSET_BONUS_ID + index]
end
end
if #bonuses > 0 then
return table.concat(bonuses, ':')
end
return 0
end
function MoreTooltipInfo.getGemString(self,itemLink)
local gems = {}
local gemBonuses = {}
local itemSplit = MoreTooltipInfo.GetItemSplit(itemLink)
for gemOffset = UIParameters.OFFSET_GEM_ID_1, UIParameters.OFFSET_GEM_ID_4 do
local gemIndex = (gemOffset - UIParameters.OFFSET_GEM_ID_1) + 1
if itemSplit[gemOffset] > 0 then
local gemId = MoreTooltipInfo.GetGemItemID(itemLink, gemIndex)
if gemId > 0 then
gems[gemIndex] = gemId
gemBonuses[gemIndex] = MoreTooltipInfo.GetGemBonuses(itemLink, gemIndex)
end
else
gems[gemIndex] = 0
gemBonuses[gemIndex] = 0
end
end
-- Remove any trailing zeros from the gems array
while #gems > 0 and gems[#gems] == 0 do
table.remove(gems, #gems)
end
-- Remove any trailing zeros from the gem bonuses
while #gemBonuses > 0 and gemBonuses[#gemBonuses] == 0 do
table.remove(gemBonuses, #gemBonuses)
end
if #gems > 0 then
MoreTooltipInfo.TooltipLine(self, table.concat(gems, '/'), "GemID")
if #gemBonuses > 0 then
MoreTooltipInfo.TooltipLine(self, table.concat(gemBonuses, '/'), "GemBonusID")
end
end
end
function MoreTooltipInfo.GetItemSpellID(itemID)
local spellID = DBC.ItemSpell[itemID]
if spellID then
return spellID
end
end
function MoreTooltipInfo.GetRPPM(spellID)
local rppmtable = DBC.SpellRPPM[spellID]
if not rppmtable then
return nil
end
local specID = MoreTooltipInfo.GetSpecID()
local classID = MoreTooltipInfo.GetClassID()
local race = MoreTooltipInfo.GetRace()
local baseRPPM = rppmtable[0]
local modHaste = false
if rppmtable[1] then
modHaste = true
end
local modCrit = false
if rppmtable[2] then
modCrit = true
end
local modRace = nil
if rppmtable[5] then
if rppmtable[5][race] then
modRace = rppmtable[5][race]
end
end
local modClass = nil
if rppmtable[3] then
if rppmtable[3][classID] then
modClass = rppmtable[3][classID]
end
end
local modSpec = nil
if rppmtable[4] then
if rppmtable[4][specID] then
modSpec = rppmtable[4][specID]
end
end
local rppmString = ""
if modRace then
rppmString = modRace
elseif modClass then
rppmString = modClass
elseif modSpec then
rppmString = modSpec
else
rppmString = baseRPPM
end
if modHaste then
local currentHasteRating = MoreTooltipInfo.GetHastePct()
local hastedRPPM = rppmString * (1 + (currentHasteRating / 100))
rppmString = rppmString .. " (Hasted : " .. string.format("%.4f", hastedRPPM) ..")"
elseif modCrit then
local currentCritRating = MoreTooltipInfo.GetCritPct()
local critRPPM = rppmString * (1 + (currentCritRating / 100))
rppmString = rppmString .. " (Crit : " .. string.format("%.4f", critRPPM) ..")"
end
return rppmString
end
function MoreTooltipInfo.GetGCD(spellID)
local gcd = 0
if DBC.SpellGCD[spellID] ~= nil then
gcd = DBC.SpellGCD[spellID]
else
return nil
end
return gcd
end
function MoreTooltipInfo.GetDPS(itemLink,itemID,tooltip)
local dps
local specID = MoreTooltipInfo.GetSpecID()
local classID = MoreTooltipInfo.GetClassID()
if MoreTooltipInfo.Data.ItemDPS[itemID] then
local itemData = MoreTooltipInfo.Data.ItemDPS[itemID]
local itemlevel = IUI:GetUpgradedItemLevel(itemLink) or 0
if itemlevel and specID and classID then
if itemData[classID] and itemData[classID][specID] and itemData[classID][specID][itemlevel] then
dps = MoreTooltipInfo.FormatSpace(itemData[classID][specID][itemlevel])
end
end
end
return dps
end
function MoreTooltipInfo.RPPMTooltip(destination, spellID, forceTitle)
if spellID then
local rppm = MoreTooltipInfo.GetRPPM(spellID)
if rppm then
local title = "RPPM"
if forceTitle then
title = forceTitle
end
MoreTooltipInfo.TooltipLine(destination, rppm, title)
end
end
end
function MoreTooltipInfo.GCDTooltip(destination, spellID)
if spellID then
local gcd = MoreTooltipInfo.GetGCD(spellID)
if gcd then
gcd = gcd / 1000
MoreTooltipInfo.TooltipLine(destination, gcd, "GCD")
end
end
end
function MoreTooltipInfo.ItemDPSTooltip(destination, itemLink, itemID, personnalData)
if itemID then
local _, _, itemRarity, _, _, _, _, _, itemEquipLoc, _, _ = GetItemInfo(itemLink)
local InfoType
local specID = MoreTooltipInfo.GetSpecID()
local classID = MoreTooltipInfo.GetClassID()
local dps
if personnalData == "base" then
if itemEquipLoc == "INVTYPE_TRINKET" then --trinkets
InfoType = "trinket"
dps = MoreTooltipInfo.GetDPS(itemLink, itemID, destination)
if dps then
MoreTooltipInfo.TooltipLine(destination, dps, "Base simDPS")
end
end
elseif personnalData == "perso" then
if itemEquipLoc == "INVTYPE_TRINKET" then --trinkets
InfoType = "trinket"
local itemlevel = IUI:GetUpgradedItemLevel(itemLink) or 0
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["enable"] and v["data"] and v["data"][itemID] and v["data"][itemID][itemlevel] then
dps = MoreTooltipInfo.FormatSpace(v["data"][itemID][itemlevel])
MoreTooltipInfo.TooltipLine(destination, dps, i, v["color"])
end
end
end
elseif personnalData == "legendary" then
if itemRarity == 5 then --legendaries
InfoType = "legendary"
local itemSplit = MoreTooltipInfo.GetItemSplit(itemLink)
local bonusIDs = MoreTooltipInfo.GetItemBonusID(itemSplit)
if not bonusIDs then return end
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["enable"] and v["data"] then
for j, w in ipairs({strsplit("/", bonusIDs)}) do
if v["data"][tonumber(w)] then
dps = MoreTooltipInfo.FormatSpace(v["data"][tonumber(w)])
MoreTooltipInfo.TooltipLine(destination, dps, i, v["color"])
end
end
end
end
end
end
end
end
function MoreTooltipInfo.SpellDPSTooltip(destination, spellID, InfoType, conduitrank)
if spellID then
local specID = MoreTooltipInfo.GetSpecID()
local classID = MoreTooltipInfo.GetClassID()
local dps
--talent
if InfoType == "talent" then
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["enable"] and v["data"] and v["data"][spellID] and v["data"][spellID]["Base"] then
dps = MoreTooltipInfo.FormatSpace(v["data"][spellID]["Base"])
MoreTooltipInfo.TooltipLine(destination, dps, i.." Base", v["color"])
end
if v["enable"] and v["data"] and v["data"][spellID] and v["data"][spellID]["Best"] then
dps = MoreTooltipInfo.FormatSpace(v["data"][spellID]["Best"])
MoreTooltipInfo.TooltipLine(destination, dps, i.." Best", v["color"])
end
end
end
--conduit
if InfoType == "conduit" then
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["enable"] and v["data"] and v["data"][spellID] and v["data"][spellID][conduitrank] then
dps = MoreTooltipInfo.FormatSpace(v["data"][spellID][conduitrank])
MoreTooltipInfo.TooltipLine(destination, dps, i.." Rank "..conduitrank, v["color"])
end
end
end
--soulbind
if InfoType == "soulbind" then
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["enable"] and v["data"] and v["data"][spellID] and v["data"][spellID]["Base"] then
dps = MoreTooltipInfo.FormatSpace(v["data"][spellID]["Base"])
MoreTooltipInfo.TooltipLine(destination, dps, i.." Base", v["color"])
end
if v["enable"] and v["data"] and v["data"][spellID] and v["data"][spellID]["Best"] then
dps = MoreTooltipInfo.FormatSpace(v["data"][spellID]["Best"])
MoreTooltipInfo.TooltipLine(destination, dps, i.." Best", v["color"])
end
end
end
end
end
function MoreTooltipInfo.GetDefaultColor(classID)
return MoreTooltipInfo.SpecNames[classID]["color"]
end
function MoreTooltipInfo.CheckIfUseOnUIExists(InfoType, classID, specID)
local exists = false
local profileName = ""
if profiles[InfoType][classID] == nil then return end
if profiles[InfoType][classID][specID] == nil then return end
for i, v in pairs(profiles[InfoType][classID][specID]) do
if v["useOnUI"] then
exists = true
profileName = i
end
end
return exists,profileName
end
function MoreTooltipInfo.NewProfile(type, classID, specID, profileName, data, enable, color, string, useOnUI)
profiles[type][classID][specID][profileName] = {}
profiles[type][classID][specID][profileName]["enable"] = enable
profiles[type][classID][specID][profileName]["color"] = color
profiles[type][classID][specID][profileName]["data"] = data
profiles[type][classID][specID][profileName]["string"] = string
profiles[type][classID][specID][profileName]["useOnUI"] = useOnUI
end
function MoreTooltipInfo.ValidateItemPersonnalData(info,value)
-- Split data into a table
local stringSplit = {strsplit(":",value)}
-- check MTI string
if stringSplit[1] ~= "MoreTooltipInfo" then print("Incorect prefix") return false end
-- check class
if not MoreTooltipInfo.SpecNames[tonumber(stringSplit[2])] then print("Incorect classID") return false end
local classID = tonumber(stringSplit[2])
-- check specs
if not MoreTooltipInfo.SpecNames[classID][tonumber(stringSplit[3])] then print("Incorect specID") return false end
local specID = tonumber(stringSplit[3])
--Profile Name
local profileName = stringSplit[4]:gsub('"', '')
-- Split data into a table
local dpsData = {strsplit("^",stringSplit[5])}
local data = {}
local infoType = dpsData[1]
local color = MoreTooltipInfo.GetDefaultColor(classID) .. "ff" --add alpha at the end
local useOnUI = false
if not MoreTooltipInfo.CheckIfUseOnUIExists(infoType, classID, specID) then
useOnUI = true --if no other profile is shown, use this one
end
if infoType == "trinket" then
-- MoreTooltipInfo:8:63:"X.com-patchwerk":trinket^[174103]125=1234;130=1250;150=9999^[174500]125=123;130=456;135=789
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
if profiles[infoType][classID][specID] == nil then profiles[infoType][classID][specID] = {} end
for i, v in ipairs(dpsData) do
if i ~= 1 then -- 1 is the type
local itemID, dpsData = strsplit("]",v)
itemID = tonumber(string.sub(itemID,2))--remove the first[
if itemID then
data[itemID] = {}
for _, w in ipairs({strsplit(";", dpsData)}) do
local ilvl,dps = strsplit("=",w)
data[itemID][tonumber(ilvl)] = tonumber(dps)
end
end
end
end
elseif infoType == "talent" then
--MoreTooltipInfo:8:64:\"X.com-patchwerk\":talent^[56377]Base=1234;Best=9999^[153595]Base=5678;Best=8888
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
if profiles[infoType][classID][specID] == nil then profiles[infoType][classID][specID] = {} end
for i, v in ipairs(dpsData) do
if i ~= 1 then -- 1 is the type
local talentID, dpsData = strsplit("]",v)
talentID = tonumber(string.sub(talentID,2))--remove the first[
if talentID then
data[talentID] = {}
for _, w in ipairs({strsplit(";", dpsData)}) do
local talentType,dps = strsplit("=",w)
data[talentID][talentType] = tonumber(dps)
end
end
end
end
elseif infoType == "conduit" then
--MoreTooltipInfo:8:64:"X.com-patchwerk":conduit^[56377]1=111;2=222^[153595]1=333;2=444
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
if profiles[infoType][classID][specID] == nil then profiles[infoType][classID][specID] = {} end
for i, v in ipairs(dpsData) do
if i ~= 1 then -- 1 is the type
local conduitID, dpsData = strsplit("]",v)
conduitID = tonumber(string.sub(conduitID,2))--remove the first[
if conduitID then
data[conduitID] = {}
for _, w in ipairs({strsplit(";", dpsData)}) do
local rank,dps = strsplit("=",w)
data[conduitID][tonumber(rank)] = tonumber(dps)
end
end
end
end
elseif infoType == "soulbind" then
--MoreTooltipInfo:8:64:"X.com-patchwerk":soulbind^[56377]Base=111;Best=222^[153595]Base=333;Best=444
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
if profiles[infoType][classID][specID] == nil then profiles[infoType][classID][specID] = {} end
for i, v in ipairs(dpsData) do
if i ~= 1 then -- 1 is the type
local spellID, dpsData = strsplit("]",v)
spellID = tonumber(string.sub(spellID,2))--remove the first[
if spellID then
data[spellID] = {}
for _, w in ipairs({strsplit(";", dpsData)}) do
local soulbindType,dps = strsplit("=",w)
data[spellID][soulbindType] = tonumber(dps)
end
end
end
end
elseif infoType == "legendary" then
--MoreTooltipInfo:8:64:"X.com-patchwerk":legendary^[56377]111^[336522]666
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
if profiles[infoType][classID][specID] == nil then profiles[infoType][classID][specID] = {} end
for i, v in ipairs(dpsData) do
if i ~= 1 then -- 1 is the type
local bonusID, dpsData = strsplit("]",v)
bonusID = tonumber(string.sub(bonusID,2))--remove the first[
if bonusID then
data[bonusID] = tonumber(dpsData)
end
end
end
end
if profiles[infoType][classID][specID][profileName] ~= nil then
local tempdata = {}
tempdata["type"] = infoType
tempdata["classID"] = classID
tempdata["specID"] = specID
tempdata["profileName"] = profileName
tempdata["data"] = data
tempdata["enable"] = true
tempdata["color"] = color
tempdata["string"] = value
tempdata["useOnUI"] = useOnUI
StaticPopup_Show("MTI_CONFIRM_EXISTS_POPUP","","",tempdata)
return false
end
MoreTooltipInfo.NewProfile(infoType, classID, specID, profileName, data, true, color, value, useOnUI)
return true
end
function MoreTooltipInfo.AzeritePowerTooltip(destination, azeritePowerID)
if azeritePowerID then
MoreTooltipInfo.TooltipLine(destination, azeritePowerID, "Azerite Power ID")
end
end
function MoreTooltipInfo.ItemTooltipOverride(self)
local itemLink = select(2, self:GetItem())
if itemLink then
local itemID = tonumber(MoreTooltipInfo.GetIDFromLink("item",itemLink))
if itemID then
if cfg.enableItemID then MoreTooltipInfo.TooltipLine(self, itemID, "ItemID") end
local itemSplit = MoreTooltipInfo.GetItemSplit(itemLink)
local bonusID = MoreTooltipInfo.GetItemBonusID(itemSplit)
if bonusID then
if cfg.enableItemBonusID then MoreTooltipInfo.TooltipLine(self, bonusID, "BonusID") end
end
local enchantID = itemSplit[2]
if enchantID > 0 then
if cfg.enableItemEnchantID then MoreTooltipInfo.TooltipLine(self, enchantID, "EnchantID") end
local enchantSpellID = DBC.SpellEnchants[enchantID]
if enchantSpellID then --enchant, we put enchant spellid and rppm
if cfg.enableItemEnchantSpellID then MoreTooltipInfo.TooltipLine(self, enchantSpellID, "Enchant SpellID") end
if cfg.enableItemEnchantSpellRPPM then MoreTooltipInfo.RPPMTooltip(self, enchantSpellID, "Enchant RPPM") end
end
end
if cfg.enableItemGemID then MoreTooltipInfo.getGemString(self,itemLink) end
local spellID = MoreTooltipInfo.GetItemSpellID(itemID)
if spellID then
if cfg.enableItemSpellID then MoreTooltipInfo.TooltipLine(self, spellID, "SpellID") end
if cfg.enableItemRPPM then MoreTooltipInfo.RPPMTooltip(self, spellID) end
end
if cfg.enableBaseItemDPS then MoreTooltipInfo.ItemDPSTooltip(self, itemLink, itemID, "base") end
if cfg.enablePersonnalItemDPS then MoreTooltipInfo.ItemDPSTooltip(self, itemLink, itemID, "perso") end
if cfg.enableLegendaryItemDPS then MoreTooltipInfo.ItemDPSTooltip(self, itemLink, itemID, "legendary") end
end
end
end
function MoreTooltipInfo.SpellTooltipOverride(option, self, ...)
local spellID
local talentID = 0
local conduitID = 0
if option == "default" then
spellID = select(2, self:GetSpell())
--Todo : disable when in talent tooltip to let the talent part manage itself
elseif option == "aura" then
spellID = select(10, UnitAura(...))
elseif option == "buff" then
spellID = select(10, UnitBuff(...))
elseif option == "debuff" then
spellID = select(10, UnitDebuff(...))
elseif option == "conduit" then
conduitID = select(1, ...)
spellID = C_Soulbinds.GetConduitSpellID(conduitID,select(2, ...))
elseif option == "talent" then
talentID = select(1, ...)
spellID = select(6, GetTalentInfoByID(talentID))
elseif option == "ref" then
spellID = MoreTooltipInfo.GetIDFromLink("spell", self)
self = ItemRefTooltip
end
if spellID then
if option ~= "conduit" then
if cfg.enableSpellID then MoreTooltipInfo.TooltipLine(self, spellID, "SpellID") end
end
if cfg.enableSpellRPPM then MoreTooltipInfo.RPPMTooltip(self, spellID) end
if cfg.enableSpellGCD then MoreTooltipInfo.GCDTooltip(self, spellID) end
if option == "conduit" then
local conduitRank = select(2, ...)
if cfg.enableConduitID then MoreTooltipInfo.TooltipLine(self, conduitID, "ConduitID") end
if cfg.enableConduitRank then MoreTooltipInfo.TooltipLine(self, conduitRank, "ConduitRank") end
if cfg.enableConduitSpellID then MoreTooltipInfo.TooltipLine(self, spellID, "ConduitSpellID") end
if cfg.enableConduitDPS then MoreTooltipInfo.SpellDPSTooltip(self, spellID, option, conduitRank) end
end
MoreTooltipInfo.SpellDPSTooltip(self, spellID, "soulbind")
if cfg.enableTextureID then
local spellTexture = GetSpellTexture(spellID)
if spellTexture then MoreTooltipInfo.TooltipLine(self, spellTexture, "TextureID") end
end
if talentID > 0 then
if cfg.enableSpellTalentID then MoreTooltipInfo.TooltipLine(self, talentID, "TalentID") end
MoreTooltipInfo.SpellDPSTooltip(self, spellID, option)
end
end
end
function MoreTooltipInfo.UnitTooltipOverride(self)
if cfg.enableNPCID then
local unit = select(2, self:GetUnit())
if unit then
local guid = UnitGUID(unit) or ""
local id = tonumber(guid:match("-(%d+)-%x+$"), 10)
if id and guid:match("%a+") ~= "Player" then MoreTooltipInfo.TooltipLine(self, id, "NPC ID") end
end
end
end
function MoreTooltipInfo.ManageTooltips(tooltipType, option, ...)
--print(tooltipType, option)
if tooltipType =="spell" then
MoreTooltipInfo.SpellTooltipOverride(option, ...)
elseif tooltipType =="item" then
MoreTooltipInfo.ItemTooltipOverride(...)
elseif tooltipType =="unit" then
MoreTooltipInfo.UnitTooltipOverride(...)
end
end
function MoreTooltipInfo:initDB(db, defaults)
if type(db) ~= "table" then db = {} end
if type(defaults) ~= "table" then return db end
for k, v in pairs(defaults) do
if type(v) == "table" then
db[k] = MoreTooltipInfo:initDB(db[k], v)
elseif type(v) ~= type(db[k]) then
db[k] = v
end
end
return db
end
-------------------
-- Interface UI --
-------------------
StaticPopupDialogs["MTI_CONFIRM_EXISTS_POPUP"] = {
text = "The profile %s already exists. Do you want to overwrite it?",
button1 = "Yes",
button2 = "No",
OnAccept = function(self, data, data2)
DeleteProfile(data["classID"],data["specID"],data["profileName"])
MoreTooltipInfo.NewProfile(data["type"], data["classID"], data["specID"], data["profileName"], data["data"], data["enable"], data["color"], data["string"], data["useOnUI"])
OpenProfileUI()
end,
timeout = 0,
cancels = "MTI_IMPORT_POPUP",
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopupDialogs["MTI_CONFIRM_USEONUI_POPUP"] = {
text = "A profile is already shown on UI. Do you want to overwrite it?",
button1 = "Yes",
button2 = "No",
OnAccept = function(self, data, data2)
UIParameters.talentOnUILoaded = false
DisableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, data["profileName"])
EnableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopupDialogs["MTI_EXISTS_POPUP"] = {
text = "The profile %s already exists. ",
button1 = "Cancel",
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopupDialogs["MTI_RENAME_POPUP"] = {
text = "New profile name for %s?",
button1 = "Validate",
button2 = "Cancel",
OnShow = function (self, data)
self.editBox:SetText(UIParameters.currentProfile)
end,
OnAccept = function(self, data, data2)
if profiles[UIParameters.currentType][UIParameters.currentClassID][UIParameters.currentSpecID][self.editBox:GetText()] ~= nil then
StaticPopup_Show("MTI_EXISTS_POPUP",self.editBox:GetText())
return false
end
RenameProfile(UIParameters.currentClassID,UIParameters.currentSpecID,UIParameters.currentProfile,self.editBox:GetText())
OpenProfileUI()
end,
timeout = 0,
hasEditBox = true,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopupDialogs["MTI_DELETE_POPUP"] = {
text = "Are you sure you want to delete the profile %s?",
button1 = "Yes",
button2 = "No",
OnAccept = function()
DeleteProfile(UIParameters.currentClassID,UIParameters.currentSpecID,UIParameters.currentProfile)
OpenProfileUI()
end,
timeout = 0,
showAlert = true,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
StaticPopupDialogs["MTI_IMPORT_POPUP"] = {
text = "New Profile",
button1 = "Validate",
button2 = "Cancel",
OnAccept = function(self, data, data2)
MoreTooltipInfo.ValidateItemPersonnalData("test",self.editBox:GetText())
OpenProfileUI()
end,
timeout = 0,
exclusive = true,
hasEditBox = true,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
}
function DrawOptionGroup(classID, specID, profileName)
if UIParameters.detailsLoaded then
if not UIParameters.detailsDrawn then
UIElements.mainframe:AddChild(UIElements.detailsGroup)
UIParameters.detailsDrawn = true
end
--print("draw "..classID.." "..specID.." "..profileName)
UIParameters.currentProfile = profileName
UIParameters.currentClassID = classID
UIParameters.currentSpecID = specID
UIElements.titleLabel:SetText(profileName)
UIElements.enablecheckbox:SetValue(profiles[UIParameters.currentType][classID][specID][profileName]["enable"])
UIElements.useOnUIChechbox:SetValue(profiles[UIParameters.currentType][classID][specID][profileName]["useOnUI"])
local r,g,b = hex2rgb(profiles[UIParameters.currentType][classID][specID][profileName]["color"])
UIElements.colorpicker:SetColor(r/255,g/255,b/255,1)
else
print("settings not loaded")
end
end
function RenameProfile(classID, specID, profileName, newName)
--print("rename "..classID.." "..specID.." "..profileName.." to "..newName)
profiles[UIParameters.currentType][classID][specID][newName] = profiles[UIParameters.currentType][classID][specID][profileName];
profiles[UIParameters.currentType][classID][specID][profileName] = nil
end
function DeleteProfile(classID, specID, profileName)
--print("delete "..classID.." "..specID.." "..profileName)
profiles[UIParameters.currentType][classID][specID][profileName] = nil
--clean Empty tables
local profilesCountClass = 0
local profilesCountSpec = 0
for k1, v1 in pairs(profiles[UIParameters.currentType]) do
profilesCountClass = 0
for k2, v2 in pairs(v1) do
profilesCountSpec = 0
for k3, v3 in pairs(v2) do
profilesCountClass = profilesCountClass + 1
profilesCountSpec = profilesCountSpec + 1
end
if profilesCountSpec == 0 then
profiles[UIParameters.currentType][k1][k2] = nil
end
end
if profilesCountClass == 0 then
profiles[UIParameters.currentType][k1] = nil
end
end
end
function EnableProfile(classID, specID, profileName)
--print("enable "..classID.." "..specID.." "..profileName)
profiles[UIParameters.currentType][classID][specID][profileName]["enable"] = true
end
function DisableProfile(classID, specID, profileName)
--print("disable "..classID.." "..specID.." "..profileName)
profiles[UIParameters.currentType][classID][specID][profileName]["enable"] = false
end
function EnableOnUI(classID, specID, profileName)
--print("enable "..classID.." "..specID.." "..profileName)
profiles[UIParameters.currentType][classID][specID][profileName]["useOnUI"] = true
end
function DisableOnUI(classID, specID, profileName)