-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInit.lua
More file actions
81 lines (66 loc) · 2.25 KB
/
Init.lua
File metadata and controls
81 lines (66 loc) · 2.25 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
local addon, Engine = ...
local F = LibStub('AceAddon-3.0'):NewAddon(addon, 'AceEvent-3.0', 'AceTimer-3.0', 'AceBucket-3.0')
-- Lua functions
local _G = _G
local date, format, pairs, tinsert, type = date, format, pairs, tinsert, type
-- WoW API / Variables
-- GLOBALS: FISConfig, LibStub
local L = {}
setmetatable(L, {
-- Make missing translations available
__index = function(self, key)
self[key] = (key or "")
return key
end
})
F.DF = { profile = {}, global = {} }
F.Options = { name = L["Free Instance Sharer"], type = 'group', args = {} }
Engine[1] = F
Engine[2] = L
Engine[3] = F.DF.profile
Engine[4] = F.DF.global
_G[addon] = Engine
F.addonPrefix = "\124cFF70B8FF" .. addon .. "\124r: "
F.playerFullName = UnitName('player') .. '-' .. GetRealmName()
F.playerGUID = UnitGUID('player')
function F:OnEnable()
self.data = LibStub('AceDB-3.0'):New('FreeInstanceSharerDB', self.DF, true)
-- Depreciated: Will be removed in next tier
if FISConfig then
-- old database
if FISConfig.DBVer and FISConfig.DBVer == 2 then
-- last version
self.data:SetProfile(self.playerFullName)
for key in pairs(self.DF.profile) do
if type(FISConfig[key]) ~= 'nil' then
self.data.profile[key] = FISConfig[key]
end
end
end
FISConfig = nil
end
self.data.RegisterCallback(self, 'OnProfileChanged', 'Initialize')
self.data.RegisterCallback(self, 'OnProfileCopied', 'Initialize')
self.data.RegisterCallback(self, 'OnProfileReset', 'Initialize')
self.db = self.data.profile
self.global = self.data.global
self.global.DebugLog[1] = self.global.DebugLog[2]
self.global.DebugLog[2] = self.global.DebugLog[3]
self.global.DebugLog[3] = {}
self:Initialize()
end
function F:Print(...)
_G.DEFAULT_CHAT_FRAME:AddMessage(self.addonPrefix .. format(...))
end
function F:Log(...)
tinsert(
self.global.DebugLog[3],
date("%Y-%m-%d %H:%M:%S%z") .. " - Status: " .. self.status .. " - " .. format(...)
)
end
function F:Debug(...)
if self.db.Debug then
self:Log(...)
self:Print(...)
end
end