-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTrinketMenu.lua
More file actions
executable file
·1418 lines (1330 loc) · 51.8 KB
/
TrinketMenu.lua
File metadata and controls
executable file
·1418 lines (1330 loc) · 51.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
--[[ TrinketMenu 12.0.5 ]]--
TrinketMenu = { }
local _G, math, tonumber, string, type, pairs, ipairs, table, select = _G, math, tonumber, string, type, pairs, ipairs, table, select
local Masque = LibStub("Masque", true)
local IsClassic = WOW_PROJECT_ID >= WOW_PROJECT_CLASSIC
local IsVanillaClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
local IsRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
-- ids required to support engineering bags
TrinketMenu.BAG = 0 -- 13th return of GetItemInfo on a normal bag
TrinketMenu.ENGINEERING_BAG = 4 -- 13th return of GetItemInfo on an engineering bag
TrinketMenu.TRADE_GOODS = 7 -- 12th return of GetItemInfo on most engineered trinkets
TrinketMenu.DEVICES = 3 -- 13th return of GetItemInfo on most engineered trinkets
TrinketMenu.REQUIRES_ENGINEERING = UNIT_SKINNABLE_BOLTS -- from tooltip when GetItemInfo ambiguous
function TrinketMenu.LoadDefaults()
TrinketMenuOptions = TrinketMenuOptions or {
IconPos = - 100, -- angle of initial minimap icon position
ShowIcon = "ON", -- whether to show the minimap button
SquareMinimap = "OFF", -- whether the minimap is square instead of circular
CooldownCount = "OFF", -- whether to display numerical cooldown counters
CooldownCountBlizzard = "ON", -- whether to display numerical blizzard cooldown counters
CooldownCountOmniCC = "ON", -- whether to display numerical omnicc cooldown counters
LargeCooldown = "ON", -- whether cooldown numbers are large or small
TooltipFollow = "OFF", -- whether tooltips follow the mouse
KeepOpen = "OFF", -- whether menu hides after use
KeepDocked = "ON", -- whether to keep menu docked at all times
Notify = "OFF", -- whether a message appears when a trinket is ready
DisableToggle = "OFF", -- whether minimap button toggles trinkets
NotifyUsedOnly = "OFF", -- whether notify happens only on trinkets used
NotifyChatAlso = "OFF", -- whether to send notify to chat also
Locked = "OFF", -- whether windows can be moved/scaled/rotated
ShowTooltips = "ON", -- whether to display tooltips at all
NotifyThirty = "OFF", -- whether to notify cooldowns at 30 seconds instead of 0
MenuOnShift = "OFF", -- whether menu requires Shift to display
TinyTooltips = "OFF", -- whether tooltips display only name and cooldown
SetColumns = "OFF", -- whether number of columns in menu is chosen automatically
Columns = 4, -- if SetColumns "ON", number of columns before menu wraps
ShowHotKeys = "OFF", -- whether hotkeys show on trinkets
StopOnSwap = "OFF", -- whether to stop auto queue on all manual swaps
--RedRange = "OFF", -- whether to monitor and red out out of range trinkets
HidePetBattle = "ON", -- whether to hide the trinkets while in a pet battle
MenuOnRight = "OFF" -- whether to open menu with right-click
}
TrinketMenuPerOptions = TrinketMenuPerOptions or {
MainDock = "BOTTOMRIGHT", -- corner of main window docked to
MenuDock = "BOTTOMLEFT", -- corner menu window is docked from
MainOrient = "HORIZONTAL", -- direction of main window
MenuOrient = "VERTICAL", -- direction of menu window
XPos = 400, -- left edge of main window
YPos = 400, -- top edge of main window
MainScale = 1, -- scaling of main window
MenuScale = 1, -- scaling of menu window
Visible = "ON", -- whether to display the trinkets
FirstUse = true, -- whether this is the first time this user has used the mod
ItemsUsed = { }, -- table of trinkets used and their cooldown status
Alpha = 1, -- alpha of both windows
Hidden = { } -- table of trinkets hidden
}
end
--[[ Misc Variables ]]--
TrinketMenu_Version = (C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata)("TrinketMenu", "Version")
BINDING_HEADER_TRINKETMENU = "TrinketMenu"
setglobal("BINDING_NAME_CLICK TrinketMenu_Trinket0:LeftButton", "Use Top Trinket")
setglobal("BINDING_NAME_CLICK TrinketMenu_Trinket1:LeftButton", "Use Bottom Trinket")
TrinketMenu.MaxTrinkets = 30 -- add more to TrinketMenu_MenuFrame if this changes
TrinketMenu.BaggedTrinkets = { } -- indexed by number, 1-30 of trinkets in the menu
TrinketMenu.NumberOfTrinkets = 0 -- number of trinkets in the menu
TrinketMenu.CombatQueue = { } -- [0] or [1] = name of trinket queued for slot 0 or 1
TrinketMenu.Corners = {"TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT"}
--[[ Local functions ]]--
-- dock-dependant offset and directions: MainDock..MenuDock
-- x/yoff = offset MenuFrame is positioned to MainFrame
-- x/ydir = direction trinkets are added to menu
-- x/ystart = starting offset when building a menu, relativePoint MenuDock
if IsRetail then
TrinketMenu.DockStats = {
["TOPRIGHTTOPLEFT"] = { xoff = -7, yoff = 0, xdir = 1, ydir = - 1, xstart = 4, ystart = -4 },
["BOTTOMRIGHTBOTTOMLEFT"] = { xoff = -7, yoff = 0, xdir = 1, ydir = 1, xstart = 4, ystart = 48 },
["TOPLEFTTOPRIGHT"] = { xoff = 7, yoff = 0, xdir = - 1, ydir = -1, xstart = -48, ystart = -4 },
["BOTTOMLEFTBOTTOMRIGHT"] = { xoff = 7, yoff = 0, xdir = - 1, ydir = 1, xstart = -48, ystart = 48 },
["TOPRIGHTBOTTOMRIGHT"] = { xoff = 0, yoff = -7, xdir = -1, ydir = 1, xstart = -48, ystart = 48 },
["BOTTOMRIGHTTOPRIGHT"] = { xoff = 0, yoff = 7, xdir = - 1, ydir = -1, xstart = -48, ystart = -4 },
["TOPLEFTBOTTOMLEFT"] = { xoff = 0, yoff = -7, xdir = 1, ydir = 1, xstart = 4, ystart = 48 },
["BOTTOMLEFTTOPLEFT"] = { xoff = 0, yoff = 7, xdir = 1, ydir = - 1, xstart = 4, ystart = -4 }
}
else
TrinketMenu.DockStats = {
["TOPRIGHTTOPLEFT"] = { xoff = -12, yoff = 0, xdir = 1, ydir = - 1, xstart = 8, ystart = -8 },
["BOTTOMRIGHTBOTTOMLEFT"] = { xoff = -12, yoff = 0, xdir = 1, ydir = 1, xstart = 8, ystart = 44 },
["TOPLEFTTOPRIGHT"] = { xoff = 12, yoff = 0, xdir = -1, ydir = -1, xstart = -44, ystart = -8 },
["BOTTOMLEFTBOTTOMRIGHT"] = { xoff = 12, yoff = 0, xdir = -1, ydir = 1, xstart = -44, ystart = 44 },
["TOPRIGHTBOTTOMRIGHT"] = { xoff = 0, yoff = -12, xdir = -1, ydir = 1, xstart = -44, ystart = 44 },
["BOTTOMRIGHTTOPRIGHT"] = { xoff = 0, yoff = 12, xdir = -1, ydir = -1, xstart = -44, ystart = -8 },
["TOPLEFTBOTTOMLEFT"] = { xoff = 0, yoff = -12, xdir = 1, ydir = 1, xstart = 8, ystart = 44 },
["BOTTOMLEFTTOPLEFT"] = { xoff = 0, yoff = 12, xdir = 1, ydir = - 1, xstart = 8, ystart = -8 }
}
end
-- returns offset and direction depending on current docking. ie: TrinketMenu.DockInfo("xoff")
function TrinketMenu.DockInfo(arg1)
local anchor = TrinketMenuPerOptions.MainDock..TrinketMenuPerOptions.MenuDock
if TrinketMenu.DockStats[anchor] and arg1 and TrinketMenu.DockStats[anchor][arg1] then
return TrinketMenu.DockStats[anchor][arg1]
else
return 0
end
end
-- hide the docking markers
function TrinketMenu.ClearDocking()
for i = 1, 4 do
_G["TrinketMenu_MainDock_"..TrinketMenu.Corners[i]]:Hide()
_G["TrinketMenu_MenuDock_"..TrinketMenu.Corners[i]]:Hide()
end
end
-- returns true if the two values are close to each other
function TrinketMenu.Near(arg1, arg2)
return (math.max(arg1, arg2) - math.min(arg1, arg2)) < 15
end
-- moves the MenuFrame to the dock position against MainFrame
function TrinketMenu.DockWindows()
TrinketMenu.ClearDocking()
if TrinketMenuOptions.KeepDocked == "ON" then
TrinketMenu_MenuFrame:ClearAllPoints()
TrinketMenu_MenuFrame:SetPoint(TrinketMenuPerOptions.MenuDock, "TrinketMenu_MainFrame", TrinketMenuPerOptions.MainDock, TrinketMenu.DockInfo("xoff"), TrinketMenu.DockInfo("yoff"))
end
if TrinketMenu_MenuFrame:IsVisible() then
TrinketMenu.BuildMenu()
end
end
-- displays windows vertically or horizontally
function TrinketMenu.OrientWindows()
if TrinketMenuPerOptions.MainOrient == "HORIZONTAL" then
if IsRetail then
TrinketMenu_MainFrame:SetWidth(97)
TrinketMenu_MainFrame:SetHeight(52)
else
TrinketMenu_MainFrame:SetWidth(92)
TrinketMenu_MainFrame:SetHeight(52)
end
else
if IsRetail then
TrinketMenu_MainFrame:SetWidth(52)
TrinketMenu_MainFrame:SetHeight(97)
else
TrinketMenu_MainFrame:SetWidth(52)
TrinketMenu_MainFrame:SetHeight(92)
end
end
end
function TrinketMenu.ScaleFrame(scale)
TrinketMenu.FrameToScale:SetScale(scale)
end
if C_Container then
function TrinketMenu.GetContainerNumSlots(bagID)
return C_Container.GetContainerNumSlots(bagID)
end
function TrinketMenu.GetContainerItemCooldown(bagID, slotIndex)
return C_Container.GetContainerItemCooldown(bagID, slotIndex)
end
function TrinketMenu.GetContainerItemInfo(bagID, slotIndex)
return C_Container.GetContainerItemInfo(bagID, slotIndex)
end
function TrinketMenu.GetContainerItemLink(bagID, slotIndex)
return C_Container.GetContainerItemLink(bagID, slotIndex)
end
function TrinketMenu.PickupContainerItem(bagID, slotIndex)
return C_Container.PickupContainerItem(bagID, slotIndex)
end
function TrinketMenu.GetItemCooldown(itemID)
return C_Container.GetItemCooldown(itemID)
end
else
function TrinketMenu.GetContainerNumSlots(bagID)
return _G.GetContainerNumSlots(bagID)
end
function TrinketMenu.GetContainerItemCooldown(bagID, slotIndex)
return _G.GetContainerItemCooldown(bagID, slotIndex)
end
function TrinketMenu.GetContainerItemInfo(bagID, slotIndex)
local texture, itemCount, locked, quality, readable, lootable, itemLink, isFiltered, noValue, itemID, isBound = _G.GetContainerItemInfo(bagID, slotIndex)
if texture then
return {
iconFileID = texture,
stackCount = itemCount,
isLocked = locked,
quality = quality,
isReadable = readable,
hasLoot = lootable,
hyperlink = itemLink,
isFiltered = isFiltered,
hasNoValue = noValue,
itemID = itemID,
isBound = isBound,
}
end
end
function TrinketMenu.GetContainerItemLink(bagID, slotIndex)
return _G.GetContainerItemLink(bagID, slotIndex)
end
function TrinketMenu.PickupContainerItem(bagID, slotIndex)
return _G.PickupContainerItem(bagID, slotIndex)
end
function TrinketMenu.GetItemCooldown(itemID)
return _G.GetItemCooldown(itemID)
end
end
-- scan inventory and build MenuFrame
function TrinketMenu.BuildMenu()
if not IsShiftKeyDown() and TrinketMenuOptions.MenuOnShift == "ON" then
return
end
local trinketIndex = 1
local _, itemLink, itemID, itemName, equipSlot, itemTexture
-- go through bags and gather trinkets into .BaggedTrinkets
for i = 0, 4 do
for j = 1, TrinketMenu.GetContainerNumSlots(i) do
itemLink = TrinketMenu.GetContainerItemLink(i, j)
if itemLink then
_, _, itemID, itemName = string.find(itemLink, "item:(%d+).+%[(.+)%]")
_, _, _, _, _, _, _, _, equipSlot, itemTexture = C_Item.GetItemInfo(itemID or "")
if equipSlot == "INVTYPE_TRINKET" and (IsAltKeyDown() or not TrinketMenuPerOptions.Hidden[itemID]) then
if not TrinketMenu.BaggedTrinkets[trinketIndex] then
TrinketMenu.BaggedTrinkets[trinketIndex] = { }
end
TrinketMenu.BaggedTrinkets[trinketIndex].id = itemID
TrinketMenu.BaggedTrinkets[trinketIndex].bag = i
TrinketMenu.BaggedTrinkets[trinketIndex].slot = j
TrinketMenu.BaggedTrinkets[trinketIndex].name = itemName
TrinketMenu.BaggedTrinkets[trinketIndex].texture = itemTexture
trinketIndex = trinketIndex + 1
end
end
end
end
TrinketMenu.NumberOfTrinkets = math.min(trinketIndex - 1, TrinketMenu.MaxTrinkets)
if TrinketMenu.NumberOfTrinkets < 1 then
-- user has no bagged trinkets :(
TrinketMenu_MenuFrame:Hide()
else
-- display trinkets outward from docking point
local col, row, xpos, ypos = 0, 0, TrinketMenu.DockInfo("xstart"), TrinketMenu.DockInfo("ystart")
local max_cols = 1
if TrinketMenu.NumberOfTrinkets > 24 then
max_cols = 5
elseif TrinketMenu.NumberOfTrinkets > 18 then
max_cols = 4
elseif TrinketMenu.NumberOfTrinkets > 12 then
max_cols = 3
elseif TrinketMenu.NumberOfTrinkets > 4 then
max_cols = 2
end
if TrinketMenuOptions.SetColumns == "ON" and TrinketMenuOptions.Columns then
max_cols = TrinketMenuOptions.Columns
end
local item, icon
for i = 1, TrinketMenu.NumberOfTrinkets do
item = _G["TrinketMenu_Menu"..i]
icon = _G["TrinketMenu_Menu"..i.."Icon"]
icon:SetTexture(TrinketMenu.BaggedTrinkets[i].texture)
if TrinketMenuPerOptions.Hidden[TrinketMenu.BaggedTrinkets[i].id] then
icon:SetDesaturated(true)
else
icon:SetDesaturated(false)
end
item:SetPoint("TOPLEFT", "TrinketMenu_MenuFrame", TrinketMenuPerOptions.MenuDock, xpos, ypos)
if TrinketMenuPerOptions.MenuOrient == "VERTICAL" then
xpos = xpos + TrinketMenu.DockInfo("xdir") * (IsRetail and 45 or 40)
col = col + 1
if col == max_cols then
xpos = TrinketMenu.DockInfo("xstart")
col = 0
ypos = ypos + TrinketMenu.DockInfo("ydir") * (IsRetail and 45 or 40)
row = row + 1
end
item:Show()
else
ypos = ypos + TrinketMenu.DockInfo("ydir") * (IsRetail and 45 or 40)
col = col + 1
if col == max_cols then
ypos = TrinketMenu.DockInfo("ystart")
col = 0
xpos = xpos + TrinketMenu.DockInfo("xdir") * (IsRetail and 45 or 40)
row = row + 1
end
item:Show()
end
end
for i = (TrinketMenu.NumberOfTrinkets + 1), TrinketMenu.MaxTrinkets do
_G["TrinketMenu_Menu"..i]:Hide()
end
if col == 0 then
row = row - 1
end
if TrinketMenuPerOptions.MenuOrient == "VERTICAL" then
TrinketMenu_MenuFrame:SetWidth((IsRetail and 7 or 12) + (max_cols * (IsRetail and 45 or 40)))
TrinketMenu_MenuFrame:SetHeight((IsRetail and 7 or 12) + ((row + 1) * (IsRetail and 45 or 40)))
else
TrinketMenu_MenuFrame:SetWidth((IsRetail and 7 or 12) + ((row + 1) * (IsRetail and 45 or 40)))
TrinketMenu_MenuFrame:SetHeight((IsRetail and 7 or 12) + (max_cols * (IsRetail and 45 or 40)))
end
TrinketMenu.UpdateMenuCooldowns()
TrinketMenu_MenuFrame:Show()
TrinketMenu.StartTimer("MenuMouseover")
end
end
function TrinketMenu.Initialize()
local options = TrinketMenuOptions
-- set skin
if (Masque and not TrinketMenu.MasqueGroup) then
local group = Masque:Group("TrinketMenu")
TrinketMenu.MasqueGroup = group
group:AddButton(TrinketMenu_Trinket0)
group:AddButton(TrinketMenu_Trinket1)
for i = 1, 30 do
_G["TrinketMenu_Menu"..i]:SetFrameLevel(2)
group:AddButton(_G["TrinketMenu_Menu"..i])
end
end
options.KeepDocked = options.KeepDocked or "ON" -- new option for 2.1
options.Notify = options.Notify or "OFF" -- 2.1
options.DisableToggle = options.DisableToggle or "OFF" -- new option for 2.2
options.NotifyUsedOnly = options.NotifyUsedOnly or "OFF" -- 2.2
options.NotifyChatAlso = options.NotifyChatAlso or "OFF" -- 2.2
options.ShowTooltips = options.ShowTooltips or "ON" -- 2.3
options.NotifyThirty = options.NotifyThirty or "OFF" -- 2.5
options.SquareMinimap = options.SquareMinimap or "OFF" -- 2.6
options.MenuOnShift = options.MenuOnShift or "OFF" -- 2.6
options.TinyTooltips = options.TinyTooltips or "OFF" -- 3.0
options.SetColumns = options.SetColumns or "OFF" -- 3.0
options.Columns = options.Columns or 4 -- 3.0
options.CooldownCount = options.CooldownCount or "OFF" -- 3.0
options.LargeCooldown = options.LargeCooldown or "OFF" -- 3.0
options.ShowHotKeys = options.ShowHotKeys or "OFF" -- 3.0
TrinketMenuPerOptions.ItemsUsed = TrinketMenuPerOptions.ItemsUsed or { } -- 3.0
options.StopOnSwap = options.StopOnSwap or "OFF" -- 3.2
options.HideOnLoad = options.HideOnLoad or "OFF" -- 3.4
--options.RedRange = options.RedRange or "OFF" -- 3.54
options.HidePetBattle = options.HidePetBattle or "ON" -- 6.0.3
options.CooldownCountBlizzard = options.CooldownCountBlizzard or "ON" -- 11.1.6
options.CooldownCountOmniCC = options.CooldownCountOmniCC or "ON" -- 11.1.6
TrinketMenuPerOptions.Alpha = TrinketMenuPerOptions.Alpha or 1 -- 3.5
TrinketMenuPerOptions.Hidden = TrinketMenuPerOptions.Hidden or { }
options.MenuOnRight = options.MenuOnRight or "OFF" -- 3.61
if TrinketMenuPerOptions.XPos and TrinketMenuPerOptions.YPos then
TrinketMenu_MainFrame:ClearAllPoints()
TrinketMenu_MainFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", TrinketMenuPerOptions.XPos, TrinketMenuPerOptions.YPos)
end
if TrinketMenuPerOptions.MainScale then
TrinketMenu_MainFrame:SetScale(TrinketMenuPerOptions.MainScale)
end
if TrinketMenuPerOptions.MenuScale then
TrinketMenu_MenuFrame:SetScale(TrinketMenuPerOptions.MenuScale)
end
TrinketMenu.ReflectAlpha()
TrinketMenu_Trinket0:SetAttribute("type", "item")
TrinketMenu_Trinket1:SetAttribute("type", "item")
TrinketMenu_Trinket0:SetAttribute("slot", 13)
TrinketMenu_Trinket1:SetAttribute("slot", 14)
if TrinketMenu.QueueInit then
-- alt has a special purpose if queue installed
TrinketMenu_Trinket0:SetAttribute("alt-slot*", ATTRIBUTE_NOOP)
TrinketMenu_Trinket1:SetAttribute("alt-slot*", ATTRIBUTE_NOOP)
end
TrinketMenu_Trinket0:SetAttribute("shift-slot*", ATTRIBUTE_NOOP)
TrinketMenu_Trinket1:SetAttribute("shift-slot*", ATTRIBUTE_NOOP)
TrinketMenu.ReflectMenuOnRight()
TrinketMenu.InitTimers()
TrinketMenu.CreateTimer("UpdateWornTrinkets", TrinketMenu.UpdateWornTrinkets, .75)
TrinketMenu.CreateTimer("DockingMenu", TrinketMenu.DockingMenu, .2, 1)
TrinketMenu.CreateTimer("MenuMouseover", TrinketMenu.MenuMouseover, .25, 1)
TrinketMenu.CreateTimer("TooltipUpdate", TrinketMenu.TooltipUpdate, 1, 1)
TrinketMenu.CreateTimer("CooldownUpdate", TrinketMenu.CooldownUpdate, 1, 1)
TrinketMenu.CreateTimer("QueueUpdate", TrinketMenu.QueueUpdate, 1, 1)
--TrinketMenu.CreateTimer("RedRange", TrinketMenu.RedRangeUpdate, .33, 1)
hooksecurefunc("UseInventoryItem", TrinketMenu.UseInventoryItem)
hooksecurefunc("UseAction", TrinketMenu.UseAction)
TrinketMenu.InitOptions()
TrinketMenu.UpdateWornTrinkets()
TrinketMenu.DockWindows()
TrinketMenu.OrientWindows()
if options.CooldownCount == "ON" or options.NotifyThirty == "ON" or options.Notify == "ON" then
TrinketMenu.StartTimer("CooldownUpdate")
end
if TrinketMenu_Trinket0 and TrinketMenu_Trinket0.cooldown then
if options.CooldownCountBlizzard == "ON" then
TrinketMenu_Trinket0.cooldown:SetHideCountdownNumbers(false)
else
TrinketMenu_Trinket0.cooldown:SetHideCountdownNumbers(true)
end
if options.CooldownCountOmniCC == "ON" then
TrinketMenu_Trinket0.cooldown.noCooldownCount = false
else
TrinketMenu_Trinket0.cooldown.noCooldownCount = true
end
end
if TrinketMenu_Trinket1 and TrinketMenu_Trinket1.cooldown then
if options.CooldownCountBlizzard == "ON" then
TrinketMenu_Trinket1.cooldown:SetHideCountdownNumbers(false)
else
TrinketMenu_Trinket1.cooldown:SetHideCountdownNumbers(true)
end
if options.CooldownCountOmniCC == "ON" then
TrinketMenu_Trinket1.cooldown.noCooldownCount = false
else
TrinketMenu_Trinket1.cooldown.noCooldownCount = true
end
end
for i = 1, TrinketMenu.MaxTrinkets do
local menuButton = _G["TrinketMenu_Menu"..i]
if menuButton and menuButton.cooldown then
if options.CooldownCountBlizzard == "ON" then
menuButton.cooldown:SetHideCountdownNumbers(false)
else
menuButton.cooldown:SetHideCountdownNumbers(true)
end
if options.CooldownCountOmniCC == "ON" then
menuButton.cooldown.noCooldownCount = false
else
menuButton.cooldown.noCooldownCount = true
end
end
end
if TrinketMenu.PeriodicQueueCheck then
TrinketMenu.PeriodicQueueCheck()
end
--TrinketMenu.StartTimer("QueueUpdate")
--TrinketMenu.ReflectRedRange()
if TrinketMenuPerOptions.Visible == "ON" and (GetInventoryItemLink("player", 13) or GetInventoryItemLink("player", 14)) then
TrinketMenu_MainFrame:Show()
end
-- fix for OmniCC
TrinketMenu_MainFrame:SetFrameLevel(1)
TrinketMenu_MenuFrame:SetFrameLevel(1)
TrinketMenu_Trinket0:SetFrameLevel(2)
TrinketMenu_Trinket1:SetFrameLevel(2)
for i = 1, TrinketMenu.MaxTrinkets do
_G["TrinketMenu_Menu"..i]:SetFrameLevel(2)
end
end
function TrinketMenu.ReflectMenuOnRight()
if InCombatLockdown() then
return
end
TrinketMenu_Trinket0:SetAttribute("slot2", TrinketMenuOptions.MenuOnRight == "ON" and ATTRIBUTE_NOOP or nil)
TrinketMenu_Trinket1:SetAttribute("slot2", TrinketMenuOptions.MenuOnRight == "ON" and ATTRIBUTE_NOOP or nil)
end
-- returns true if the player is really dead or ghost, not merely FD
function TrinketMenu.IsPlayerReallyDead()
if IsVanillaClassic then
return UnitIsDeadOrGhost("player") and not UnitIsFeignDeath("player")
else
return UnitIsDeadOrGhost("player")
end
end
function TrinketMenu.ItemInfo(slot)
local link = GetInventoryItemLink("player", slot)
local name, equipLoc, texture
if link then
local _, _, id = string.find(link, "item:(%d+)")
name, _, _, _, _, _, _, _, equipLoc, texture = C_Item.GetItemInfo(id)
else
_, texture = GetInventorySlotInfo("Trinket"..(slot - 13).."Slot")
end
return texture, name, equipLoc
end
function TrinketMenu.FindItem(item, includeInventory)
if includeInventory then
for i = 13, 14 do
local itemLink = GetInventoryItemLink("player", i) or ""
local inventoryItemID = strmatch(itemLink, "item:(%d+)")
local itemName = C_Item.GetItemInfo(itemLink)
if item == itemName or item == inventoryItemID then
return i
end
end
end
for i = 0, 4 do
for j = 1, TrinketMenu.GetContainerNumSlots(i) do
local containerItemLink = TrinketMenu.GetContainerItemLink(i, j) or ""
local containerItemID = strmatch(containerItemLink, "item:(%d+)")
local containerItemName = C_Item.GetItemInfo(containerItemLink)
if item == containerItemName or item == containerItemID then
return nil, i, j
end
end
end
end
--[[ Frame Scripts ]]--
function TrinketMenu.OnLoad(self)
self:OnBackdropLoaded()
self:SetBackdropColor(0.0, 0.0, 0.0)
self:SetBackdropBorderColor(0.0, 0.0, 0.0)
SlashCmdList["TrinketMenuCOMMAND"] = TrinketMenu.SlashHandler
SLASH_TrinketMenuCOMMAND1 = "/trinketmenu"
SLASH_TrinketMenuCOMMAND2 = "/trinket"
self:RegisterEvent("PLAYER_LOGIN")
end
function TrinketMenu.OnEvent(self, event, ...)
if event == "UNIT_INVENTORY_CHANGED" then
local unitID = ...
if unitID == "player" then
TrinketMenu.UpdateWornTrinkets()
end
elseif event == "PLAYER_EQUIPMENT_CHANGED" then
TrinketMenu.UpdateWornTrinkets()
elseif event == "ACTIONBAR_UPDATE_COOLDOWN" then
TrinketMenu.UpdateWornCooldowns(1)
elseif event == "PET_BATTLE_OPENING_START" then
if TrinketMenuOptions.HidePetBattle == "ON" then
TrinketMenu_MainFrame.WasShown = TrinketMenu_MainFrame:IsShown()
if TrinketMenu_MainFrame.WasShown then
TrinketMenu_MainFrame:Hide()
end
TrinketMenu_MenuFrame.WasShown = TrinketMenu_MenuFrame:IsShown()
if TrinketMenu_MenuFrame.WasShown then
TrinketMenu_MenuFrame:Hide()
end
end
elseif event == "PET_BATTLE_CLOSE" then
if TrinketMenuOptions.HidePetBattle == "ON" then
if TrinketMenu_MainFrame.WasShown then
TrinketMenu_MainFrame:Show()
end
if TrinketMenu_MenuFrame.WasShown then
TrinketMenu_MenuFrame:Show()
end
end
elseif (event == "PLAYER_REGEN_ENABLED" or event == "PLAYER_UNGHOST" or event == "PLAYER_ALIVE") and not TrinketMenu.IsPlayerReallyDead() then
if TrinketMenu.CombatQueue[0] or TrinketMenu.CombatQueue[1] then
TrinketMenu.EquipTrinketByName(TrinketMenu.CombatQueue[0], 13)
TrinketMenu.EquipTrinketByName(TrinketMenu.CombatQueue[1], 14)
TrinketMenu.CombatQueue[0] = nil
TrinketMenu.CombatQueue[1] = nil
TrinketMenu.UpdateCombatQueue()
end
TrinketMenu_OptMenuOnRight:Enable()
elseif event == "UPDATE_BINDINGS" then
TrinketMenu.KeyBindingsChanged()
elseif event == "PLAYER_REGEN_DISABLED" then
TrinketMenu_OptMenuOnRight:Disable()
elseif event == "PLAYER_LOGIN" then
TrinketMenu.LoadDefaults()
TrinketMenu.Initialize()
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_UNGHOST")
self:RegisterEvent("PLAYER_ALIVE")
self:RegisterEvent("UNIT_INVENTORY_CHANGED")
self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
self:RegisterEvent("UPDATE_BINDINGS")
self:RegisterEvent("ACTIONBAR_UPDATE_COOLDOWN")
if not IsClassic then
self:RegisterEvent("PET_BATTLE_OPENING_START")
self:RegisterEvent("PET_BATTLE_CLOSE")
end
end
end
function TrinketMenu.UpdateWornTrinkets()
local texture, name = TrinketMenu.ItemInfo(13)
TrinketMenu_Trinket0Icon:SetTexture(texture)
texture, name = TrinketMenu.ItemInfo(14)
TrinketMenu_Trinket1Icon:SetTexture(texture)
TrinketMenu_Trinket0Icon:SetDesaturated(false)
TrinketMenu_Trinket0:SetChecked(false)
TrinketMenu_Trinket1Icon:SetDesaturated(false)
TrinketMenu_Trinket1:SetChecked(false)
TrinketMenu.UpdateWornCooldowns()
if TrinketMenu_MenuFrame:IsVisible() then
TrinketMenu.BuildMenu()
end
end
function TrinketMenu.SlashHandler(msg)
local _, _, which, profile = string.find(msg, "load (%S+) (.+)")
if profile and TrinketMenu.SetQueue then
which = string.lower(which)
if which == "top" or which == "0" then
which = 0
elseif which == "bottom" or which == "1" then
which = 1
end
if type(which) == "number" then
TrinketMenu.SetQueue(which, "SORT", profile)
return
end
end
msg = string.lower(msg)
if not msg or msg == "" then
TrinketMenu.ToggleFrame(TrinketMenu_MainFrame)
elseif string.find(msg, "^opt") or string.find(msg, "^config") then
TrinketMenu.ToggleFrame(TrinketMenu_OptFrame)
elseif msg == "lock" then
TrinketMenuOptions.Locked = "ON"
TrinketMenu.DockWindows()
TrinketMenu.ReflectLock()
elseif msg == "unlock" then
TrinketMenuOptions.Locked = "OFF"
TrinketMenu.DockWindows()
TrinketMenu.ReflectLock()
elseif msg == "reset" then
TrinketMenu.ResetSettings()
elseif msg == "clear" then
wipe(TrinketMenuPerOptions.Hidden)
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00TrinketMenu: Cleared all ignored/hidden trinkets.")
elseif string.find(msg, "alpha") then
local _, _, alpha = string.find(msg, "alpha (.+)")
alpha = tonumber(alpha)
if alpha and alpha > 0 and alpha <= 1.0 then
TrinketMenuPerOptions.Alpha = alpha
else
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00TrinketMenu alpha:")
DEFAULT_CHAT_FRAME:AddMessage("trinket alpha (number) : set alpha from 0.1 to 1.0")
end
TrinketMenu.ReflectAlpha()
elseif string.find(msg, "scale") then
local _, _, menuscale = string.find(msg, "scale menu (.+)")
if tonumber(menuscale) then
TrinketMenu.FrameToScale = TrinketMenu_MenuFrame
TrinketMenu.ScaleFrame(menuscale)
end
local _, _, mainscale = string.find(msg, "scale main (.+)")
if tonumber(mainscale) then
TrinketMenu.FrameToScale = TrinketMenu_MainFrame
TrinketMenu.ScaleFrame(mainscale)
end
if not tonumber(menuscale) and not tonumber(mainscale) then
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00TrinketMenu scale:")
DEFAULT_CHAT_FRAME:AddMessage("/trinket scale main (number) : set exact main scale")
DEFAULT_CHAT_FRAME:AddMessage("/trinket scale menu (number) : set exact menu scale")
DEFAULT_CHAT_FRAME:AddMessage("ie, /trinket scale menu 0.85")
DEFAULT_CHAT_FRAME:AddMessage("Note: You can drag the lower-right corner of either window to scale. This slash command is for those who want to set an exact scale.")
end
TrinketMenu.FrameToScale = nil
TrinketMenuPerOptions.MainScale = TrinketMenu_MainFrame:GetScale()
TrinketMenuPerOptions.MenuScale = TrinketMenu_MenuFrame:GetScale()
elseif string.find(msg, "load") then
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00TrinketMenu load:")
DEFAULT_CHAT_FRAME:AddMessage("/trinket load (top|bottom) profilename\nie: /trinket load bottom PvP")
else
DEFAULT_CHAT_FRAME:AddMessage("|cFFFFFF00TrinketMenu useage:")
DEFAULT_CHAT_FRAME:AddMessage("/trinket or /trinketmenu : toggle the window")
DEFAULT_CHAT_FRAME:AddMessage("/trinket reset : reset all settings")
DEFAULT_CHAT_FRAME:AddMessage("/trinket clear : clear all ignored/hidden trinkets")
DEFAULT_CHAT_FRAME:AddMessage("/trinket opt : summon options window")
DEFAULT_CHAT_FRAME:AddMessage("/trinket lock|unlock : toggles window lock")
DEFAULT_CHAT_FRAME:AddMessage("/trinket scale main|menu (number) : sets an exact scale")
DEFAULT_CHAT_FRAME:AddMessage("/trinket load top|bottom profilename : loads a profile to top or bottom trinket")
end
end
function TrinketMenu.ResetSettings()
StaticPopupDialogs["TRINKETMENURESET"] = {
text = "Are you sure you want to reset TrinketMenu to default state and reload the UI?",
button1 = "Yes", button2 = "No", showAlert = 1, timeout = 0, whileDead = 1,
OnAccept = function()
TrinketMenuOptions = nil
TrinketMenuPerOptions = nil
TrinketMenuQueue = nil
ReloadUI()
end
}
StaticPopup_Show("TRINKETMENURESET")
end
--[[ Window Movement ]]--
function TrinketMenu.MainFrame_OnMouseUp(self)
if InCombatLockdown() then
return
end
local arg1 = GetMouseButtonClicked()
if arg1 == "LeftButton" then
self:StopMovingOrSizing()
TrinketMenuPerOptions.XPos = TrinketMenu_MainFrame:GetLeft()
TrinketMenuPerOptions.YPos = TrinketMenu_MainFrame:GetTop()
elseif TrinketMenuOptions.Locked == "OFF" then
if TrinketMenuPerOptions.MainOrient == "VERTICAL" then
TrinketMenuPerOptions.MainOrient = "HORIZONTAL"
else
TrinketMenuPerOptions.MainOrient = "VERTICAL"
end
TrinketMenu.OrientWindows()
end
end
function TrinketMenu.MainFrame_OnMouseDown(self)
if InCombatLockdown() then
return
end
if GetMouseButtonClicked() == "LeftButton" and TrinketMenuOptions.Locked == "OFF" then
self:StartMoving()
end
end
--[[ Timers ]]
function TrinketMenu.InitTimers()
TrinketMenu.TimerPool = { }
TrinketMenu.Timers = { }
end
function TrinketMenu.CreateTimer(name, func, delay, rep)
TrinketMenu.TimerPool[name] = {func = func, delay = delay, rep = rep, elapsed = delay}
end
function TrinketMenu.IsTimerActive(name)
for i, j in ipairs(TrinketMenu.Timers) do
if j == name then
return i
end
end
return nil
end
function TrinketMenu.StartTimer(name, delay)
TrinketMenu.TimerPool[name].elapsed = delay or TrinketMenu.TimerPool[name].delay
if not TrinketMenu.IsTimerActive(name) then
table.insert(TrinketMenu.Timers, name)
TrinketMenu_TimersFrame:Show()
end
end
function TrinketMenu.StopTimer(name)
local idx = TrinketMenu.IsTimerActive(name)
if idx then
table.remove(TrinketMenu.Timers, idx)
if #TrinketMenu.Timers < 1 then
TrinketMenu_TimersFrame:Hide()
end
end
end
function TrinketMenu.TimersFrame_OnUpdate(elapsed)
local timerPool
local toStop
local snapshot = {unpack(TrinketMenu.Timers)}
for _, name in ipairs(snapshot) do
if TrinketMenu.IsTimerActive(name) then
timerPool = TrinketMenu.TimerPool[name]
timerPool.elapsed = timerPool.elapsed - elapsed
if timerPool.elapsed < 0 then
timerPool.func()
if timerPool.rep then
timerPool.elapsed = timerPool.delay
else
toStop = toStop or {}
toStop[#toStop + 1] = name
end
end
end
end
if toStop then
for _, name in ipairs(toStop) do
TrinketMenu.StopTimer(name)
end
end
end
function TrinketMenu.TimerDebug()
local on = "|cFF00FF00On"
local off = "|cFFFF0000Off"
DEFAULT_CHAT_FRAME:AddMessage("|cFF44AAFFTrinketMenu_TimersFrame is "..(TrinketMenu_TimersFrame:IsVisible() and on or off))
for i in pairs(TrinketMenu.TimerPool) do
DEFAULT_CHAT_FRAME:AddMessage(i.." is "..(TrinketMenu.IsTimerActive(i) and on or off))
end
end
--[[ OnClicks ]]
function TrinketMenu.MainTrinket_OnClick(self, button, down)
self:SetChecked(false)
if button == "RightButton" and TrinketMenuOptions.MenuOnRight == "ON" then
if TrinketMenu_MenuFrame:IsVisible() then
TrinketMenu_MenuFrame:Hide()
else
TrinketMenu.BuildMenu()
end
elseif IsShiftKeyDown() and down then
if ChatFrame1EditBox:IsVisible() then
ChatFrame1EditBox:Insert(GetInventoryItemLink("player", self:GetID()) or "")
end
elseif IsAltKeyDown() and not down and TrinketMenu.QueueInit then
local which = self:GetID() - 13
if TrinketMenuQueue.Enabled[which] then
TrinketMenu.CombatQueue[self:GetID() - 13] = nil
TrinketMenuQueue.Enabled[which] = nil
else
TrinketMenuQueue.Enabled[which] = true
end
TrinketMenu.ReflectQueueEnabled()
-- toggle queue
TrinketMenu.UpdateCombatQueue()
else
TrinketMenu.ReflectTrinketUse(self:GetID())
end
end
function TrinketMenu.MenuTrinket_OnClick(self, button, down)
self:SetChecked(false)
if IsShiftKeyDown() and ChatFrame1EditBox:IsVisible() then
ChatFrame1EditBox:Insert(TrinketMenu.GetContainerItemLink(TrinketMenu.BaggedTrinkets[self:GetID()].bag, TrinketMenu.BaggedTrinkets[self:GetID()].slot))
elseif IsAltKeyDown() then
local _, _, itemID = string.find(TrinketMenu.GetContainerItemLink(TrinketMenu.BaggedTrinkets[self:GetID()].bag, TrinketMenu.BaggedTrinkets[self:GetID()].slot) or "", "item:(%d+)")
if not itemID then
return
end
if TrinketMenuPerOptions.Hidden[itemID] then
TrinketMenuPerOptions.Hidden[itemID] = nil
else
TrinketMenuPerOptions.Hidden[itemID] = 1
end
TrinketMenu.BuildMenu()
else
local slot = (button == "LeftButton") and 13 or 14
if TrinketMenu.QueueInit then
local _, _, canCooldown = TrinketMenu.GetContainerItemCooldown(TrinketMenu.BaggedTrinkets[self:GetID()].bag, TrinketMenu.BaggedTrinkets[self:GetID()].slot)
if canCooldown == 0 or TrinketMenuOptions.StopOnSwap == "ON" then -- if incoming trinket can't go on cooldown
TrinketMenuQueue.Enabled[slot - 13] = nil -- turn off autoqueue
TrinketMenu.ReflectQueueEnabled()
end
end
TrinketMenu.EquipTrinketByName(TrinketMenu.BaggedTrinkets[self:GetID()].name, slot)
if not IsShiftKeyDown() and TrinketMenuOptions.KeepOpen == "OFF" then
TrinketMenu_MenuFrame:Hide()
end
end
end
--[[ Docking ]]
function TrinketMenu.MenuFrame_OnMouseDown(button)
if InCombatLockdown() then
return
end
if button == "LeftButton" and TrinketMenuOptions.Locked == "OFF" then
TrinketMenu_MenuFrame:StartMoving()
if TrinketMenuOptions.KeepDocked == "ON" then
TrinketMenu.StartTimer("DockingMenu")
end
end
end
function TrinketMenu.MenuFrame_OnMouseUp(button)
if InCombatLockdown() then
return
end
if button == "LeftButton" then
TrinketMenu.StopTimer("DockingMenu")
TrinketMenu_MenuFrame:StopMovingOrSizing()
if TrinketMenuOptions.KeepDocked == "ON" then
TrinketMenu.DockWindows()
end
elseif TrinketMenuOptions.Locked == "OFF" then
if TrinketMenuPerOptions.MenuOrient == "VERTICAL" then
TrinketMenuPerOptions.MenuOrient = "HORIZONTAL"
else
TrinketMenuPerOptions.MenuOrient = "VERTICAL"
end
TrinketMenu.BuildMenu()
end
end
function TrinketMenu.DockingMenu()
local main = TrinketMenu_MainFrame
local menu = TrinketMenu_MenuFrame
local mainscale = TrinketMenu_MainFrame:GetScale()
local menuscale = TrinketMenu_MenuFrame:GetScale()
local near = TrinketMenu.Near
if near(main:GetRight() * mainscale,menu:GetLeft() * menuscale) then
if near(main:GetTop() * mainscale,menu:GetTop() * menuscale) then
TrinketMenuPerOptions.MainDock = "TOPRIGHT"
TrinketMenuPerOptions.MenuDock = "TOPLEFT"
elseif near(main:GetBottom() * mainscale,menu:GetBottom() * menuscale) then
TrinketMenuPerOptions.MainDock = "BOTTOMRIGHT"
TrinketMenuPerOptions.MenuDock = "BOTTOMLEFT"
end
elseif near(main:GetLeft() * mainscale,menu:GetRight() * menuscale) then
if near(main:GetTop() * mainscale,menu:GetTop() * menuscale) then
TrinketMenuPerOptions.MainDock = "TOPLEFT"
TrinketMenuPerOptions.MenuDock = "TOPRIGHT"
elseif near(main:GetBottom() * mainscale,menu:GetBottom() * menuscale) then
TrinketMenuPerOptions.MainDock = "BOTTOMLEFT"
TrinketMenuPerOptions.MenuDock = "BOTTOMRIGHT"
end
elseif near(main:GetRight() * mainscale,menu:GetRight() * menuscale) then
if near(main:GetTop() * mainscale,menu:GetBottom() * menuscale) then
TrinketMenuPerOptions.MainDock = "TOPRIGHT"
TrinketMenuPerOptions.MenuDock = "BOTTOMRIGHT"
elseif near(main:GetBottom() * mainscale,menu:GetTop() * menuscale) then
TrinketMenuPerOptions.MainDock = "BOTTOMRIGHT"
TrinketMenuPerOptions.MenuDock = "TOPRIGHT"
end
elseif near(main:GetLeft() * mainscale,menu:GetLeft() * menuscale) then
if near(main:GetTop() * mainscale,menu:GetBottom() * menuscale) then
TrinketMenuPerOptions.MainDock = "TOPLEFT"
TrinketMenuPerOptions.MenuDock = "BOTTOMLEFT"
elseif near(main:GetBottom() * mainscale,menu:GetTop() * menuscale) then
TrinketMenuPerOptions.MainDock = "BOTTOMLEFT"
TrinketMenuPerOptions.MenuDock = "TOPLEFT"
end
end
TrinketMenu.ClearDocking()
_G["TrinketMenu_MainDock_"..TrinketMenuPerOptions.MainDock]:Show()
_G["TrinketMenu_MenuDock_"..TrinketMenuPerOptions.MenuDock]:Show()
end
function TrinketMenu.MenuMouseover()
if (not MouseIsOver(TrinketMenu_MainFrame)) and (not MouseIsOver(TrinketMenu_MenuFrame)) and not IsShiftKeyDown() and (TrinketMenuOptions.KeepOpen == "OFF") then
TrinketMenu.StopTimer("MenuMouseover")
TrinketMenu_MenuFrame:Hide()
end
end
--[[ Cooldowns ]]
function TrinketMenu.UpdateWornCooldowns(maybeGlobal)
local start, duration, enable = GetInventoryItemCooldown("player", 13)
CooldownFrame_Set(TrinketMenu_Trinket0Cooldown, start, duration, enable)
start, duration, enable = GetInventoryItemCooldown("player", 14)
CooldownFrame_Set(TrinketMenu_Trinket1Cooldown, start, duration, enable)
if not maybeGlobal then
TrinketMenu.WriteWornCooldowns()
end
end
function TrinketMenu.UpdateMenuCooldowns()
local start, duration, enable
for i = 1, TrinketMenu.NumberOfTrinkets do
start,duration,enable = TrinketMenu.GetContainerItemCooldown(TrinketMenu.BaggedTrinkets[i].bag, TrinketMenu.BaggedTrinkets[i].slot)
CooldownFrame_Set(_G["TrinketMenu_Menu"..i.."Cooldown"], start, duration, enable)
end
TrinketMenu.WriteMenuCooldowns()
end
--[[ Item use ]]
function TrinketMenu.ReflectTrinketUse(slot)
_G["TrinketMenu_Trinket"..(slot - 13)]:SetChecked(true)
TrinketMenu.StartTimer("UpdateWornTrinkets")
local _, _, id = string.find(GetInventoryItemLink("player", slot) or "", "item:(%d+)")
id = tonumber(id)
if id then
TrinketMenuPerOptions.ItemsUsed[id] = 0 -- 0 is an indeterminate state, cooldown will figure if it's worth watching
end
end
function TrinketMenu.UseInventoryItem(slot)
slot = tonumber(slot) -- /use 13-14
if (slot == 13 or slot == 14) and not MerchantFrame:IsVisible() then
TrinketMenu.ReflectTrinketUse(slot)
end
end
function TrinketMenu.UseAction(slot)
if IsRetail and C_ActionBar.IsEquippedAction(slot) or not IsRetail and IsEquippedAction(slot) then
TrinketMenu_TooltipScan:SetOwner(WorldFrame, "ANCHOR_NONE")
TrinketMenu_TooltipScan:SetAction(slot)
local _, trinket0 = TrinketMenu.ItemInfo(13)
local _, trinket1 = TrinketMenu.ItemInfo(14)
local tooltipLine = _G["TrinketMenu_TooltipScanTextLeft1"]
if tooltipLine and tooltipLine:GetText() == trinket0 then
TrinketMenu.ReflectTrinketUse(13)
elseif tooltipLine and tooltipLine:GetText() == trinket1 then
TrinketMenu.ReflectTrinketUse(14)
end
end
end
--[[ Tooltips ]]
function TrinketMenu.WornTrinketTooltip(self)
if TrinketMenuOptions.ShowTooltips == "OFF" then