vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2 -- Buttonhole Advanced: Swallows Minimap Buttons
3 -- Copyright (C) 2006 Aaron Griffith
4  
5 -- This program is free software; you can redistribute it and/or
6 -- modify it under the terms of the GNU General Public License
7 -- as published by the Free Software Foundation; either version 2
8 -- of the License, or (at your option) any later version.
9  
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
14  
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  
19 ButtonholeAd_Version = "0.1"; -- Buttonhole Advanced Version. Change at Release
20  
21 ButtonholeAd_Branch = ""; -- Buttonhole Advanced Branch. Change this all you AddOn ripoff posers! <3
22  
23 ButtonholeAd_Author = "|cffff0000Swatch|r of Stormrage"; -- Change this too ^^
24  
25 -- This next block is the text for the help window.
26 ButtonholeAd_windowtext = [[Welcome to Buttonhole Advanced ]] .. ButtonholeAd_Version .. ButtonholeAd_Branch .. [[
27 (by ]] .. ButtonholeAd_Author .. [[)
28  
29 When the original Buttonhole was killed, alot of
30 people were sent steaming into unknown depths
31 of anger. Seeing an oppurtunity, I pounced on it.
32 Hence, Buttonhole Advanced.
33  
34 Completely rewritten and with more features to
35 use, it's the ultimate Buttonhole.
36  
37 Classic Mode: |cffff8888(SemiWorking)|r
38  
39 In classic mode, Buttonhole Advanced behaves
40 just like it's predicessor. It hides all the
41 buttons in one, allowing you to scroll through
42 them with the scrollwheel.
43  
44 Menu Mode: |cffff0000(Not Working)|r
45  
46 In menu mode, all of the buttons hidden in
47 the buttonhole are accessable through a menu,
48 shown when you left click the button.
49  
50 Expander Mode:
51  
52 In expander mode, all of the buttons only
53 become visible when you toggle the button-
54 hole.
55  
56 Off Mode:
57  
58 This is obvious. This mode disables button-
59 holing.]];
60  
61 ButtonholeAdDetails = {
62 name = "Buttonhole Advanced",
63 version = ButtonholeAd_Version,
64 releaseDate = "June 25, 2006",
65 author = ButtonholeAd_Author,
66 email = "aargri@gmail.com",
67 --website = "fixme",
68 category = MYADDONS_CATEGORY_OTHERS,
69 optionsframe = "ButtonholeAdFrame" };
70  
71 ButtonholeAd_Debug = 0;
72 ButtonholeAd_Method = 0;
73 ButtonholeAd_Pos = 97;
74  
75 ButtonholeAd_SwallowButtons = {};
76  
77 function BHA_Debug(msg)
78 if (ButtonholeAd_Debug == 1) then
79 DEFAULT_CHAT_FRAME:AddMessage("Buttonhole Advanced : Debug : " .. msg, 0.2, 0.8, 0.8);
80 end
81 end
82  
83 -- This is the /bh command
84 function ButtonholeAd_Command(cmd)
85 if (cmd == "debug") then -- Handle a debug call real quick-like
86 if (ButtonholeAd_Debug == 1) then
87 ButtonholeAd_Debug=0;
88 DEFAULT_CHAT_FRAME:AddMessage("Buttonhole Advanced : Debug Off", 0.2, 0.8, 0.8);
89 else
90 ButtonholeAd_Debug=1;
91 DEFAULT_CHAT_FRAME:AddMessage("Buttonhole Advanced : Debug On", 0.2, 0.8, 0.8);
92 end
93 return nil;
94 end
95 if (cmd == "") then -- If there is no string, open help
96 BHA_Debug("Showing config frame");
97 ButtonholeAdFrame:Show();
98 return nil;
99 end
100 end
101  
102 function ButtonholeAd_UpdateMethodUI()
103 ButtonholeAdFrameCheckButtonClassic:SetChecked(0);
104 ButtonholeAdFrameCheckButtonMenu:SetChecked(0);
105 ButtonholeAdFrameCheckButtonExpander:SetChecked(0);
106 ButtonholeAdFrameCheckButtonOff:SetChecked(0);
107 if (ButtonholeAd_Method == 0) then
108 BHA_Debug("Method set to Classic");
109 ButtonholeAdFrameCheckButtonClassic:SetChecked(1);
110 ButtonholeAd_Off_Init();
111 ButtonholeAd_Classic_Init();
112 return nil;
113 end
114 if (ButtonholeAd_Method == 1) then
115 BHA_Debug("Method set to Menu");
116 ButtonholeAdFrameCheckButtonMenu:SetChecked(1);
117 ButtonholeAd_Off_Init();
118 ButtonholeAd_Menu_Init();
119 return nil;
120 end
121 if (ButtonholeAd_Method == 2) then
122 BHA_Debug("Method set to Expander");
123 ButtonholeAdFrameCheckButtonExpander:SetChecked(1);
124 ButtonholeAd_Off_Init();
125 ButtonholeAd_Expander_Init();
126 return nil;
127 end
128 if (ButtonholeAd_Method == 3) then
129 BHA_Debug("Method set to Off");
130 ButtonholeAdFrameCheckButtonOff:SetChecked(1);
131 ButtonholeAd_Off_Init();
132 return nil;
133 end
134 end
135  
136 function ButtonholeAd_UpdatePosUI()
137 ButtonholeAdFramePosSlider:SetValue(ButtonholeAd_Pos);
138  
139 x = cos(ButtonholeAd_Pos);
140 y = sin(ButtonholeAd_Pos);
141 x = -x;
142 y = -y;
143 x = x * 81;
144 y = y * 81;
145 x = x + 53;
146 y = y - 54;
147  
148 ButtonholeAd_Minimap:SetPoint("TOPLEFT", x, y);
149  
150 -- BHA_Debug("Setting button position to " .. ButtonholeAd_Pos);
151 end
152  
153 function ButtonholeAd_Minimap_OnClick(arg1)
154 if (arg1 == "RightButton") then
155 if (ButtonholeAdFrame:IsShown()) then
156 BHA_Debug("Hiding config frame");
157 ButtonholeAdFrame:Hide();
158 return nil;
159 end
160 BHA_Debug("Showing config frame");
161 ButtonholeAdFrame:Show();
162 return nil;
163 end
164 ButtonholeAd_Menu_Click();
165 ButtonholeAd_Expander_Click();
166 end
167  
168 -- Does this on load (duh)
169 function ButtonholeAd_OnLoad()
170 this:RegisterEvent("VARIABLES_LOADED"); -- Registers for Loaded Variables (standard)
171 this:RegisterEvent("PLAYER_LOGIN");
172 this:RegisterEvent("ADDON_LOADED");
173 SLASH_BUTTONHOLEAD1 = "/buttonhole"; -- Long Command
174 SLASH_BUTTONHOLEAD2 = "/bh"; -- Short Command
175 SLASH_BUTTONHOLEAD3 = "/buttonholead"; -- Semi-Long Command
176 SLASH_BUTTONHOLEAD4 = "/buttonholeadvanced"; -- Really Long Command
177 SLASH_BUTTONHOLEAD5 = "/bha"; -- Semi-Short Command
178 SlashCmdList["BUTTONHOLEAD"] = ButtonholeAd_Command;
179 ButtonholeAdFrameText:SetText(ButtonholeAd_windowtext); -- Sets the Help Text
180 end
181  
182  
183 ---------------------------------------------------------------------------
184  
185 function ButtonholeAd_WheelWrapper()
186 ButtonholeAd_Classic_Wheel(arg1);
187 end
188  
189 function ButtonholeAd_OnEvent()
190 if ( event == "VARIABLES_LOADED" ) then
191 -- ButtonholeAd_UpdateMethodUI();
192 -- ButtonholeAd_UpdatePosUI();
193 DEFAULT_CHAT_FRAME:AddMessage("Buttonhole Advanced : Ready for Work!", 0.2, 0.8, 0.8); -- Something need doing?
194 end
195 if (event == "ADDON_LOADED") and (myAddOnsFrame_Register) then
196 myAddOnsFrame_Register(ButtonholeAdDetails);
197 end
198 if (event == "PLAYER_LOGIN") then
199 local kids = { Minimap:GetChildren() };
200 for _,child in ipairs(kids) do
201 if (child:GetName() == nil) then
202 -- skip, unamed freaks!
203 else
204 local name = child:GetName();
205 local first = string.find(strlower(name), "minimap");
206 local second = string.find(strlower(name), "gathernote");
207 if (second == 1) then
208 -- Gatherer Wierdness
209 elseif (first == 1) then
210 -- skip, original frames
211 else
212 if not (name == "ButtonholeAd_Minimap") then -- Skip ourselves...
213 local tmp = {
214 ModName = name,
215 ModFrame = child,
216 ModOriginalX = child:GetLeft(),
217 ModOriginalY = child:GetBottom(),
218 ModOriginalS = child:GetScale();
219 ModOriginalSetPoint = child.SetPoint };
220 if (name == "CT_OptionBarFrame") then tmp.ModOriginalX = nil; end
221 if (name == "GathererUI_IconFrame") then
222 if (Chronos) then
223 Chronos.schedule(1, child.Hide, child); -- Hides teh
224 end -- Annoying Icon!
225 end
226 child:EnableMouseWheel(1);
227 child:SetScript("OnMouseWheel", ButtonholeAd_WheelWrapper);
228 tinsert(ButtonholeAd_SwallowButtons, tmp);
229 -- DEFAULT_CHAT_FRAME:AddMessage("The new is " .. name);
230 end
231 end
232 end
233 end
234 for _, v in ipairs(ButtonholeAd_SwallowButtons) do
235 -- v.ModFrame.RegisterForClicks = function() end;
236 end
237 ButtonholeAd_UpdateMethodUI();
238 ButtonholeAd_UpdatePosUI();
239 end
240 end
241  
242  
243 --------------------------------------------------------------------------
244  
245  
246 ButtonholeAd_Classic_Num = 0;
247  
248 function ButtonholeAd_Classic_Init()
249 if not (ButtonholeAd_Method == 0) then
250 return nil;
251 end
252 ButtonholeAd_Classic_Num = 0;
253 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
254 if (v.ModOriginalX == nil) or (v.ModOriginalY == nil) then
255 v.ModFrame:Hide();
256 if (i == ButtonholeAd_Classic_Num) then v.ModFrame:Show(); end
257 else
258 BHA_Debug("Classic : Jiggering frame " .. v.ModName);
259  
260 v.ModFrame.SetPoint = function() end;
261  
262 v.ModFrame:ClearAllPoints();
263  
264 -- BHA_Debug("Off : X: " .. v.ModOriginalX .. " Y: " .. v.ModOriginalY);
265 v.ModFrame:SetParent(ButtonholeAd_Minimap);
266 v.ModOriginalSetPoint(v.ModFrame, "TOPLEFT", 0, 0);
267 v.ModFrame:SetParent(Minimap);
268 v.ModFrame:Hide();
269 if (i == ButtonholeAd_Classic_Num) then v.ModFrame:Show(); ButtonholeAd_Minimap:Hide(); end
270 end
271 end
272 end
273  
274 function ButtonholeAd_Classic_Wheel(arg1)
275 if not (ButtonholeAd_Method == 0) then
276 return nil;
277 end
278 ButtonholeAd_Classic_Num = ButtonholeAd_Classic_Num + arg1;
279 if (ButtonholeAd_Classic_Num == -1) then ButtonholeAd_Classic_Num = table.getn(ButtonholeAd_SwallowButtons); end
280 if (ButtonholeAd_Classic_Num == table.getn(ButtonholeAd_SwallowButtons)+1) then ButtonholeAd_Classic_Num = 0; end
281 if (ButtonholeAd_Classic_Num == 0) then
282 BHA_Debug("Classic : Setting frame to Buttonhole");
283 else
284 BHA_Debug("Classic : Setting frame to " .. ButtonholeAd_SwallowButtons[ButtonholeAd_Classic_Num].ModFrame:GetName() );
285 end
286  
287 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
288 v.ModFrame:Hide();
289 if (i == ButtonholeAd_Classic_Num) then v.ModFrame:Show(); end
290 end
291  
292 if (ButtonholeAd_Classic_Num == 0) then
293 ButtonholeAd_Minimap:Show();
294 else
295 local tmp = ButtonholeAd_SwallowButtons[ButtonholeAd_Classic_Num];
296 if (tmp.ModOriginalX == nil) or (tmp.ModOriginalY == nil) then
297 ButtonholeAd_Minimap:Show();
298 else
299 ButtonholeAd_Minimap:Hide();
300 end
301 end
302 end
303  
304  
305 --------------------------------------------------------------------------
306  
307  
308 function ButtonholeAd_Menu_Init()
309 if not (ButtonholeAd_Method == 1) then
310 return nil;
311 end
312 end
313  
314 function ButtonholeAd_Menu_Click()
315 if not (ButtonholeAd_Method == 1) then
316 return nil;
317 end
318 BHA_Debug("Menu : Clicked");
319 end
320  
321  
322 --------------------------------------------------------------------------
323  
324  
325 ButtonholeAd_Expander_State = 0;
326  
327 function ButtonholeAd_Expander_Init()
328 if not (ButtonholeAd_Method == 2) then
329 return nil;
330 end
331 ButtonholeAd_Expander_State = 0;
332 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
333 BHA_Debug("Expander : Hiding frame " .. v.ModName);
334 v.ModFrame:Hide();
335 end
336 end
337  
338 function ButtonholeAd_Expander_Click()
339 if not (ButtonholeAd_Method == 2) then
340 return nil;
341 end
342  
343 if (ButtonholeAd_Expander_State == 0) then
344 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
345 BHA_Debug("Expander : Showing frame " .. v.ModName);
346 v.ModFrame:Show();
347 end
348 ButtonholeAd_Expander_State = 1;
349 else
350 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
351 BHA_Debug("Expander : Hiding frame " .. v.ModName);
352 v.ModFrame:Hide();
353 end
354 ButtonholeAd_Expander_State = 0;
355 end
356  
357 BHA_Debug("Expander : Toggled");
358 end
359  
360  
361 --------------------------------------------------------------------------
362  
363  
364 function ButtonholeAd_Off_Init()
365 -- if not (ButtonholeAd_Method == 3) then
366 -- return nil;
367 -- end
368 ButtonholeAd_Minimap:Show();
369 for i,v in ipairs(ButtonholeAd_SwallowButtons) do
370 BHA_Debug("Off : Reshowing frame " .. v.ModName);
371  
372 v.ModFrame.SetPoint = v.ModOriginalSetPoint;
373  
374 if (v.ModOriginalX == nil) or (v.ModOriginalY == nil) then
375 v.ModFrame:Show();
376 else
377 BHA_Debug("Off : X: " .. v.ModOriginalX .. " Y: " .. v.ModOriginalY .. " S: " .. v.ModOriginalS);
378 v.ModFrame:ClearAllPoints();
379 v.ModFrame:SetParent(UIParent);
380 v.ModFrame:SetPoint("BOTTOMLEFT", "UIParent", v.ModOriginalX, v.ModOriginalY);
381 v.ModFrame:SetParent(Minimap);
382 v.ModFrame:Show();
383 end
384 end
385 end