forked from alexqu0822/alaGearMan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalaGearMan.lua
More file actions
2638 lines (2560 loc) · 83.2 KB
/
alaGearMan.lua
File metadata and controls
2638 lines (2560 loc) · 83.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
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[--
by ALA @ 163UI
Please Keep WOW Addon open-source & Reduce barriers for others.
复用代码请在显著位置标注来源【ALA@网易有爱】
请勿加密、乱码、删除空格tab换行符、设置加载依赖
--]]--
----------------------------------------------------------------------------------------------------
local GetContainerNumFreeSlots = GetContainerNumFreeSlots or C_Container.GetContainerNumFreeSlots
local GetContainerItemID = GetContainerItemID or C_Container.GetContainerItemID
local GetContainerNumSlots, GetContainerItemLink, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID
if C_Container then
GetContainerNumSlots = C_Container.GetContainerNumSlots
GetContainerItemLink = C_Container.GetContainerItemLink
GetContainerItemCooldown = C_Container.GetContainerItemCooldown
GetItemCooldown = C_Container.GetItemCooldown
PickupContainerItem = C_Container.PickupContainerItem
ContainerIDToInventoryID = C_Container.ContainerIDToInventoryID
GetContainerItemInfo = function(bag, slot)
local info = C_Container.GetContainerItemInfo(bag, slot)
if info then
return info.iconFileID, info.stackCount, info.isLocked, info.quality, info.isReadable, info.hasLoot, info.hyperlink, info.isFiltered, info.hasNoValue, info.itemID, info.isBound
else
return
end
end
else
GetContainerNumSlots, GetContainerItemLink, GetContainerItemCooldown, GetContainerItemInfo, GetItemCooldown, PickupContainerItem, ContainerIDToInventoryID =
_G.GetContainerNumSlots, _G.GetContainerItemLink, _G.GetContainerItemCooldown, _G.GetContainerItemInfo, _G.GetItemCooldown, _G.PickupContainerItem, _G.ContainerIDToInventoryID
end
local _G = _G;
local __ala_meta__ = _G.__ala_meta__;
local uireimp = __ala_meta__.uireimp;
local autostyle = __ala_meta__.autostyle;
local ADDON, NS = ...;
local L = NS.L;
do
if NS.__fenv == nil then
NS.__fenv = setmetatable({ },
{
__index = _G,
__newindex = function(t, key, value)
rawset(t, key, value);
print("agm assign global", key, value);
return value;
end,
}
);
end
setfenv(1, NS.__fenv);
end
----------------------------------------------------------------------------------------------------upvalue LUA
local math, table, string, bit = math, table, string, bit;
local type, tonumber, tostring = type, tonumber, tostring;
local getfenv, setfenv, pcall, xpcall, assert, error, loadstring = getfenv, setfenv, pcall, xpcall, assert, error, loadstring;
local abs, ceil, floor, max, min, random, sqrt = abs, ceil, floor, max, min, random, sqrt;
local format, gmatch, gsub, strbyte, strchar, strfind, strlen, strlower, strmatch, strrep, strrev, strsub, strupper, strtrim, strsplit, strjoin, strconcat =
format, gmatch, gsub, strbyte, strchar, strfind, strlen, strlower, strmatch, strrep, strrev, strsub, strupper, strtrim, strsplit, strjoin, strconcat;
local getmetatable, setmetatable, rawget, rawset = getmetatable, setmetatable, rawget, rawset;
local next, ipairs, pairs, sort, tContains, tinsert, tremove, wipe, unpack = next, ipairs, pairs, sort, tContains, tinsert, tremove, wipe, unpack;
local tConcat = table.concat;
local select = select;
local date, time = date, time;
local C_Timer = C_Timer;
----------------------------------------------------------------------------------------------------
local _ = nil;
local GameTooltip = GameTooltip;
local ItemRefTooltip = ItemRefTooltip;
----------------------------------------------------------------------------------------------------
local GUID = UnitGUID('player');
local saved_sets = { };
local default_sv = {
sets = { },
useBar = true,
quickSize = 18,
quickStyle = 'C', --'T' 'C' 'TC'
quickPos = { "TOP", 0, - 100, },
quickPosChar = { },
takeoffAll_pos = 'RIGHT',
takeoffAll_include_neck_finger_and_trinket = false,
show_outfit_in_tooltip = true,
multi_lines = false,
num_per_line = 6,
};
local _PaperDollItemSlotButton_OnEnter = PaperDollItemSlotButton_OnEnter;
local _PaperDollItemSlotButton_OnLeave = PaperDollItemSlotButton_OnLeave;
local SlotInfo = {
[0] = { INVTYPE_AMMO = 1, },
[1] = { INVTYPE_HEAD = 1, },
[2] = { INVTYPE_NECK = 1, },
[3] = { INVTYPE_SHOULDER = 1, },
[4] = { INVTYPE_BODY = 1, },
[5] = { INVTYPE_CHEST = 1, INVTYPE_ROBE = 1, },
[6] = { INVTYPE_WAIST = 1, },
[7] = { INVTYPE_LEGS = 1, },
[8] = { INVTYPE_FEET = 1, },
[9] = { INVTYPE_WRIST = 1, },
[10] = { INVTYPE_HAND = 1, },
[11] = { INVTYPE_FINGER = 1, },
[12] = { INVTYPE_FINGER = 1, },
[13] = { INVTYPE_TRINKET = 1, },
[14] = { INVTYPE_TRINKET = 1, },
[15] = { INVTYPE_CLOAK = 1, },
[16] = { INVTYPE_WEAPONMAINHAND = 1, INVTYPE_2HWEAPON = 1, INVTYPE_WEAPON = 1, },
[17] = { INVTYPE_WEAPON = 1, INVTYPE_WEAPONOFFHAND = 1, INVTYPE_SHIELD = 1, INVTYPE_HOLDABLE = 1, },
[18] = { INVTYPE_RANGED = 1, INVTYPE_RANGEDRIGHT = 1, INVTYPE_THROWN = 1, INVTYPE_RELIC = 1, },
[19] = { INVTYPE_TABARD = 1, },
};
local loc2Slot = { };
for slot, v in next, SlotInfo do
for loc, _ in next, v do
loc2Slot[loc] = loc2Slot[loc] or { };
tinsert(loc2Slot[loc], slot);
end
end
local slot2Name = {
[0] = "CharacterAmmoSlot",
[1] = "CharacterHeadSlot",
[2] = "CharacterNeckSlot",
[3] = "CharacterShoulderSlot",
[4] = "CharacterShirtSlot",
[5] = "CharacterChestSlot",
[6] = "CharacterWaistSlot",
[7] = "CharacterLegsSlot",
[8] = "CharacterFeetSlot",
[9] = "CharacterWristSlot",
[10] = "CharacterHandsSlot",
[11] = "CharacterFinger0Slot",
[12] = "CharacterFinger1Slot",
[13] = "CharacterTrinket0Slot",
[14] = "CharacterTrinket1Slot",
[15] = "CharacterBackSlot",
[16] = "CharacterMainHandSlot",
[17] = "CharacterSecondaryHandSlot",
[18] = "CharacterRangedSlot",
[19] = "CharacterTabardSlot",
};
local name2Slot = { };
for slot, name in next, slot2Name do
name2Slot[name] = slot;
end
local takeoffAll_order = { -- by price
16, 17, 18, 1, 5, 7, 3, 6, 8, 10, 9, 2, 11, 12, 13, 14, 15,--[[ 4,]]--[[ 19,]]
};
local NAME = "alaGearMan";
local SECURE_QUICK_NAME_PREFIX = "alaGearMan_SecureQuick";
local MACRO_NAME_PREFIX = "alaGearMan";
local NUM_GEAR_BINDING = 9;
--------------------------------------------------
----------------------------------------------------------------------------------------------------main
local function _log_(...)
-- print(date('\124cff00ff00%H:%M:%S\124r'), ...);
end
local function _error_(...)
print(date('\124cffff0000%H:%M:%S\124r'), ...);
end
local function _noop_()
end
local PDF_COUNTING_TIME = 0.5;
local PDF_UPDATE_TIME = 0.5;
local num_button_per_line = 6;
local buttonSize = 36;
local texture_unk = 134400; --"Interface\\Icons\\inv_misc_questionmark";
local texture_open = "interface\\AddOns\\alaGearMan\\ARTWORK\\ui-gearmanager-button";
local texture_takeoff = "Interface\\AddOns\\alaGearMan\\ARTWORK\\ui-gearmanager-leaveitem-opaque";
local texture_ignore = "Interface\\AddOns\\alaGearMan\\ARTWORK\\ui-gearmanager-undo";
local texture_add = "interface\\paperdollinfoframe\\character-plus";
local texture_highlight = "Interface\\Buttons\\ButtonHilight-Square";
local texture_highlight_coord = { 0.05, 0.95, 0.05, 0.95, };
local texture_glow = "Interface\\Buttons\\UI-ActionButton-Border";
local texture_glow_coord = { 0.25, 0.75, 0.25, 0.75, };
local texture_ignore_mask = "Interface\\paperdollinfoframe\\ui-gearmanager-leaveitem-transparent";
local texture_delete = "interface\\raidframe\\readycheck-notready";
local texture_modify = "interface\\scenarios\\scenarioicon-interact";
local texture_up = "interface\\AddOns\\alaGearMan\\ARTWORK\\ui-mainmenu-scrollupbutton-up";
local texture_down = "interface\\AddOns\\alaGearMan\\ARTWORK\\ui-mainmenu-scrolldownbutton-up";
local texture_style_char = "interface\\buttons\\checkbuttonhilight";
local buttonBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
tileSize = 2,
edgeSize = 2,
insets = { left = 0, right = 0, top = 0, bottom = 0 }
};
local buttonBackdropColor = { 0.25, 0.25, 0.25, 0.75 };
local buttonBackdropBorderColor = { 0.0, 0.0, 0.0, 1.0 };
local win_SizeX = 240;
local win_SizeY = 360;
local btn_SizeY = 36;
----------------------------------------------------------------------------------------------------main
local _EventHandler = CreateFrame("FRAME");
_EventHandler:SetSize(4, 4);
_EventHandler:EnableMouse(false);
local T_Scheduler = setmetatable({ }, { __mode = 'k', })
function NS.F_ScheduleDelayCall(func, delay)
local sch = T_Scheduler[func];
if sch == nil then
sch = { };
sch[1] = function()
func();
sch[2] = false;
end;
elseif sch[2] then
return;
end
sch[2] = true;
C_Timer.After(delay or 0.2, sch[1]);
end
--EquipItemByName(id/name/link, slot)
--RepairAllItems
local ui = { pdf_buttons = { }, pdf_ignore_mask = { }, };
local func = { };
local var = {
pdf_list = { }, pdf_cur_slot = nil, pdf_cur_anchor = nil, pdf_update_timer = 0,
pdf_ofs_ignore = nil, pdf_ofs_takeoff = nil,
gm_cur_set = nil, --cur selected set / vary with delete action
gm_prev_clicked_set = nil, gm_prev_clicked_time = -9999,
gm_is_editing = nil, gm_editing_set = nil, gm_custom_icon_selected = nil,
gm_ignore = { },
cache = { },
bagItemCache1 = { }, bagItemCache2 = { }, itemLoc = ItemLocation:CreateEmpty();
isBankOpened = false,
};
local global_var = {
drop_table = { },
};
local iconTable = {
texture_unk,
-- 136033, 132141, 132136, 132121, 132118, 134296, 136231,
-- 132122, 132142, 132091, 132127, 132140, 132242, 132089, 132152,
-- 132114, 132120, 132320, 132090, 132155, 132310, 132297, 132294,
-- 132302, 132282, 132354, 132219, 132274, 136066, 132273, 132290,
-- 136189, 132292, 132307, 132306, 132331, 136012, 132355, 134951,
-- 132223, 132338, 136105,
132349, 132341, 132275, 132282, 132337, 132155, 132333, 136105, 132316, 136080, 132363,
132223, 132110, 135358, 132362, 132369, 136012, 132355, 134951, 135920, 135906, 135959, 135964,
135928, 135970, 135968, 135907, 135967, 135943, 135966, 135926, 135995, 136051, 135934, 135972,
136048, 136052, 136026, 135813, 135127, 136018, 136015, 136114, 136042, 135861, 132292, 136189,
132090, 132307, 132310, 132306, 132219, 132092, 136175, 136168, 136023, 136206, 136183, 135932,
135812, 135843, 135846, 136096, 136071, 135848, 136116, 135826, 136153, 135857, 135736, 135852,
135991, 135869, 135808, 135903, 135841, 135824, 135988, 136006, 136078, 136041, 136081, 132136,
136085, 132114, 136033, 135753, 135987, 136207, 135940, 135953, 136224, 136184, 135894, 136123,
136200, 135946, 132204, 132218, 132212, 136076, 132330, 132169, 132208, 132293, 135815, 132157,
135130, 132329, 136185, 135817, 136197, 136118, 136139, 135230, 136210, 136186, 136135,
};
function func.pdf_CreateButton(index)
local button = CreateFrame("BUTTON", nil, ui.pdf_menu);
button:SetSize(buttonSize, buttonSize);
button:EnableMouse(true);
button:SetNormalTexture(texture_unk);
button:SetPushedTexture(texture_unk);
button:GetPushedTexture():SetVertexColor(0.5, 0.5, 0.5, 1.0);
button:SetHighlightTexture(texture_highlight);
button:GetHighlightTexture():SetTexCoord(unpack(texture_highlight_coord));
if autostyle ~= nil then
autostyle:AddReskinObject(button, "BUTTON.WITH.TEXTURE");
end
local glow = button:CreateTexture(nil, "OVERLAY");
glow:SetAllPoints();
glow:SetTexture(texture_glow);
glow:SetBlendMode("ADD");
glow:SetTexCoord(unpack(texture_glow_coord));
-- glow:SetAlpha(0.75);
glow:Show();
button.glow = glow;
button:SetScript("OnEnter", function(self, button)
local id = self.id;
GameTooltip:Hide();
if id > #var.pdf_list then
else
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetHyperlink(var.pdf_list[id]);
GameTooltip:Show();
end
ui.pdf_menu.countingTime = nil;
end);
button:SetScript("OnLeave", function(self, button)
if GameTooltip:IsOwned(self) then
GameTooltip:Hide();
end
ui.pdf_menu.countingTime = PDF_COUNTING_TIME;
end);
button:SetScript("OnClick", function(self, button)
local id = self.id;
if var.pdf_ofs_ignore and id == #var.pdf_list + var.pdf_ofs_ignore then
var.gm_ignore[var.pdf_cur_slot] = not var.gm_ignore[var.pdf_cur_slot];
if var.gm_ignore[var.pdf_cur_slot] then
ui.pdf_ignore_mask[var.pdf_cur_slot]:Show();
else
ui.pdf_ignore_mask[var.pdf_cur_slot]:Hide();
end
elseif var.pdf_ofs_takeoff and id == #var.pdf_list + var.pdf_ofs_takeoff then
if not InCombatLockdown() or var.pdf_cur_slot == 16 or var.pdf_cur_slot == 17 or var.pdf_cur_slot == 18 then
func.takeoff(var.pdf_cur_slot);
end
else
if not InCombatLockdown() then
func.equipItem(var.pdf_list[id], var.pdf_cur_slot);
ui.pdf_menu.countingTime = - 1.0;
end
end
end);
ui.pdf_buttons[index] = button;
button.id = index;
return button;
end
function func.pdf_CreateMenu(direction)
local hasInv = GetInventoryItemID('player', var.pdf_cur_slot) ~= nil;
local nButtons = (hasInv and 1 or 0) + ((var.gm_is_editing or var.gm_cur_set) and 1 or 0) + #var.pdf_list
if nButtons > #ui.pdf_buttons then
for i = #ui.pdf_buttons + 1, nButtons do
func.pdf_CreateButton(i);
end
elseif nButtons < #ui.pdf_buttons then
for i = nButtons + 1, #ui.pdf_buttons do
ui.pdf_buttons[i]:Hide();
end
end
for i = 1, #var.pdf_list do
local button = ui.pdf_buttons[i];
local name, _, quality, _, _, _, _, _, _, t = GetItemInfo(var.pdf_list[i]);
button:SetNormalTexture(t);
button:SetPushedTexture(t);
button.glow:SetVertexColor(GetItemQualityColor(quality));
button.glow:Show();
button:Show();
end
if hasInv then
var.pdf_ofs_takeoff = 1;
local i = #var.pdf_list + var.pdf_ofs_takeoff;
local button = ui.pdf_buttons[i];
button:SetNormalTexture(texture_takeoff);
button:SetPushedTexture(texture_takeoff);
-- button.glow:SetVertexColor(1.0, 0.0, 0.0);
button.glow:Hide();
button:Show();
else
var.pdf_ofs_takeoff = nil;
end
if var.gm_is_editing or var.gm_cur_set then
var.pdf_ofs_ignore = (hasInv and 1 or 0) + 1;
local i = #var.pdf_list + var.pdf_ofs_ignore;
local button = ui.pdf_buttons[i];
button:SetNormalTexture(texture_ignore);
button:SetPushedTexture(texture_ignore);
-- button.glow:SetVertexColor(1.0, 0.0, 0.0);
button.glow:Hide();
button:Show();
else
var.pdf_ofs_ignore = nil;
end
local pos = 2;
local lines = 1;
for i = 2, nButtons do
local button = ui.pdf_buttons[i];
if pos > num_button_per_line then
button:SetPoint("TOP", ui.pdf_buttons[i - num_button_per_line], "BOTTOM", 0, -2);
pos = 1;
lines = lines + 1;
else
button:SetPoint("LEFT", ui.pdf_buttons[i - 1], "RIGHT", 2, 0);
pos = pos + 1;
end
end
if lines == 1 then
ui.pdf_menu:SetSize(buttonSize * (pos - 1) + 2 * (pos - 2), buttonSize);
else
ui.pdf_menu:SetSize(buttonSize * num_button_per_line + 2 * (num_button_per_line - 2), buttonSize * lines + 2 * (lines - 1));
end
ui.pdf_menu:ClearAllPoints();
if direction == 1 then --down
if ui.pdf_menu:GetWidth() > var.pdf_cur_anchor:GetBottom() then
ui.pdf_menu:SetPoint("BOTTOM", var.pdf_cur_anchor, "TOP", 0, 2);
else
ui.pdf_menu:SetPoint("TOP", var.pdf_cur_anchor, "BOTTOM", 0, -2);
end
elseif direction == 2 then --slots in left
if ui.pdf_menu:GetWidth() > var.pdf_cur_anchor:GetLeft() then
ui.pdf_menu:SetPoint("LEFT", var.pdf_cur_anchor, "RIGHT", 2, 0);
else
ui.pdf_menu:SetPoint("RIGHT", var.pdf_cur_anchor, "LEFT", -2, 0);
end
elseif direction == 3 then --slot in right
if ui.pdf_menu:GetWidth() > GetScreenWidth() - var.pdf_cur_anchor:GetRight() then
ui.pdf_menu:SetPoint("RIGHT", var.pdf_cur_anchor, "LEFT", -2, 0);
else
ui.pdf_menu:SetPoint("LEFT", var.pdf_cur_anchor, "RIGHT", 2, 0);
end
end
end
function func.pdf_EventHandler_OnUpdate(self, elasped)
if var.pdf_update_timer <= 0.0 then
if IsAltKeyDown() then
local slot = var.pdf_cur_slot;
if slot then
_PaperDollItemSlotButton_OnLeave(var.pdf_cur_anchor);
wipe(var.pdf_list);
local slotHash = SlotInfo[slot];
for i = var.isBankOpened and -1 or 0, var.isBankOpened and 11 or 4 do
for j = 1, GetContainerNumSlots(i) do
local link = GetContainerItemLink(i, j);
if link and IsEquippableItem(link) then
local loc = select(9, GetItemInfo(link));
if slotHash[loc] then
tinsert(var.pdf_list, link);
end
end
end
end
if slot == 0 or slot == 16 or slot == 17 or slot == 18 then
func.pdf_CreateMenu(1);
elseif slot == 1 or slot == 2 or slot == 3 or slot == 4 or slot == 5 or slot == 9 or slot == 15 or slot == 19 then
func.pdf_CreateMenu(2);
else
func.pdf_CreateMenu(3);
end
ui.pdf_menu.countingTime = nil;
ui.pdf_menu:Show();
end
else
ui.pdf_menu:Hide();
--_PaperDollItemSlotButton_OnEnter(var.pdf_cur_anchor);
end
var.pdf_update_timer = PDF_UPDATE_TIME;
else
if IsAltKeyDown() then
if not ui.pdf_menu:IsShown() then
var.pdf_update_timer = 0.0;
func.pdf_EventHandler_OnUpdate(nil, 0.0);
else
var.pdf_update_timer = var.pdf_update_timer - elasped;
end
else
ui.pdf_menu:Hide();
end
end
end
function func.pdf_init()
for i, n in next, slot2Name do
local sf = _G[n];
local ignore_mask = sf:CreateTexture(nil, "OVERLAY");
ignore_mask:SetAllPoints();
ignore_mask:SetTexture(texture_ignore_mask);
ignore_mask:Hide();
ui.pdf_ignore_mask[i] = ignore_mask;
end
ui.pdf_menu = CreateFrame("FRAME", nil, PaperDollFrame);
ui.pdf_menu:SetFrameStrata("FULLSCREEN_DIALOG");
ui.pdf_menu:SetScript("OnEnter", function(self)
self.countingTime = nil;
end);
ui.pdf_menu:SetScript("OnLeave", function(self)
self.countingTime = PDF_COUNTING_TIME;
end);
ui.pdf_menu:SetScript("OnUpdate", function(self, elasped)
if self.countingTime then
self.countingTime = self.countingTime - elasped;
if self.countingTime <= 0.0 then
self:Hide();
self.countingTime = nil;
wipe(var.pdf_list);
end
end
end);
ui.pdf_menu:SetScript("OnHide", function(self)
if var.pdf_cur_anchor then
_PaperDollItemSlotButton_OnEnter(var.pdf_cur_anchor);
end
end);
func.pdf_CreateButton(1);
ui.pdf_buttons[1]:SetPoint("TOPLEFT");
local handler = CreateFrame("FRAME");
_G.PaperDollItemSlotButton_OnEnter = function(self)
var.pdf_cur_anchor = self;
local slot = name2Slot[self:GetName()];
if slot then
var.pdf_cur_slot = slot;
var.pdf_update_timer = 0.0;
handler:SetScript("OnUpdate", func.pdf_EventHandler_OnUpdate);
ui.pdf_menu.countingTime = nil;
ui.pdf_menu:Show();
end
if not IsAltKeyDown() then
return _PaperDollItemSlotButton_OnEnter(self);
end
end
_G.PaperDollItemSlotButton_OnLeave = function(self)
var.pdf_cur_anchor = nil;
handler:SetScript("OnUpdate", nil);
ui.pdf_menu.countingTime = PDF_COUNTING_TIME;
return _PaperDollItemSlotButton_OnLeave(self);
end
end
function func.pdf_hide_mask()
for slot, mask in next, ui.pdf_ignore_mask do
mask:Hide();
var.gm_ignore[slot] = false;
end
end
function func.pdf_show_mask(set)
for slot, mask in next, ui.pdf_ignore_mask do
if set[slot] == -1 then
ui.pdf_ignore_mask[slot]:Show();
var.gm_ignore[slot] = true;
else
ui.pdf_ignore_mask[slot]:Hide();
var.gm_ignore[slot] = false;
end
end
end
function func.OnEnter_Info_Outfit(self, index)
local T, isCur = func.check(index);
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
if T then
GameTooltip:AddLine(T.name, 1.0, 1.0, 1.0);
if isCur then
GameTooltip:AddLine(L["CURRENT_OUTFIT"], 0.0, 1.0, 0.0);
else
local set = saved_sets[index];
local missed = false;
for slot = 1, 19 do
local link = T[slot];
if type(link) == 'string' then
missed = true;
GameTooltip:AddDoubleLine(L.slot[slot] .. L["TOOLTIP_MISSING"], link, 1.0, 0.0, 0.0);
end
end
if not missed then
--
end
for slot = 1, 19 do
if T[slot] == 0 then
local link = set[slot];
GameTooltip:AddDoubleLine(L.slot[slot] .. L["IN_BAG"], link, 1.0, 1.0, 0.0);
end
end
for slot = 1, 19 do
if T[slot] == 1 then
local link = set[slot];
GameTooltip:AddDoubleLine(L.slot[slot] .. L["SHOULD_TAKE_OFF"], link, 1.0, 1.0, 0.0);
end
end
end
else
end
GameTooltip:Show();
end
function func.OnEnter_Info(self)
if self.info then
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
for _, msg in next, self.info do
GameTooltip:AddLine(msg);
end
GameTooltip:Show();
end
end
function func.OnLeave_Info(self)
if GameTooltip:GetOwner() == self then
GameTooltip:Hide();
end
end
function func.Sound_Equip()
PlaySound(841);
end
function func.Sound_Save()
PlaySound(841);
end
function func.Sound_Show()
PlaySound(841);
end
function func.Sound_Hide()
PlaySound(851);
end
function func.Sound_Order()
PlaySound(842);
end
StaticPopupDialogs["alaGearMan_DelSet"] = {
text = L["Delete this outfit?"],
button1 = L["OK"],
button2 = L["Cancel"],
OnShow = function(self) end,
OnAccept = function(self)
func.delete_onclick();
-- self.which = nil;
end,
OnHide = function(self)
self.which = nil;
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 1,
};
function func.gm_CreateButton(parent, index, buttonHeight)
-- print("CREATE", index)
local button = CreateFrame("BUTTON", nil, parent);
button:SetHeight(buttonHeight);
uireimp._SetBackdrop(button, buttonBackdrop);
uireimp._SetBackdropColor(button, buttonBackdropColor[1], buttonBackdropColor[2], buttonBackdropColor[3], buttonBackdropColor[4]);
uireimp._SetBackdropBorderColor(button, buttonBackdropBorderColor[1], buttonBackdropBorderColor[2], buttonBackdropBorderColor[3], buttonBackdropBorderColor[4]);
button:SetHighlightTexture("Interface\\FriendsFrame\\UI-FriendsFrame-HighlightBar");
button:EnableMouse(true);
button:RegisterForDrag("LeftButton");
button:Show();
if autostyle ~= nil then
autostyle:AddReskinObject(button, "BUTTON.WITH.TEXTURE");
end
local icon = button:CreateTexture(nil, "OVERLAY");
icon:SetTexture(texture_unk);
icon:SetSize(buttonHeight - 4, buttonHeight - 4);
icon:SetPoint("LEFT", 4, 0);
button.icon = icon;
if autostyle ~= nil then
autostyle:AddReskinObject(icon, "TEXTURE");
end
local title = button:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall");
title:SetPoint("LEFT", icon, "RIGHT", 4, 0);
button.title = title;
local glow_current = button:CreateTexture(nil, "OVERLAY");
glow_current:SetTexture(texture_glow);
glow_current:SetTexCoord(unpack(texture_glow_coord));
glow_current:SetVertexColor(1.0, 0.5, 0.0, 1.0);
glow_current:SetAllPoints();
glow_current:SetBlendMode("ADD");
glow_current:Hide();
button.glow_current = glow_current;
local glow_selected = button:CreateTexture(nil, "OVERLAY");
glow_selected:SetTexture(texture_glow);
glow_selected:SetTexCoord(unpack(texture_glow_coord));
glow_selected:SetAllPoints();
glow_selected:SetBlendMode("ADD");
glow_selected:Hide();
button.glow_selected = glow_selected;
local delete = CreateFrame("BUTTON", nil, button);
delete:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
delete:SetNormalTexture(texture_delete);
delete:SetPushedTexture(texture_delete);
delete:GetPushedTexture():SetVertexColor(0.25, 0.25, 0.25, 1.0);
delete:SetPoint("TOPRIGHT", -4, -2);
delete:Show();
delete:SetScript("OnEnter", func.OnEnter_Info);
delete:SetScript("OnLeave", func.OnLeave_Info);
delete:SetScript("OnClick", function(self)
local index = button:GetDataIndex();
if var.gm_is_editing and var.gm_editing_set == index then
ui.custom:Hide();
end
var.gm_editing_set = index;
StaticPopup_Show("alaGearMan_DelSet");
end);
-- delete.info = { };
button.delete = delete;
-- func.StyleObject('button', delete);
local modify = CreateFrame("BUTTON", nil, button);
modify:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
modify:SetNormalTexture(texture_modify);
modify:SetPushedTexture(texture_modify);
modify:GetPushedTexture():SetVertexColor(0.25, 0.25, 0.25, 1.0);
modify:SetPoint("BOTTOMRIGHT", -4, 2);
modify:Show();
modify:SetScript("OnEnter", func.OnEnter_Info);
modify:SetScript("OnLeave", func.OnLeave_Info);
modify:SetScript("OnClick", function(self)
ui.custom:CustomShow(button:GetDataIndex());
end);
-- modify.info = { };
button.modify = modify;
-- func.StyleObject('button', modify);
local up = CreateFrame("BUTTON", nil, button);
up:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
up:SetNormalTexture(texture_up);
up:SetPushedTexture(texture_up);
up:GetPushedTexture():SetVertexColor(0.25, 0.25, 0.25, 1.0);
up:SetDisabledTexture(texture_up);
up:GetDisabledTexture():SetVertexColor(0.5, 0.5, 0.5, 1.0);
up:SetPoint("TOPRIGHT", -6 - buttonHeight * 0.4, -2);
up:Show();
up:SetScript("OnEnter", func.OnEnter_Info);
up:SetScript("OnLeave", func.OnLeave_Info);
up:SetScript("OnClick", function(self)
func.up(button:GetDataIndex());
end);
-- up.info = { };
button.up = up;
-- func.StyleObject('button', up);
local down = CreateFrame("BUTTON", nil, button);
down:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
down:SetNormalTexture(texture_down);
down:SetPushedTexture(texture_down);
down:GetPushedTexture():SetVertexColor(0.25, 0.25, 0.25, 1.0);
down:SetDisabledTexture(texture_down);
down:GetDisabledTexture():SetVertexColor(0.5, 0.5, 0.5, 1.0);
down:SetPoint("BOTTOMRIGHT", -6 - buttonHeight * 0.4, 2);
down:Show();
down:SetScript("OnEnter", func.OnEnter_Info);
down:SetScript("OnLeave", func.OnLeave_Info);
down:SetScript("OnClick", function(self)
func.down(button:GetDataIndex());
end);
-- down.info = { };
button.down = down;
-- func.StyleObject('button', down);
local helmet = CreateFrame("CHECKBUTTON", nil, button, "OptionsBaseCheckButtonTemplate");
helmet:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
helmet:SetHitRectInsets(0, 0, 0, 0);
helmet:SetPoint("TOPRIGHT", -8 - buttonHeight * 0.8, -2);
helmet:Show();
local helmetStr = helmet:CreateFontString(nil, "ARTWORK");
helmetStr:SetFont(GameFontHighlightSmall:GetFont(), 13, "OUTLINE");
helmetStr:SetText(L.slot[1]);
helmet.fontString = helmetStr;
helmetStr:SetPoint("RIGHT", helmet, "LEFT", 0, 0);
helmet:SetScript("OnClick", function(self)
func.helmet(button:GetDataIndex(), self:GetChecked());
end);
button.helmet = helmet;
func.StyleObject('check', helmet);
local cloak = CreateFrame("CHECKBUTTON", nil, button, "OptionsBaseCheckButtonTemplate");
cloak:SetSize(buttonHeight * 0.4, buttonHeight * 0.4);
cloak:SetHitRectInsets(0, 0, 0, 0);
cloak:SetPoint("BOTTOMRIGHT", -8 - buttonHeight * 0.8, 2);
cloak:Show();
local cloakStr = cloak:CreateFontString(nil, "ARTWORK");
cloakStr:SetFont(GameFontHighlightSmall:GetFont(), 13, "OUTLINE");
cloakStr:SetText(L.slot[15]);
cloak.fontString = cloakStr;
cloakStr:SetPoint("RIGHT", cloak, "LEFT", 0, 0);
cloak:SetScript("OnClick", function(self)
func.cloak(button:GetDataIndex(), self:GetChecked());
end);
button.cloak = cloak;
func.StyleObject('check', cloak);
function button:SetIconTexture(tex)
icon:SetTexture(tex);
end
function button:SetTitleText(text)
title:SetText(text);
end
function button:Current()
self.current = true;
self.glow_current:Show();
end
function button:NonCurrent()
self.current = false;
self.glow_current:Hide();
end
function button:Select()
self.selected = true;
self.glow_selected:Show();
end
function button:Deselect()
self.selected = nil;
self.glow_selected:Hide();
end
function button:IsSelected()
return self.selected;
end
button:SetScript("OnClick", function(self)
local dataIndex = self:GetDataIndex();
if dataIndex > #saved_sets then
if var.gm_cur_set then
ui.scroll:CallButtonFuncByDataIndex(var.gm_cur_set, "Deselect");
end
var.gm_cur_set = nil;
var.gm_prev_clicked_set = nil;
func.pdf_hide_mask();
func.new_onclick();
elseif dataIndex == var.gm_prev_clicked_set and GetTime() - var.gm_prev_clicked_time <= 0.5 then
var.gm_cur_set = dataIndex;
self:Select();
var.gm_prev_clicked_set = nil;
func.equip();
func.pdf_show_mask(saved_sets[dataIndex] or { });
elseif dataIndex == var.gm_cur_set then
var.gm_prev_clicked_set = var.gm_cur_set;
var.gm_prev_clicked_time = GetTime();
var.gm_cur_set = nil;
self:Deselect();
func.pdf_hide_mask();
else
if var.gm_cur_set then
ui.scroll:CallButtonFuncByDataIndex(var.gm_cur_set, "Deselect");
end
var.gm_cur_set = dataIndex;
self:Select();
var.gm_prev_clicked_set = dataIndex;
var.gm_prev_clicked_time = GetTime();
func.pdf_show_mask(saved_sets[var.gm_cur_set] or { });
end
end);
button:SetScript("OnEnter", function(self)
local index = button:GetDataIndex();
GameTooltip:SetOwner(self, "ANCHOR_BOTTOMLEFT");
if index > 0 and index <= #saved_sets then
func.OnEnter_Info_Outfit(self, index);
else
GameTooltip:AddLine(L["Add a new outfit"], 1.0, 1.0, 1.0);
end
GameTooltip:Show();
end);
button:SetScript("OnLeave", func.OnLeave_Info);
button:SetScript("OnDragStart", function(self)
if alaGearManSV.UseMacro then
local index = button:GetDataIndex();
local macro_name = MACRO_NAME_PREFIX .. index;
if GetMacroInfo(macro_name) then
PickupMacro(macro_name);
end
end
end);
button.id = index;
return button;
end
function func.gm_SetButton(button, index)
local sets = saved_sets;
if index <= #sets then
button:SetIconTexture(iconTable[sets[index].icon or 1]);
button:SetTitleText(sets[index].name or "UNK_NAME");
button:Show();
local T, isCur = func.check(index);
if isCur then
button:Current();
else
button:NonCurrent();
end
if button:IsSelected() and button:GetDataIndex() ~= var.gm_cur_set then
button:Deselect();
elseif not button:IsSelected() and button:GetDataIndex() == var.gm_cur_set then
button:Select();
end
button.delete:Show();
button.modify:Show();
button.up:Show();
button.down:Show();
button.helmet:Show();
button.cloak:Show();
if index == 1 then
button.up:Disable();
else
button.up:Enable();
end
if index == #saved_sets then
button.down:Disable();
else
button.down:Enable();
end
local cur = saved_sets[index];
if cur.helmet then
button.helmet:SetChecked(true);
else
button.helmet:SetChecked(false);
end
if cur.cloak then
button.cloak:SetChecked(true);
else
button.cloak:SetChecked(false);
end
if GetMouseFocus() == button then
button:GetScript("OnEnter")(button);
end
elseif index == #sets + 1 then
button:SetIconTexture(texture_add);
button:SetTitleText(L["Add a new outfit"]);
button:Show();
button:NonCurrent();
if button:IsSelected() and button:GetDataIndex() ~= var.gm_cur_set then
button:Deselect();
elseif not button:IsSelected() and button:GetDataIndex() == var.gm_cur_set then
button:Select();
end
button.delete:Hide();
button.modify:Hide();
button.up:Hide();
button.down:Hide();
button.helmet:Hide();
button.cloak:Hide();
else
button:Hide();
end
end
function func.get_pos(frame)
local pos = { frame:GetPoint() };
for index, val in next, pos do
if type(val) == 'table' then
pos[index] = val:GetName();
elseif type(val) ~= 'number' and type(val) ~= 'string' then
pos[index] = nil;
end
end
return pos;
end
function func.initUI()
ui.open = CreateFrame("BUTTON", nil, PaperDollFrame);
ui.open:SetSize(32, 32);
ui.open:SetPoint("TOPRIGHT", -40, -40);
ui.open:SetNormalTexture(texture_open);
ui.open:SetPushedTexture(texture_open);
ui.open:GetPushedTexture():SetVertexColor(0.25, 0.25, 0.25, 1.0);
ui.open:EnableMouse(true);
ui.open:SetScript("OnClick", func.open_onclick);
do --win
ui.gearWin = CreateFrame("FRAME", nil, PaperDollFrame);
ui.gearWin:SetFrameStrata("FULLSCREEN");
uireimp._SetBackdrop(ui.gearWin, {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "interface\\dialogframe\\ui-dialogbox-border",
tile = true,
tileSize = 16,
edgeSize = 20,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
});
uireimp._SetBackdropColor(ui.gearWin, 0.0, 0.0, 0.0, 0.9);
ui.gearWin:SetWidth(win_SizeX);
-- ui.gearWin:SetPoint("TOPLEFT", PaperDollFrame, "TOPRIGHT");
-- ui.gearWin:SetPoint("BOTTOMLEFT", PaperDollFrame, "BOTTOMRIGHT");
-- ui.gearWin:SetSize(240, 128);
ui.gearWin:SetHeight(win_SizeY);
ui.gearWin:SetPoint("TOPLEFT", ui.open, "TOPLEFT", 45, 0);
ui.gearWin:SetScript("OnShow", function()
ui.scroll:SetNumValue(#saved_sets + 1);
-- if var.gm_cur_set and saved_sets[var.gm_cur_set] then
-- func.pdf_show_mask(saved_sets[var.gm_cur_set]);
-- end
func.Sound_Show();
end);
ui.gearWin:SetScript("OnHide", function(self)
func.pdf_hide_mask();
var.gm_cur_set = nil;
func.Sound_Hide();
end);
ui.gearWin:Hide();
if autostyle ~= nil then
autostyle:AddReskinObject(ui.gearWin);
end
ui.scroll = ALASCR(ui.gearWin, win_SizeX - 20, win_SizeY - 64, btn_SizeY, func.gm_CreateButton, func.gm_SetButton);
ui.scroll:SetPoint("BOTTOMLEFT", 10, 10);
ui.save = CreateFrame("BUTTON", nil, ui.gearWin, "UIPanelButtonTemplate");
ui.save:SetPoint("TOPLEFT", win_SizeX / 9, -16);
ui.save:SetText(L["Save"]);
ui.save:SetSize(win_SizeX / 3, 24);
ui.save:SetScript("OnClick", function(self) func.save(); end);
if autostyle ~= nil then
autostyle:AddReskinObject(ui.save);
end
ui.equip = CreateFrame("BUTTON", nil, ui.gearWin, "UIPanelButtonTemplate");
ui.equip:SetPoint("TOPLEFT", win_SizeX * 5 / 9, -16);
ui.equip:SetText(L["Equip"]);
ui.equip:SetSize(win_SizeX / 3, 24);
ui.equip:SetScript("OnClick", function(self) func.equip(); end);
if autostyle ~= nil then
autostyle:AddReskinObject(ui.equip);
end