-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInit.lua
131 lines (116 loc) · 3.21 KB
/
Init.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
--INITIALIZE
local Self = LibStub("AceAddon-3.0"):NewAddon(
"SlackUI",
"AceConsole-3.0",
"AceEvent-3.0"
)
Self.config = LibStub("AceConfig-3.0")
Self.frame = CreateFrame("Frame", "SlackUI")
Self.itemBindingFrame = CreateFrame("Frame", "SlackUI Item Bindings")
_G.SlackUI = Self
Self.Self = Self
setmetatable(Self, {__index = _G}) -- The global environment is now checked if a key is not found in addon
setfenv(1, Self) -- Namespace local to addon
addonName, addonTable = ...
dbDefaults = {
global = {
isDebugging = false,
log = {}
},
profile = {
mounts = {
["ground"] = nil,
["ground-showoff"] = nil,
["skyriding"] = nil,
["skyriding-showoff"] = nil,
["steadyflight"] = nil,
["steadyflight-showoff"] = nil,
["water"] = nil,
["water-showoff"] = nil,
["ground-passenger"] = nil,
["ground-passenger-showoff"] = nil,
["skyriding-passenger"] = nil,
["skyriding-passenger-showoff"] = nil,
["steadyflight-passenger"] = nil,
["steadyflight-passenger-showoff"] = nil,
}
}
}
function getBattletag()
return select(2, BNGetInfo())
end
function isSlackwise()
return getBattletag() == "Slackwise#1121" or false
end
-- Gatekeeping new features with no UI
function isTester()
-- Use a checkbox in settings later, probably, but right now it's just me
return isSlackwise()
end
function isRetail()
-- Official way Blizzard distinguishes between game clients: https://warcraft.wiki.gg/wiki/WOW_PROJECT_ID
if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
return true
else
return false
end
end
function isClassic()
-- Official way Blizzard distinguishes between game clients: https://warcraft.wiki.gg/wiki/WOW_PROJECT_ID
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then
return true
else
return false
end
end
function getGameType()
if isRetail() then
return "RETAIL"
elseif isClassic() then
return "CLASSIC"
else
return "UNKNOWN" -- Uh oh
end
end
function isDebugging()
if isInitialized() then
return Self.db.global.isDebugging
end
if isSlackwise() then
return true
else
return false
end
end
COLOR_START = "\124c"
COLOR_END = "\124r"
function color(color)
return function(text)
return COLOR_START .. "FF" .. color .. text .. COLOR_END
end
end
grey = color("AAAAAA")
function log(message, ...)
if isDebugging() then
print(grey(date()) .. " " .. message)
if isInitialized() then -- we have a DB to save to:
table.insert(Self.db.global.log, date() .. " " .. message)
if arg then
for i, v in ipairs(arg) do
print("Arg " .. i .. " = " .. v)
table.insert(Self.db.global.log, "Arg " .. i .. " = " .. v)
end
end
end
end
end
--Event Handlers
function Self:OnInitialize()
Self.db = LibStub("AceDB-3.0"):New("SlackUIDB", dbDefaults)
config:RegisterOptionsTable("SlackUI", options, "slack")
Self.configDialog = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("SlackUI")
end
function isInitialized()
-- Check for presence of last thing loaded at init
return not not Self["configDialog"]
end