-
Notifications
You must be signed in to change notification settings - Fork 0
/
CraftLog.lua
920 lines (844 loc) · 45.4 KB
/
CraftLog.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
-- get reference to main frame
local f = CraftLogFrame
local sc = scScroll
local GameToolTip = _G["GameTooltip"]
local CraftLogItemButtons = {}
local CraftLogContainerFrames = {}
local CraftLogSubContainerFrames = {}
local _, CL = ...
local showOldData = false
-- settings
local debugToggle = false
local filterCreated, filterUsed, filter1d, filter7d, filter30d, filterAll = true, true, true, true, true, true
-- temp storage for current castGUID
local castGUID, delayedSpell, delayedTimestamp
-- bool to store match/no match of castGUID from UNIT_SPELLCAST_SUCCEEDED to BAG_UPDATE_DELAYED
local castGUIDmatched = false
-- mass prospecting/milling craft IDs for special handling and temp storage for product inventory
local prospectingSpellIDs = {
[359492] = true, -- Progenium
[311953] = true, -- Elethium
[311948] = true, -- Laestrite
[311950] = true, -- Oxxein
[311951] = true, -- Phaedrum
[311952] = true, -- Sinvyr
[311949] = true -- Solenium
}
local prospectingInventory = {
[173110] = 0, -- Umbryl
[173108] = 0, -- Oriblase
[173109] = 0, -- Angerseye
[173172] = 0, -- Essence of Servitude
[173173] = 0, -- Essence of Valor
[173171] = 0, -- Essence of Torment
[173170] = 0 -- Essence of Rebirth
--[175788] = 0, -- Tranquil Pigment
--[173057] = 0, -- Luminous Pigment
--[173056] = 0 -- Umbral Pigment
}
-- bonusIDs for itemLink cleanup
local bonusIDs = {
-- BS legendaries
["171419"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171412"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171414"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171416"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171415"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171417"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171413"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["171418"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
-- JC legendaries
["178926"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["178927"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
-- TA legendaries
["173248"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173249"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173242"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173245"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173244"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173246"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173241"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173243"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["173247"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
-- LW legendaries
["172316"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172315"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172314"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172321"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172319"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172317"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172320"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172318"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172329"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172323"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172327"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172326"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172328"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172325"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172322"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
["172324"] = { [190] = { 1487, 6716 }, [210] = { 1507, 6716 }, [225] = { 1522, 6716 }, [235] = { 1532, 6716 }, [249] = { 1546, 6716 }, [262] = { 1559, 6716 }, [291] = { 1588, 6716 } },
-- BS Shadowsteel
["171446"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171442"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171443"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171448"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171447"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171449"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171444"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["171445"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
-- JC Rings & Necks
["173134"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173145"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173133"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173146"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173144"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173131"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173132"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
["173147"] = { [87] = { 7224 }, [117] = { 7180 }, [168] = { 7185 }, [200] = { 7183 }, [230] = { 7461 }, [233] = { 7880 }, [262] = { 7881 } },
-- TA Shadowlace
["173222"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173218"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173217"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173216"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173219"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173221"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173215"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173214"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["173220"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
-- LW Shadebound
["172257"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172253"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172254"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172251"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172252"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172256"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172255"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172250"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
-- LW Shadowscale
["172265"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172260"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172259"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172262"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172261"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172258"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172263"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } },
["172264"] = { [87] = { 6893, 7224 }, [117] = { 6893, 7180 }, [168] = { 6893, 7185 }, [200] = { 6893, 7183 }, [230] = { 6893, 7461 }, [233] = { 6893, 7880 }, [262] = { 6893, 7881 } }
}
-- optional reagents with ilvl effect and temp storage for current inventory
local optionalReagentsIlvl = {
[185960] = { [190] = 225, [210] = 235, [225] = 249, [235] = 262 }, --VoO -> +2
[187784] = { [190] = 235, [210] = 249, [225] = 262, [235] = 291 }, --VotE -> +3
[183942] = 87, --NCM -> 87
[173381] = 117, --CM1 -> 117
[173382] = 168, --CM2 -> 168
[173383] = 200, --CM3 -> 200
[173384] = 230, --CMotCI -> 230
[187741] = 233, --CM4 -> 233
[187742] = 262 --CMotFO -> 262
}
local optionalReagentsInventory = {
[185960] = 0, --VoO -> +2
[187784] = 0, --VotE -> +3
[183942] = 0, --NCM -> 87
[173381] = 0, --CM1 -> 117
[173382] = 0, --CM2 -> 168
[173383] = 0, --CM3 -> 200
[173384] = 0, --CMotCI -> 230
[187741] = 0, --CM4 -> 233
[187742] = 0 --CMotFO -> 262
}
-- register additional events
f:RegisterEvent("UNIT_SPELLCAST_START")
f:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
f:RegisterEvent("BAG_UPDATE_DELAYED")
-- handle additional events
f:SetScript("OnEvent", function(self, event, ...)
self[event](self, ...)
end)
function f:UNIT_SPELLCAST_START(...)
if (debugToggle) then print("UNIT_SPELLCAST_START handler start") end
if (debugToggle) then print(...) end
OnUnitSpellcastStart(...)
if (debugToggle) then print("UNIT_SPELLCAST_START handler end") end
end
function f:UNIT_SPELLCAST_SUCCEEDED(...)
if (debugToggle) then print("UNIT_SPELLCAST_SUCCEEDED handler start") end
if (debugToggle) then print(...) end
OnUnitSpellcastSucceeded(...)
if (debugToggle) then print("UNIT_SPELLCAST_SUCCEEDED handler end") end
end
function f:BAG_UPDATE_DELAYED(...)
if (debugToggle) then print("BAG_UPDATE_DELAYED handler start") end
if (debugToggle) then print(...) end
OnBagUpdateDelayed(...)
if (debugToggle) then print("BAG_UPDATE_DELAYED handler end") end
end
-- event handler UNIT_SPELLCAST_START
function OnUnitSpellcastStart(...)
local unit, cast, spell = ...
-- only run if caster is the player and tradeskillUI is open
if (unit == "player" and C_TradeSkillUI.IsTradeSkillReady()) then
--print start of cast event details
if (debugToggle) then print("starting craft with spell "..spell.." and id "..cast) end
--set castGUID to check if UNIT_SPELLCAST_SUCCEEDED matches
castGUID = cast
--check if optional reagents are usable
if not (C_TradeSkillUI.GetOptionalReagentInfo(spell)[1] == nil) then
if (debugToggle) then print("available optional reagents:") end
--add inventory of optional reagents
for k, v in pairs(optionalReagentsInventory) do
optionalReagentsInventory[k] = GetItemCount(k, true, false, true)
local _, itemLink = GetItemInfo(k)
if (debugToggle) then print(optionalReagentsInventory[k].." x "..itemLink) end
end
end
--check if we are prospecting/milling
if not (prospectingSpellIDs[spell] == nil) then
if (debugToggle) then print("prospecting / milling...") end
for k, v in pairs(prospectingInventory) do
prospectingInventory[k] = GetItemCount(k, true, false, true)
local _, itemLink = GetItemInfo(k)
if (debugToggle) then print(prospectingInventory[k].." x "..itemLink) end
end
end
end
end
-- event handler UNIT_SPELLCAST_SUCCEEDED
function OnUnitSpellcastSucceeded(...)
local unit, cast, spell = ...
local timestamp = date('%Y-%m-%d')
-- only run if caster is player and castGUID matches
if (unit == "player" and cast == castGUID) then
-- confirm castGUID match
castGUIDmatched = true
--store spell and timestamp for retrieval after OnBagUpdateDelayed(event, ...) fires
if (debugToggle) then print("finished craft with spell "..spell.." and id "..cast) end
delayedSpell = spell
delayedTimestamp = timestamp
else
delayedSpell = nil
delayedTimestamp = nil
end
end
-- event handler BAG_UPDATE_DELAYED
function OnBagUpdateDelayed(...)
if not (delayedSpell == nil) and not (delayedTimestamp == nil) and (castGUIDmatched) then
-- reset castGUIDmatched
castGUIDmatched = nil
--retrieve stored spell and timestamp
local spell = delayedSpell
local timestamp = delayedTimestamp
local itemproduced
-- log item produced
if not (prospectingSpellIDs[spell] == nil) then
--prospecting
if (debugToggle) then print("using prospecing/milling logic") end
for i = 1, C_TradeSkillUI.GetRecipeNumReagents(spell) do
local itemused = C_TradeSkillUI.GetRecipeReagentItemLink(spell,i)
local itemusedID = GetItemInfoInstant(itemused)
local _, _, _, ilvlused = GetItemInfo(itemused)
local _, _, numitemused, _ = C_TradeSkillUI.GetRecipeReagentInfo(spell,i)
--log used items
CL:addItemToCraftLog(timestamp, spell, itemusedID, ilvlused, "-", numitemused)
end
-- TODO: work out the prospecting results, current solution is buggy af
if (debugToggle) then print("prospecting results:") end
for k, v in pairs(prospectingInventory) do
local cur = GetItemCount(k, true, false, true)
local amount = cur - prospectingInventory[k]
local _, itemLink, _, ilvlproduced = GetItemInfo(k)
local itemCreatedID = GetItemInfoInstant(itemLink)
if (debugToggle) then print(prospectingInventory[k].." - "..cur.." = "..amount.." x "..itemLink) end
CL:addItemToCraftLog(timestamp, spell, itemCreatedID, ilvlproduced, "+", amount)
end
else
--default crafting
if (debugToggle) then print("using default crafting logic") end
itemproduced = C_TradeSkillUI.GetRecipeItemLink(spell)
end
--only continue if itemproduced exists aka tradeskill used
if not (itemproduced == nil) then
local numitemproduced = C_TradeSkillUI.GetRecipeNumItemsProduced(spell)
local _, _, _, ilvlproduced = GetItemInfo(itemproduced)
local itemProducedID = GetItemInfoInstant(itemproduced)
--check if optional reagents are usable
if not (C_TradeSkillUI.GetOptionalReagentInfo(spell)[1] == nil) then
--remove inventory of optional reagents
for k, v in pairs(optionalReagentsInventory) do
local cur = GetItemCount(k, true, false, true)
local amount = optionalReagentsInventory[k] - cur
local _, itemLink = GetItemInfo(k)
if (debugToggle) then print(cur.. " - "..optionalReagentsInventory[k].." = "..amount.." x "..itemLink) end
optionalReagentsInventory[k] = cur
--if optional reagent is still > 0 it was used -> adjust ilvlproduced accordingly
if (amount>0) then
local optionalReagent, optionalReagentIlvl, optionalReagentID
--set used optional reagent
_, optionalReagent, _, optionalReagentIlvl = GetItemInfo(k)
optionalReagentID = GetItemInfoInstant(optionalReagent)
--crafted a legendary?
if (ilvlproduced >= 190) then
ilvlproduced = optionalReagentsIlvl[k][ilvlproduced]
--crafted something else?
else
ilvlproduced = optionalReagentsIlvl[k]
end
if (debugToggle) then print(optionalReagent.." used to change ilvl to "..ilvlproduced) end
--add optional reagent to CraftLog
CL:addItemToCraftLog(timestamp, spell, optionalReagentID, optionalReagentIlvl, "-", amount)
end
end
end
--iterate through reagents to log items used
for i = 1, C_TradeSkillUI.GetRecipeNumReagents(spell) do
local itemused = C_TradeSkillUI.GetRecipeReagentItemLink(spell,i)
local _, _, _, ilvlused = GetItemInfo(itemused)
local _, _, numitemused, _ = C_TradeSkillUI.GetRecipeReagentInfo(spell,i)
local itemUsedID = GetItemInfoInstant(itemused)
--log used items
CL:addItemToCraftLog(timestamp, spell, itemUsedID, ilvlused, "-", numitemused)
end
--log produced item
CL:addItemToCraftLog(timestamp, spell, itemProducedID, ilvlproduced, "+", numitemproduced)
end
--reset delayed spell and timestamp
delayedSpell = nil
delayedTimestamp = nil
end
end
-- clean itemlinks to remove extraeneous info like crafter's level and spec
function CL:GetCleanItemLinkFromID(itemID, ilvl)
local cleanLink = ""
local stripBonus = false
if (debugToggle) then print("GetCleanItemLinkFromID("..itemID..", "..ilvl..")") end
local _, newLink = GetItemInfo("item:"..itemID)
if (newLink == nil ) then
cleanLink = itemID.." @ "..ilvl
else
local splitLink = {strsplit(":", newLink)}
if (debugToggle) and (newLink) then print("Base Item Link: "..newLink) end
--if (debugToggle) then print(splitLink.toString()) end
splitLink[10] = "" -- strip crafters level
splitLink[11] = "" -- strip crafters spec
splitLink[13] = "" -- strip item context
-- correct bonusids if known
if not (bonusIDs[splitLink[2]] == nil) then
if (debugToggle) then
if (bonusIDs[splitLink[2]][ilvl][2] == nil) then
print("bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found: "..bonusIDs[splitLink[2]][ilvl][1])
else
print("bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found: "..bonusIDs[splitLink[2]][ilvl][1]..":"..bonusIDs[splitLink[2]][ilvl][2])
end
end
if (splitLink[14] == "2") then
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]
if not (bonusIDs[splitLink[2]][ilvl][2] == nil) then
splitLink[16] = bonusIDs[splitLink[2]][ilvl][2]
else
splitLink[14] = 1
end
elseif (splitLink[14] == "1") then
if (bonusIDs[splitLink[2]][ilvl][2] == nil) then
splitLink[14] = 10
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]
else
splitLink[14] = 2
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]..":"..bonusIDs[splitLink[2]][ilvl][2]
end
end
else
-- item without known bonus id. create clean link and work with that
if (newLink) then
splitLink = {strsplit(":", newLink)}
end
if (debugToggle) then print("no bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found, stripping existing bonusIDs: "..splitLink[14]..":"..splitLink[15]..":"..splitLink[16]) end
stripBonus = true
end
if (stripBonus) then
if (splitLink[14] == "2") then
table.remove(splitLink,16)
end
table.remove(splitLink,15)
splitLink[14] = ""
end
cleanLink = table.concat(splitLink,":")
end
if (debugToggle) then print("cleaned up link to: "..cleanLink) end
return cleanLink
end
function CL:GetCleanItemLink(itemLink, ilvl)
local cleanLink = ""
local stripBonus = false
local splitLink = {strsplit(":", itemLink)}
if (debugToggle) then print("GetCleanItemLink("..itemLink.." ("..splitLink[2].."), "..ilvl..")") end
-- retrieve base itemlink
local _, newLink = GetItemInfo(splitLink[2])
if (debugToggle) and (newLink) then print("Base Item Link: "..newLink) end
--if (debugToggle) then print(splitLink.toString()) end
splitLink[10] = "" -- strip crafters level
splitLink[11] = "" -- strip crafters spec
splitLink[13] = "" -- strip item context
-- correct bonusids if known
if not (bonusIDs[splitLink[2]] == nil) then
if (debugToggle) then
if (bonusIDs[splitLink[2]][ilvl][2] == nil) then
print("bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found: "..bonusIDs[splitLink[2]][ilvl][1])
else
print("bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found: "..bonusIDs[splitLink[2]][ilvl][1]..":"..bonusIDs[splitLink[2]][ilvl][2])
end
end
if (splitLink[14] == "2") then
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]
if not (bonusIDs[splitLink[2]][ilvl][2] == nil) then
splitLink[16] = bonusIDs[splitLink[2]][ilvl][2]
else
splitLink[14] = 1
end
elseif (splitLink[14] == "1") then
if (bonusIDs[splitLink[2]][ilvl][2] == nil) then
splitLink[14] = 10
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]
else
splitLink[14] = 2
splitLink[15] = bonusIDs[splitLink[2]][ilvl][1]..":"..bonusIDs[splitLink[2]][ilvl][2]
end
end
else
-- item without known bonus id. create clean link and work with that
if (newLink) then
splitLink = {strsplit(":", newLink)}
end
if (debugToggle) then print("no bonusIDs for itemID "..splitLink[2].." @ "..ilvl.." found, stripping existing bonusIDs: "..splitLink[14]..":"..splitLink[15]..":"..splitLink[16]) end
stripBonus = true
end
if (stripBonus) then
if (splitLink[14] == "2") then
table.remove(splitLink,16)
end
table.remove(splitLink,15)
splitLink[14] = ""
end
cleanLink = table.concat(splitLink,":")
if (debugToggle) then print("cleaned up link to: "..cleanLink) end
return cleanLink
end
-- return distinct items from CRAFTLOG including usage/crafted amounts over various periods
function CL:CraftLogGetItemStats()
-- TODO: cleanup itemLinks so that crafting profession, character etc do not matter
local t = {} -- temp table
local r = {} -- return table
-- structure of r {}
-- r {
-- { itemlink=link, ilvl=ilvl, used7day=7day, used14day=14day, used30day=30day, usedtotal=total, crafted7day=7day, crafted14day=14day, crafted30day=30day, craftedtotal=total},
-- { ... }
--}
-- sum up crafted/used amounts per item/ilvl over 7/14/30day/total time
for kDay, vDay in pairs(CraftLog) do
local year, month, day = kDay:match("(%d+)-(%d+)-(%d+)")
local age = floor((time() - time({day=day, month=month, year=year}))/86400)
for kCraft, vCraft in pairs(vDay) do
for kID, vID in pairs(vCraft) do
for kIlvl, vIlvl in pairs(vID) do
local kLinkClean = CL:GetCleanItemLinkFromID(kID, kIlvl)
local _, itemType = GetItemInfoInstant(kID)
local effectiveIlvl
if (itemType == "Tradeskill") then effectiveIlvl = 1 else effectiveIlvl=kIlvl end
if (t[kLinkClean] == nil) then t[kLinkClean] = {} end
if (t[kLinkClean][effectiveIlvl] == nil) then t[kLinkClean][effectiveIlvl] = {} end
for kDir, vDir in pairs(vIlvl) do
if (t[kLinkClean][effectiveIlvl][kDir] == nil) then t[kLinkClean][effectiveIlvl][kDir] = {} end
if (age<=7) then
if (t[kLinkClean][effectiveIlvl][kDir]["7day"] == nil) then
t[kLinkClean][effectiveIlvl][kDir]["7day"] = vDir
else
t[kLinkClean][effectiveIlvl][kDir]["7day"] = t[kLinkClean][effectiveIlvl][kDir]["7day"] + vDir
end
end
if (age<=14) then
if (t[kLinkClean][effectiveIlvl][kDir]["14day"] == nil) then
t[kLinkClean][effectiveIlvl][kDir]["14day"] = vDir
else
t[kLinkClean][effectiveIlvl][kDir]["14day"] = t[kLinkClean][effectiveIlvl][kDir]["14day"] + vDir
end
end
if (age<=30) then
if (t[kLinkClean][effectiveIlvl][kDir]["30day"] == nil) then
t[kLinkClean][effectiveIlvl][kDir]["30day"] = vDir
else
t[kLinkClean][effectiveIlvl][kDir]["30day"] = t[kLinkClean][effectiveIlvl][kDir]["30day"] + vDir
end
end
if (t[kLinkClean][effectiveIlvl][kDir]["total"] == nil) then
t[kLinkClean][effectiveIlvl][kDir]["total"] = vDir
else
t[kLinkClean][effectiveIlvl][kDir]["total"] = t[kLinkClean][effectiveIlvl][kDir]["total"] + vDir
end
end
end
end
end
end
-- flatten table before returning it
for kLink, vLink in pairs(t) do
for kIlvl, vIlvl in pairs(t[kLink]) do
local crafted7day, crafted14day, crafted30dy, craftedtotal, used7day, used14day, used30day, usedtotal
local _, itemTypeID, itemSubTypeID = GetItemInfoInstant(kLink)
if (itemTypeID == nil or itemSubTypeID == nil) then
print(kLink.." not cached, skipping for now")
else
if not (showOldData) then
if (r[itemTypeID]==nil) then r[itemTypeID] = {} end
if (r[itemTypeID][itemSubTypeID]==nil) then r[itemTypeID][itemSubTypeID] = {} end
end
if (t[kLink][kIlvl]["+"] == nil) then
crafted7day = 0
crafted14day = 0
crafted30day = 0
craftedtotal = 0
else
if (t[kLink][kIlvl]["+"]["7day"] == nil) then crafted7day = 0 else crafted7day = t[kLink][kIlvl]["+"]["7day"] end
if (t[kLink][kIlvl]["+"]["14day"] == nil) then crafted14day = 0 else crafted14day = t[kLink][kIlvl]["+"]["14day"] end
if (t[kLink][kIlvl]["+"]["30day"] == nil) then crafted30day = 0 else crafted30day = t[kLink][kIlvl]["+"]["30day"] end
if (t[kLink][kIlvl]["+"]["total"] == nil) then craftedtotal = 0 else craftedtotal = t[kLink][kIlvl]["+"]["total"] end
end
if (t[kLink][kIlvl]["-"] == nil) then
used7day = 0
used14day = 0
used30day = 0
usedtotal = 0
else
if (t[kLink][kIlvl]["-"]["7day"] == nil) then used7day = 0 else used7day = t[kLink][kIlvl]["-"]["7day"] end
if (t[kLink][kIlvl]["-"]["14day"] == nil) then used14day = 0 else used14day = t[kLink][kIlvl]["-"]["14day"] end
if (t[kLink][kIlvl]["-"]["30day"] == nil) then used30day = 0 else used30day = t[kLink][kIlvl]["-"]["30day"] end
if (t[kLink][kIlvl]["-"]["total"] == nil) then usedtotal = 0 else usedtotal = t[kLink][kIlvl]["-"]["total"] end
end
if (showOldData) then
table.insert(r, {itemlink=kLink, ilvl=kIlvl, used7day=used7day, used14day=used14day, used30day=used30day, usedtotal=usedtotal, crafted7day=crafted7day, crafted14day=crafted14day, crafted30day=crafted30day, craftedtotal=craftedtotal, itemTypeID=itemTypeID, itemSubTypeID=itemSubTypeID, itemName=itemName})
table.sort(r, function(a,b) return
a.itemTypeID<b.itemTypeID or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID<b.itemSubTypeID) or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID==b.itemSubTypeID and a.itemlink<b.itemlink) or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID==b.itemSubTypeID and a.itemlink==b.itemlink and a.ilvl<b.ilvl)
end)
else
table.insert(r[itemTypeID][itemSubTypeID], {itemlink=kLink, ilvl=kIlvl, used7day=used7day, used14day=used14day, used30day=used30day, usedtotal=usedtotal, crafted7day=crafted7day, crafted14day=crafted14day, crafted30day=crafted30day, craftedtotal=craftedtotal, itemTypeID=itemTypeID, itemSubTypeID=itemSubTypeID})
end
end
end
end
table.sort(r, function(a,b) return
a.itemTypeID<b.itemTypeID or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID<b.itemSubTypeID) or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID==b.itemSubTypeID and a.itemName<b.itemName) or
(a.itemTypeID==b.itemTypeID and a.itemSubTypeID==b.itemSubTypeID and a.itemName==b.itemName and a.ilvl<b.ilvl)
end)
return r
end
-- adds item to the CraftLog table
function CL:addItemToCraftLog(timestamp, spell, link, ilvl, dir, amount)
-- structure of CraftLog table
--CraftLog {
-- [date] = {
-- [craftid] = {
-- [itemlink] = { -> itemID
-- [ilvl] = {
-- [-] = numused,
-- [+] = numproduced
-- }
-- }
-- }
-- }
--}
--first entry for the day
if (CraftLog[timestamp] == nil) then CraftLog[timestamp] = {} end
-- first entry for day -> spellid
if (CraftLog[timestamp][spell] == nil) then CraftLog[timestamp][spell] = {} end
--first craft of the day using/producing optional reagent
if (CraftLog[timestamp][spell][link] == nil) then CraftLog[timestamp][spell][link] = {} end
--first craft of the day using/producing optional reagent @ ilvl
if (CraftLog[timestamp][spell][link][ilvl] == nil) then CraftLog[timestamp][spell][link][ilvl] = {} end
--first craft of the day using optional reagent
if (CraftLog[timestamp][spell][link][ilvl][dir] == nil) then
CraftLog[timestamp][spell][link][ilvl][dir] = amount
else
CraftLog[timestamp][spell][link][ilvl][dir] = CraftLog[timestamp][spell][link][ilvl][dir] + amount
end
if (debugToggle) then print(timestamp.." "..dir.." "..amount.." "..link.." via "..spell) end
end
-- event handlers
function CL:cbCreated_OnShow(cb)
cb:SetChecked(filterCreated)
end
function CL:cbCreated_OnClick(cb)
filterCreated = cb:GetChecked()
end
function CL:cbUsed_OnShow(cb)
cb:SetChecked(filterUsed)
end
function CL:cbUsed_OnClick( cb )
filterUsed = cb:GetChecked()
end
function CL:cbTimeframe1day_OnShow(cb)
cb:SetChecked(filter1d)
end
function CL:cbTimeframe1day_OnClick( cb )
filter1d = cb:GetChecked()
end
function CL:cbTimeframe7day_OnShow(cb)
cb:SetChecked(filter1d)
end
function CL:cbTimeframe7day_OnClick( cb )
filter1d = cb:GetChecked()
end
function CL:cbTimeframe30day_OnShow(cb)
cb:SetChecked(filter1d)
end
function CL:cbTimeframe30day_OnClick( cb )
filter1d = cb:GetChecked()
end
function CL:cbTimeframeTotal_OnShow(cb)
cb:SetChecked(filter1d)
end
function CL:cbTimeframeTotal_OnClick( cb )
filter1d = cb:GetChecked()
end
function CL:cbDebugToggle_OnShow(cb)
cb:SetChecked(debugToggle)
end
function CL:cbDebugToggle_OnClick( cb )
debugToggle = cb:GetChecked()
end
-- event handler ADDON_LOADED
function CL:InitializeSavedVariables(...)
local arg1 = ...
if (arg1 == "CraftLog") then
if (CraftLog == nil) then
CraftLog = {}
end
end
end
function f:ShowData()
-- headers for Timeframes
local header1d = f:CreateFontString(f, "ARTWORK", "GameFontHighlight")
header1d:SetPoint("TOPLEFT", 375, -40)
header1d:SetText("7 days")
local header7d = f:CreateFontString(f, "ARTWORK", "GameFontHighlight")
header7d:SetPoint("TOPLEFT", 475, -40)
header7d:SetText("14 days")
local header30d = f:CreateFontString(f, "ARTWORK", "GameFontHighlight")
header30d:SetPoint("TOPLEFT", 575, -40)
header30d:SetText("30 days")
local headerAll = f:CreateFontString(f, "ARTWORK", "GameFontHighlight")
headerAll:SetPoint("TOPLEFT", 675, -40)
headerAll:SetText("total")
sc:HookScript("OnEnter", function()
if not (v==nil) and (v.itemlink) then
GameToolTip:SetOwner(sc, "ANCHOR_CURSOR")
GameToolTip:SetHyperlink(v.itemlink)
GameToolTip:Show()
end
end)
sc:HookScript("OnLeave", function()
GameToolTip:Hide()
end)
--add data (old way)
-- { itemlink=link, ilvl=ilvl, used7day=7day, used14day=14day, used30day=30day, usedtotal=total, crafted7day=7day, crafted14day=14day, crafted30day=30day, craftedtotal=total},
if (showOldData) then
for i, v in ipairs(CL:CraftLogGetItemStats()) do
local itemButton = CraftLogItemButtons[i] or CreateFrame("Button", nil, sc)
CraftLogItemButtons[i] = itemButton
local itemText = itemButton:CreateFontString(itemButton, "ARTWORK", "GameFontHighlight")
itemText:SetText(v.itemlink.." ("..v.ilvl..")")
--itemText:SetPoint("TOPLEFT", 20, -i*50)
itemButton:SetPoint("TOPLEFT", 20, -i*50)
itemButton:SetHeight(20)
itemButton:SetWidth(itemText:GetStringWidth())
--itemButton:SetText(v.itemlink.." ("..v.ilvl..")")
itemButton:SetFontString(itemText)
itemButton:HookScript("OnEnter", function()
if(v.itemlink) then
GameToolTip:SetOwner(itemButton, "ANCHOR_CURSOR")
GameToolTip:SetHyperlink(v.itemlink)
GameToolTip:Show()
end
end)
itemButton:HookScript("OnLeave", function()
GameToolTip:Hide()
end)
-- 7 day timeframe
local used7day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
used7day:SetText("- "..v.used7day)
used7day:SetPoint("TOPLEFT", 250-used7day:GetStringWidth(), -i*50+10)
local crafted7day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
crafted7day:SetText("+ "..v.crafted7day)
crafted7day:SetPoint("TOPLEFT", 250-crafted7day:GetStringWidth(), -i*50-10)
-- 14 day timeframe
local used14day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
used14day:SetText("- "..v.used14day)
used14day:SetPoint("TOPLEFT", 350-used14day:GetStringWidth(), -i*50+10)
local crafted14day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
crafted14day:SetText("+ "..v.crafted14day)
crafted14day:SetPoint("TOPLEFT", 350-crafted14day:GetStringWidth(), -i*50-10)
-- 30 day timeframe
local used30day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
used30day:SetText("- "..v.used30day)
used30day:SetPoint("TOPLEFT", 450-used30day:GetStringWidth(), -i*50+10)
local crafted30day = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
crafted30day:SetText("+ "..v.crafted30day)
crafted30day:SetPoint("TOPLEFT", 450-crafted30day:GetStringWidth(), -i*50-10)
-- total timeframe
local usedtotal = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
usedtotal:SetText("- "..v.usedtotal)
usedtotal:SetPoint("TOPLEFT", 550-usedtotal:GetStringWidth(), -i*50+10)
local craftedtotal = sc:CreateFontString(sc, "ARTWORK", "GameFontHighlightRight")
craftedtotal:SetText("+ "..v.craftedtotal)
craftedtotal:SetPoint("TOPLEFT", 550-craftedtotal:GetStringWidth(), -i*50-10)
end
else
-- create headers for itemclass
local i = 1
for kItemType, vItemType in pairs(CL:CraftLogGetItemStats()) do
local headerHeight = 40
local itemContainer = CraftLogContainerFrames[i] or CreateFrame("Frame", "CraftLogContainer"..kItemType, sc)
CraftLogContainerFrames[i] = itemContainer
if (i==1) then
itemContainer:SetPoint("TOPLEFT", 20, -20)
else
itemContainer:SetPoint("TOPLEFT", CraftLogContainerFrames[i-1], "BOTTOMLEFT", 0, 0)
end
itemContainer:SetPoint("RIGHT", 0, 0)
itemContainer:SetClipsChildren(true)
--itemContainer:SetWidth(200)
--itemContainer:SetHeight(40)
local headerButton = CraftLogItemButtons[i] or CreateFrame("Button", "CraftLogContainerHeaderButton"..kItemType, itemContainer, "UIPanelButtonTemplate")
CraftLogItemButtons[i] = headerButton
local headerButtonText = headerButton:CreateFontString(headerButton, "ARTWORK", "GameFontHighlight")
headerButtonText:SetText("+")
headerButton:SetPoint("TOPLEFT", 10, -10)
headerButton:SetHeight(20)
headerButton:SetWidth(20)
headerButton:SetFontString(headerButtonText)
local headerText = itemContainer:CreateFontString(itemContainer, "ARTWORK", "GameFontHighlight")
headerText:SetText(kItemType)
headerText:SetPoint("TOPLEFT", 40, -15)
-- create headers for itemsubclass
local n = 1
for kItemSubType, vItemSubType in pairs(vItemType) do
local subHeaderHeight = 40
local itemSubContainer = CraftLogSubContainerFrames[100*i+n] or CreateFrame("Frame", "CraftLogSubContainer"..kItemType..kItemSubType, itemContainer)
CraftLogSubContainerFrames[100*i+n] = itemSubContainer
if (n==1) then
itemSubContainer:SetPoint("TOPLEFT", 20, -40)
else
itemSubContainer:SetPoint("TOPLEFT", CraftLogSubContainerFrames[100*i+n-1], "BOTTOMLEFT", 0, 0)
end
itemSubContainer:SetPoint("RIGHT", 0, 0)
--itemSubContainer:SetWidth(200)
--itemSubContainer:SetHeight(40)
local subHeaderButton = CraftLogItemButtons[i*100+n] or CreateFrame("Button", "CraftLogContainerSubHeaderButton"..kItemType..kItemSubType, itemSubContainer, "UIPanelButtonTemplate")
CraftLogItemButtons[100*i+n] = subHeaderButton
local subHeaderButtonText = subHeaderButton:CreateFontString(subHeaderButton, "ARTWORK", "GameFontHighlight")
subHeaderButtonText:SetText("+")
subHeaderButton:SetPoint("TOPLEFT", 10 , -10)
subHeaderButton:SetWidth(20)
subHeaderButton:SetHeight(20)
subHeaderButton:SetFontString(subHeaderButtonText)
local subHeaderText = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlight")
subHeaderText:SetText(kItemType.." / "..kItemSubType)
subHeaderText:SetPoint("TOPLEFT", 40, -15)
-- create item entries
table.sort(vItemSubType, function(a,b) return
a.itemlink<b.itemlink or
(a.itemlink==b.itemlink and a.ilvl<b.ilvl)
end)
local m = 1
for k, v in ipairs(vItemSubType) do
local itemButton = CraftLogItemButtons[10000*i+100*n+k] or CreateFrame("Button", nil, itemSubContainer)
CraftLogItemButtons[10000*i+100*n+k] = itemButton
local itemText = itemButton:CreateFontString(itemButton, "ARTWORK", "GameFontHighlight")
itemText:SetText(v.itemlink.." ("..v.ilvl..")")
itemButton:SetPoint("TOPLEFT", 60, -k*50)
itemButton:SetHeight(20)
itemButton:SetWidth(itemText:GetStringWidth())
itemButton:SetFontString(itemText)
itemButton:HookScript("OnEnter", function()
if(v.itemlink) then
GameToolTip:SetOwner(itemButton, "ANCHOR_CURSOR")
GameToolTip:SetHyperlink(v.itemlink)
GameToolTip:Show()
end
end)
itemButton:HookScript("OnLeave", function()
GameToolTip:Hide()
end)
-- 7 day timeframe
local used7day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
used7day:SetText("- "..v.used7day)
used7day:SetPoint("TOPLEFT", 350-used7day:GetStringWidth(), -k*50+10)
local crafted7day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
crafted7day:SetText("+ "..v.crafted7day)
crafted7day:SetPoint("TOPLEFT", 350-crafted7day:GetStringWidth(), -k*50-10)
-- 14 day timeframe
local used14day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
used14day:SetText("- "..v.used14day)
used14day:SetPoint("TOPLEFT", 450-used14day:GetStringWidth(), -k*50+10)
local crafted14day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
crafted14day:SetText("+ "..v.crafted14day)
crafted14day:SetPoint("TOPLEFT", 450-crafted14day:GetStringWidth(), -k*50-10)
-- 30 day timeframe
local used30day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
used30day:SetText("- "..v.used30day)
used30day:SetPoint("TOPLEFT", 550-used30day:GetStringWidth(), -k*50+10)
local crafted30day = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
crafted30day:SetText("+ "..v.crafted30day)
crafted30day:SetPoint("TOPLEFT", 550-crafted30day:GetStringWidth(), -k*50-10)
-- total timeframe
local usedtotal = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
usedtotal:SetText("- "..v.usedtotal)
usedtotal:SetPoint("TOPLEFT", 650-usedtotal:GetStringWidth(), -k*50+10)
local craftedtotal = itemSubContainer:CreateFontString(itemSubContainer, "ARTWORK", "GameFontHighlightRight")
craftedtotal:SetText("+ "..v.craftedtotal)
craftedtotal:SetPoint("TOPLEFT", 650-craftedtotal:GetStringWidth(), -k*50-10)
m = k
subHeaderHeight = subHeaderHeight + 50
end
itemSubContainer:SetHeight(subHeaderHeight)
n = n + 1
headerHeight = headerHeight + subHeaderHeight
end
itemContainer:SetHeight(headerHeight)
i = i + 1
end
--local btnCategoryToggle = CreateFrame("Button", nil, sc, "OptionsButtonTemplate")
--btnCategoryToggle:SetText("+")
--btnCategoryToggle:SetPoint("TOPLEFT", 20, -20)
--btnCategoryToggle:SetSize(20,20)
end
--local temptext = sc:CreateFontString(sc, "ARTWORK", "GameFontNormal")
--temptext:SetPoint("TOPLEFT", 20, -1000)
--temptext:SetText("testText")
--end
end
-- slash command handler
function SlashCraftLog(arg1)
if (arg1 == "help") or (arg1 == "?") then
print("use /craftlog debug to toggle debug mode")
--toggle debug mode
elseif (arg1 == "debug") then
debugToggle = not debugToggle
if (debugToggle) then
print("CraftLog: Debug Mode is now on")
else
print("CraftLog: Debug Mode is now off")
end
-- show main window
elseif (arg1 == "") then
if (debugToggle) then print("CraftLog: showing Frame") end
f:Show()
f:ShowData()
end
end
-- register slash commands
SLASH_CRAFTLOG1 = "/cl"
SLASH_CRAFTLOG2 = "/craftlog"
SlashCmdList["CRAFTLOG"] = SlashCraftLog