vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | visibility.lua |
||
3 | Scripts for the Visibility panel of the Bongos Options menu |
||
4 | --]] |
||
5 | |||
6 | local list; |
||
7 | |||
8 | local function sortList(bar1, bar2) |
||
9 | if tonumber(bar1.id) and tonumber(bar2.id) then |
||
10 | return bar1.id < bar2.id; |
||
11 | elseif not(tonumber(bar1.id) or tonumber(bar2.id)) then |
||
12 | return bar1.id < bar2.id; |
||
13 | elseif tonumber(bar1.id) then |
||
14 | return false; |
||
15 | end |
||
16 | return true; |
||
17 | end |
||
18 | |||
19 | function BOptionsVisibility_OnMousewheel(scrollframe, direction) |
||
20 | local scrollbar = getglobal(scrollframe:GetName() .. "ScrollBar"); |
||
21 | scrollbar:SetValue(scrollbar:GetValue() - direction * (scrollbar:GetHeight() / 2)); |
||
22 | BOptionsVisibilityScrollBar_Update() |
||
23 | end |
||
24 | |||
25 | function BOptionsVisibility_OnLoad() |
||
26 | local name = this:GetName() |
||
27 | |||
28 | local allButton = CreateFrame("CheckButton", name .. "All", this, "BOptionsShowButton"); |
||
29 | allButton:SetPoint("TOPLEFT", this, "TOPLEFT", 4, 4); |
||
30 | allButton:SetText("all"); |
||
31 | allButton:SetScript("OnClick", function() |
||
32 | if this:GetChecked() then |
||
33 | BBar.ForAll(BBar.Show, 1); |
||
34 | else |
||
35 | BBar.ForAll(BBar.Hide, 1); |
||
36 | end |
||
37 | BOptionsVisibilityScrollBar_Update(); |
||
38 | end) |
||
39 | allButton:SetChecked(true); |
||
40 | |||
41 | if IsAddOnLoaded("Dominos_ActionBar") then |
||
42 | local allActionBars = CreateFrame("CheckButton", name .. "AllActionBars", this, "BOptionsShowButton"); |
||
43 | allActionBars:SetPoint("LEFT", allButton, "RIGHT", 34, 0); |
||
44 | allActionBars:SetText("actionbars"); |
||
45 | allActionBars:SetScript("OnClick", function() |
||
46 | if this:GetChecked() then |
||
47 | for i = 1, BActionBar.GetNumber() do |
||
48 | BBar.Show(BBar.IDToBar(i), 1); |
||
49 | end |
||
50 | else |
||
51 | for i = 1, BActionBar.GetNumber() do |
||
52 | BBar.Hide(BBar.IDToBar(i), 1); |
||
53 | end |
||
54 | end |
||
55 | BOptionsVisibilityScrollBar_Update(); |
||
56 | end) |
||
57 | allActionBars:SetChecked(true) |
||
58 | end |
||
59 | |||
60 | local firstOfRow; |
||
61 | local name = this:GetName(); |
||
62 | for i = 1, 7 do |
||
63 | local button = CreateFrame("CheckButton", name .. (i-1)*3 + 1, this, "BOptionsShowButton"); |
||
64 | if not firstOfRow then |
||
65 | button:SetPoint("TOPLEFT", allButton, "BOTTOMLEFT", 0, -8); |
||
66 | else |
||
67 | button:SetPoint("TOPLEFT", firstOfRow, "BOTTOMLEFT"); |
||
68 | end |
||
69 | firstOfRow = button; |
||
70 | for j = 2, 3 do |
||
71 | local button = CreateFrame("CheckButton", name .. (i-1)*3 + j, this, "BOptionsShowButton"); |
||
72 | button:SetPoint("LEFT", name .. (i-1)*3 + j-1, "RIGHT", 34, 0); |
||
73 | end |
||
74 | end |
||
75 | end |
||
76 | |||
77 | function BOptionsVisibility_OnShow() |
||
78 | list = BBar.GetAll(); |
||
79 | for i, bar in pairs(list) do |
||
80 | if bar.alwaysShow then |
||
81 | table.remove(list, i) |
||
82 | end |
||
83 | end |
||
84 | table.sort(list, sortList); |
||
85 | |||
86 | BOptionsVisibilityScrollBar_Update(); |
||
87 | end |
||
88 | |||
89 | function BOptionsVisibilityScrollBar_Update() |
||
90 | local size = table.getn(list); |
||
91 | local offset = BOptionsPanelVisibilityScrollFrame.offset; |
||
92 | FauxScrollFrame_Update(BOptionsPanelVisibilityScrollFrame, size - 1, 21, 21); |
||
93 | |||
94 | for index = 1, 21 do |
||
95 | local rIndex = index + offset; |
||
96 | local button = getglobal("BOptionsPanelVisibility".. index); |
||
97 | |||
98 | if rIndex <= size then |
||
99 | button:SetText(list[rIndex].id); |
||
100 | button:SetChecked(list[rIndex].sets.vis); |
||
101 | button:Show(); |
||
102 | else |
||
103 | button:Hide(); |
||
104 | end |
||
105 | end |
||
106 | end |