vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Bongos\core\utility.lua |
||
3 | Utility functions for Bongos |
||
4 | --]] |
||
5 | |||
6 | --takes a Bongos BarID, and performs the specified action on that bar |
||
7 | --this adds two special IDs, "all" for all bars and number-number for a range of IDs |
||
8 | function Bongos_ForBar(barID, action, ...) |
||
9 | assert(barID and barID ~= "", "Invalid barID"); |
||
10 | |||
11 | if barID == "all" then |
||
12 | BBar.ForAll(action, unpack(arg)); |
||
13 | else |
||
14 | local _, _, startID, endID = string.find(barID, "(%d+)-(%d+)"); |
||
15 | startID = tonumber(startID); |
||
16 | endID = tonumber(endID); |
||
17 | if startID and endID then |
||
18 | for id = startID, endID do |
||
19 | local bar = BBar.IDToBar(id); |
||
20 | if(bar) then |
||
21 | action(bar, unpack(arg)); |
||
22 | end |
||
23 | end |
||
24 | else |
||
25 | local bar = BBar.IDToBar(barID); |
||
26 | if bar then |
||
27 | action(bar, unpack(arg)); |
||
28 | end |
||
29 | end |
||
30 | end |
||
31 | end |
||
32 | |||
33 | --same thing as the previous function, except we pass the bar's ID as an arg instead of the bar itself |
||
34 | function Bongos_ForBarID(barID, action, ...) |
||
35 | assert(barID and barID ~= "", "Invalid barID"); |
||
36 | |||
37 | if barID == "all" then |
||
38 | BBar.ForAllIDs(action, unpack(arg)); |
||
39 | else |
||
40 | local _, _, startID, endID = string.find(barID, "(%d+)-(%d+)"); |
||
41 | if startID and endID then |
||
42 | for id = tonumber(startID), tonumber(endID) do |
||
43 | action(id, unpack(arg)); |
||
44 | end |
||
45 | else |
||
46 | if tonumber(barID) then |
||
47 | barID = tonumber(barID); |
||
48 | end |
||
49 | action(barID, unpack(arg)); |
||
50 | end |
||
51 | end |
||
52 | end |
||
53 | |||
54 | --[[ Configuration Functions ]]-- |
||
55 | |||
56 | function Bongos_SetLock(enable) |
||
57 | if enable then |
||
58 | BongosSets.locked = 1; |
||
59 | BBar.ForAll(BBar.Lock); |
||
60 | else |
||
61 | BongosSets.locked = nil; |
||
62 | BBar.ForAll(BBar.Unlock); |
||
63 | end |
||
64 | end |
||
65 | |||
66 | --enable disable "sticky" bars |
||
67 | function Bongos_SetStickyBars(enable) |
||
68 | if enable then |
||
69 | BongosSets.sticky = 1; |
||
70 | else |
||
71 | BongosSets.sticky = nil; |
||
72 | end |
||
73 | BBar.ForAll(BBar.Reanchor); |
||
74 | end |
||
75 | |||
76 | --Print a chat message |
||
77 | function BMsg(msg) |
||
78 | ChatFrame1:AddMessage("Bongos: " .. (msg or "error"), 0,1,0.4); |
||
79 | end |