-
Notifications
You must be signed in to change notification settings - Fork 6
/
Skillet.lua
1805 lines (1703 loc) · 57.3 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/>.
]]--
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
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata
Skillet.version = GetAddOnMetadata("Skillet-Classic", "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
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.isCraft = false -- true for the Blizzard Craft UI, false for the Blizzard TradeSkill UI
Skillet.lastCraft = false -- help events know when to call ConfigureRecipeControls()
Skillet.ignoreClose = false -- when switching from the Craft UI to the TradeSkill UI, ignore the other's close.
Skillet.gttScale = GameTooltip:GetScale()
Skillet.tradeUpdate = 0
Skillet.craftUpdate = 0
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_detailed_recipe_tooltip = true, -- show any tooltips?
display_full_tooltip = true, -- show full blizzards tooltip
display_item_tooltip = true, -- show item tooltip or recipe tooltip
link_craftable_reagents = true,
queue_craftable_reagents = true,
queue_tools = false,
ignore_banked_reagents = false,
ignore_queued_reagents = false,
queue_glyph_reagents = false, -- not in Classic
display_required_level = false,
display_item_level = false,
select_top_recipe = false,
display_shopping_list_at_bank = true,
display_shopping_list_at_auction = true,
display_shopping_list_at_merchant = true,
display_shopping_list_at_guildbank = false, -- not in Classic
use_guildbank_as_alt = false, -- not in Classic
use_bank_as_alt = false,
use_blizzard_for_followers = false, -- not in Classic
hide_blizzard_frame = true, -- primarily for debugging
support_crafting = true,
ignore_change = false, -- not in Classic
queue_crafts = false,
include_craftbuttons = true,
enchant_scrolls = false,
-- use_higher_vellum = false,
include_tradebuttons = true,
search_includes_reagents = true,
interrupt_clears_queue = false,
sound_on_empty_queue = false,
clamp_to_screen = true,
scale_tooltip = false,
transparency = 1.0,
scale = 1.0,
ttscale = 1.0,
plugins = {},
SavedQueues = {},
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
},
realm = {
--
-- notes added to items crafted or used in crafting
--
notes = {},
},
}
--
-- 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,
}
Skillet.unknownRecipe = {
tradeID = 0,
name = "unknown",
tools = {},
reagentData = {},
cooldown = 0,
itemID = 0,
numMade = 0,
spellID = 0,
numCraftable = 0,
numCraftableVendor = 0,
numCraftableAlts = 0,
}
function Skillet:DisableBlizzardFrame()
DA.DEBUG(0,"DisableBlizzardFrame()")
if self.BlizzardTradeSkillFrame == nil then
if (not IsAddOnLoaded("Blizzard_TradeSkillUI")) then
LoadAddOn("Blizzard_TradeSkillUI");
end
self.BlizzardTradeSkillFrame = TradeSkillFrame
self.tradeSkillHide = TradeSkillFrame:GetScript("OnHide")
TradeSkillFrame:SetScript("OnHide", nil)
HideUIPanel(TradeSkillFrame)
end
if self.BlizzardCraftFrame == nil then
if (not IsAddOnLoaded("Blizzard_CraftUI")) then
LoadAddOn("Blizzard_CraftUI");
end
if CraftFrame then
self.BlizzardCraftFrame = CraftFrame
self.craftHide = CraftFrame:GetScript("OnHide")
CraftFrame:SetScript("OnHide", nil)
HideUIPanel(CraftFrame)
end
end
end
function Skillet:EnableBlizzardFrame()
DA.DEBUG(0,"EnableBlizzardFrame()")
if self.BlizzardTradeSkillFrame ~= nil then
if (not IsAddOnLoaded("Blizzard_TradeSkillUI")) then
LoadAddOn("Blizzard_TradeSkillUI");
end
self.BlizzardTradeSkillFrame = nil
TradeSkillFrame:SetScript("OnHide", Skillet.tradeSkillHide)
Skillet.tradeSkillHide = nil
-- ShowUIPanel(TradeSkillFrame)
end
if self.BlizzardCraftFrame ~= nil then
if (not IsAddOnLoaded("Blizzard_CraftUI")) then
LoadAddOn("Blizzard_CraftUI");
end
self.BlizzardCraftFrame = nil
CraftFrame:SetScript("OnHide", Skillet.craftHide)
self.craftHide = nil
self:RestoreEnchantButton(true)
-- ShowUIPanel(CraftFrame)
end
end
--
-- Called with events that should have an existing profile.
--
function Skillet:RefreshConfig(event, database, profile)
DA.MARK3("RefreshConfig("..tostring(event)..", "..tostring(profile)..")")
end
--
-- Called with events that need the profile created.
--
function Skillet:InitializeProfile(event, database, profile)
DA.MARK3("InitializeProfile("..tostring(event)..", "..tostring(profile)..")")
self:ConfigureProfile()
self:ConfigurePlayerProfile()
end
--
-- Called from events related to profile manipulation and new characters
--
function Skillet:ConfigureProfile()
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
end
--
-- Called from events related to profile manipulation and new characters
--
function Skillet:ConfigurePlayerProfile()
if not self.db.profile.groupDB then
self.db.profile.groupDB = {}
end
if not self.db.profile.groupSN then
self.db.profile.groupSN = {}
end
if not self.db.profile.SavedQueues then
self.db.profile.SavedQueues = {}
end
if not self.db.profile.plugins then
self.db.profile.plugins = {}
self:InitializePlugins()
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
self.db = AceDB:New("SkilletDB", defaults)
self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
self.db.RegisterCallback(self, "OnProfileReset", "InitializeProfile")
self.db.RegisterCallback(self, "OnNewProfile", "InitializeProfile")
self.db.RegisterCallback(self, "OnProfileDeleted", "RefreshConfig")
--
-- Clean up obsolete data
--
--
-- 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 = 5
local queueVersion = 1
local customVersion = 1
local recipeVersion = 5
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.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.itemRecipeSource then
self.db.global.itemRecipeSource = {}
end
if not self.db.global.itemRecipeUsedIn then
self.db.global.itemRecipeUsedIn = {}
end
if not self.db.global.MissingVendorItems then
self:InitializeMissingVendorItems()
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
--
-- 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.
--
-- Note: Undefined is the same as false so we only need to predefine true variables
--
Skillet:ConfigureProfile()
--
-- Create a static popup 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
};
--
-- Create a static popup for changing professions
--
StaticPopupDialogs["SKILLET_IGNORE_CHANGE"] = {
text = "Skillet-Classic\n"..L["Use Action Bar button to change professions"],
button1 = OKAY,
OnAccept = function( self )
return
end,
timeout = 0,
exclusive = 1,
whileDead = 1,
hideOnEscape = 1
};
--
-- Now do the character initialization
--
self:InitializeDatabase(UnitName("player"))
self:InitializePlugins()
self.NewsGUI:Initialize()
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.bagData = {}
Skillet.db.realm.bagDetails = {}
Skillet.db.realm.bankData = {}
Skillet.db.realm.bankDetails = {}
Skillet.db.realm.userIgnoredMats = {}
Skillet:FlushCustomData()
Skillet:FlushQueueData()
Skillet:FlushRecipeData()
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.profile.groupDB = {}
Skillet.db.profile.groupSN = {}
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 = {}
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.itemRecipeUsedIn = {}
Skillet.db.global.itemRecipeSource = {}
Skillet.db.global.SkillLevels = nil
Skillet.db.realm.skillDB = {}
Skillet.db.realm.subClass = {}
Skillet.db.realm.invSlot = {}
Skillet:InitializeSkillLevels()
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}
--
-- Note: Classic doesn't have any alternate currencies yet.
--
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",
}
end
function Skillet:InitializeDatabase(player, clean)
if clean then action = "Clean" else action = "Initialize" end
DA.DEBUG(0,action.." database for "..tostring(player))
if self.linkedSkill or self.isGuild then -- Avoid adding unnecessary data to savedvariables
return
end
if player then
--
-- Session data
--
if not self.data then
self.data = {}
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.skillList[player] or clean then
self.data.skillList[player] = {}
end
if not self.data.groupList then
self.data.groupList = {}
end
if not self.data.groupList[player] or clean then
self.data.groupList[player] = {}
end
if not self.data.skillIndexLookup then
self.data.skillIndexLookup = {}
end
if not self.data.skillIndexLookup[player] or clean then
self.data.skillIndexLookup[player] = {}
end
--
-- Realm data
--
if not self.db.realm.skillDB then
self.db.realm.skillDB = {}
end
if not self.db.realm.skillDB[player] or clean then
self.db.realm.skillDB[player] = {}
end
if not self.db.realm.subClass then
self.db.realm.subClass = {}
end
if not self.db.realm.subClass[player] or clean then
self.db.realm.subClass[player] = {}
end
if not self.db.realm.invSlot then
self.db.realm.invSlot = {}
end
if not self.db.realm.invSlot[player] or clean then
self.db.realm.invSlot[player] = {}
end
if not self.db.realm.tradeSkills then
self.db.realm.tradeSkills = {}
end
if not self.db.realm.tradeSkills[player] or clean then
self.db.realm.tradeSkills[player] = {}
end
if not self.db.realm.queueData then
self.db.realm.queueData = {}
end
if not self.db.realm.queueData[player] or clean 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] or clean then
self.db.realm.auctionData[player] = {}
end
if not self.db.realm.trade_wait then
self.db.realm.trade_wait = 1 -- variable to control how many TRADE_SKILL_UPDATE events to ignore
end
if not self.db.realm.craft_wait then
self.db.realm.craft_wait = 1 -- variable to control how many CRAFT_UPDATE events to ignore
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] or clean then
self.db.realm.inventoryData[player] = {}
end
--
-- For debugging, having the contents of bags could be useful.
--
if not self.db.realm.bagData then
self.db.realm.bagData = {}
end
if not self.db.realm.bagData[player] or clean 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] or clean then
self.db.realm.bagDetails[player] = {}
end
--
-- In Classic, you can't craft from the bank but
-- for debugging, having the contents of the bank could be useful.
--
if not self.db.realm.bankData then
self.db.realm.bankData = {}
end
if not self.db.realm.bankData[player] or clean 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] or clean 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] or clean then
self.db.realm.reagentsInQueue[player] = {}
end
if not self.db.realm.userIgnoredMats then
self.db.realm.userIgnoredMats = {}
end
if not self.db.realm.userIgnoredMats[player] or clean then
self.db.realm.userIgnoredMats[player] = {}
end
--
-- Profile data
--
Skillet:ConfigurePlayerProfile()
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_UPDATE")
self:RegisterEvent("TRADE_SKILL_NAME_UPDATE")
if not TSM_API then
self:RegisterEvent("CRAFT_CLOSE") -- craft event (could call SkilletClose)
self:RegisterEvent("CRAFT_SHOW") -- craft event (could call SkilletShow)
self:RegisterEvent("CRAFT_UPDATE") -- craft event
self:RegisterEvent("UNIT_PET_TRAINING_POINTS") -- craft event
end
self:RegisterEvent("UNIT_PORTRAIT_UPDATE") -- Not sure if this is helpful but we will track it.
self:RegisterEvent("SPELLS_CHANGED") -- Not sure if this is helpful but we will track it.
-- self:RegisterEvent("BAG_OPEN") -- Not sure if this is helpful but we will track it.
-- self:RegisterEvent("BAG_CLOSED") -- Not sure if this is helpful but we will track it.
-- self:RegisterEvent("BAG_CONTAINER_UPDATE") -- Not sure if this is helpful but we will track it.
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
--
if isWrath then
self:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_SHOW")
self:RegisterEvent("PLAYER_INTERACTION_MANAGER_FRAME_HIDE")
end
--
-- 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("BANKFRAME_CLOSED")
if not isClassic then
self:RegisterEvent("GUILDBANKFRAME_OPENED")
self:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED")
self:RegisterEvent("GUILDBANKFRAME_CLOSED")
end
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")
--
-- 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("UNIT_SPELLCAST_CHANNEL_START")
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
self:RegisterEvent("UI_ERROR_MESSAGE")
self:RegisterEvent("UI_INFO_MESSAGE")
-- self:RegisterEvent("GET_ITEM_INFO_RECEIVED");
--
-- more useful for debugging (for now)
--
self:RegisterEvent("TRADE_SHOW");
self:RegisterEvent("TRADE_CLOSED")
self:RegisterEvent("TRADE_MONEY_CHANGED")
self:RegisterEvent("TRADE_TARGET_ITEM_CHANGED");
self:RegisterEvent("TRADE_PLAYER_ITEM_CHANGED")
self:RegisterEvent("TRADE_REPLACE_ENCHANT")
self:RegisterEvent("TRADE_POTENTIAL_BIND_ENCHANT");
self:RegisterEvent("TRADE_REQUEST")
self:RegisterEvent("TRADE_REQUEST_CANCEL")
self:RegisterEvent("TRADE_UPDATE");
self:RegisterEvent("TRADE_ACCEPT_UPDATE")
--
-- Debugging cleanup if enabled
--
self:RegisterEvent("PLAYER_LOGOUT")
self:RegisterEvent("PLAYER_LOGIN")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("NEW_RECIPE_LEARNED") -- arg1 = recipeID
self:RegisterEvent("SKILL_LINES_CHANGED") -- replacement for CHAT_MSG_SKILL?
self:RegisterEvent("LEARNED_SPELL_IN_TAB") -- arg1 = professionID
self:RegisterEvent("ADDON_ACTION_BLOCKED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
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.skippedQueue = {}
self:UpgradeDataAndOptions() -- run the upgrade code to convert any old settings
self:ConvertIgnoreListData()
self:CollectTradeSkillData()
self:CollectCurrencyData()
self:ScanPlayerTradeSkills()
self:CreateAdditionalButtonsList()
self:EnablePlugins()
self:DisableBlizzardFrame()
end
function Skillet:PLAYER_LOGIN()
DA.TRACE("PLAYER_LOGIN")
Skillet.loginTime = GetTime()
end
function Skillet:PLAYER_ENTERING_WORLD()
DA.TRACE("PLAYER_ENTERING_WORLD")
local player = UnitName("player")
local realm = GetRealmName()
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
--
-- Skillet-Classic doesn't do well in combat. These functions need to be
-- flushed out to deal with it gracefully.
--
function Skillet:ADDON_ACTION_BLOCKED()
DA.TRACE("ADDON_ACTION_BLOCKED()")
if self:HideAllWindows() then
DA.MARK3("|cf0f00000Skillet-Classic|r: Combat lockdown restriction. Leave combat and try again.")
end
end
function Skillet:PLAYER_REGEN_DISABLED()
DA.TRACE("PLAYER_REGEN_DISABLED()")
self.inCombat = true
if self:HideAllWindows() then
DA.MARK3("|cf0f00000Skillet-Classic|r: Combat lockdown restriction. Leave combat and try again.")
end
end
function Skillet:PLAYER_REGEN_ENABLED()
DA.TRACE("PLAYER_REGEN_ENABLED()")
self.inCombat = false
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
for tradeID in pairs(self.db.realm.tradeSkills[self.currentPlayer]) do
--DA.DEBUG(0,"tradeID= "..tostring(tradeID)..", count= "..tostring(self.db.realm.tradeSkills[self.currentPlayer][tradeID].count))
self.db.realm.tradeSkills[self.currentPlayer][tradeID].count = 0
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.dataSourceChanged = true -- Process the change on the next TRADE_SKILL_UPDATE
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_UPDATE
end
end
function Skillet:TRADE_SKILL_NAME_UPDATE()
DA.TRACE("TRADE_SKILL_NAME_UPDATE")
DA.TRACE("TRADE_SKILL_NAME_UPDATE: tradeShow= "..tostring(Skillet.tradeShow)..", linkedSkill= "..tostring(Skillet.linkedSkill))
if not Skillet.tradeShow then return end
if Skillet.linkedSkill then
Skillet:ConfigureRecipeControls()
Skillet:SkilletShow()
end
end
function Skillet:TRADE_SKILL_UPDATE()
DA.TRACE("TRADE_SKILL_UPDATE")
Skillet.tradeUpdate = Skillet.tradeUpdate + 1
DA.TRACE("TRADE_SKILL_UPDATE: closingTrade= "..tostring(Skillet.closingTrade)..", tradeShow= "..tostring(Skillet.tradeShow)..", tradeUpdate= "..tostring(Skillet.tradeUpdate))
if Skillet.closingTrade or not Skillet.tradeShow then return end
if Skillet.tradeUpdate < Skillet.db.realm.trade_wait then return end
if Skillet.tradeSkillFrame and Skillet.tradeSkillFrame:IsVisible() then
Skillet:ConfigureRecipeControls()
end
DA.TRACE("TRADE_SKILL_UPDATE: dataSourceChanged= "..tostring(Skillet.dataSourceChanged)..", dataScanned= "..tostring(Skillet.dataScanned))
if Skillet.dataSourceChanged or not Skillet.dataScanned then
Skillet.dataSourceChanged = false
Skillet:SkilletShowWindow()
end
end
function Skillet:CRAFT_UPDATE()
DA.TRACE("CRAFT_UPDATE")
Skillet.craftUpdate = Skillet.craftUpdate + 1
DA.TRACE("CRAFT_UPDATE: closingTrade= "..tostring(Skillet.closingTrade)..", tradeShow= "..tostring(Skillet.tradeShow)..", craftUpdate= "..tostring(Skillet.craftUpdate))
if Skillet.closingTrade or not Skillet.craftShow then return end
if Skillet.craftUpdate < Skillet.db.realm.craft_wait then return end
if Skillet.tradeSkillFrame and Skillet.tradeSkillFrame:IsVisible() then
Skillet:ConfigureRecipeControls()
end
DA.TRACE("CRAFT_UPDATE: dataSourceChanged= "..tostring(Skillet.dataSourceChanged)..", dataScanned= "..tostring(Skillet.dataScanned))
if Skillet.dataSourceChanged or not Skillet.dataScanned then
Skillet.dataSourceChanged = false
Skillet:SkilletShowWindow()
end
end
function Skillet:SKILL_LINES_CHANGED()
DA.TRACE("SKILL_LINES_CHANGED")
if Skillet.tradeSkillOpen then