1
0
Fork 0

core functionality: RegisterSlashCommand

This commit is contained in:
pigmonkey 2011-05-30 14:57:41 -04:00
parent b5ace77c95
commit 0bd08158bb
2 changed files with 42 additions and 7 deletions

View file

@ -17,18 +17,19 @@ local options = {
}, },
} }
local slashCallback = {}
function core:OnInitialize() function core:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("AllTheLittleThingsDB", defaults, "Default") self.db = LibStub("AceDB-3.0"):New("AllTheLittleThingsDB", defaults, "Default")
-- self:RegisterChatCommand("atlt", function() end) self:RegisterChatCommand("atlt", "MainSlashHandle")
-- LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("AllTheLittleThings", options) -- LibStub("AceConfigRegistry-3.0"):RegisterOptionsTable("AllTheLittleThings", options)
-- local ACD = LibStub("AceConfigDialog-3.0") -- local ACD = LibStub("AceConfigDialog-3.0")
-- ACD:AddToBlizOptions("AllTheLittleThings", "AllTheLittleThings") -- ACD:AddToBlizOptions("AllTheLittleThings", "AllTheLittleThings")
self:SetDefaultModulePrototype({ self:SetDefaultModulePrototype({
OnEnable = function(self) RegisterOptions = core.RegisterOptions,
end, RegisterSlashCommand = core.RegisterSlashCommand,
}) })
end end
@ -40,8 +41,9 @@ function core:OnDisable()
end end
function core:RegisterOptions(module, options, defaults) -- two registry functions called with self=mod
local name = module:GetName() function core:RegisterOptions(options, defaults)
local name = self:GetName()
defaults.profile[name] = defaults defaults.profile[name] = defaults
options.args[name] = { options.args[name] = {
name = name, name = name,
@ -50,3 +52,20 @@ function core:RegisterOptions(module, options, defaults)
} }
end end
function core:RegisterSlashCommand(callback, ...)
for i=1,select('#', ...) do
slashCallback[select('i', ...)] = self[callback]
end
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

View file

@ -15,6 +15,22 @@ Libs\AceConsole-3.0\AceConsole-3.0.xml
Libs\AceConfig-3.0\AceConfig-3.0.xml Libs\AceConfig-3.0\AceConfig-3.0.xml
Libs\AceTimer-3.0\AceTimer-3.0.xml Libs\AceTimer-3.0\AceTimer-3.0.xml
transitive.lua # transitive.lua
# PriorityQueue.lua
AllTheLittleThings.lua AllTheLittleThings.lua
PriorityQueue.lua
modules\announce.lua
modules\battlegrounds.lua
modules\chatfilter.lua
modules\defaultui.lua
# modules\deprecated.lua
modules\guildroster.lua
modules\macros.lua
modules\miscellaneous.lua
modules\potions.lua
modules\prat.lua
modules\raid.lua
modules\rbs.lua
modules\template.lua