forked from shagu/ShaguTweaks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
56 lines (44 loc) · 1.5 KB
/
main.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
local _G = _G or getfenv(0)
SLASH_RELOAD1 = '/rl'
function SlashCmdList.RELOAD(msg, editbox) ReloadUI() end
message = function(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cffffff00" .. ( msg or "nil" ))
end
print = message
error = function(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cffff0000".. (msg or "nil" ))
end
seterrorhandler(error)
ShaguTweaks = CreateFrame("Frame")
ShaguTweaks.mods = {}
-- load translation tables
ShaguTweaks.L = (ShaguTweaks_locale[GetLocale()] or ShaguTweaks_locale["enUS"])
ShaguTweaks.T = (ShaguTweaks_translation[GetLocale()] or ShaguTweaks_translation["enUS"])
-- use table index key as translation fallback
ShaguTweaks.T = setmetatable(ShaguTweaks.T, { __index = function(tab,key)
local value = tostring(key)
rawset(tab, key, value)
return value
end})
ShaguTweaks:RegisterEvent("VARIABLES_LOADED")
ShaguTweaks:SetScript("OnEvent", function()
-- load current expansion
local expansion = ShaguTweaks:GetExpansion()
-- initialize empty config
if not ShaguTweaks_config then ShaguTweaks_config = {} end
-- read all registered mods
for title, mod in pairs(ShaguTweaks.mods) do
-- write initial default config
if not ShaguTweaks_config[title] then
ShaguTweaks_config[title] = mod.enabled and 1 or 0
end
-- load enabled mods
if mod.expansions[expansion] and ShaguTweaks_config[title] == 1 then
mod:enable()
end
end
end)
ShaguTweaks.register = function(self, mod)
ShaguTweaks.mods[mod.title] = mod
return ShaguTweaks.mods[mod.title]
end