2011-05-30 13:01:19 -04:00
|
|
|
local core = LibStub("AceAddon-3.0"):NewAddon("AllTheLittleThings", "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0")
|
|
|
|
atlt = core
|
|
|
|
|
|
|
|
local defaults = {
|
|
|
|
profile = {
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
local options_setter = function(info, v) local t=core.db.profile for k=1,#info-1 do t=t[info[k]] end t[info[#info]]=v core:UpdatePins(true) end
|
|
|
|
local options_getter = function(info) local t=core.db.profile for k=1,#info-1 do t=t[info[k]] end return t[info[#info]] end
|
|
|
|
local options = {
|
|
|
|
name = "AllTheLittleThings",
|
|
|
|
type = 'group',
|
|
|
|
set = options_setter,
|
|
|
|
get = options_getter,
|
|
|
|
args = {
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
2011-05-30 14:57:41 -04:00
|
|
|
local slashCallback = {}
|
2011-05-30 18:13:08 -04:00
|
|
|
local slashList = {}
|
|
|
|
|
|
|
|
local prototype = {}
|
|
|
|
core:SetDefaultModulePrototype(prototype)
|
|
|
|
core:SetDefaultModuleLibraries("AceConsole-3.0")
|
2011-05-30 13:01:19 -04:00
|
|
|
|
|
|
|
function core:OnInitialize()
|
2011-05-30 18:30:56 -04:00
|
|
|
self.db = LibStub("AceDB-3.0"):New("AllTheLittleThingsDB", defaults, "Default")
|
2011-05-30 14:57:41 -04:00
|
|
|
self:RegisterChatCommand("atlt", "MainSlashHandle")
|
2011-05-30 13:01:19 -04:00
|
|
|
|
2011-05-30 18:13:08 -04:00
|
|
|
LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("AllTheLittleThings", options)
|
|
|
|
local ACD = LibStub("AceConfigDialog-3.0")
|
|
|
|
ACD:AddToBlizOptions("AllTheLittleThings", "AllTheLittleThings")
|
2011-05-30 13:01:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function core:OnEnable()
|
|
|
|
end
|
|
|
|
|
|
|
|
function core:OnDisable()
|
|
|
|
end
|
|
|
|
|
2011-05-30 14:57:41 -04:00
|
|
|
-- two registry functions called with self=mod
|
2011-05-30 18:13:08 -04:00
|
|
|
function core:RegisterOptions(modOptions, modDefaults)
|
2011-05-30 14:57:41 -04:00
|
|
|
local name = self:GetName()
|
2011-05-30 18:13:08 -04:00
|
|
|
defaults.profile[name] = modDefaults
|
2011-05-30 13:01:19 -04:00
|
|
|
options.args[name] = {
|
|
|
|
name = name,
|
|
|
|
type = 'group',
|
2011-05-30 18:13:08 -04:00
|
|
|
args = modOptions
|
2011-05-30 13:01:19 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2011-05-30 14:57:41 -04:00
|
|
|
function core:RegisterSlashCommand(callback, ...)
|
2011-05-30 18:13:08 -04:00
|
|
|
local long = ""
|
2011-05-30 14:57:41 -04:00
|
|
|
for i=1,select('#', ...) do
|
2011-05-30 18:13:08 -04:00
|
|
|
local slash = select(i, ...)
|
|
|
|
slashCallback[slash] = self[callback]
|
|
|
|
long = string.len(slash)>string.len(long) and slash or long
|
2011-05-30 14:57:41 -04:00
|
|
|
end
|
2011-05-30 18:13:08 -04:00
|
|
|
|
|
|
|
slashList[long] = ("%s:%s()"):format(self:GetName(), callback)
|
2011-05-30 14:57:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
function core:MainSlashHandle(msg)
|
|
|
|
local _, e, command = string.find("(%S+)", msg)
|
|
|
|
msg = string.sub(msg, e+1)
|
|
|
|
|
|
|
|
if command and slashCallback[command] then
|
|
|
|
slashCallback[command](msg)
|
|
|
|
else
|
|
|
|
-- print all commands
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-30 18:13:08 -04:00
|
|
|
-- fill out our prototype now that our addon's indicies are populated
|
|
|
|
prototype.RegisterOptions = core.RegisterOptions
|
|
|
|
prototype.RegisterSlashCommand = core.RegisterSlashCommand
|
|
|
|
|