-
Notifications
You must be signed in to change notification settings - Fork 6
/
Skillet.lua
1846 lines (1745 loc) · 58.4 KB
/
Skillet.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
local addonName,addonTable = ...
--[[
Skillet: A tradeskill window replacement.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]--
local isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE -- 1
local isClassic = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC -- 2
local isBCC = WOW_PROJECT_ID == WOW_PROJECT_BURNING_CRUSADE_CLASSIC -- 5
local isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC -- 11
local isCata = WOW_PROJECT_ID == WOW_PROJECT_CATACLYSM_CLASSIC -- 14
Skillet = LibStub("AceAddon-3.0"):NewAddon("Skillet", "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0")
local AceDB = LibStub("AceDB-3.0")
-- Pull it into the local namespace, it's faster to access that way
local Skillet = Skillet
local DA = Skillet -- needed because LibStub changed the definition of Skillet
-- Localization
local L = LibStub("AceLocale-3.0"):GetLocale("Skillet")
Skillet.L = L
-- Get version info from the .toc file
Skillet.version = C_AddOns.GetAddOnMetadata("Skillet", "Version")
Skillet.isTest = string.find(Skillet.version,"-") or string.find(Skillet.version,"+")
Skillet.interface = select(4, GetBuildInfo())
Skillet.build = (Skillet.interface < 20000 and "Classic") or (Skillet.interface < 30000 and "BCC") or
(Skillet.interface < 40000 and "Wrath") or (Skillet.interface < 50000 and "Cata") or "Retail"
Skillet.project = WOW_PROJECT_ID
Skillet.gttScale = GameTooltip:GetScale()
local nonLinkingTrade = { [2656] = true, [53428] = true } -- smelting, runeforging
local defaults = {
profile = {
--
-- user configurable options
--
vendor_buy_button = true,
vendor_auto_buy = false,
show_item_notes_tooltip = false,
show_crafters_tooltip = false,
show_detailed_recipe_tooltip = true, -- show any tooltips?
display_full_tooltip = true, -- show full blizzards tooltip
link_craftable_reagents = true,
queue_craftable_reagents = true,
queue_one_at_a_time = true,
queue_to_front = false,
ignore_banked_reagents = false,
ignore_queued_reagents = false,
queue_glyph_reagents = false,
display_required_level = false,
display_shopping_list_at_bank = true,
display_shopping_list_at_guildbank = true,
display_shopping_list_at_auction = true,
display_shopping_list_at_merchant = false,
use_blizzard_for_followers = false,
show_recipe_source_for_learned = false,
recipe_source_first = false,
use_guildbank_as_alt = false,
use_altcurrency_vendor_items = false,
show_max_upgrade = true,
enhanced_recipe_display = false,
confirm_queue_clear = false,
queue_only_view = true,
dialog_switch = false,
scale_tooltip = false,
always_show_progress_bar = true,
tsm_compat = false,
transparency = 1.0,
scale = 1.0,
ttscale = 1.0,
plugins = {},
SavedQueues = {},
},
realm = {
--
-- notes added to items crafted or used in crafting
--
notes = {},
},
char = {
--
-- options specific to a current tradeskill
--
tradeskill_options = {},
include_alts = true, -- Display alt's items in shopping list
same_faction = true, -- Display same faction alt items only
ignore_on_hand = false, -- Ignore items in inventory
item_order = false, -- Order shopping list by item
merge_items = false, -- Merge same shopping list items together
include_guild = false, -- Use the contents of the Guild Bank
},
}
--
-- default options for each player/tradeskill
--
Skillet.defaultOptions = {
["sortmethod"] = "None",
["grouping"] = "Blizzard",
["searchtext"] = "",
["filterInventory-bag"] = true,
["filterInventory-crafted"] = true,
["filterInventory-vendor"] = true,
["filterInventory-alts"] = false,
["filterInventory-owned"] = true,
["filterLevel"] = 1,
["hideuncraftable"] = false,
["favoritesOnly"] = false,
}
Skillet.unknownRecipe = {
tradeID = 0,
name = "unknown",
tools = {},
reagentData = {},
numOptional = 0,
cooldown = 0,
itemID = 0,
numMade = 0,
spellID = 0,
numCraftable = 0,
numCraftableVendor = 0,
numCraftableAlts = 0,
}
function Skillet:DisableBlizzardFrame()
DA.DEBUG(0,"DisableBlizzardFrame()")
if not ProfessionsFrame then
DA.WARN("DisableBlizzardFrame: ProfessionsFrame is nil")
elseif self.BlizzardTradeSkillFrame == nil then
self.BlizzardTradeSkillFrame = ProfessionsFrame
self.tradeSkillHide = ProfessionsFrame:GetScript("OnHide")
ProfessionsFrame:SetScript("OnHide", nil)
--[[ From @plusmouse on WoWUIDev Discord channel
if not self.craftingFrame then
DA.DEBUG(1,"DisableBlizzardFrame: creating hack frames")
self.craftingFrame = CreateFrame("Frame", nil, nil, "ProfessionsCraftingPageTemplate")
self.craftingFrame:SetParent(nil)
self.craftingFrame:Hide()
EventRegistry:UnregisterCallback("ProfessionsRecipeListMixin.Event.OnRecipeSelected", self.craftingFrame)
EventRegistry:UnregisterCallback("Professions.ProfessionSelected", self.craftingFrame)
EventRegistry:UnregisterCallback("Professions.ReagentClicked", self.craftingFrame)
EventRegistry:UnregisterCallback("Professions.TransactionUpdated", self.craftingFrame)
self.craftingFrame:RegisterEvent("UPDATE_TRADESKILL_CAST_COMPLETE")
end
--]]
end
if self.interface < 100100 then
SetUIPanelAttribute(ProfessionsFrame, "width", 0) -- Prevent AH from closing when Skillet is opened
end
HideUIPanel(ProfessionsFrame)
self.BlizzardUIshowing = false
end
function Skillet:EnableBlizzardFrame()
DA.DEBUG(0,"EnableBlizzardFrame()")
if self.BlizzardTradeSkillFrame ~= nil then
self.BlizzardTradeSkillFrame = nil
if self.interface < 100100 then
SetUIPanelAttribute(ProfessionsFrame, "width", nil) -- Allow the frame to use its real width
end
ProfessionsFrame:SetScript("OnHide", self.tradeSkillHide)
self.tradeSkillHide = nil
end
end
--
-- Called when the addon is loaded
--
function Skillet:OnInitialize()
if not SkilletWho then
SkilletWho = {}
end
if not SkilletDBPC then
SkilletDBPC = {}
end
if not SkilletProfile then
SkilletProfile = {}
end
if not SkilletMemory then
SkilletMemory = {}
end
if DA.deepcopy then -- For serious debugging, start with a clean slate
SkilletMemory = {}
SkilletDBPC = {}
end
DA.DebugLog = SkilletDBPC
DA.DebugProfile = SkilletProfile
if not self.InProgress then
self.InProgress = {}
end
self.db = AceDB:New("SkilletDB", defaults)
--
-- Clean up obsolete data
--
if self.db.realm.dataVersion then
self.db.global.dataVersion = self.db.realm.dataVersion
self.db.realm.dataVersion = nil
end
if self.db.realm.reagentBank then
self.db.realm.reagentBank = nil
end
if self.db.global.AllRecipe then
self.db.global.AllRecipe = nil
end
if self.db.realm.Filtered then
self.db.realm.Filtered = nil
end
if self.db.realm.recipeInfo then
self.db.realm.recipeInfo = nil
end
if self.db.realm.skillDB then
self.db.realm.skillDB = nil
end
--
-- Change the dataVersion when (major) code changes
-- obsolete the current saved variables database.
--
-- Change the customVersion when code changes obsolete
-- the custom group specific saved variables data.
--
-- Change the queueVersion when code changes obsolete
-- the queue specific saved variables data.
--
-- Change the recipeVersion when code changes obsolete
-- the recipe specific saved variables data.
--
-- When Blizzard releases a new build, there's a chance that
-- recipes have changed (i.e. different reagent requirements) so
-- we clear the saved variables recipe data just to be safe.
--
local dataVersion = 10
local queueVersion = 1
local customVersion = 1
local recipeVersion = 1
local detailsVersion = 1
local _,wowBuild,_,wowVersion = GetBuildInfo();
self.wowBuild = wowBuild
self.wowVersion = wowVersion
if not self.db.global.dataVersion or self.db.global.dataVersion ~= dataVersion then
self.db.global.dataVersion = dataVersion
self:FlushAllData()
elseif not self.db.global.customVersion or self.db.global.customVersion ~= customVersion then
self.db.global.customVersion = customVersion
self:FlushCustomData()
elseif not self.db.global.queueVersion or self.db.global.queueVersion ~= queueVersion then
self.db.global.queueVersion = queueVersion
self:FlushQueueData()
elseif not self.db.global.recipeVersion or self.db.global.recipeVersion ~= recipeVersion then
self.db.global.recipeVersion = recipeVersion
self:FlushRecipeData()
elseif not self.db.global.detailsVersion or self.db.global.detailsVersion ~= detailsVersion then
self.db.global.detailsVersion = detailsVersion
self:FlushDetailData()
elseif not self.db.global.wowBuild or self.db.global.wowBuild ~= self.wowBuild then
self.db.global.wowBuild = self.wowBuild
self.db.global.wowVersion = self.wowVersion -- actually TOC version
self:FlushRecipeData()
end
--
-- Information useful for debugging
--
self.db.global.locale = GetLocale()
self.db.global.version = self.version
self.db.global.build = self.build
self.db.global.project = self.project
--
-- Initialize global data
--
if not self.db.global.recipeDB then
self.db.global.recipeDB = {}
end
if not self.db.global.recipeNameDB then
self.db.global.recipeNameDB = {}
end
if not self.db.global.itemRecipeSource then
self.db.global.itemRecipeSource = {}
end
if not self.db.global.itemRecipeUsedIn then
self.db.global.itemRecipeUsedIn = {}
end
if not self.db.global.Categories then
self.db.global.Categories = {}
end
if not self.db.global.MissingVendorItems then
self:InitializeMissingVendorItems()
end
if not self.db.global.AdjustNumMade then
self.db.global.AdjustNumMade = {}
end
if not self.db.global.MissingSkillLevels then
self.db.global.MissingSkillLevels = {}
end
if not self.db.global.SkillLevels then
self:InitializeSkillLevels()
end
if not self.db.global.cachedGuildbank then
self.db.global.cachedGuildbank = {}
end
if not self.db.global.customPrice then
self.db.global.customPrice = {}
end
if not self.db.global.warbandData then
self.db.global.warbandData = {}
end
if not self.db.global.warbandDetails then
self.db.global.warbandDetails = {}
end
--
-- Initialize the Skill Levels data if any of the tables are missing
--
local initSkillLevels
if not self.db.global.MissingSkillLevels then
self.db.global.MissingSkillLevels = {}
initSkillLevels = true
end
if not self.db.global.SkillLineAbility_era then
self.db.global.SkillLineAbility_era = {}
initSkillLevels = true
end
if not self.db.global.SkillLineAbility_cata then
self.db.global.SkillLineAbility_cata = {}
initSkillLevels = true
end
if not self.db.global.SkillLineAbility_retail then
self.db.global.SkillLineAbility_retail = {}
initSkillLevels = true
end
if initSkillLevels then
self:InitializeSkillLevels()
end
--[[
-- Hook default tooltips
--
local tooltipsToHook = { ItemRefTooltip, GameTooltip, ShoppingTooltip1, ShoppingTooltip2 };
for _, tooltip in pairs(tooltipsToHook) do
if tooltip then
tooltip:HookScript("OnTooltipSetItem", function(tooltip)
Skillet:AddItemNotesToTooltip(tooltip)
end)
end
end
--]]
--
-- configure the addon options and the slash command handler
-- (Skillet.options is defined in SkilletOptions.lua)
--
Skillet:ConfigureOptions()
--
-- Copy the profile debugging variables to the global table
-- where DebugAids.lua is looking for them.
--
-- Warning: Setting TableDump can be a performance hog, use caution.
-- Setting DebugLogging (without DebugShow) is a minor performance hit.
-- WarnLog (with or without WarnShow) can remain on as warning messages are rare.
-- TraceLog2 controls event tracing of high frequency events like BAG_UPDATE
--
-- Note: Undefined is the same as false so we only need to predefine true variables
--
if Skillet.db.profile.WarnLog == nil then
Skillet.db.profile.WarnLog = true
end
Skillet.WarnLog = Skillet.db.profile.WarnLog
Skillet.WarnShow = Skillet.db.profile.WarnShow
Skillet.DebugShow = Skillet.db.profile.DebugShow
Skillet.DebugLogging = Skillet.db.profile.DebugLogging
Skillet.DebugLevel = Skillet.db.profile.DebugLevel
Skillet.LogLevel = Skillet.db.profile.LogLevel
Skillet.MAXDEBUG = Skillet.db.profile.MAXDEBUG or 4000
Skillet.MAXPROFILE = Skillet.db.profile.MAXPROFILE or 2000
Skillet.TableDump = Skillet.db.profile.TableDump
Skillet.TraceShow = Skillet.db.profile.TraceShow
Skillet.TraceLog = Skillet.db.profile.TraceLog
Skillet.TraceLog2 = Skillet.db.profile.TraceLog2
Skillet.ProfileShow = Skillet.db.profile.ProfileShow
--
-- Profile variable to control Skillet fixes for Blizzard bugs.
-- Can be toggled [or turned off] with "/skillet fixbugs [off]"
--
if Skillet.db.profile.FixBugs == nil then
Skillet.db.profile.FixBugs = true
end
Skillet.FixBugs = Skillet.db.profile.FixBugs
--
-- Create static popups for changing professions
--
StaticPopupDialogs["SKILLET_CONTINUE_CHANGE"] = {
text = "Skillet-Classic\n"..L["Press Okay to continue changing professions"],
button1 = OKAY,
OnAccept = function( self )
Skillet:ContinueChange()
return
end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
StaticPopupDialogs["SKILLET_MANUAL_CHANGE"] = {
text = "Skillet\n"..L["Press your button which opens %s"],
-- button1 = OKAY,
-- OnAccept = function( self )
-- Skillet:ContinueChange(true)
-- return
-- end,
OnCancel = function( self )
Skillet:FinishChange()
return
end,
OnHide = function( self )
Skillet:FinishChange()
return
end,
timeout = 30,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
--
-- Create our frame
--
if not Skillet.tradeSkillFrame then
Skillet.tradeSkillFrame = Skillet:CreateTradeSkillWindow()
tinsert(UISpecialFrames, Skillet.tradeSkillFrame:GetName())
end
--
-- Now do the character initialization
--
self:InitializeDatabase(UnitName("player"))
self:InitializePlugins()
self.NewsGUI:Initialize()
--
-- Some counters for high frequency events
--
if not Skillet.bagUpdateCounts then
Skillet.bagUpdateCounts = {}
Skillet.bagUpdateDelayedCount = 0
Skillet.bankUpdateCount = 0
end
end
--
-- These functions reset parts of the database primarily
-- when code changes obsolete the current database.
--
-- FlushAllData covers everything and (hopefully) is
-- rarely used. There is a dataVersion number to
-- increment to trigger a call.
--
function Skillet:FlushAllData()
DA.DEBUG(0,"FlushAllData()");
Skillet.data = {}
Skillet.db.realm.tradeSkills = {}
Skillet.db.realm.auctionData = {}
Skillet.db.realm.inventoryData = {}
Skillet.db.realm.userIgnoredMats = {}
Skillet:FlushCustomData()
Skillet:FlushQueueData()
Skillet:FlushRecipeData()
Skillet:FlushDetailData()
Skillet:InitializeMissingVendorItems()
end
--
-- Flush all data for the current player
--
function Skillet:FlushPlayerData()
DA.DEBUG(0,"FlushPlayerData()");
local player = UnitName("player")
Skillet.db.realm.tradeSkills[player] = {}
Skillet.db.realm.auctionData[player] = {}
Skillet.db.realm.inventoryData[player] = {}
Skillet.db.realm.userIgnoredMats[player] = {}
Skillet.db.realm.bagData[player] = {}
Skillet.db.realm.bagDetails[player] = {}
Skillet.db.realm.bankData[player] = {}
Skillet.db.realm.bankDetails[player] = {}
Skillet.db.realm.queueData[player] = {}
Skillet.db.realm.reagentsInQueue[player] = {}
Skillet.db.realm.modifiedInQueue[player] = {}
Skillet.db.realm.groupDB[player] = {}
Skillet.db.realm.options[player] = {}
end
--
-- Custom Groups data could represent significant
-- effort by the player so don't clear it without
-- good cause.
--
function Skillet:FlushCustomData()
DA.DEBUG(0,"FlushCustomData()");
Skillet.db.realm.groupDB = {}
end
--
-- Saved queues are in the profile so
-- clearing these tables is just the current
-- queue and should have minimal impact.
--
function Skillet:FlushQueueData()
DA.DEBUG(0,"FlushQueueData()");
Skillet.db.realm.queueData = {}
Skillet.db.realm.reagentsInQueue = {}
Skillet.db.realm.modifiedInQueue = {}
end
--
-- Recipe data is constantly getting rebuilt so
-- clearing it should have minimal (if any) impact.
-- Blizzard's "stealth" changes to recipes are the
-- primary reason this function exists.
--
function Skillet:FlushRecipeData()
DA.DEBUG(0,"FlushRecipeData()");
Skillet.db.global.recipeDB = {}
Skillet.db.global.recipeNameDB = {}
Skillet.db.global.itemRecipeUsedIn = {}
Skillet.db.global.itemRecipeSource = {}
Skillet.db.global.Categories = {}
if Skillet.data and Skillet.data.recipeInfo then
Skillet.data.recipeInfo = {}
Skillet:InitializeSkillLevels()
end
end
--
-- Detailed contents of the bags, bank, and guildbank
-- can take a lot of space so clearing these tables
-- can free that up.
--
function Skillet:FlushDetailData()
DA.DEBUG(0,"FlushDetailData()");
Skillet.db.realm.bagData = {}
Skillet.db.realm.bagDetails = {}
Skillet.db.realm.bankData = {}
Skillet.db.realm.bankDetails = {}
Skillet.db.global.warbandData = {}
Skillet.db.global.warbandDetails = {}
Skillet.db.global.detailedGuildbank = {}
end
--
-- MissingVendorItem entries can be a string when bought with gold
-- or a table when bought with an alternate currency
-- table entries are {name, quantity, currencyName, currencyID, currencyCount}
--
function Skillet:InitializeMissingVendorItems()
self.db.global.MissingVendorItems = {
[30817] = "Simple Flour",
[4539] = "Goldenbark Apple",
[17035] = "Stranglethorn Seed",
[17034] = "Maple Seed",
[4399] = "Wooden Stock",
[3857] = "Coal",
[52188] = "Jeweler's Setting",
[38682] = "Enchanting Vellum",
}
end
function Skillet:InitializeDatabase(player)
DA.DEBUG(0,"Initialize database for "..tostring(player))
if self.linkedSkill or self.isGuild then -- Avoid adding unnecessary data to savedvariables
return
end
if not self.data then
self.data = {}
end
if not self.data.recipeInfo then
self.data.recipeInfo = {}
end
if not self.data.recipeList then
self.data.recipeList = {}
end
if not self.data.skillList then
self.data.skillList = {}
end
if not self.data.groupList then
self.data.groupList = {}
end
if not self.data.skillIndexLookup then
self.data.skillIndexLookup = {}
end
if player then
if not self.db.realm.groupDB then
self.db.realm.groupDB = {}
end
if not self.db.realm.queueData then
self.db.realm.queueData = {}
end
if not self.db.realm.queueData[player] then
self.db.realm.queueData[player] = {}
end
if not self.db.realm.auctionData then
self.db.realm.auctionData = {}
end
if not self.db.realm.auctionData[player] then
self.db.realm.auctionData[player] = {}
end
if not self.db.realm.tradeSkills then
self.db.realm.tradeSkills = {}
end
if not self.db.realm.faction then
self.db.realm.faction = {}
end
if not self.db.realm.race then
self.db.realm.race = {}
end
if not self.db.realm.class then
self.db.realm.class = {}
end
if not self.db.realm.guid then
self.db.realm.guid = {}
end
if not self.db.global.faction then
self.db.global.faction = {}
end
if not self.db.global.server then
self.db.global.server = {}
end
if player == UnitName("player") then
if not self.db.realm.inventoryData then
self.db.realm.inventoryData = {}
end
if not self.db.realm.inventoryData[player] then
self.db.realm.inventoryData[player] = {}
end
if not self.db.realm.bagData then
self.db.realm.bagData = {}
end
if not self.db.realm.bagData[player] then
self.db.realm.bagData[player] = {}
end
if not self.db.realm.bagDetails then
self.db.realm.bagDetails = {}
end
if not self.db.realm.bagDetails[player] then
self.db.realm.bagDetails[player] = {}
end
if not self.db.realm.bankData then
self.db.realm.bankData = {}
end
if not self.db.realm.bankData[player] then
self.db.realm.bankData[player] = {}
end
if not self.db.realm.bankDetails then
self.db.realm.bankDetails = {}
end
if not self.db.realm.bankDetails[player] then
self.db.realm.bankDetails[player] = {}
end
if not self.db.realm.reagentsInQueue then
self.db.realm.reagentsInQueue = {}
end
if not self.db.realm.reagentsInQueue[player] then
self.db.realm.reagentsInQueue[player] = {}
end
if not self.db.realm.modifiedInQueue then
self.db.realm.modifiedInQueue = {}
end
if not self.db.realm.modifiedInQueue[player] then
self.db.realm.modifiedInQueue[player] = {}
end
if not self.db.realm.userIgnoredMats then
self.db.realm.userIgnoredMats = {}
end
if not self.db.realm.userIgnoredMats[player] then
self.db.realm.userIgnoredMats[player] = {}
end
if not self.db.profile.SavedQueues then
self.db.profile.SavedQueues = {}
end
if not self.db.profile.plugins then
self.db.profile.plugins = {}
end
if self.db.profile.plugins.recipeNamePlugin then
if not self.db.profile.plugins.recipeNameSuffix then
self.db.profile.plugins.recipeNameSuffix = self.db.profile.plugins.recipeNamePlugin
end
self.db.profile.plugins.recipeNamePlugin = nil
end
Skillet:InitializePlugins()
end
end
end
function Skillet:RegisterRecipeFilter(name, namespace, initMethod, filterMethod)
if not self.recipeFilters then
self.recipeFilters = {}
end
--DA.DEBUG(0,"add recipe filter "..name)
self.recipeFilters[name] = { namespace = namespace, initMethod = initMethod, filterMethod = filterMethod }
end
--
-- Called when the addon is enabled
--
function Skillet:OnEnable()
DA.DEBUG(0,"OnEnable()");
--
-- Hook into the events that we care about
--
-- Trade skill window changes
--
self:RegisterEvent("TRADE_SKILL_CLOSE")
self:RegisterEvent("TRADE_SKILL_SHOW")
self:RegisterEvent("TRADE_SKILL_NAME_UPDATE")
self:RegisterEvent("TRADE_SKILL_DATA_SOURCE_CHANGED")
self:RegisterEvent("TRADE_SKILL_DATA_SOURCE_CHANGING")
self:RegisterEvent("TRADE_SKILL_DETAILS_UPDATE")
-- self:RegisterEvent("TRADE_SKILL_FILTER_UPDATE")
self:RegisterEvent("TRADE_SKILL_LIST_UPDATE")
-- self:RegisterEvent("GUILD_RECIPE_KNOWN_BY_MEMBERS", "SkilletShowGuildCrafters")
self:RegisterEvent("GARRISON_TRADESKILL_NPC_CLOSED")
self:RegisterEvent("BAG_UPDATE") -- Fires for both bag and bank updates.
self:RegisterEvent("BAG_UPDATE_DELAYED") -- Fires after all applicable BAG_UPDATE events for a specific action have been fired.
self:RegisterEvent("UNIT_INVENTORY_CHANGED") -- BAG_UPDATE_DELAYED seems to have disappeared. Using this instead.
--
-- Events that replace *_SHOW and *_CLOSED by adding a PlayerInteractionType parameter
--
self:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")
self:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")
--
-- MERCHANT_SHOW, MERCHANT_HIDE, MERCHANT_UPDATE events needed for auto buying.
--
self:RegisterEvent("MERCHANT_SHOW")
self:RegisterEvent("MERCHANT_UPDATE")
self:RegisterEvent("MERCHANT_CLOSED")
--
-- To show a shopping list when at the bank/guildbank/auction house
--
self:RegisterEvent("BANKFRAME_OPENED")
self:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
self:RegisterEvent("PLAYERREAGENTBANKSLOTS_CHANGED")
self:RegisterEvent("BANKFRAME_CLOSED")
self:RegisterEvent("GUILDBANKFRAME_OPENED")
self:RegisterEvent("GUILDBANK_UPDATE_TEXT")
self:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED")
self:RegisterEvent("GUILDBANKFRAME_CLOSED")
self:RegisterEvent("AUCTION_HOUSE_SHOW")
self:RegisterEvent("AUCTION_HOUSE_CLOSED")
--
-- Events needed to process the queue and to update
-- the tradeskill window to update the number of items
-- that can be crafted as we consume reagents.
--
self:RegisterEvent("UNIT_SPELLCAST_START")
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
self:RegisterEvent("UNIT_SPELLCAST_FAILED")
self:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET")
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
-- self:RegisterEvent("UPDATE_TRADESKILL_CAST_COMPLETE")
-- self:RegisterEvent("UPDATE_TRADESKILL_RECAST")
self:RegisterEvent("ITEM_COUNT_CHANGED")
self:RegisterEvent("TRADE_SKILL_ITEM_CRAFTED_RESULT")
--
-- Events needed to handle caching of item info
--
self:RegisterEvent("ITEM_DATA_LOAD_RESULT")
self:RegisterEvent("GET_ITEM_INFO_RECEIVED")
--
-- Not sure these are needed for crafting but they
-- are useful for debugging.
--
self:RegisterEvent("UNIT_SPELLCAST_SENT")
self:RegisterEvent("UNIT_SPELLCAST_DELAYED")
self:RegisterEvent("UNIT_SPELLCAST_STOP")
-- self:RegisterEvent("CHAT_MSG_SKILL")
self:RegisterEvent("SKILL_LINES_CHANGED") -- replacement for CHAT_MSG_SKILL?
self:RegisterEvent("LEARNED_SPELL_IN_TAB") -- arg1 = professionID
self:RegisterEvent("NEW_RECIPE_LEARNED") -- arg1 = recipeID
-- self:RegisterEvent("ADDON_ACTION_BLOCKED")
if Skillet.db.profile.BlizzOR then
--
-- Dump the data passed to C_TradeSkillUI functions so we can learn how Blizzard handles the new stuff
--
-- C_TradeSkillUI.CraftRecipe(recipeSpellID [, numCasts, craftingReagents, recipeLevel, orderID])
--
hooksecurefunc(C_TradeSkillUI,"CraftRecipe",function(...)
local recipeSpellID, numCasts, craftingReagents, recipeLevel, orderID = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftRecipe: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", recipeLevel= "..tostring(recipeLevel)..", orderID= "..tostring(orderID))
end)
--
-- C_TradeSkillUI.CraftSalvage(recipeSpellID [, numCasts, itemTarget])
--
hooksecurefunc(C_TradeSkillUI,"CraftSalvage",function(...)
local recipeSpellID, numCasts, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftSalvage: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", itemTarget= "..DA.DUMP(itemTarget))
end)
--
-- C_TradeSkillUI.CraftEnchant(recipeSpellID [, numCasts, craftingReagents, itemTarget])
--
hooksecurefunc(C_TradeSkillUI,"CraftEnchant",function(...)
local recipeSpellID, numCasts, craftingReagents, itemTarget = ...
DA.DEBUG(0, "C_TradeSkillUI.CraftEnchant: recipeSpellID= "..tostring(recipeSpellID)..", numCasts= "..tostring(numCasts)..", craftingReagents= "..DA.DUMP(craftingReagents)..", itemTarget= "..DA.DUMP(itemTarget))
end)
--
-- result = C_TradeSkillUI.RecraftRecipe(itemGUID [, craftingReagents])
--
hooksecurefunc(C_TradeSkillUI,"RecraftRecipe",function(...)
local itemGUID, craftingReagents = ...
DA.DEBUG(0, "C_TradeSkillUI.RecraftRecipe: itemGUID= "..tostring(itemGUID)..", craftingReagents= "..DA.DUMP(craftingReagents))
end)
end
--
-- Debugging cleanup if enabled
--
self:RegisterEvent("PLAYER_LOGOUT")
self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self.bagsChanged = true
self.hideUncraftableRecipes = false
self.hideTrivialRecipes = false
self.currentTrade = nil
self.selectedSkill = nil
self.currentPlayer = UnitName("player")
self.currentGroupLabel = "Blizzard"
self.currentGroup = nil
self.dataScanned = false
self.recipeDump = {}
--
-- run the upgrade code to convert any old settings
--
self:UpgradeDataAndOptions()
self:CollectTradeSkillData()
self:CollectCurrencyData()
self:EnablePlugins()
end
function Skillet:PLAYER_LOGIN()
DA.TRACE("PLAYER_LOGIN")
end
function Skillet:PLAYER_ENTERING_WORLD()
DA.TRACE("PLAYER_ENTERING_WORLD")
local player, realm = UnitFullName("player")
local faction = UnitFactionGroup("player")
local raceName, raceFile, raceID = UnitRace("player")
local className, classFile, classId = UnitClass("player")
local locale = GetLocale()
local _,wowBuild,_,wowVersion = GetBuildInfo();
local guid = UnitGUID("player") -- example: guid="Player-970-0002FD64" kind=="Player" server=="970" ID="0002FD64"
--
-- PLAYER_ENTERING_WORLD happens on login and when changing zones so
-- only save the time of the first one.
--
if not Skillet.loginTime then
Skillet.loginTime = GetTime()
end
--
-- Store some identifying data in the per character saved variables file
--
SkilletWho.player = player
SkilletWho.realm = realm
SkilletWho.faction = faction
SkilletWho.raceFile = raceFile
SkilletWho.classFile = classFile
self.db.realm.faction[player] = faction
self.db.realm.race[player] = raceFile
self.db.realm.class[player] = classFile
SkilletWho.locale = locale
SkilletWho.wowBuild = wowBuild
SkilletWho.wowVersion = wowVersion
SkilletWho.guid = guid
SkilletWho.version = Skillet.version
if guid then
local kind, server, ID = strsplit("-", guid)
DA.DEBUG(1,"player="..tostring(player)..", faction="..tostring(faction)..", guid="..tostring(guid)..", server="..tostring(server))
--
-- If we support data sharing across connected realms, then
-- Skillet.db.realm.* data needs to move to
-- Skillet.db.global.* data indexed by server.
--
self.db.realm.guid[player]= guid
if (server) then
if not self.data then
self.data = {}
end
self.data.server = server
self.data.realm = realm
if not self.db.global.server[server] then
self.db.global.server[server] = {}
end
self.db.global.server[server][realm] = player
if not self.db.global.customPrice[server] then
self.db.global.customPrice[server] = {}
end
if not self.db.global.faction[server] then
self.db.global.faction[server] = {}
end
self.db.global.faction[server][player] = faction
end
end
end
function Skillet:ADDON_ACTION_BLOCKED()
DA.TRACE("ADDON_ACTION_BLOCKED")
-- print("|cf0f00000Skillet-Classic|r: Combat lockdown restriction." ..
-- " Leave combat and try again.")
-- self:HideAllWindows()
end
function Skillet:PLAYER_LOGOUT()
DA.TRACE("PLAYER_LOGOUT")
--
-- Make a copy of the in memory data for debugging. Note: DeepCopy.lua needs to be added to the .toc
--
if DA.deepcopy then
self.data.sortedSkillList = {"Removed"} -- This table is huge so don't save it unless needed.
-- SkilletMemory = DA.deepcopy(self.data) -- Everything else
--
-- For RecipeGroups debugging:
--
local tradeID, rest
for tradeID in pairs(self.db.realm.tradeSkills[self.currentPlayer]) do
DA.DEBUG(0,"tradeID= "..tostring(tradeID))
if self.data.groupList[self.currentPlayer][tradeID] then
self.data.groupList[self.currentPlayer][tradeID]["Blizzard"] = {"Removed"}
end
end
SkilletMemory = DA.deepcopy(self.data.groupList) -- minus all the group "Blizzard" stuff
end
end
function Skillet:CHAT_MSG_SKILL() -- Replaced by SKILL_LINES_CHANGED?
DA.TRACE("CHAT_MSG_SKILL")
if Skillet.tradeSkillOpen then
Skillet:RescanTrade()
Skillet:UpdateTradeSkillWindow()
end
end
function Skillet:SKILL_LINES_CHANGED()
DA.TRACE("SKILL_LINES_CHANGED")
if Skillet.tradeSkillOpen then
-- Skillet:RescanTrade()
-- Skillet:UpdateTradeSkillWindow()
Skillet.dataSourceChanged = true -- Process the change on the next TRADE_SKILL_LIST_UPDATE
end
end
function Skillet:LEARNED_SPELL_IN_TAB(event, profession)
DA.TRACE("LEARNED_SPELL_IN_TAB")
DA.TRACE("profession= "..tostring(profession))
if Skillet.tradeSkillOpen then
Skillet:RescanTrade() -- Untested
Skillet:UpdateTradeSkillWindow() -- Untested
end
end
function Skillet:NEW_RECIPE_LEARNED(event, recipeID)
DA.TRACE("NEW_RECIPE_LEARNED")
DA.TRACE("recipeID= "..tostring(recipeID))
if Skillet.tradeSkillOpen then
Skillet.dataSourceChanged = true -- Process the change on the next TRADE_SKILL_LIST_UPDATE
end
end
function Skillet:TRADE_SKILL_SHOW()
DA.TRACE("TRADE_SKILL_SHOW")
Skillet.dataSourceChanged = false
Skillet.detailsUpdate = false
Skillet.skillListUpdate = false
Skillet.adjustInventory = false