vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 BMenuBar
3 A
4  
5 Saved Variables:
6 Bongos.menu = {
7 <All variables from BBar>
8 space
9 The spacing between action buttons, in pixels. A nil value means that the bar is using default spacing
10 rows
11 How many rows the bar is organized into.
12 }
13 --]]
14  
15 local DEFAULT_SPACING = 2;
16 local DEFAULT_ROWS = 1;
17  
18 --[[ Update Functions ]]--
19  
20 local function Layout(bar, rows, space)
21 if not space or space == DEFAULT_SPACING then
22 bar.sets.space = nil;
23 space = DEFAULT_SPACING;
24 else
25 bar.sets.space = space;
26 end
27 if not rows or rows == DEFAULT_ROWS then
28 bar.sets.rows = nil;
29 rows = DEFAULT_ROWS;
30 else
31 bar.sets.rows = rows;
32 end
33  
34 SpellbookMicroButton:ClearAllPoints();
35 TalentMicroButton:ClearAllPoints();
36 QuestLogMicroButton:ClearAllPoints();
37 SocialsMicroButton:ClearAllPoints();
38 WorldMapMicroButton:ClearAllPoints();
39 MainMenuMicroButton:ClearAllPoints();
40 HelpMicroButton:ClearAllPoints();
41  
42 local actSpace = space;
43 if rows == DEFAULT_ROWS then
44 space = space - 4; --apparently the anchors are weird on the micro buttons, and need to be adjusted
45 --horizontal layout
46 SpellbookMicroButton:SetPoint("LEFT", CharacterMicroButton, "RIGHT", space, 0);
47 TalentMicroButton:SetPoint("LEFT", SpellbookMicroButton, "RIGHT", space, 0);
48 QuestLogMicroButton:SetPoint("LEFT", TalentMicroButton, "RIGHT", space, 0);
49 SocialsMicroButton:SetPoint("LEFT", QuestLogMicroButton, "RIGHT", space, 0);
50 WorldMapMicroButton:SetPoint("LEFT", SocialsMicroButton, "RIGHT", space, 0);
51 MainMenuMicroButton:SetPoint("LEFT", WorldMapMicroButton, "RIGHT", space, 0);
52 HelpMicroButton:SetPoint("LEFT", MainMenuMicroButton, "RIGHT", space, 0);
53  
54 bar:SetHeight(39);
55 bar:SetWidth(14 + (24 + actSpace) * 8 - actSpace);
56 else
57 --vertical layout
58 space = space - 24; --apparently the anchors are weird on the micro buttons, and need to be adjusted
59  
60 SpellbookMicroButton:SetPoint("TOP", CharacterMicroButton, "BOTTOM", 0, -space);
61 TalentMicroButton:SetPoint("TOP", SpellbookMicroButton, "BOTTOM", 0, -space);
62 QuestLogMicroButton:SetPoint("TOP", TalentMicroButton, "BOTTOM", 0, -space);
63 SocialsMicroButton:SetPoint("TOP", QuestLogMicroButton, "BOTTOM", 0, -space);
64 WorldMapMicroButton:SetPoint("TOP", SocialsMicroButton, "BOTTOM", 0, -space);
65 MainMenuMicroButton:SetPoint("TOP", WorldMapMicroButton, "BOTTOM", 0, -space);
66 HelpMicroButton:SetPoint("TOP", MainMenuMicroButton, "BOTTOM", 0, -space);
67  
68 bar:SetHeight(12 + (33 + actSpace) * 8 - actSpace);
69 bar:SetWidth(28);
70 end
71 end
72  
73 --[[ Overrides ]]--
74  
75 --Prevents the talent button from always showing up even when the bar is hidden
76 UpdateTalentButton = function()
77 if UnitLevel("player") < 10 then
78 TalentMicroButton:Hide();
79 elseif BMenuBar and BMenuBar.sets.vis then
80 TalentMicroButton:Show();
81 end
82 end
83  
84 --[[ Rightclick Menu Functions ]]--
85 local function CreateConfigMenu(name)
86 local menu = CreateFrame("Button", name, UIParent, "BongosRightClickMenu");
87 menu:SetText("Menu Bar");
88 menu:SetWidth(220);
89 menu:SetHeight(220);
90  
91 local hideButton = CreateFrame("CheckButton", name .. "Hide", menu, "BongosHideButtonTemplate");
92  
93 local verticalButton = CreateFrame("CheckButton", name .. "Vertical", menu, "BongosCheckButtonTemplate");
94 verticalButton:SetScript("OnClick", function()
95 if this:GetChecked() then
96 Layout(BMenuBar, 5, BMenuBar.sets.space);
97 else
98 Layout(BMenuBar, nil, BMenuBar.sets.space);
99 end
100 end);
101 verticalButton:SetPoint("TOP", hideButton, "BOTTOM", 0, 4);
102 verticalButton:SetText("Vertical");
103  
104 local spacingSlider = CreateFrame("Slider", name .. "Spacing", menu, "BongosSpaceSlider");
105 spacingSlider:SetPoint("TOPLEFT", name .. "Vertical", "BOTTOMLEFT", 2, -10);
106 spacingSlider:SetScript("OnValueChanged", function()
107 if(not this:GetParent().onShow) then
108 Layout(BMenuBar, BMenuBar.sets.rows, this:GetValue() );
109 end
110 getglobal(this:GetName() .. "ValText"):SetText( this:GetValue() );
111 end);
112  
113 local scaleSlider = CreateFrame("Slider", name .. "Scale", menu, "BongosScaleSlider");
114 scaleSlider:SetPoint("TOP", spacingSlider, "BOTTOM", 0, -24);
115  
116 local opacitySlider = CreateFrame("Slider", name .. "Opacity", menu, "BongosOpacitySlider");
117 opacitySlider:SetPoint("TOP", scaleSlider, "BOTTOM", 0, -24);
118 end
119  
120 --Called when the right click menu is shown, loads the correct values to the checkbuttons/sliders/text
121 local function ShowMenu(bar)
122 if(not BongosMenuBarMenu) then
123 CreateConfigMenu("BongosMenuBarMenu");
124 end
125  
126 BongosMenuBarMenu.onShow = 1;
127 BongosMenuBarMenu.frame = bar;
128  
129 BongosMenuBarMenuHide:SetChecked(not bar.sets.vis);
130 BongosMenuBarMenuVertical:SetChecked(bar.sets.rows);
131 BongosMenuBarMenuSpacing:SetValue(bar.sets.space or DEFAULT_SPACING);
132 BongosMenuBarMenuScale:SetValue(bar:GetScale() * 100);
133 BongosMenuBarMenuOpacity:SetValue(bar:GetAlpha() * 100);
134  
135 BMenu.ShowMenuForBar(BongosMenuBarMenu, bar);
136 BongosMenuBarMenu.onShow = nil;
137 end
138  
139 --[[ Startup ]]--
140  
141 local function AddFrameToBar(frame, bar)
142 frame:SetParent(bar);
143 frame:SetFrameLevel(0);
144 frame:SetAlpha(bar:GetAlpha());
145 end
146  
147 BScript.AddStartupAction(function()
148 local bar = BBar.Create("menu", "BMenuBar", "BActionSets.menu", ShowMenu);
149 if not bar:IsUserPlaced() then
150 bar:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -224, 0);
151 end
152  
153 AddFrameToBar(CharacterMicroButton, bar);
154 AddFrameToBar(SpellbookMicroButton, bar);
155 AddFrameToBar(TalentMicroButton, bar);
156 AddFrameToBar(QuestLogMicroButton, bar);
157 AddFrameToBar(SocialsMicroButton, bar);
158 AddFrameToBar(WorldMapMicroButton, bar);
159 AddFrameToBar(MainMenuMicroButton, bar);
160 AddFrameToBar(HelpMicroButton, bar);
161  
162 CharacterMicroButton:ClearAllPoints();
163 CharacterMicroButton:SetPoint("TOPLEFT", bar, "TOPLEFT", 0, 20);
164  
165 Layout(bar, bar.sets.rows, bar.sets.space);
166  
167 if bar:IsShown() then
168 bar:Hide();
169 bar:Show();
170 end
171 end)