-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathItemRack.lua
5099 lines (4307 loc) · 164 KB
/
ItemRack.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
--[[ ItemRack 1.975 7/27/06 Gello ]]--
--[[ SavedVariables ]]--
ItemRack_Users = {} -- per-user bar settings (position, orientation, scale, locked status, bar contents)
ItemRack_Settings = { -- These settings are for all users:
TooltipFollow = "OFF", -- whether tooltip shows at pointer or default position
CooldownNumbers = "OFF", -- whether cooldowns show a number overlay
Soulbound = "OFF", -- whether menu limits items to soulbound only
Bindings = "OFF", -- whether key bindings is displayed
MenuShift = "OFF", -- whether Shift key needs held to open the menu
Notify = "OFF", -- whether to notify when cooldowns finished on used items
ShowEmpty = "ON", -- whether to show empty slot in the menu
FlipMenu = "OFF", -- whether to display menu on the opposite side
RightClick = "OFF", -- whether right click sends to second slot
TinyTooltip = "OFF", -- whether to only display name, durability and cooldown in tooltip
ShowTooltips = "ON", -- whether to display tooltip at all
RotateMenu = "OFF", -- whether menu is rotated (temporary setting)
ShowIcon = "ON", -- whether to show the minimap button
DisableToggle = "ON", -- whether left-clicking disables the minimap button
FlipBar = "OFF", -- whether control appears on bottom or right bar grows other direction
EnableEvents = "OFF", -- whether automated event scrips run
CompactList = "OFF", -- whether saved sets list is compacted or not
NotifyThirty = "ON", -- whether notify happens at 30 seconds
ShowAllEvents = "OFF", -- whether to show all classes' events
AllowHidden = "OFF", -- whether to hide menu items with ALT+click
LargeFont = "OFF", -- whether event script font is large or small
SquareMinimap = "OFF", -- whether minimap button should go around square minimap
BigCooldown = "OFF", -- whether cooldown numbers are huge (like Cooldown Count)
SetLabels = "ON", -- whether labels show on set icons
AutoToggle = "OFF", -- whether sets automatically toggle when chosen
}
-- all event scripts are stored globally in this saved variable. Defaults are in localization.lua
ItemRack_Events = {}
ItemRack_Version = 1.975
--[[ Local Variables ]]--
-- some mount textures share non-mount buff textures, if you run across one put it here
local problem_mounts = {
["Interface\\Icons\\Ability_Mount_PinkTiger"] = 1,
["Interface\\Icons\\Ability_Mount_WhiteTiger"] = 1,
["Interface\\Icons\\Spell_Nature_Swiftness"] = 1,
["Interface\\Icons\\INV_Misc_Foot_Kodo"] = 1,
["Interface\\Icons\\Ability_Mount_JungleTiger"] =1,
}
local current_events_version = 1.975 -- use to control when to upgrade events
-- defaults for ItemRack_Users
local ItemRackOpt_Defaults = {
MainOrient = "HORIZONTAL", -- direction of main bar, "HORIZONTAL" or "VERTICAL", menu orient always opposite
MainScale = 1, -- scale 0-1 of main bar and menu bar
XPos = 400, -- left position of main bar
YPos = 350, -- top position of main bar
Locked = "OFF", -- lock status of main bar (for all intents menu always locked)
Visible = "ON" -- whether the bar should be drawn on the screen
}
local user = "default" -- "Gello of Hyjal" or "Gello of Deathwing ", defined at PLAYER_LOGIN
ItemRack = {}
ItemRack.FrameToScale = nil -- holds frame being scaled for ScaleUpdate
ItemRack.BaggedItems = {} -- table containing items in bags to show in menu
ItemRack.NumberOfItems = 0 -- number of items in the menu
ItemRack.MaxItems = 30 -- maximum number of items that can display in the menu
ItemRack.InvOpen = nil -- which inventory slot has its menu open
ItemRack.TooltipOwner = nil -- (this) when tooltip created
ItemRack.TooltipType = nil -- "BAG" or "INVENTORY"
ItemRack.TooltipBag = nil -- bag number
ItemRack.TooltipSlot = nil -- bag or inventory slot number
ItemRack.CurrentTime = GetTime()
ItemRack.MainDock = "" -- "TOPLEFT" "BOTTOMRIGHT" etc
ItemRack.MenuDock = ""
ItemRack.Queue = {} -- [slot]="ItemName" if an item in queue, ie [13]="Arcanite Dragonling", [slot]=nil for no item in queue
ItemRack.NotifyList = {} -- ["item name"] = { bag=0-4, slot=1-x, inv=0-19, hadcooldown=true/nil }
ItemRack.AmmoCounts = {} -- ["Heavy Shot"]=200, ["Thorium Arrow"]=982, etc
ItemRack.TrinketsPaired = false -- true if the two trinkets are next to each other
ItemRack.KeyBindingsSettled = false
ItemRack.MenuDockedTo = nil -- "SET" for set window, "CHARACTERSHEET" for PaperDollFrame, nil for rack
ItemRack.SelectedEvent = 0 -- index in list of event selected
ItemRack.CanWearOneHandOffHand = nil -- whether player can wear one-hand in offhand (warrior, rogue, hunter)
ItemRack.Buffs = {} -- table indexed by buff names, whether a buff is on or not
ItemRack.BankedItems = {} -- items in the bank indexed by itemID
ItemRack.BankSlots = { -1,5,6,7,8,9,10 }
local eventList = {} -- note the departure from using the table for local values -- mod will be rewritten to a consistent style
local eventListSize = 1
local scratchTable = { {}, {} } -- for secondary sorts
local scratchTableSize = { 1, 1 }
--[[ reference tables ]]--
ItemRack.OptInfo = {
["ItemRack_Control_Rotate"] = { text=ItemRackText.CONTROL_ROTATE_TEXT, tooltip=ItemRackText.CONTROL_ROTATE_TOOLTIP },
["ItemRack_Control_Lock"] = { text=ItemRackText.CONTROL_LOCK_TEXT, tooltip=ItemRackText.CONTROL_LOCK_TOOLTIP },
["ItemRack_Control_Options"] = { text=ItemRackText.CONTROL_OPTIONS_TEXT, tooltip=ItemRackText.CONTROL_OPTIONS_TOOLTIP },
["ItemRack_Opt_TooltipFollow"] = { text=ItemRackText.OPT_TOOLTIPFOLLOW_TEXT, tooltip=ItemRackText.OPT_TOOLTIPFOLLOW_TOOLTIP, type="Check", info="TooltipFollow" },
["ItemRack_Opt_CooldownNumbers"] = { text=ItemRackText.OPT_COOLDOWNNUMBERS_TEXT, tooltip=ItemRackText.OPT_COOLDOWNNUMBERS_TOOLTIP, type="Check", info="CooldownNumbers" },
["ItemRack_Opt_Soulbound"] = { text=ItemRackText.OPT_SOULBOUND_TEXT, tooltip=ItemRackText.OPT_SOULBOUND_TOOLTIP, type="Check", info="Soulbound" },
["ItemRack_Opt_Bindings"] = { text=ItemRackText.OPT_BINDINGS_TEXT, tooltip=ItemRackText.OPT_BINDINGS_TOOLTIP, type="Check", info="Bindings" },
["ItemRack_Opt_MenuShift"] = { text=ItemRackText.OPT_MENUSHIFT_TEXT, tooltip=ItemRackText.OPT_MENUSHIFT_TOOLTIP, type="Check", info="MenuShift" },
["ItemRack_Opt_Close"] = { text=ItemRackText.OPT_CLOSE_TEXT, tooltip=ItemRackText.OPT_CLOSE_TOOLTIP },
["ItemRack_InvFrame_Resize"] = { text=ItemRackText.INVFRAME_RESIZE_TEXT, tooltip=ItemRackText.INVFRAME_RESIZE_TOOLTIP },
["ItemRack_Opt_ShowEmpty"] = { text=ItemRackText.OPT_SHOWEMPTY_TEXT, tooltip=ItemRackText.OPT_SHOWEMPTY_TOOLTIP, type="Check", info="ShowEmpty" },
["ItemRack_Opt_FlipMenu"] = { text=ItemRackText.OPT_FLIPMENU_TEXT, tooltip=ItemRackText.OPT_FLIPMENU_TOOLTIP, type="Check", info="FlipMenu" },
["ItemRack_Opt_RightClick"] = { text=ItemRackText.OPT_RIGHTCLICK_TEXT, tooltip=ItemRackText.OPT_RIGHTCLICK_TOOLTIP, type="Check", info="RightClick" },
["ItemRack_Opt_TinyTooltip"] = { text=ItemRackText.OPT_TINYTOOLTIP_TEXT, tooltip=ItemRackText.OPT_TINYTOOLTIP_TOOLTIP, type="Check", info="TinyTooltip" },
["ItemRack_Opt_ShowTooltips"] = { text=ItemRackText.OPT_SHOWTOOLTIPS_TEXT, tooltip=ItemRackText.OPT_SHOWTOOLTIPS_TOOLTIP, type="Check", info="ShowTooltips" },
["ItemRack_Opt_Notify"] = { text=ItemRackText.OPT_NOTIFY_TEXT, tooltip=ItemRackText.OPT_NOTIFY_TOOLTIP, type="Check", info="Notify" },
["ItemRack_Opt_RotateMenu"] = { text=ItemRackText.OPT_ROTATEMENU_TEXT, tooltip=ItemRackText.OPT_ROTATEMENU_TOOLTIP, type="Check", info="RotateMenu" },
["ItemRack_Sets_Close"] = { text=ItemRackText.SETS_CLOSE_TEXT, tooltip=ItemRackText.SETS_CLOSE_TOOLTIP },
["ItemRack_Sets_NameLabel"] = { text=ItemRackText.SETS_NAMELABEL_TEXT, type="Label" },
["ItemRack_Sets_HideSet"] = { text=ItemRackText.SETS_HIDESET_TEXT, tooltip=ItemRackText.SETS_HIDESET_TOOLTIP, type="Check" },
["ItemRack_Sets_Tab1"] = { text=ItemRackText.SETS_TAB1_TEXT, tooltip=ItemRackText.SETS_TAB1_TOOLTIP, type="Tab" },
["ItemRack_Sets_Tab2"] = { text=ItemRackText.SETS_TAB2_TEXT, tooltip=ItemRackText.SETS_TAB2_TOOLTIP, type="Tab" },
["ItemRack_Sets_Tab3"] = { text=ItemRackText.SETS_TAB3_TEXT, tooltip=ItemRackText.SETS_TAB3_TOOLTIP, type="Tab" },
["ItemRack_Opt_ShowIcon"] = { text=ItemRackText.OPT_SHOWICON_TEXT, tooltip=ItemRackText.OPT_SHOWICON_TOOLTIP, type="Check", info="ShowIcon" },
["ItemRack_Opt_DisableToggle"] = { text=ItemRackText.OPT_DISABLETOGGLE_TEXT, tooltip=ItemRackText.OPT_DISABLETOGGLE_TOOLTIP, type="Check", info="DisableToggle" },
["ItemRack_Sets_Lock"] = { text=ItemRackText.CONTROL_LOCK_TEXT, tooltip=ItemRackText.CONTROL_LOCK_TOOLTIP },
["ItemRack_Sets_BindButton"] = { text=ItemRackText.SETS_BINDBUTTON_TEXT, tooltip=ItemRackText.SETS_BINDBUTTON_TOOLTIP, type="Label" },
["ItemRack_Sets_SaveButton"] = { text=ItemRackText.SETS_SAVEBUTTON_TEXT, tooltip=ItemRackText.SETS_SAVEBUTTON_TOOLTIP, type="Label" },
["ItemRack_Sets_RemoveButton"] = { text=ItemRackText.SETS_REMOVEBUTTON_TEXT, tooltip=ItemRackText.SETS_REMOVEBUTTON_TOOLTIP, type="Label" },
["ItemRack_Opt_FlipBar"] = { text=ItemRackText.OPT_FLIPBAR_TEXT, tooltip=ItemRackText.OPT_FLIPBAR_TOOLTIP, type="Check", info="FlipBar" },
["ItemRack_Opt_EnableEvents"] = { text=ItemRackText.OPT_ENABLEEVENTS_TEXT, tooltip=ItemRackText.OPT_ENABLEEVENTS_TOOLTIP, type="Check", info="EnableEvents" },
["ItemRack_Opt_CompactList"] = { text=ItemRackText.OPT_COMPACTLIST_TEXT, tooltip=ItemRackText.OPT_COMPACTLIST_TOOLTIP, type="Check", info="CompactList" },
["ItemRack_SavedSets_Close"] = { text=ItemRackText.OPT_SAVEDSETSCLOSE_TEXT, tooltip=ItemRackText.OPT_SAVEDSETSCLOSE_TOOLTIP },
["ItemRack_Events_DeleteButton"] = { text=ItemRackText.EVENTSDELETE_TEXT, tooltip=ItemRackText.EVENTSDELETE_TOOLTIP },
["ItemRack_Events_EditButton"] = { text=ItemRackText.EVENTSEDIT_TEXT, tooltip=ItemRackText.EVENTSEDIT_TOOLTIP },
["ItemRack_Events_NewButton"] = { text=ItemRackText.EVENTSNEW_TEXT, tooltip=ItemRackText.EVENTSNEW_TOOLTIP },
["ItemRack_EditEvent_Save"] = { text=ItemRackText.EVENTSSAVE_TEXT, tooltip=ItemRackText.EVENTSSAVE_TOOLTIP },
["ItemRack_EditEvent_Test"] = { text=ItemRackText.EVENTSTEST_TEXT, tooltip=ItemRackText.EVENTSTEST_TOOLTIP },
["ItemRack_EditEvent_Cancel"] = { text=ItemRackText.EVENTSCANCEL_TEXT, tooltip=ItemRackText.EVENTSCANCEL_TOOLTIP },
["ItemRack_EventName"] = { text=ItemRackText.EVENTNAME_TEXT, tooltip=ItemRackText.EVENTNAME_TOOLTIP },
["ItemRack_EventTrigger"] = { text=ItemRackText.EVENTTRIGGER_TEXT, tooltip=ItemRackText.EVENTTRIGGER_TOOLTIP },
["ItemRack_EventDelay"] = { text=ItemRackText.EVENTDELAY_TEXT, tooltip=ItemRackText.EVENTDELAY_TOOLTIP },
["ItemRack_Opt_NotifyThirty"] = { text=ItemRackText.OPT_NOTIFYTHIRTY_TEXT, tooltip=ItemRackText.OPT_NOTIFYTHIRTY_TOOLTIP, type="Check", info="NotifyThirty" },
["ItemRack_Opt_ShowAllEvents"] = { text=ItemRackText.OPT_SHOWALLEVENTS_TEXT, tooltip=ItemRackText.OPT_SHOWALLEVENTS_TOOLTIP, type="Check", info="ShowAllEvents" },
["ItemRack_ResetButton"] = { text=ItemRackText.RESETBUTTON_TEXT, tooltip=ItemRackText.RESETBUTTON_TOOLTIP },
["ItemRack_Opt_AllowHidden"] = { text=ItemRackText.OPT_ALLOWHIDDEN_TEXT, tooltip=ItemRackText.OPT_ALLOWHIDDEN_TOOLTIP, type="Check", info="AllowHidden" },
["ItemRack_Opt_LargeFont"] = { text=ItemRackText.OPT_LARGEFONT_TEXT, tooltip=ItemRackText.OPT_LARGEFONT_TOOLTIP, type="Check", info="LargeFont" },
["ItemRack_ResetEventsButton"] = { text=ItemRackText.RESETEVENTSBUTTON_TEXT, tooltip=ItemRackText.RESETEVENTSBUTTON_TOOLTIP },
["ItemRack_Opt_SquareMinimap"] = { text=ItemRackText.OPT_SQUAREMINIMAP_TEXT, tooltip=ItemRackText.OPT_SQUAREMINIMAP_TOOLTIP, info="SquareMinimap" },
["ItemRack_Opt_BigCooldown"] = { text=ItemRackText.OPT_BIGCOOLDOWN_TEXT, tooltip=ItemRackText.OPT_BIGCOOLDOWN_TOOLTIP, info="BigCooldown" },
["ItemRack_ShowHelmText"] = { text="Helm", type="Label" },
["ItemRack_ShowCloakText" ] = { text="Cloak", type="Label" },
["ItemRack_Opt_SetLabels"] = { text=ItemRackText.OPT_SETLABELS_TEXT, tooltip=ItemRackText.OPT_SETLABELS_TOOLTIP, info="SetLabels" },
["ItemRack_Opt_AutoToggle"] = { text=ItemRackText.OPT_AUTOTOGGLE_TEXT, tooltip=ItemRackText.OPT_AUTOTOGGLE_TOOLTIP, info="AutoToggle" },
}
-- numerically indexed list of options for scrollable options window
ItemRack.OptScroll = {
{ idx="ItemRack_Opt_ShowTooltips" },
{ idx="ItemRack_Opt_TooltipFollow", dependency="ItemRack_Opt_ShowTooltips" },
{ idx="ItemRack_Opt_TinyTooltip", dependency="ItemRack_Opt_ShowTooltips" },
{ idx="ItemRack_Opt_ShowIcon" },
{ idx="ItemRack_Opt_DisableToggle", dependency="ItemRack_Opt_ShowIcon" },
{ idx="ItemRack_Opt_SquareMinimap", dependency="ItemRack_Opt_ShowIcon" },
{ idx="ItemRack_Opt_Bindings" },
{ idx="ItemRack_Opt_SetLabels" },
{ idx="ItemRack_Opt_CooldownNumbers" },
{ idx="ItemRack_Opt_BigCooldown", dependency="ItemRack_Opt_CooldownNumbers" },
{ idx="ItemRack_Opt_Notify" },
{ idx="ItemRack_Opt_NotifyThirty", dependency="ItemRack_Opt_Notify" },
{ idx="ItemRack_Opt_MenuShift" },
{ idx="ItemRack_Opt_AutoToggle" },
{ idx="ItemRack_Opt_ShowEmpty" },
{ idx="ItemRack_Opt_AllowHidden" },
{ idx="ItemRack_Opt_Soulbound" },
{ idx="ItemRack_Opt_RightClick" },
{ idx="ItemRack_Opt_FlipMenu" },
{ idx="ItemRack_Opt_RotateMenu" },
{ idx="ItemRack_Opt_FlipBar" }
}
-- paperdoll_slot=frame name of the slot on the paperdoll frame (for alt+click purposes)
-- ["SlotName"]=1 for each allowable slot
-- swappable=1 for slots that can be swapped in combat
-- ignore_soulbound = ignore soulbound flag for this slot
ItemRack.Indexes = {
[0] = { name=AMMOSLOT, paperdoll_slot="CharacterAmmoSlot", keybind="Use Ammo Item", ignore_soulbound=1, swappable=1, INVTYPE_AMMO=1 },
[1] = { name=INVTYPE_HEAD, paperdoll_slot="CharacterHeadSlot", keybind="Use Head Item", INVTYPE_HEAD=1 },
[2] = { name=INVTYPE_NECK, paperdoll_slot="CharacterNeckSlot", keybind="Use Neck Item", INVTYPE_NECK=1 },
[3] = { name=INVTYPE_SHOULDER, paperdoll_slot="CharacterShoulderSlot", keybind="Use Shoulder Item", INVTYPE_SHOULDER=1 },
[4] = { name=INVTYPE_BODY, paperdoll_slot="CharacterShirtSlot", keybind="Use Shirt Item", ignore_soulbound=1, INVTYPE_BODY=1 },
[5] = { name=INVTYPE_CHEST, paperdoll_slot="CharacterChestSlot", keybind="Use Chest Item", INVTYPE_CHEST=1, INVTYPE_ROBE=1 },
[6] = { name=INVTYPE_WAIST, paperdoll_slot="CharacterWaistSlot", keybind="Use Waist Item", INVTYPE_WAIST=1 },
[7] = { name=INVTYPE_LEGS, paperdoll_slot="CharacterLegsSlot", keybind="Use Legs Item", INVTYPE_LEGS=1 },
[8] = { name=INVTYPE_FEET, paperdoll_slot="CharacterFeetSlot", keybind="Use Feet Item", INVTYPE_FEET=1 },
[9] = { name=INVTYPE_WRIST, paperdoll_slot="CharacterWristSlot", keybind="Use Wrist Item", INVTYPE_WRIST=1 },
[10]= { name=INVTYPE_HAND, paperdoll_slot="CharacterHandsSlot", keybind="Use Hands Item", INVTYPE_HAND=1 },
[11]= { name=INVTYPE_FINGER, paperdoll_slot="CharacterFinger0Slot", keybind="Use Top Finger Item", INVTYPE_FINGER=1 },
[12]= { name=INVTYPE_FINGER, paperdoll_slot="CharacterFinger1Slot", keybind="Use Bottom Finger Item", INVTYPE_FINGER=1 },
[13]= { name=INVTYPE_TRINKET, paperdoll_slot="CharacterTrinket0Slot", ignore_soulbound=1, keybind="Use Top Trinket Item", INVTYPE_TRINKET=1 },
[14]= { name=INVTYPE_TRINKET, paperdoll_slot="CharacterTrinket1Slot", ignore_soulbound=1, keybind="Use Bottom Trinket Item", INVTYPE_TRINKET=1 },
[15]= { name=INVTYPE_CLOAK, paperdoll_slot="CharacterBackSlot", keybind="Use Back Item", INVTYPE_CLOAK=1 },
[16]= { name=INVTYPE_WEAPONMAINHAND, paperdoll_slot="CharacterMainHandSlot", keybind="Use Main-Hand Item", swappable=1, INVTYPE_WEAPONMAINHAND=1, INVTYPE_2HWEAPON=1, INVTYPE_WEAPON=1 },
[17]= { name=INVTYPE_WEAPONOFFHAND, paperdoll_slot="CharacterSecondaryHandSlot", keybind="Use Off-Hand Item", swappable=1, INVTYPE_WEAPONOFFHAND=1, INVTYPE_SHIELD=1, INVTYPE_HOLDABLE=1, INVTYPE_WEAPON=1 },
[18]= { name=INVTYPE_RANGED, paperdoll_slot="CharacterRangedSlot", keybind="Use Range Item", swappable=1, INVTYPE_RANGED=1, INVTYPE_RANGEDRIGHT=1, INVTYPE_THROWN=1, INVTYPE_RELIC=1 },
[19]= { name=INVTYPE_TABARD, paperdoll_slot="CharacterTabardSlot", keybind="Use Tabard Item", ignore_soulbound=1, INVTYPE_TABARD=1 }
}
-- "add" or "remove" a frame from UISpecialFrames
local function make_escable(frame,add)
local found
for i in UISpecialFrames do
if UISpecialFrames[i]==frame then
found = i
end
end
if not found and add=="add" then
table.insert(UISpecialFrames,frame)
elseif found and add=="remove" then
table.remove(UISpecialFrames,found)
end
end
local _,_,durability_pattern = string.find(DURABILITY_TEMPLATE,"(.+) .+/.+")
durability_pattern = durability_pattern or ""
-- dock-dependant offset and directions: MainDock..MenuDock
-- x/yoff = offset MenuFrame is positioned to InvFrame
-- x/ydir = direction items are added to menu
-- x/ystart = starting offset when building a menu, relativePoint MenuDock
-- mx/y = offset MenuFrame is positioned to contents of InvFrame
local dock_stats = { ["TOPRIGHTTOPLEFT"] = { xoff=-4, yoff=0, xdir=1, ydir=-1, xstart=8, ystart=-8, mx=3, my=8 },
["BOTTOMRIGHTBOTTOMLEFT"] = { xoff=-4, yoff=0, xdir=1, ydir=1, xstart=8, ystart=44, mx=3, my=-8 },
["TOPLEFTTOPRIGHT"] = { xoff=4, yoff=0, xdir=-1, ydir=-1, xstart=-44, ystart=-8, mx=-2, my=8 },
["BOTTOMLEFTBOTTOMRIGHT"] = { xoff=4, yoff=0, xdir=-1, ydir=1, xstart=-44, ystart=44, mx=-2, my=-8 },
["TOPRIGHTBOTTOMRIGHT"] = { xoff=0, yoff=-4, xdir=-1, ydir=1, xstart=-44, ystart=44, mx=8, my=3 },
["BOTTOMRIGHTTOPRIGHT"] = { xoff=0, yoff=4, xdir=-1, ydir=-1, xstart=-44, ystart=-8, mx=8, my=-3 },
["TOPLEFTBOTTOMLEFT"] = { xoff=0, yoff=-4, xdir=1, ydir=1, xstart=8, ystart=44, mx=-8, my=2 },
["BOTTOMLEFTTOPLEFT"] = { xoff=0, yoff=4, xdir=1, ydir=-1, xstart=8, ystart=-8, mx=-8, my=-2 } }
-- returns info depending on current docking. ie: dock_info("xoff")
local function dock_info(which)
local anchor = ItemRack.MainDock..ItemRack.MenuDock
if dock_stats[anchor] and which and dock_stats[anchor][which] then
return dock_stats[anchor][which]
else
return 0
end
end
-- returns info depending on where the window is currently
-- since frame scales and positions can be nil at the most inconvenient times, it approximates
-- its corner based on settings and makes no assumptions that even UIParent exists
-- no argument : return corner window is in
-- "LEFTRIGHT" : return "LEFT" or "RIGHT"
-- "TOPBOTTOM" : return "TOP" or "BOTTOM"
local function corner_info(which)
local length,cx,cy,xpoint,ypoint
local vertside,horzside = "TOP","LEFT"
local info
if table.getn(ItemRack_Users[user].Bar)>0 then
length = table.getn(ItemRack_Users[user].Bar)*40 + 32
if ItemRack_Users[user].MainOrient=="HORIZONTAL" then
cx = length
cy = 55
else
cx = 55
cy = length
end
xpoint = cx/2+(ItemRack_Users[user].XPos*ItemRack_Users[user].MainScale)
ypoint = (ItemRack_Users[user].YPos*ItemRack_Users[user].MainScale)-cy/2
if xpoint<(UIParent and UIParent:GetWidth()/2 or 512) then
horzside = "LEFT"
else
horzside = "RIGHT"
end
if ypoint<(UIParent and UIParent:GetHeight()/2 or 386) then
vertside = "BOTTOM"
else
vertside = "TOP"
end
end
if which=="LEFTRIGHT" then
info = horzside
elseif which=="TOPBOTTOM" then
info = vertside
else
info = vertside..horzside
end
return info
end
local inv_dock = {
[0] = { orient="HORIZONTAL", maindock="BOTTOMLEFT", menudock="TOPLEFT" },
[1] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[2] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[3] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[4] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[5] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[6] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[7] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[8] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[9] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[10] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[11] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[12] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[13] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[14] = { orient="VERTICAL", maindock="TOPRIGHT", menudock="TOPLEFT" },
[15] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" },
[16] = { orient="HORIZONTAL", maindock="BOTTOMLEFT", menudock="TOPLEFT" },
[17] = { orient="HORIZONTAL", maindock="BOTTOMLEFT", menudock="TOPLEFT" },
[18] = { orient="HORIZONTAL", maindock="BOTTOMLEFT", menudock="TOPLEFT" },
[19] = { orient="VERTICAL", maindock="TOPLEFT", menudock="TOPRIGHT" }
}
-- places the menu against the invslot
-- setframe = true when docking to set frame
function ItemRack_DockMenu(invslot,relativeTo)
local attachTo = ((not relativeTo) and "ItemRackInv"..invslot) or (relativeTo=="TITAN" and "TitanPanelItemRackButton") or (relativeTo=="SET" and "ItemRack_Sets_Inv"..invslot) or (relativeTo=="MINIMAP" and "ItemRack_IconFrame") or ItemRack.Indexes[invslot].paperdoll_slot
local item = getglobal(attachTo)
local noflip = ItemRack_Settings.FlipMenu=="OFF"
local corner=corner_info()
local mainorient = ItemRack_Users[user].MainOrient
local ynudge -- amount if any to nudge the y offset
if relativeTo then
ItemRack.MenuDockedTo = relativeTo
end
if relativeTo=="MINIMAP" then
if (ItemRack_IconFrame:GetTop() or 0)<(UIParent:GetHeight() or 0)/2 then
ItemRack.MainDock = "TOPLEFT"
ItemRack.MenuDock = "BOTTOMLEFT"
ynudge = -12
else
ItemRack.MainDock = "BOTTOMRIGHT"
ItemRack.MenuDock = "TOPRIGHT"
ynudge = 12
end
elseif relativeTo=="TITAN" then
local xpos, ypos = GetCursorPosition()
if ypos<400 then
ItemRack.MainDock = "TOPLEFT"
ItemRack.MenuDock = "BOTTOMLEFT"
ynudge = 0
else
ItemRack.MainDock = "BOTTOMLEFT"
ItemRack.MenuDock = "TOPLEFT"
ynudge = 0
end
elseif mainorient=="HORIZONTAL" then
if corner=="BOTTOMLEFT" then
ItemRack.MainDock = noflip and "TOPLEFT" or "BOTTOMLEFT"
ItemRack.MenuDock = noflip and "BOTTOMLEFT" or "TOPLEFT"
elseif corner=="BOTTOMRIGHT" then
ItemRack.MainDock = noflip and "TOPRIGHT" or "BOTTOMRIGHT"
ItemRack.MenuDock = noflip and "BOTTOMRIGHT" or "TOPRIGHT"
elseif corner=="TOPLEFT" then
ItemRack.MainDock = noflip and "BOTTOMLEFT" or "TOPLEFT"
ItemRack.MenuDock = noflip and "TOPLEFT" or "BOTTOMLEFT"
else -- "TOPRIGHT"
ItemRack.MainDock = noflip and "BOTTOMRIGHT" or "TOPRIGHT"
ItemRack.MenuDock = noflip and "TOPRIGHT" or "BOTTOMRIGHT"
end
else
if corner=="BOTTOMLEFT" then
ItemRack.MainDock = noflip and "BOTTOMRIGHT" or "BOTTOMLEFT"
ItemRack.MenuDock = noflip and "BOTTOMLEFT" or "BOTTOMRIGHT"
elseif corner=="BOTTOMRIGHT" then
ItemRack.MainDock = noflip and "BOTTOMLEFT" or "BOTTOMRIGHT"
ItemRack.MenuDock = noflip and "BOTTOMRIGHT" or "BOTTOMLEFT"
elseif corner=="TOPLEFT" then
ItemRack.MainDock = noflip and "TOPRIGHT" or "TOPLEFT"
ItemRack.MenuDock = noflip and "TOPLEFT" or "TOPRIGHT"
else -- "TOPRIGHT"
ItemRack.MainDock = noflip and "TOPLEFT" or "TOPRIGHT"
ItemRack.MenuDock = noflip and "TOPRIGHT" or "TOPLEFT"
end
end
if relativeTo=="SET" then
ItemRack_MenuFrame:SetScale(ItemRack_SetsFrame:GetScale())
ItemRack.MainDock = inv_dock[invslot].maindock
ItemRack.MenuDock = inv_dock[invslot].menudock
elseif relativeTo=="CHARACTERSHEET" then
ItemRack_MenuFrame:SetScale(getglobal(ItemRack.Indexes[1].paperdoll_slot):GetScale())
ItemRack.MainDock = inv_dock[invslot].maindock
ItemRack.MenuDock = inv_dock[invslot].menudock
if ItemRack.MainDock == "TOPLEFT" then
-- horizontal menus always go to right on character sheet
ItemRack.MainDock = "TOPRIGHT"
ItemRack.MenuDock = "TOPLEFT"
end
else
ItemRack_MenuFrame:SetScale(ItemRack_Users[user].MainScale)
end
ItemRack_MenuFrame:ClearAllPoints()
ItemRack_MenuFrame:SetPoint(ItemRack.MenuDock,attachTo,ItemRack.MainDock,dock_info("mx"),dock_info("my")+ (ynudge and ynudge or 0))
end
-- v1="Left1" or "Right1" up to "Left30" or "Right30"
local function is_red(v1)
local its_red,r,g,b = false
r,g,b = getglobal("Rack_TooltipScanText"..v1):GetTextColor()
if r>.9 and g<.2 and b<.2 then
its_red = true
end
return its_red
end
-- returns true if the player can wear this item (no red text on its tooltip)
-- separated from get_item_info because tooltip scanning should be done only at utmost need
local function player_can_wear(bag,slot,invslot)
local found,i,txt = false
for i=2,15 do
-- ClearLines doesn't remove colors, manually remove them
getglobal("Rack_TooltipScanTextLeft"..i):SetTextColor(0,0,0)
getglobal("Rack_TooltipScanTextRight"..i):SetTextColor(0,0,0)
end
Rack_TooltipScan:SetBagItem(bag,slot)
for i=2,15 do
txt = getglobal("Rack_TooltipScanTextLeft"..i):GetText()
-- if either left or right text is red and this isn't a Durability x/x line, this item can't be worn
if (is_red("Left"..i) or is_red("Right"..i)) and not string.find(txt,durability_pattern) and not string.find(txt,"^Requires") then
found = true
end
end
local _,_,_,itemType = Rack.GetItemInfo(bag,slot)
if itemType=="INVTYPE_WEAPON" and invslot==17 and not ItemRack.CanWearOneHandOffHand then
found = true
end
return not found
end
-- the old central info gatherer, now a wrapper to Rack.GetItemInfo
local function get_item_info(bag,slot)
local texture,name,equipslot,soulbound,count
if bag==20 then
-- if querying set slot, return current set texture and name
name = Rack.CurrentSet()
texture = "Interface\\AddOns\\ItemRack\\ItemRack-Icon"
if name and Rack_User[user].Sets[name] and not string.find(name,"^ItemRack") and not string.find(name,"^Rack-") then
texture = Rack_User[user].Sets[name].icon
else
name = nil
end
return texture,name
end
texture,_,name,equipslot = Rack.GetItemInfo(bag,slot)
if slot then
_,count = GetContainerItemInfo(bag,slot)
end
if ItemRack_Settings.Soulbound=="ON" and name then
local text
if slot then
Rack_TooltipScan:SetBagItem(bag,slot)
else
Rack_TooltipScan:SetInventoryItem("player",bag)
end
for i=2,5 do
text = getglobal("Rack_TooltipScanTextLeft"..i):GetText() or ""
if text==ITEM_SOULBOUND or text==ITEM_BIND_QUEST or text==ITEM_CONJURED then
soulbound = true
end
end
end
return texture,name,equipslot,soulbound,count
end
local function cursor_empty()
return not (CursorHasItem() or CursorHasMoney() or CursorHasSpell())
end
-- updates cooldown spinners in the menu
local function update_menu_cooldowns()
local start, duration, enable
if ItemRack.InvOpen then
for i=1,ItemRack.NumberOfItems do
if ItemRack.BaggedItems[i].bag then
start, duration, enable = GetContainerItemCooldown(ItemRack.BaggedItems[i].bag,ItemRack.BaggedItems[i].slot)
CooldownFrame_SetTimer(getglobal("ItemRackMenu"..i.."Cooldown"), start, duration, enable)
else
getglobal("ItemRackMenu"..i.."Time"):SetText("")
end
end
end
end
-- updates cooldown spinners in the main bar
local function update_inv_cooldowns()
local i, start, duration, enable
if table.getn(ItemRack_Users[user].Bar)>0 then
for i=1,table.getn(ItemRack_Users[user].Bar) do
start, duration, enable = GetInventoryItemCooldown("player",ItemRack_Users[user].Bar[i])
CooldownFrame_SetTimer(getglobal("ItemRackInv"..ItemRack_Users[user].Bar[i].."Cooldown"), start, duration, enable)
end
end
update_menu_cooldowns()
end
-- call this when window has changed and cooldowns need redrawn
local function cooldowns_need_updating()
Rack.StartTimer("CooldownUpdate",.25)
ItemRack.CooldownsNeedUpdating = true
end
local function populate_baggeditems(idx,bag,slot,name,texture)
if not ItemRack.BaggedItems[idx] then
ItemRack.BaggedItems[idx] = {}
end
ItemRack.BaggedItems[idx].bag = bag
ItemRack.BaggedItems[idx].slot = slot
ItemRack.BaggedItems[idx].name = name
ItemRack.BaggedItems[idx].texture = texture
end
-- to minimize garbage creation, tables are manipulated by copying values instead of tables
local function copy_baggeditems(source,dest)
if not ItemRack.BaggedItems[dest] then
ItemRack.BaggedItems[dest] = {}
end
ItemRack.BaggedItems[dest].bag = ItemRack.BaggedItems[source].bag
ItemRack.BaggedItems[dest].slot = ItemRack.BaggedItems[source].slot
ItemRack.BaggedItems[dest].name = ItemRack.BaggedItems[source].name
ItemRack.BaggedItems[dest].texture = ItemRack.BaggedItems[source].texture
end
-- sorts menu up to stop_point, which is idx+1 usually (sort uses stop_point as a temp spot for swapping)
local function sort_menu(stop_point)
local done,i=false
if stop_point>2 then
while not done do
done = true
for i=1,stop_point-2 do
if ItemRack.BaggedItems[i].name > ItemRack.BaggedItems[i+1].name then
copy_baggeditems(i,stop_point)
copy_baggeditems(i+1,i)
copy_baggeditems(stop_point,i+1)
done = false
end
end
end
end
end
function ItemRack_CurrentSet()
return Rack.CurrentSet()
end
-- builds a menu outward from invslot (0-19)
-- setframe = true if this is to dock to the set frame
function ItemRack_BuildMenu(invslot,relativeTo)
local idx,i,j,k,item,texture,name,equipslot,soulbound,found = 1
local mainorient = ItemRack_Users[user].MainOrient
local bagStart,bagEnd = 0,4
if relativeTo=="SET" or relativeTo=="CHARACTERSHEET" then
-- if displaying to a set, then
mainorient = "VERTICAL"
if invslot==0 or invslot==16 or invslot==17 or invslot==18 then
mainorient = "HORIZONTAL"
end
elseif relativeTo=="MINIMAP" then
mainorient = "HORIZONTAL"
elseif relativeTo=="TITAN" then
mainorient = "HORIZONTAL"
end
ItemRack_DockMenu(invslot,relativeTo)
for i=1,table.getn(ItemRack_Users[user].Bar) do
if invslot~=ItemRack_Users[user].Bar[i] then
getglobal("ItemRackInv"..ItemRack_Users[user].Bar[i]):UnlockHighlight()
else
getglobal("ItemRackInv"..ItemRack_Users[user].Bar[i]):LockHighlight()
end
end
if invslot==0 then
-- if this is an ammo slot, clear totals
for i in ItemRack.AmmoCounts do
ItemRack.AmmoCounts[i] = 0
end
end
if invslot<20 then
if ItemRack.BankIsOpen then
bagStart,bagEnd = -1,10
end
-- go through bags and gather items into .BaggedItems
for i=bagStart,bagEnd do
for j=1,GetContainerNumSlots(i) do
texture,name,equipslot,soulbound,count = get_item_info(i,j)
soulbound = soulbound or ItemRack.Indexes[invslot].ignore_soulbound -- pretend item soulbound if flagged to ignore_soulbound
if (equipslot and ItemRack.Indexes[invslot][equipslot]) and (soulbound or ItemRack_Settings.Soulbound=="OFF") then
if ItemRack_Settings.AllowHidden=="ON" and ItemRack_Users[user].Ignore[name] and not IsAltKeyDown() then
-- skip items that are on ignore list
elseif player_can_wear(i,j,invslot) then
if invslot==0 and count then
-- if this is an ammo slot menu
ItemRack.AmmoCounts[name] = (ItemRack.AmmoCounts[name] or 0) + count
found = false
for k=1,(idx-1) do
if ItemRack.BaggedItems[k].name==name then
found=true
end
end
if not found then
populate_baggeditems(idx,i,j,name,texture)
idx = idx + 1
end
else
populate_baggeditems(idx,i,j,name,texture)
idx = idx + 1
end
end
end
end
end
sort_menu(idx)
if ItemRack_Settings.ShowEmpty=="ON" and GetInventoryItemLink("player",invslot) and not (ItemRack_Settings.RightClick=="ON" and (invslot==13 or invslot==14)) then
-- add an empty slot to the menu
_,_,i = string.find(ItemRack.Indexes[invslot].keybind,"Use (.+) Item")
_,j = GetInventorySlotInfo(string.gsub(ItemRack.Indexes[invslot].paperdoll_slot,"Character",""))
populate_baggeditems(idx,nil,nil,"(empty)",j)
idx = idx + 1
end
else
-- this is a menu for sets
-- go through sets and gather them into .BaggedItems
for i in Rack_User[user].Sets do
if not string.find(i,"^ItemRack") and not string.find(i,"^Rack-") and (not Rack_User[user].Sets[i].hide or IsAltKeyDown()) then
populate_baggeditems(idx,nil,nil,i,Rack_User[user].Sets[i].icon)
idx = idx + 1
end
end
sort_menu(idx)
end
ItemRack.NumberOfItems = math.min(idx-1,ItemRack.MaxItems)
if ItemRack.NumberOfItems<1 then
-- user has no bagged items for this type
ItemRack_MenuFrame:Hide()
else
-- display items outward from docking point
local col,row,xpos,ypos = 0,0,dock_info("xstart"),dock_info("ystart")
local max_cols = 1
if ItemRack.NumberOfItems>24 then
max_cols = 5
elseif ItemRack.NumberOfItems>18 then
max_cols = 4
elseif ItemRack.NumberOfItems>12 then
max_cols = 3
elseif ItemRack.NumberOfItems>4 then
max_cols = 2
end
for i=1,ItemRack.NumberOfItems do
local item = getglobal("ItemRackMenu"..i.."Icon")
item:SetTexture(ItemRack.BaggedItems[i].texture)
-- grey menu item if it's on the ignore list (ALT key is down if it made it to BaggedItems)
if ItemRack_Settings.AllowHidden=="ON" and (ItemRack_Users[user].Ignore[ItemRack.BaggedItems[i].name] or (Rack_User[user].Sets[ItemRack.BaggedItems[i].name] and Rack_User[user].Sets[ItemRack.BaggedItems[i].name].hide)) then
SetDesaturation(item,1)
else
SetDesaturation(item,nil)
end
local item = getglobal("ItemRackMenu"..i)
item:SetPoint("TOPLEFT","ItemRack_MenuFrame",ItemRack.MenuDock,xpos,ypos)
if (mainorient=="HORIZONTAL" and ItemRack_Settings.RotateMenu=="OFF") or (mainorient=="VERTICAL" and ItemRack_Settings.RotateMenu=="ON") then
xpos = xpos + dock_info("xdir")*40
col = col + 1
if col==max_cols then
xpos = dock_info("xstart")
col = 0
ypos = ypos + dock_info("ydir")*40
row = row + 1
end
item:Show()
else
ypos = ypos + dock_info("ydir")*40
col = col + 1
if col==max_cols then
ypos = dock_info("ystart")
col = 0
xpos = xpos + dock_info("xdir")*40
row = row + 1
end
item:Show()
end
end
for i=(ItemRack.NumberOfItems+1),ItemRack.MaxItems do
getglobal("ItemRackMenu"..i):Hide()
end
if col==0 then
row = row-1
end
if (mainorient=="HORIZONTAL" and ItemRack_Settings.RotateMenu=="OFF") or (mainorient=="VERTICAL" and ItemRack_Settings.RotateMenu=="ON") then
ItemRack_MenuFrame:SetWidth(12+(max_cols*40))
ItemRack_MenuFrame:SetHeight(12+((row+1)*40))
else
ItemRack_MenuFrame:SetWidth(12+((row+1)*40))
ItemRack_MenuFrame:SetHeight(12+(max_cols*40))
end
-- apply slot-dependant overlays, ammo count, set name and key bindings
if invslot==0 then -- if this is an ammo slot, show counts
for i=1,ItemRack.NumberOfItems do
if ItemRack.AmmoCounts[ItemRack.BaggedItems[i].name] then
getglobal("ItemRackMenu"..i.."Count"):SetText(ItemRack.AmmoCounts[ItemRack.BaggedItems[i].name])
end
end
elseif invslot==20 then -- if this is a set slot, show names and bindings
for i=1,ItemRack.NumberOfItems do
name = ItemRack.BaggedItems[i].name
if ItemRack.BankIsOpen and Rack.SetHasBanked(name) then
getglobal("ItemRackMenu"..i.."Border"):Show()
getglobal("ItemRackMenu"..i.."Icon"):SetVertexColor(.5,.5,.5)
else
getglobal("ItemRackMenu"..i.."Border"):Hide()
getglobal("ItemRackMenu"..i.."Icon"):SetVertexColor(1,1,1)
end
item = getglobal("ItemRackMenu"..i.."Name")
if ItemRack_Settings.SetLabels=="ON" then
item:SetText(name)
item:Show()
else
item:Hide()
end
item = getglobal("ItemRackMenu"..i.."HotKey")
if Rack_User[user].Sets[name].key and ItemRack_Settings.Bindings=="ON" then
_,_,j,k = string.find(Rack_User[user].Sets[name].key or "","(.).+(-.)")
item:SetText((j or "")..(k or ""))
item:Show()
else
item:Hide()
end
end
else -- normal slot (1-19) has no overlays
for i=1,ItemRack.NumberOfItems do
getglobal("ItemRackMenu"..i.."Name"):SetText("")
getglobal("ItemRackMenu"..i.."Count"):SetText("")
getglobal("ItemRackMenu"..i.."HotKey"):SetText("")
if ItemRack.BankedItems[ItemRack.BaggedItems[i].id] then
getglobal("ItemRackMenu"..i.."Border"):Show()
getglobal("ItemRackMenu"..i.."Icon"):SetVertexColor(.5,.5,.5)
else
getglobal("ItemRackMenu"..i.."Border"):Hide()
getglobal("ItemRackMenu"..i.."Icon"):SetVertexColor(1,1,1)
end
end
end
ItemRack.InvOpen = invslot
ItemRack_MenuFrame:Show()
update_menu_cooldowns()
Rack.StartTimer("CooldownUpdate",0) -- immediate cooldown update
Rack.StartTimer("MenuFrame")
end
end
-- for use with main/menu frames with UIParent parent when relocated by the mod, to register for layout-cache.txt
local function really_setpoint(frame,point,relativeTo,relativePoint,xoff,yoff)
frame:SetPoint(point,relativeTo,relativePoint,xoff,yoff)
ItemRack_Users[user].XPos = xoff
ItemRack_Users[user].YPos = yoff
end
-- updates the image inside the minimap button depending on current set and disable toggle option ("Minimap set menu")
local function draw_minimap_icon()
local setname = Rack.CurrentSet()
if setname and Rack_User[user].Sets[setname] and ItemRack_Settings.DisableToggle=="ON" then
ItemRack_IconFrame_Icon:SetTexture(Rack_User[user].Sets[setname].icon)
else
ItemRack_IconFrame_Icon:SetTexture("Interface\\AddOns\\ItemRack\\ItemRack-Icon")
end
end
-- draws the inventory bar
local function draw_inv()
local oldx = ItemRack_InvFrame:GetLeft() or ItemRack_Users[user].XPos
local oldy = ItemRack_InvFrame:GetTop() or ItemRack_Users[user].YPos
local oldcx = ItemRack_InvFrame:GetWidth() or 0
local oldcy = ItemRack_InvFrame:GetHeight() or 0
local bar = ItemRack_Users[user].Bar
if not oldx or not oldy then
return -- frame isn't fully defined yet, leave now
end
-- for a left-to-right horizontal configuration
local cx,cy,i,item,texture,xspacer,yspacer = 56,56
if ItemRack_Users[user].MainOrient=="HORIZONTAL" then
-- horizontal from left to right
xdir,ydir,corner,cornerTo,cornerStart,xdirStart,ydirStart,xadd,yadd = 4,0,"TOPRIGHT","TOPLEFT","TOPLEFT",10,-10,40,0
if ItemRack_Settings.FlipBar=="ON" then
-- horizontal from right to left
xdir,ydir,corner,cornerTo,cornerStart,xdirStart,ydirStart,xadd,yadd = -4,0,"TOPLEFT","TOPRIGHT","TOPRIGHT",-10,-10,-40,0
end
else
-- vertical from top to bottom
xdir,ydir,corner,cornerTo,cornerStart,xdirStart,ydirStart,xadd,yadd = 0,-4,"BOTTOMLEFT","TOPLEFT","TOPLEFT",10,-10,0,40
if ItemRack_Settings.FlipBar=="ON" then
-- vertical from bottom to top
xdir,ydir,corner,cornerTo,cornerStart,xdirStart,ydirStart,xadd,yadd = 0,4,"TOPLEFT","BOTTOMLEFT","BOTTOMLEFT",10,10,0,-40
end
end
for i=0,20 do
getglobal("ItemRackInv"..i):Hide()
end
ItemRack.TrinketsPaired = false -- changes to true if two trinkets are beside each other
if table.getn(bar)>0 then
item = getglobal("ItemRackInv"..bar[1])
item:ClearAllPoints()
item:SetPoint(cornerStart,"ItemRack_InvFrame",cornerStart,xdirStart,ydirStart)
getglobal("ItemRackInv"..bar[1].."Icon"):SetTexture(get_item_info(bar[1]))
item:Show()
if ItemRack_Settings.RightClick=="ON" and (bar[1]==13 and bar[2]==14) then
ItemRack.TrinketsPaired = true
end
for i=2,table.getn(bar) do
xspacer,yspacer = 0,0
if ItemRack_Settings.RightClick=="ON" and ((bar[i]==13 and bar[i+1] and bar[i+1]==14) or
(bar[i-1]==14 and bar[i-2] and bar[i-2]==13)) then
ItemRack.TrinketsPaired = true
end
if ItemRack_Users[user].Spaces[bar[i-1]] then
xspacer = xdir*2
yspacer = ydir*2
end
item = getglobal("ItemRackInv"..bar[i])
item:ClearAllPoints()
item:SetPoint(cornerTo,"ItemRackInv"..bar[i-1],corner,xdir+xspacer,ydir+yspacer)
getglobal("ItemRackInv"..bar[i].."Icon"):SetTexture(get_item_info(bar[i]))
item:Show()
cx = cx + math.abs(xadd) + math.abs(xspacer)
cy = cy + math.abs(yadd) + math.abs(yspacer) -- was minus yspacer
end
ItemRack_InvFrame:SetWidth(cx)
ItemRack_InvFrame:SetHeight(cy)
if ItemRack_Settings.FlipBar=="ON" and oldcx>32 and oldcy>32 then
-- if bar size changed (after being drawn before), and we're flipped, we need to shift it over
ItemRack_InvFrame:ClearAllPoints()
if ItemRack_Users[user].MainOrient=="HORIZONTAL" then
oldx = oldx + (oldcx-cx)
else
oldy = oldy + (cy-oldcy)
end
really_setpoint(ItemRack_InvFrame,"TOPLEFT","UIParent","BOTTOMLEFT",oldx,oldy)
end
if ItemRack_Users[user].Visible~="OFF" then
ItemRack_InvFrame:Show()
end
cooldowns_need_updating()
Rack.StartTimer("CooldownUpdate",0)
if ItemRack_Settings.SetLabels=="ON" then
local currentset = Rack.CurrentSet()
if currentset and Rack_User[user].Sets[currentset] then
ItemRackInv20Name:SetText(currentset)
else
ItemRackInv20Name:SetText(ItemRackText.EMPTYSET)
end
else
ItemRackInv20Name:SetText("")
end
else
ItemRack_Users[user].Visible="OFF"
ItemRack_InvFrame:Hide()
end
draw_minimap_icon()
if ItemRack_UpdatePlugins then
-- update plugin if it exists
local setname = Rack.CurrentSet()
if setname and ItemRack_Users[user].Sets[setname] then
ItemRack_UpdatePlugins(setname,ItemRack_Users[user].Sets[setname].icon)
else
ItemRack_UpdatePlugins(nil,"Interface\\AddOns\\ItemRack\\ItemRack-Icon")
end
end
end
local function unlocked()
return ItemRack_Users[user].Locked~="ON"
end
-- sets window lock "ON" or "OFF"
local function set_lock(arg1)
ItemRack_Users[user].Locked = arg1
if arg1=="ON" then
ItemRack_InvFrame:SetBackdropColor(0,0,0,0)
ItemRack_InvFrame:SetBackdropBorderColor(0,0,0,0)
ItemRack_InvFrame_Resize:Hide()
ItemRack_Control_Rotate:SetAlpha(.4)
ItemRack_Control_Rotate:Disable()
else
ItemRack_InvFrame:SetBackdropColor(1,1,1,1)
ItemRack_InvFrame:SetBackdropBorderColor(1,1,1,1)
ItemRack_InvFrame_Resize:Show()
ItemRack_Control_Rotate:SetAlpha(1)
ItemRack_Control_Rotate:Enable()
ItemRack_ControlFrame:Show()
Rack.StartTimer("ControlFrame")
end
end
-- called at startup, UPDATE_BINDINGS and option change to show/hide key bindings
local function update_keybindings()
local i,modifier,key,text
-- update bindings for inventory slots
for i=0,19 do
if ItemRack.Indexes[i].keybind and ItemRack_Settings.Bindings=="ON" then
text = GetBindingKey(ItemRack.Indexes[i].keybind)
_,_,modifier,key = string.find(text or "","(.).+(-.)")
if modifier and key then
text = modifier..key
end
getglobal("ItemRackInv"..i.."HotKey"):SetText(text)
else
getglobal("ItemRackInv"..i.."HotKey"):SetText("")
end
end
-- update bindings for items on the rack
ItemRack_AgreeOnKeyBindings()
end
local function move_control()