vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | slash |
||
3 | Slash command handler for Bongos |
||
4 | All commands start with /bg or /bongos |
||
5 | |||
6 | Valid strings for <bar>: |
||
7 | <number> - an action bar |
||
8 | bags - bag bar |
||
9 | menu - menu bar |
||
10 | pet - pet bar |
||
11 | class - class bar |
||
12 | stats - stat bar |
||
13 | all - all bars |
||
14 | --]] |
||
15 | |||
16 | local function GetRestofMessage(args) |
||
17 | if args[2] then |
||
18 | local name = args[2]; |
||
19 | for i = 3, table.getn(args) do |
||
20 | name = name .. " " .. args[i]; |
||
21 | end |
||
22 | return name; |
||
23 | end |
||
24 | end |
||
25 | |||
26 | local function printMsg(msg) |
||
27 | DEFAULT_CHAT_FRAME:AddMessage(msg or "error", 0, 1, 0.4); |
||
28 | end |
||
29 | |||
30 | --Display commands |
||
31 | local function ShowCommands() |
||
32 | printMsg("Bongos Commands:"); |
||
33 | printMsg("/bob - Shows the options menu, if present."); |
||
34 | printMsg("/bob help or /bob ? - Displays list of commands"); |
||
35 | |||
36 | --bar commands |
||
37 | printMsg("/bob lock - Locks the position all bars"); |
||
38 | printMsg("/bob unlock - Unlocks the positions all bars"); |
||
39 | printMsg("/bob show <bar> - Shows the given bar"); |
||
40 | printMsg("/bob hide <bar> - Hides the given bar"); |
||
41 | printMsg("/bob toggle <bar> - Toggles the given bar"); |
||
42 | printMsg("/bob scale <bar> <value> - Set the scale of the given bar. 1 is normal size."); |
||
43 | printMsg("/bob setalpha <bar> <value> - Set the opacity of a bar to <value>. 0 is translucent, 1 is opaque."); |
||
44 | printMsg("/bob stickybars <on | off> - Enable/disable bars automatically \"sticking\" to each other when positioning them"); |
||
45 | |||
46 | --Profile commands |
||
47 | printMsg("/bob load <profile> - Loads the given layout."); |
||
48 | printMsg("/bob save <profile> - Saves the current setup as <profile>."); |
||
49 | printMsg("/bob delete <profile> - Deletes the given saved layout."); |
||
50 | printMsg("/bob setdefault <profile> - Sets a given saved profile as the default settings for new characters."); |
||
51 | end |
||
52 | |||
53 | --Slash handler |
||
54 | SlashCmdList["BongosCOMMAND"] = function(msg) |
||
55 | if msg == "" then |
||
56 | if BOptions then |
||
57 | BOptions:Show(); |
||
58 | else |
||
59 | local _, _, _, enabled = GetAddOnInfo("Bongos_Options"); |
||
60 | if enabled then |
||
61 | LoadAddOn("Bongos_Options"); |
||
62 | else |
||
63 | ShowCommands(); |
||
64 | end |
||
65 | end |
||
66 | else |
||
67 | local args = {}; |
||
68 | for word in string.gfind(msg, "[^%s]+") do |
||
69 | table.insert(args, word); |
||
70 | end |
||
71 | local cmd = string.lower(args[1]); |
||
72 | |||
73 | if cmd == "help" or cmd == "?" then |
||
74 | ShowCommands(); |
||
75 | elseif cmd == "lock" then |
||
76 | Bongos_SetLock(true); |
||
77 | elseif cmd == "unlock" then |
||
78 | Bongos_SetLock(nil); |
||
79 | elseif cmd == "stickybars" then |
||
80 | Bongos_SetStickyBars(string.lower(args[2]) == "on"); |
||
81 | elseif cmd == "show" then |
||
82 | for i = 2, table.getn(args) do |
||
83 | Bongos_ForBar(string.lower(args[i]), BBar.Show, 1); |
||
84 | end |
||
85 | elseif cmd == "hide" then |
||
86 | for i = 2, table.getn(args) do |
||
87 | Bongos_ForBar(string.lower(args[i]), BBar.Hide, 1); |
||
88 | end |
||
89 | elseif cmd == "toggle" then |
||
90 | for i = 2, table.getn(args) do |
||
91 | Bongos_ForBar(string.lower(args[i]), BBar.Toggle, 1); |
||
92 | end |
||
93 | elseif cmd == "scale" then |
||
94 | local size = table.getn(args); |
||
95 | local scale = tonumber(args[size]); |
||
96 | for i = 2, size - 1 do |
||
97 | Bongos_ForBar(string.lower(args[i]), BBar.SetScale, scale, 1); |
||
98 | end |
||
99 | elseif cmd == "setalpha" then |
||
100 | local size = table.getn(args); |
||
101 | local alpha = tonumber(args[size]); |
||
102 | for i = 2, size - 1 do |
||
103 | Bongos_ForBar(string.lower(args[i]), BBar.SetAlpha, alpha, 1); |
||
104 | end |
||
105 | elseif cmd == "reset" then |
||
106 | BBar.ForAllIDs(BBar.Delete); |
||
107 | BScript.CallStartup(); |
||
108 | elseif cmd == "load" then |
||
109 | BProfile.Load(GetRestofMessage(args)); |
||
110 | elseif cmd == "save" then |
||
111 | BProfile.Save(GetRestofMessage(args)); |
||
112 | elseif cmd == "delete" then |
||
113 | BProfile.Delete(GetRestofMessage(args)); |
||
114 | elseif cmd == "setdefault" then |
||
115 | BProfile.SetDefault(GetRestofMessage(args)); |
||
116 | elseif cmd == "reuse" then |
||
117 | if BongosSets.dontReuse then |
||
118 | BongosSets.dontReuse = nil; |
||
119 | else |
||
120 | BongosSets.dontReuse = 1; |
||
121 | end |
||
122 | ReloadUI() |
||
123 | else |
||
124 | BMsg("'" .. (cmd or "error") .."' is an unknown command."); |
||
125 | end |
||
126 | end |
||
127 | end |
||
128 | SLASH_BongosCOMMAND1 = "/bongos"; |
||
129 | SLASH_BongosCOMMAND2 = "/bob"; |