-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddon.lua
More file actions
88 lines (54 loc) · 2.31 KB
/
Addon.lua
File metadata and controls
88 lines (54 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local ADDON_NAME, Data = ...
local Addon = LibStub("AceAddon-3.0"):GetAddon(ADDON_NAME)
local L = LibStub("AceLocale-3.0"):GetLocale(ADDON_NAME)
local strGmatch = string.gmatch
local tinsert = table.insert
local tblRemove = table.remove
local tblConcat = table.concat
local dbInitFuncs
do
local self = Addon
local shared = {}
dbInitFuncs = {
global = {},
profile = {
FirstRun = nil,
upgrades = {
["2.0.0"] = function()
local profile = self:GetOptionQuiet()
local visible = {}
local ignored = {}
local defaultVisibility = {}
for slot, slotName in pairs(self.invSlotNames) do
for itemID, visible in pairs(self:CheckTable(profile, slot) or {}) do
self:SetOption(true, "items", slot, itemID, "seen")
self:SetOption(visible, "items", slot, itemID, "visible")
end
self:SetOption(self:CheckTable(profile, "DefaultVisibility", slot) == nil, "defaultItemSettings", slot)
profile[slot] = nil
end
self:SetOption(self:CheckTable(profile, "DefaultVisibility", "EnforceDefault") == nil, "defaultItemSettings", "forceVisibility")
profile.DefaultVisibility = nil
end,
},
AlwaysRun = function() end,
},
}
end
function Addon:OnInitialize()
self.db = self.AceDB:New(("%sDB"):format(ADDON_NAME), self:MakeDefaultOptions(), true)
self.dbDefault = self.AceDB:New({}, self:MakeDefaultOptions(), true)
self:FireAddonEvent"INITIALIZE"
end
function Addon:OnEnable()
self.version = self.SemVer(C_AddOns.GetAddOnMetadata(ADDON_NAME, "Version"))
self:InitDB(dbInitFuncs)
self:GetDB().RegisterCallback(self, "OnProfileChanged", function() self:OnProfileChanged() end)
self:GetDB().RegisterCallback(self, "OnProfileCopied", function() self:OnProfileChanged() end)
self:GetDB().RegisterCallback(self, "OnProfileReset", function() self:OnProfileChanged() end)
self:GetDB().RegisterCallback(self, "OnDatabaseShutdown", function() self:ShutdownDB() end)
self:InitChatCommands("hatter", "hat", ADDON_NAME:lower())
self:FireAddonEvent"ENABLE"
end
function Addon:OnDisable()
end