Mercurial > wow > breuesk
comparison Core.lua @ 43:4109683c3172
Kept AceConsole embedded - it handily disables the chat commands when the addon is disabled
Did a little passthrough to properly set the self param for commands like Print()
author | John@Yosemite-PC |
---|---|
date | Thu, 15 Mar 2012 22:27:51 -0400 |
parents | 72055fc7e115 |
children | 8913e7d79cad |
comparison
equal
deleted
inserted
replaced
42:72055fc7e115 | 43:4109683c3172 |
---|---|
20 | 20 |
21 local _G=_G | 21 local _G=_G |
22 local strsplit=strsplit | 22 local strsplit=strsplit |
23 local string=string | 23 local string=string |
24 local sformat=string.format | 24 local sformat=string.format |
25 local bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0", "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0") | 25 local bsk = LibStub("AceAddon-3.0"):NewAddon("bsk","AceConsole-3.0") |
26 -- "AceHook-3.0", "AceComm-3.0", "AceSerializer-3.0" | |
26 _G.bsk=bsk | 27 _G.bsk=bsk |
27 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false) | 28 local L = LibStub("AceLocale-3.0"):GetLocale("bsk", false) |
28 setfenv(1,bsk) | 29 setfenv(1,bsk) |
29 | 30 |
30 local pkgrev = " @project-revision@ " | 31 local pkgrev = " @project-revision@ " |
35 -- 2) a.x === a["x"] | 36 -- 2) a.x === a["x"] |
36 -- 3) a["1"] =/= a[1] | 37 -- 3) a["1"] =/= a[1] |
37 -- 4) table.remove() works ok if reverse iterating, terrible at anything else | 38 -- 4) table.remove() works ok if reverse iterating, terrible at anything else |
38 -- 5) pairs() does not have a guaranteed iteration order | 39 -- 5) pairs() does not have a guaranteed iteration order |
39 | 40 |
40 | 41 -- These two functions properly format the call to AceConsole:Print(), which |
42 -- needs a full object. Calling "Print" will call the mixed-in console functions | |
43 -- but without a self parameter because of the namespacing. I would disembed | |
44 -- console, except that it has handy OnDisable behavior to disable chat | |
45 -- commands. | |
46 function print(...) | |
47 bsk:Print(...) | |
48 end | |
49 | |
50 function printf(...) | |
51 bsk:Printf(...) | |
52 end | |
41 | 53 |
42 function OnInitialize() | 54 function OnInitialize() |
43 | 55 |
44 db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default") | 56 db = _G.LibStub("AceDB-3.0"):New("BskDB", defaults, "Default") |
45 bsk:Print("Totally libstubbed a db") | |
46 | 57 |
47 options.args.profile = _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(db) | 58 options.args.profile = _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(db) |
48 _G.LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", options) | 59 _G.LibStub("AceConfig-3.0"):RegisterOptionsTable("bsk", options) |
49 --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk") | 60 --optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("bsk", "bsk") |
50 | 61 |
52 bsk:RegisterChatCommand("bsk", HandlePassThrough) | 63 bsk:RegisterChatCommand("bsk", HandlePassThrough) |
53 end | 64 end |
54 | 65 |
55 function OnEnable() | 66 function OnEnable() |
56 CreateWorkingStateFromChanges(db.profile.changes) | 67 CreateWorkingStateFromChanges(db.profile.changes) |
57 CreateGUI() | 68 --CreateGUI() |
58 end | 69 end |
59 | 70 |
60 function HandleCommand(paramIn) | 71 function HandleCommand(paramIn) |
61 local param = { strsplit(" ", paramIn) } | 72 local param = { strsplit(" ", paramIn) } |
62 local FixPersonName = function(p) | 73 local FixPersonName = function(p) |
65 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)" | 76 local MULTIBYTE_FIRST_CHAR = "^([\192-\255]?%a?[\128-\191]*)" |
66 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1) | 77 return string.gsub(p, MULTIBYTE_FIRST_CHAR, string.upper, 1) |
67 end | 78 end |
68 | 79 |
69 if param[1] == nil or param[1] == "" then | 80 if param[1] == nil or param[1] == "" then |
70 bsk:Print("need args") | 81 print("need args") |
71 return | 82 return |
72 end | 83 end |
73 if param[1] == "persons" then | 84 if param[1] == "persons" then |
74 PrintPersons() | 85 PrintPersons() |
75 elseif param[1] == "changes" then | 86 elseif param[1] == "changes" then |
90 RemovePersonFromList(person, param[4]) | 101 RemovePersonFromList(person, param[4]) |
91 elseif param[2] == "person" then | 102 elseif param[2] == "person" then |
92 local person = FixPersonName(param[3]) | 103 local person = FixPersonName(param[3]) |
93 RemovePerson(person) | 104 RemovePerson(person) |
94 else | 105 else |
95 bsk:Print(sformat("Deleting anything of type %s is not supported",param[2])) | 106 printf("Deleting anything of type %s is not supported",param[2]) |
96 end | 107 end |
97 elseif param[1] == "nuke" then | 108 elseif param[1] == "nuke" then |
98 if param[2] == nil or param[2] == "" then | 109 if param[2] == nil or param[2] == "" then |
99 PrintTable(param) | 110 PrintTable(param) |
100 return | 111 return |