-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathItemLevelDisplay.lua
More file actions
980 lines (961 loc) · 28.2 KB
/
ItemLevelDisplay.lua
File metadata and controls
980 lines (961 loc) · 28.2 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
local __FILE__=tostring(debugstack(1,2,0):match("(.*):1:")) -- MUST BE LINE 1
local toc=select(4,GetBuildInfo())
local me, ns = ...local pp=print
--@debug@
C_AddOns.LoadAddOn("Blizzard_DebugTools")
C_AddOns.LoadAddOn("LibDebug")
if LibDebug then LibDebug() ns.print=print else ns.print=function() end end
--@end-debug@
--[===[@non-debug@
ns.print=function() end
--@end-non-debug@]===]
local select=select
local INVSLOT_AMMO = INVSLOT_AMMO
local INVSLOT_HEAD = INVSLOT_HEAD
local INVSLOT_NECK = INVSLOT_NECK
local INVSLOT_SHOULDER = INVSLOT_SHOULDER
local INVSLOT_BODY = INVSLOT_BODY
local INVSLOT_CHEST = INVSLOT_CHEST
local INVSLOT_WAIST = INVSLOT_WAIST
local INVSLOT_LEGS = INVSLOT_LEGS
local INVSLOT_FEET = INVSLOT_FEET
local INVSLOT_WRIST = INVSLOT_WRIST
local INVSLOT_HAND = INVSLOT_HAND
local INVSLOT_FINGER1 = INVSLOT_FINGER1
local INVSLOT_FINGER2 = INVSLOT_FINGER2
local INVSLOT_TRINKET1 = INVSLOT_TRINKET1
local INVSLOT_TRINKET2 = INVSLOT_TRINKET2
local INVSLOT_BACK = INVSLOT_BACK
local INVSLOT_MAINHAND = INVSLOT_MAINHAND
local INVSLOT_OFFHAND = INVSLOT_OFFHAND
local INVSLOT_RANGED = INVSLOT_RANGED
local INVSLOT_TABARD = INVSLOT_TABARD
local INVSLOT_FIRST_EQUIPPED = INVSLOT_FIRST_EQUIPPED;
local INVSLOT_LAST_EQUIPPED = INVSLOT_LAST_EQUIPPED
local slots={
head='HeadSlot',
neck='NeckSlot',
shoulder='ShoulderSlot',
back='BackSlot',
chest='ChestSlot',
shirt='ShirtSlot',
tabard='TabardSlot',
wrist='WristSlot',
hands='HandsSlot',
waist='WaistSlot',
legs='LegsSlot',
feet='FeetSlot',
finger0='Finger0Slot',
finger1='Finger1Slot',
trinket0='Trinket0Slot',
trinket1='Trinket1Slot',
mainhand='MainHandSlot',
secondaryhand='SecondaryHandSlot',
}
local addon=LibStub("LibInit"):NewAddon(ns,me,{noswitch=false,profile=true,enhancedProfile=true},'AceHook-3.0','AceEvent-3.0','AceTimer-3.0') --#Addon
--@debug@
addon.debug = true
addon:Debug("Started with debug enabled")
--@end-debug@
local L=addon:GetLocale()
local C=addon:GetColorTable()
local print=ns.print or print
local debug=ns.debug or print
local bagSlots={}
local NUM_LE_ITEM_CLASSES=19
addon:Debug("NUM_LE_ITEM_CLASSES",NUM_LE_ITEM_CLASSES)
local LE_ITEM_CLASS_ARMOR=_G.Enum.ItemClass.Armor
local LE_ITEM_CLASS_WEAPON=_G.Enum.ItemClass.Weapon
local modules={}
local fontObject={}
local offset=0
function fontObject:SetFont(a,b,c)
self.a=a
self.b=b
self.c=c
end
function fontObject:GetFont(a,b,c)
return self.a,self.b,self.c
end
fontObject:SetFont(Game11Font:GetFont())
-----------------------------------------------------------------
---- ContainerFrameItem<n> (backpack
-- ContainerFrame<2-5>Item<n> bagwww
-- InspectPaperDollItemsFrame
-- Inspect<name>Slot
--------------------------------------
local l=C_AddOns.GetNumAddOns()
local baggers={"Blizzard"}
for i=1,l do
local name, title, notes, loadable, reason, security, newVersion = C_AddOns.GetAddOnInfo(i)
if name:find('ILD-')==1 then
local dep1,dep2=C_AddOns.GetAddOnDependencies(i)
if dep1=="ItemLevelDisplay" then
tinsert(baggers,dep2)
else
tinsert(baggers,dep1)
end
end
end
local colorScheme={
lvup=L['itemlevel (red best)'],
lvdn=L['itemlevel (green best)'],
qual=L['quality'],
plain=L['none (plain white)']
}
local positionScheme={
br=L['Bottom Right'],
tr=L['Top Right'],
tl=L['Top Left'],
bl=L['Bottom Left'],
bc=L['Bottom Center'],
tc=L['Top Center']
}
local bagPositionScheme={
br=L['Bottom Right'],
tr=L['Top Right'],
tl=L['Top Left'],
bl=L['Bottom Left'],
bc=L['Bottom Center'],
tc=L['Top Center']
}
local outlineScheme={
[""]=L["No shadow"],
["OUTLINE"]=L["Light shadow"],
["OUTLINE,THICKOUTLINE"]=L["Strong shadow"]
}
local class2sort={}
local function classList(self)
local iclasses=self:NewTable()
local sorted=self:NewTable()
local classes={}
for i=0,NUM_LE_ITEM_CLASSES-1 do
local name=GetItemClassInfo(i)
if name and not name:find('%(') then
iclasses[name]=i
tinsert(sorted,name)
end
end
table.sort(sorted)
for i,v in ipairs(sorted) do
class2sort[iclasses[v]]=i
classes[i]=v
end
self:DelTable(iclasses)
self:DelTable(sorted)
return {
[class2sort[LE_ITEM_CLASS_ARMOR]]=true,
[class2sort[LE_ITEM_CLASS_WEAPON]]=true
},
classes
end
local bagmanagerName="Blizzard Bags"
local bagmanager="blizzardbags"-- Baggers management function . Base definition is nop
local function findItemButtons() end
local function canDisplayLevel() end
local function nop() end
--
local _G=_G
local type=type
local pairs=pairs
local GetItemStats=C_Item.GetItemStats
local GetInventorySlotInfo=GetInventorySlotInfo
local GetAverageItemLevel=GetAverageItemLevel
local GetItemQualityColor=C_Item.GetItemQualityColor
local function GetItemInfo(item,index)
return select(index,C_Item.GetItemInfo(item))
end
local LSM=LibStub("LibSharedMedia-3.0")
--local I=LibStub("LibItemUpgradeInfo-1.0")
--------------------------------------
local addonName="ILD"
local EQUIPMENTFLYOUT_FIRST_SPECIAL_LOCATION=EQUIPMENTFLYOUT_FIRST_SPECIAL_LOCATION
local ITEM_QUALITY_COLORS=ITEM_QUALITY_COLORS
local range=8
local average=1
local markdirty
local blue={0, 0.6, 1}
local red={1, 0.4, 0.4}
local yellow={1, 1, 0}
local meta={1, 1, 1}
local green={0,1,0}
local dirty=true
local flyoutDrawn={}
local eventframe=nil
local redGems, blueGems, yellowGems, metaGems = 0, 0, 0, 0
local gems={}
local profilelabel={name=''}
local textures={
blue = "Interface\\Icons\\inv_misc_cutgemsuperior2",
red = "Interface\\Icons\\inv_misc_cutgemsuperior6",
yellow = "Interface\\Icons\\inv_misc_cutgemsuperior",
meta = "Interface\\Icons\\INV_Jewelcrafting_DragonsEye02"
}
local gemcolors={
blue=blue,
red=red,
yellow=yellow,
meta=meta
}
local always=10000 -- Hope not to reach this item level....
local never=-1
--local mop=600
local vanilla=30
local bc=34
local wotlk=35
local cata=38
local mop=45
local drenor=47
local legion=54
local slotsList={
HeadSlot={E=never},
NeckSlot={E=always},
ShoulderSlot={E=mop},
BackSlot={E=always},
ChestSlot={E=always},
ShirtSlot={E=never},
TabardSlot={E=never},
WristSlot={E=always},
HandsSlot={E=mop},
WaistSlot={E=never},
LegsSlot={E=always},
FeetSlot={E=always},
Finger0Slot={E=always},
Finger1Slot={E=always},
Trinket0Slot={E=never},
Trinket1Slot={E=never},
MainHandSlot={E=always},
SecondaryHandSlot={E=mop},
}
local stats={}
local sockets={}
local slots
local islots
local useless={}
local flyouts={}
local gframe
local gred=false
local gblue=false
local gyellow=false
local meta=false
local Red_localized = 52255
local Blue_localized = 52235
local Yellow_localized = 52267
local Green_localized = 52245
local Purple_localized = 52213
local Orange_localized = 52222
local Meta_localized = 52296
function addon:getSockets(itemlink)
--if (not sockets[itemlink]) then
local s=0
local r=0
local b=0
local y=0
local p=0
local tmp=GetItemStats(itemlink)
for k,v in pairs(tmp) do
--debug(k,v)
if (k=="EMPTY_SOCKET_RED") then
r=r+v
elseif (k=="EMPTY_SOCKET_BLUE") then
b=b+v
elseif (k=="EMPTY_SOCKET_YELLOW") then
y=y+v
elseif (k=="EMPTY_SOCKET_META") then
p=p+v
elseif (k=="EMPTY_SOCKET_PRISMATIC") then
p=p+v
end
end
self:DelTable(tmp)
s=r+b+y+p
sockets[itemlink]={s=s,r=r,y=y,b=b,p=p}
--end
return sockets[itemlink]
end
function addon:getNumGems(...)
local s=0
for i=4,7 do
local v=tonumber((select(i,...)))
if v then
s=s+1
end
end
return s
end
function addon:colorGradient(perc, ...)
if perc >= 1 then
local r, g, b = select(select('#', ...) - 2, ...)
return r, g, b
elseif perc <= 0 then
local r, g, b = ...
return r, g, b
end
local num = select('#', ...) / 3
local segment, relperc = math.modf(perc*(num-1))
local r1, g1, b1, r2, g2, b2 = select((segment*3)+1, ...)
return r1 + (r2-r1)*relperc, g1 + (g2-g1)*relperc, b1 + (b2-b1)*relperc
end
function addon:addLayer(f,id,bag,font)
id = id or tostring(f)
local t,e,g=f:CreateFontString(me.."ilevel"..id, "OVERLAY"),nil,nil
t:SetFont(font:GetFont())
t:SetText("")
if not bag then
font="NumberFont_OutlineThick_Mono_Small"
e=f:CreateFontString(me .."enc"..id,"OVERLAY",font)
e:SetText("")
g=f:CreateFontString(me..'gem'..id,"OVERLAY",font)
g:SetText("")
end
self:placeLayer(t,e,g,bag and "tr" or self:GetVar("CORNER"))
return {ilevel=t,gem=g,enc=e,itemlink='new'}
end
local function corner2points(corner)
local positions={
b="BOTTOM",
t="TOP",
r="RIGHT",
l="LEFT",
c=""
}
--debug(corner,corner:sub(1,1),corner:sub(2,2))
return positions[corner:sub(1,1)],positions[corner:sub(2,2)]
end
function addon:placeLayer(t,e,g,position)
local v,h=corner2points(position)
local additional=v=="BOTTOM" and "TOP" or "BOTTOM"
if t then
t:ClearAllPoints()
t:SetHeight(15)
t:SetPoint(v.."LEFT",offset*-1,0)
t:SetPoint(v.."RIGHT",offset*1,0)
if h=="" then h="CENTER" end
t:SetJustifyH(h)
end
if e then
e:ClearAllPoints()
e:SetHeight(15)
e:SetWidth(30)
e:SetPoint(additional .."LEFT")
e:SetJustifyH("LEFT")
e:SetTextColor(1,0,0)
end
if g then
g:ClearAllPoints()
g:SetHeight(15)
g:SetWidth(30)
g:SetPoint(additional .. "RIGHT")
g:SetTextColor(1,0,0)
g:SetJustifyH("RIGHT")
end
end
function addon:loadSlots(prefix,...)
local slots={}
for i=1,select('#',...) do
local frame=select(i,...) -- Got SlotFrame
if frame then
local name=frame:GetName()
if name then
local slotname=name:gsub(prefix,'')
if (slotsList[slotname]) then
local slotId=GetInventorySlotInfo(slotname)
if (slotId) then
slots[slotId]={
frame=self:addLayer(frame,slotId,false,fontObject),
enchantable=slotsList[slotname]['E'],
special=slotsList[slotname]['S'],
}
if (slotname=="TabardSlot" or slotname =="ShirtSlot") then
useless[slotId]=true
end
end
end
end
end
end
return slots
end
function addon:checkLink(link)
local data=select(3,strsplit("|",link))
if (data) then
local enchant=select(3,strsplit(':',data)) or 0
return tonumber(enchant) or 0
else
debug("No data for",link)
return 0
end
end
function addon:ApplyFONT(value)
local file=LSM:Fetch("font",value)
local _,b,c=fontObject:GetFont()
fontObject:SetFont(file,b,c)
self:markDirty()
end
function addon:ApplyFONTSIZE(value)
local a,b,c=fontObject:GetFont()
fontObject:SetFont(a,value,c)
self:markDirty()
end
function addon:ApplyFONTOUTLINE(value)
local a,b,c=fontObject:GetFont()
fontObject:SetFont(a,b,value)
if value=="" then
offset=0
elseif value=="OUTLINE" then
offset=3
else
offset=6
end
self:markDirty()
self:ApplyCORNER(self:GetString("CORNER"))
end
function addon:ApplyBAGSCORNER(value)
self:SendMessage("ILD_APPLY","CORNER",value)
end
function addon:ApplyBAGSFONT(value)
self:SendMessage("ILD_APPLY","FONT",value)
end
function addon:ApplyBAGSFONTSIZE(value)
self:SendMessage("ILD_APPLY","FONTSIZE",value)
end
function addon:ApplyBAGSFONTOUTLINE(value)
self:SendMessage("ILD_APPLY","FONTOUTLINE",value)
end
function addon:ApplyBAGS(value)
local ace=LibStub("AceAddon-3.0")
CloseAllBags()
for _,name in pairs(baggers) do
local modname="ILD-" .. name
local module=ace:GetAddon(modname,true)
if value then
if module then self:Print("Enabling",name) module:Enable() end
else
if module then self:Print("Disabling",name) module:Disable() end
end
end
end
function addon:ApplyCORNER(value)
self:SendMessage("ILD_APPLY","CORNER",value)
if (not slots) then return end
for slotId,data in pairs(slots) do
self:placeLayer(data.frame.ilevel,data.frame.enc,data.frame.gem,value)
end
end
function addon:ApplyGEMCORNER(value)
self:placeGemLayer()
end
function addon:Apply(...)
self:markDirty()
end
function addon:removedgetGemColors(gem)
local empty={r=0,p=0,b=0,y=0}
if (not gem) then return empty end
if (false or not gems[gem]) then
local r,b,y,p=0,0,0,0
local testGem = (select(7, GetItemInfo(gem)))
if testGem == Red_localized then
r=1
elseif testGem == Blue_localized then
b=1
elseif testGem == Yellow_localized then
y=1
elseif testGem == Green_localized then
b=1
y=1
elseif testGem == Purple_localized then
r=1
b=1
elseif testGem == Orange_localized then
r=1
y=1
elseif testGem == Meta_localized then
p=1
else
p=0
end
gems[gem]={r=r,b=b,y=y,p=p}
debug(testGem,r,b,y,p)
end
return gems[gem]
end
function addon:getColors(itemRarity,itemLevel)
-- Apply actual color scheme
if (self:GetVar('COLORSCHEME')=='qual') then
local q=ITEM_QUALITY_COLORS[itemRarity]
if (not q) then
return 1,1,1
else
return q.r,q.g,q.b
end
elseif (self:GetVar("COLORSCHEME")=='plain') then
return 1.0,1.0,1.0,1.0
else
-- Only the two level based schemes are left
local g =(itemLevel-average)/(range*2)
if (self:GetVar("COLORSCHEME")=='lvup') then
return self:colorGradient(g,0,1,0,1,1,0,1,0,0)
else
return self:colorGradient(g,1,0,0,1,1,0,0,1,0)
end
end
end
function addon:paintButton(target,t,slotId,itemLink,average,enchantable)
local itemLocation=target=='player' and ItemLocation:CreateFromEquipmentSlot(slotId) or nil
if not itemLink then
t.gem:Hide()
t.enc:Hide()
t.ilevel:Hide()
return
end
t.ilevel:Show()
local itemRarity=tonumber(GetItemInfo(itemLink,3) or -1)
if type(itemLink)=="number" then itemLink=GetItemInfo(itemLink,2) end
local ilevel=itemLocation and C_Item.GetCurrentItemLevel(itemLocation) or C_Item.GetDetailedItemLevelInfo(itemLink)
if type(ilevel)~="number" then
ilevel=0
end
t.ilevel:SetFormattedText("%3d",ilevel)
t.ilevel:SetTextColor(self:getColors(itemRarity,ilevel))
t.ilevel:SetFont(fontObject:GetFont())
if (enchantable > (ilevel) and self:GetToggle("SHOWENCHANT") ) then
local enchval=self:checkLink(itemLink)
if (enchval<1) then
t.enc:SetText(L["E"])
t.enc:Show()
else
t.enc:Hide()
end
else
t.enc:Hide()
end
local sockets=self:getSockets(itemLink)
local gems=self:getNumGems(strsplit(':',itemLink))
local loc=GetItemInfo(itemLink,9)
if (sockets.s > gems and self:GetToggle("SHOWSOCKETS")) then
t.gem:SetText("S")
t.gem:Show()
elseif ((ilevel)<601 and sockets.s==0 and loc == "INVTYPE_WAIST" and self:GetToggle("SHOWBUCKLE")) then
t.gem:SetText("B")
t.gem:Show()
else
t.gem:Hide()
end
end
--[[
InspectPaperDollFrame or some thing like that
--]]--[[
Scans my slots
--]]
function addon:slotsCheck (...)
if (not dirty) then return end
if (not PaperDollItemsFrame:IsVisible()) then return end
if (not slots) then slots=self:loadSlots("Character",PaperDollItemsFrame:GetChildren()) end
average=GetAverageItemLevel()-range -- 1 tier up are full green
local trueAvg=0
for slotId,data in pairs(slots) do
if (data.frame) then
local itemLocation = ItemLocation:CreateFromEquipmentSlot(slotId)
local itemLink = itemLocation and itemLocation:IsValid() and C_Item.GetItemLink(itemLocation) or nil
if itemLink then
self:paintButton('player',data.frame,slotId,itemLink,average,self:Is("DEATHKNIGHT") and data.enchantable or never)
else
self:paintButton('player',data.frame,slotId)
end
end
end
end
--[[
Scans inspect slots
It stays fake until Inspect Frame gets loaded
--]]
function addon:inspectCheck()
end
function addon:realinspectCheck (...)
if (not InspectPaperDollItemsFrame:IsVisible()) then return end
if (not islots) then islots=self:loadSlots("Inspect",InspectPaperDollItemsFrame:GetChildren()) end
average=GetAverageItemLevel()-range -- 1 tier up are full green
local trueAvg=0
for slotId,data in pairs(islots) do
local itemLink=GetInventoryItemLink("target",slotId)
if (itemLink) then
local itemLocation=ItemLocation:CreateFromEquipmentSlot(slotId)
local ilvl=C_Item.GetDetailedItemLevelInfo(itemLink)
if slotId==INVSLOT_OFFHAND then
-- local mainilvl=I:GetUpgradedItemLevel(GetInventoryItemLink("player",INVSLOT_MAINHAND))
local mainilvl=C_Item.GetDetailedItemLevelInfo(itemLink)
if ilvl < mainilvl then
itemLink=GetInventoryItemLink("target",INVSLOT_MAINHAND)
end
else
local offhand=GetInventoryItemLink("target",INVSLOT_OFFHAND)
if (offhand) then
-- local offilvl=I:GetUpgradedItemLevel(offhand)
local offilvl=C_Item.GetDetailedItemLevelInfo(itemLink)
if ilvl < offilvl then
itemLink=offhand
end
end
end
self:paintButton('target',data.frame,slotId,itemLink,average,self:Is("DEATHKNIGHT") and data.enchantable or never)
else
self:paintButton('target',data.frame,slotId)
end
end
end
local scheduled
function addon:markDirty()
dirty=true
self:slotsCheck()
self:inspectCheck()
end
function addon:removedloadGemLocalizedStrings()
Red_localized = select(7, GetItemInfo(Red_localized))
Blue_localized = select(7, GetItemInfo(Blue_localized))
Yellow_localized = select(7, GetItemInfo(Yellow_localized))
Green_localized = select(7, GetItemInfo(Green_localized))
Purple_localized = select(7, GetItemInfo(Purple_localized))
Orange_localized = select(7, GetItemInfo(Orange_localized))
debug(Meta_localized,GetItemInfo(Meta_localized))
Meta_localized = select(7,GetItemInfo(Meta_localized))
debug(Meta_localized)
end
local lastitemid=nil
function addon:EquipmentFlyout_DisplayButton(button,s)
local location,itemLink = button.location,nil;
local sa = button:GetName()
local where=sa:find('%d+$')
local id=tonumber(sa:sub(where))
if id > 1 then
local itemID, name, textureName, count, durability, maxDurability, invType, locked, start, duration, enable, setTooltip, quality, isUpgrade, isBound = EquipmentManager_GetItemInfoByLocation(location);
if (itemID==lastitemid) then return end
lastitemid=itemID
if (not flyouts[id]) then
flyouts[id]={frame=self:addLayer(button,"fly" .. id,false,fontObject)}
end
if ( location >= EQUIPMENTFLYOUT_FIRST_SPECIAL_LOCATION ) then
self:paintButton('player',flyouts[id].frame)
return
end
local key=id..tostring(s)
if (flyoutDrawn[key]) then return end
flyoutDrawn[key]=true
if (not slots) then self:loadSlots(PaperDollItemsFrame:GetChildren()) end
if (not slots[button.id]) then self:Debug("No slot",button.id) return end
local data= EquipmentManager_GetLocationData(location)
local isPlayer, isBank, isBags, slot, bag = data.isPlayer, data.isBank, data.isBags, data.slot, data.bag
if ( not isPlayer and not isBank and not isBags ) then -- Invalid location
return;
end
local rc
itemLink=nil
if (isBags and slot) then
if bag then itemLink=C_Container.GetContainerItemLink(bag,slot) end
elseif (isPlayer and slot) then
itemLink=GetInventoryItemLink("player",slot)
else
itemLink=nil
end
if (itemLink) then
self:paintButton('flyout',flyouts[id].frame,button.id,itemLink,average,slots[button.id].enchantable)
end
end
end
function addon:IsClassEnabled(class)
if type(class)~="number" then return false end
return self:GetVar("CLASSES")[class2sort[class]]
end
local function wipefly()
wipe(flyoutDrawn)
end
function addon:OnInitialized()
self.OptionsTable.args.on=nil
self.OptionsTable.args.off=nil
self.OptionsTable.args.standby=nil
-- GetItemInfo=I:GetCachingGetItemInfo()
profilelabel=self:AddText(L['Current profile is: '] .. C(self.db:GetCurrentProfile(),'green'))
profilelabel.fontSize="large"
--self:AddAction('switchProfile',L['Choose profile'],L['Switch between global and per character profile'])
self:AddLabel(L['Options'],L['Choose what is shown'])
self:AddToggle('SHOWENCHANT',true,L['Shows missing enchants']).width="full"
self:AddToggle('SHOWSOCKETS',true,L['Shows number of empty socket']).width="full"
self:SetBoolean('SHOWBUCKLE',false)
self:AddToggle('SHOWUSELESSILEVEL',false,L['Show iLevel on shirt and tabard']).width='full'
self:AddLabel(L['Appearance'],L['Change colors and appearance'])
self:AddSelect('CORNER',"br",positionScheme,L['Level text aligned to'],L['Position']).width="full"
self:AddSelect('COLORSCHEME',"qual",colorScheme,L['Colorize level text by'], L['Choose a color scheme'] ).width="full"
self:AddSelect('FONT',"Fritz Quadrata TT",LSM:HashTable('font'),L["Choose a font"]).dialogControl="LSM30_Font"
self:AddRange('FONTSIZE',11,9,15,L["Choose a font size"])
self:AddSelect('FONTOUTLINE',outlineScheme[1],outlineScheme,L["Choose a shadow"])
self:AddLabel(L['Bags'],L['Manages itemlevel in bags'])
self:AddToggle('BAGS',true,L["Show iLevel in bags"],L['Will have full effect on NEXT reload'])
self:AddSlider('BAGSLEVELS',1,1,1000,L["Minimum shown iLevel"],L["Items under this iLevel will not have the iLevel shown"])
self:AddSelect('BAGSCORNER',"tr",bagPositionScheme,L['Level text aligned to'],L['Position']).width="full"
self:AddSelect('BAGSFONT',"Fritz Quadrata TT",LSM:HashTable('font'),L["Choose a font"]).dialogControl="LSM30_Font"
self:AddRange('BAGSFONTSIZE',11,9,15,L["Choose a font size"])
self:AddSelect('BAGSFONTOUTLINE',outlineScheme["OUTLINE"],outlineScheme,L["Choose a shadow"])
local default, classes=classList(self)
self:AddMultiSelect("CLASSES",default,classes,L['Only show iLevel for selected classes'])
self:AddOpenCmd('showinfo',"cmdInfo",L["Debug info"],L["Show raw item info.Please post the screenshot to Curse Forum"]).width="full"
self:loadHelp()
self:RegisterEvent("UNIT_INVENTORY_CHANGED","markDirty")
local toc=select(4,GetBuildInfo())
if not self.db.char.toc or self.db.char.toc < toc then
self:SetVar("BAGSLEVELS",1)
self.db.char.toc=toc
end
if not self.db.global.hascommon then
local myprofile=self.db:GetCurrentProfile()
if (myprofile~='Default') then
self.db:SetProfile('Default')
self.db:CopyProfile(myprofile)
self.db:SetProfile(myprofile)
end
self.db.global.hascommon=true
end
self:ApplySettings()
self:SecureHookScript(CharacterFrame,"OnShow","slotsCheck")
self:SecureHookScript(EquipmentFlyoutFrameButtons,"OnHide",wipefly)
self:SecureHookScript(EquipmentFlyoutFrameButtons,"OnShow",wipefly)
average=GetAverageItemLevel()-range -- 1 tier up are full green
self:SecureHook("EquipmentFlyout_DisplayButton")
self:RegisterEvent("ARTIFACT_XP_UPDATE")
self:RegisterEvent("ADDON_LOADED")
self:RegisterEvent("ADDON_ACTION_FORBIDDEN")
self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
end
function addon:ARTIFACT_XP_UPDATE(event,...)
self:slotsCheck()
end
function addon:ADDON_ACTION_FORBIDDEN(...)
self:Debug(...)
self:Debug(debugstack())
end
function addon:PLAYER_EQUIPMENT_CHANGED(event,...)
self:slotsCheck()
end
function addon:ADDON_LOADED(event,addonName)
if addonName=="Blizzard_InspectUI" then
self.inspectCheck=self.realinspectCheck
self:SecureHookScript(InspectPaperDollItemsFrame,"OnShow","inspectCheck")
self:ScheduleTimer("inspectCheck",0.5)
end
end
function addon:TRANSMOGRIFY_SUCCESS(event,slot)
self:slotsCheck()
--ilevel doesnt change, keeping it around just in case
end
function addon:removedaddGemLayer()
gframe=CreateFrame("frame",addonName .. "main",PaperDollFrame,"BackdropTemplate")
local alarframe=LibStub("AlarFrames-3.0",true)
gframe:SetHeight(75)
gframe:SetWidth(50)
gframe:SetFrameStrata("FULLSCREEN")
if (alarframe) then
alarframe:TTAdd(gframe,L["Total compatible gems/Total sockets"],false)
end
local x=0
for i,k in pairs(textures) do
self["button"..i] = PaperDollItemsFrame:CreateTexture(addonName.."button"..i, "OVERLAY")
local frame = self["button"..i]
frame:SetHeight(15)
frame:SetWidth(15)
frame.text = PaperDollItemsFrame:CreateFontString(addonName.."text"..i, "OVERLAY", "NumberFontNormal")
frame.text:SetParent(gframe)
frame.text:SetPoint("LEFT", frame, "RIGHT", 5, 0)
frame.text:SetText("0")
frame:SetTexture(k)
frame.text:SetTextColor(unpack(gemcolors[i]))
frame:SetParent(gframe)
frame:SetPoint("TOPLEFT",0,-20*x)
x=x+1
end
self:placeGemLayer()
end
function addon:placeGemLayer()
if (not gframe) then return end
local first=true
local previous
local v,h=corner2points(self:GetVar("GEMCORNER"))
local x,y=0,0
local notv
if (v=="TOP") then
y=-65
else
y=40
end
if (h=="LEFT") then
x=55
else
h="LEFT"
x=240
end
gframe:ClearAllPoints()
gframe:SetPoint(v..h,PaperDollFrame,v..h,x,y)
end
local wininfo
local profiles={}
function addon:switchProfile(fromPanel)
local gui=LibStub("AceGUI-3.0")
wininfo=gui:Create("Window")
wininfo:SetWidth(500)
wininfo:SetHeight(180)
wininfo:SetLayout('Flow')
wininfo:SetTitle('ItemLevelDisplay')
wininfo:SetUserData("currentprofile",self.db:GetCurrentProfile())
wininfo:SetUserData("newprofile",self.db:GetCurrentProfile())
-- wininfo:SetStatusText("")
local l0=gui:Create("Label")
local l1=gui:Create("Label")
local l2=gui:Create("Label")
l0:SetFontObject(GameFontNormalLarge)
l1:SetFontObject(GameFontWhite)
l2:SetFontObject(GameFontWhite)
l0:SetText(L["Please, choose between global or per character profile"])
l0:SetColor(C.Yellow())
l1:SetText(L['You can now choose if you want all your character share the same configuration or not.'])
l2:SetText(L['You can change this decision on a per character basis in configuration panel.'])
l0:SetFullWidth(true)
l1:SetFullWidth(true)
l2:SetFullWidth(true)
local g=gui:Create("Dropdown")
g:SetList({Default=L["Common profile for all characters"],character=L["Per character profile"]},{'Default','character'})
local profile=self.db:GetCurrentProfile()
if (profile=='Default') then
g:SetValue('Default')
else
g:SetValue('character')
end
g:SetFullWidth(true)
g:SetCallback('OnValueChanged',function(widget,method,key)
if (key=='Default') then
wininfo:SetUserData("newprofile","Default")
else
wininfo:SetUserData("newprofile",self.db.keys.char)
end
end)
local b=gui:Create("Button")
b:SetText(SAVE)
b:SetCallback('OnClick',
function(this)
if (wininfo:GetUserData("currentprofile") ~= wininfo:GetUserData("newprofile")) then
self.db:SetProfile(wininfo:GetUserData("newprofile"))
end
profilelabel.name=L['Current profile is: '] .. C(self.db:GetCurrentProfile(),'green')
if (fromPanel) then
self:Gui()
end
self:markDirty()
local widget=this:GetUserData("Father")
self.db.char.choosen=true
widget:Release()
end
)
wininfo:SetCallback("OnClose",function(this) this:Release() end)
wininfo:AddChild(l0)
wininfo:AddChild(l1)
wininfo:AddChild(l2)
wininfo:AddChild(g)
wininfo:AddChild(b)
b:SetPoint("RIGHT")
b:SetUserData("Father",wininfo)
wininfo:Show()
end
function addon:cmdInfo()
local gui=LibStub("AceGUI-3.0")
wininfo=gui:Create("Frame")
wininfo:SetTitle("Please post this screenshot to curse, thanks")
-- wininfo:SetStatusText("Add the expected ilevel for upgraded items")
local rehide=true
if (not CharacterFrame:IsShown()) then
ToggleCharacter("PaperDollFrame")
else
rehide=false
end
--ToggleCharacter("PaperDollFrame")
local gui=LibStub("AceGUI-3.0")
local e=gui:Create("EditBox")
local editable=""
local pattern="%02d.%s: %s <%s> %s"
for slotId,data in pairs(slots) do
local l=gui:Create("Label")
local itemid=GetInventoryItemID("player",slotId)
if (itemid) then
local name,itemlink,itemrarity,ilevel=GetItemInfo(itemid)
local itemlink=GetInventoryItemLink("player",slotId)
local data=select(3,strsplit("|",itemlink or "|||||"))
local e=self:checkLink(itemlink)
l:SetFullWidth(true)
local data=pattern:format(
slotId,
name,
C(ilevel,"green"),
C(I:GetItemLevelUpgrade(I:GetUpgradeID(itemlink)),"orange"),
data or "<empty>"
)
l:SetText(data)
editable=editable .. data .." @ "
wininfo:AddChild(l)
end
end
e:SetText(editable)
e:SetFullWidth(true)
wininfo:AddChild(e)
if rehide then
ToggleCharacter("PaperDollFrame")
end
end
function addon:cmdProfiles()
local gui=LibStub("AceGUI-3.0")
wininfo=gui:Create("Frame")
wininfo:SetTitle("Please post this screenshot to curse, thanks")
-- wininfo:SetStatusText("Add the expected ilevel for upgraded items")
wipe(profiles)
profiles=self.db:GetProfiles(profiles)
for index,name in pairs(profiles) do
local gui=LibStub("AceGUI-3.0")
local l=gui:Create("Label")
l:SetFullWidth(true)
l:SetText(format("%s: %s",index,name))
wininfo:AddChild(l)
end
end
function addon:getEnchantLevel()
local p1,p2=GetProfessions()
if (p1) then
local name,icon,level=GetProfessionInfo(p1)
if (icon=='Interface\\Icons\\INV_Misc_Gem') then
return level
end
end
if (p2) then
local name,icon,level=GetProfessionInfo(p2)
if (icon=='Interface\\Icons\\INV_Misc_Gem') then
return level
end
end
return 0
end
_G.ILD=addon
--@do-not-package@
_G.SLASH_IBAGS1="/ibags"
SlashCmdList['IBAGS'] = function(args,chatframe)
addon:Print("ibags:")
local choosen=tonumber(args) or nil
if type(choosen)=="number" then
choosen=choosen+1
for i=1,#baggers do
if i==choosen then
EnableAddOn(baggers[i])
else
DisableAddOn(baggers[i])
end
ReloadUI()
end
else
for i=1,#baggers do
pp(format("%d. %s",i-1,baggers[i]))
end
end
end
--@do-not-package@