vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- Minimap Button Handling
2  
3 lazyr.mm = {}
4  
5  
6 function lazyr.mm.OnLoad()
7 local junk, englishClass = UnitClass("player")
8 if (englishClass ~= "ROGUE") then
9 return
10 end
11 this:SetFrameLevel(this:GetFrameLevel()+1)
12 this:RegisterForClicks("LeftButtonDown", "RightButtonDown")
13 this:RegisterEvent("VARIABLES_LOADED")
14 end
15  
16 function lazyr.mm.OnClick(button)
17 if (button == "LeftButton") then
18 -- Toggle menu
19 local menu = getglobal("LazyRogueMinimapMenu")
20 menu.point = "TOPRIGHT"
21 menu.relativePoint = "CENTER"
22 ToggleDropDownMenu(1, nil, menu, "LazyRogueMinimapButton", -120, 0)
23 end
24 end
25  
26 function lazyr.mm.OnEvent()
27 lazyr.mm.UpdateMinimap()
28 if (lazyr.perPlayerConf.mmIsVisible) then
29 this:Show()
30 LazyRogueMinimapButton:Show()
31 else
32 this:Hide()
33 LazyRogueMinimapButton:Hide()
34 end
35 end
36  
37 function lazyr.mm.OnEnter()
38 GameTooltip:SetOwner(this, "ANCHOR_LEFT")
39 GameTooltip:SetText("LazyRogue")
40 local defaultForm = lazyr.perPlayerConf.defaultForm
41 if (not defaultForm) then
42 defaultForm = "(none)"
43 end
44 GameTooltip:AddLine("Current Form: "..defaultForm)
45 GameTooltip:AddLine("Left-click to choose your form.")
46 GameTooltip:AddLine("Right-click and drag to move this button.")
47 GameTooltip:Show()
48 end
49  
50 function lazyr.mm.UpdateMinimap()
51 lazyr.mm.MoveButton()
52 if (Minimap:IsVisible()) then
53 LazyRogueMinimapButton:EnableMouse(true)
54 LazyRogueMinimapButton:Show()
55 LazyRogueMinimapFrame:Show()
56 else
57 LazyRogueMinimapButton:EnableMouse(false)
58 LazyRogueMinimapButton:Hide()
59 LazyRogueMinimapFrame:Hide()
60 end
61 end
62  
63 function lazyr.mm.Menu_Initialize()
64 if (not lazyr.perPlayerConf) then
65 -- just loading, skip it for now
66 return
67 end
68 if (UIDROPDOWNMENU_MENU_LEVEL == 1) then
69  
70 local formNames = {}
71 for form, actions in lrConf.forms do
72 table.insert(formNames, form)
73 end
74  
75 table.sort(formNames)
76  
77 local info = {}
78 info.isTitle = 1
79 info.text = "LazyRogue v"..lazyr.version
80 UIDropDownMenu_AddButton(info)
81  
82 for idx, formName in formNames do
83 local actions = lrConf.forms[formName]
84 local info = {}
85 info.text = formName
86 info.value = formName
87 info.func = lazyr.mm.Menu_ClickFunc(formName)
88 info.checked = (lazyr.perPlayerConf.defaultForm and lazyr.perPlayerConf.defaultForm == formName)
89 info.keepShownOnClick = 1
90 info.hasArrow = 1
91 info.tooltipTitle = formName
92 info.tooltipText = ""
93 for idx, action in actions do
94 info.tooltipText = info.tooltipText.."\n- "..action
95 end
96 UIDropDownMenu_AddButton(info)
97 end
98  
99 info = {}
100 info.text = "< Create new form >"
101 info.func = lazyr.mm.Menu_ClickSubFunction("New")
102 UIDropDownMenu_AddButton(info)
103  
104 info = {}
105 info.text = "< Options >"
106 info.value = "Options"
107 info.keepShownOnClick = 1
108 info.hasArrow = 1
109 UIDropDownMenu_AddButton(info)
110  
111 info = {}
112 info.text = "< Eviscerate Options >"
113 info.value = "Eviscerates"
114 info.keepShownOnClick = 1
115 info.hasArrow = 1
116 UIDropDownMenu_AddButton(info)
117  
118 info = {}
119 info.text = "< Cast Interrupt Options >"
120 info.value = "Interrupts"
121 info.keepShownOnClick = 1
122 info.hasArrow = 1
123 UIDropDownMenu_AddButton(info)
124  
125 info = {}
126 info.text = "< Debugging >"
127 info.value = "Debugging"
128 info.keepShownOnClick = 1
129 info.hasArrow = 1
130 UIDropDownMenu_AddButton(info)
131  
132 info = {}
133 info.text = "< About >"
134 info.func = lazyr.mm.Menu_ClickSubFunction("About")
135 UIDropDownMenu_AddButton(info)
136  
137 elseif (UIDROPDOWNMENU_MENU_LEVEL == 2) then
138 if (UIDROPDOWNMENU_MENU_VALUE == "Options") then
139  
140 local info = {}
141 info.isTitle = 1
142 info.text = "LazyRogue Options"
143 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
144  
145 local info = {}
146 info.text = "Auto-Target"
147 if (lazyr.perPlayerConf.autoTarget) then
148 info.checked = true
149 end
150 info.keepShownOnClick = 1
151 info.func = lazyr.mm.Menu_ClickSubFunction("AutoTarget")
152 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
153  
154 local info = {}
155 info.text = "... and initiate Auto-Attack"
156 if (lazyr.perPlayerConf.initiateAutoAttack) then
157 info.checked = true
158 end
159 info.keepShownOnClick = 1
160 info.func = lazyr.mm.Menu_ClickSubFunction("InitiateAutoAttack")
161 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
162  
163 local info = {}
164 info.text = "Show Minion"
165 if (lazyr.perPlayerConf.minionIsVisible) then
166 info.checked = true
167 end
168 info.keepShownOnClick = 1
169 info.func = lazyr.mm.Menu_ClickSubFunction("Show Minion")
170 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
171  
172 local info = {}
173 info.text = "... Only in combat"
174 if (lazyr.perPlayerConf.minionHidesOutOfCombat) then
175 info.checked = true
176 end
177 info.keepShownOnClick = 1
178 info.func = lazyr.mm.Menu_ClickSubFunction("Show Minion in Combat")
179 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
180  
181 local info = {}
182 info.text = "Show Deathstimator Minion"
183 if (lazyr.perPlayerConf.deathMinionIsVisible) then
184 info.checked = true
185 end
186 info.keepShownOnClick = 1
187 info.func = lazyr.mm.Menu_ClickSubFunction("Show Death Minion")
188 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
189  
190 local info = {}
191 info.text = "... Only in combat"
192 if (lazyr.perPlayerConf.deathMinionHidesOutOfCombat) then
193 info.checked = true
194 end
195 info.keepShownOnClick = 1
196 info.func = lazyr.mm.Menu_ClickSubFunction("Show Death Minion in Combat")
197 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
198  
199 local info = {}
200 info.isTitle = 1
201 info.text = "Deathstimator sample window:"
202 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
203  
204 for idx, i in {3, 5, 10, 15, 30, 60} do
205 local info = {}
206 info.text = "... "..i.."s"
207 if (lazyr.perPlayerConf.healthHistorySize == i) then
208 info.checked = true
209 end
210 info.keepShownOnClick = 1
211 info.func = lazyr.mm.Menu_ClickSubFunction("Deathstimate "..i)
212 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
213 end
214  
215 elseif (UIDROPDOWNMENU_MENU_VALUE == "Eviscerates") then
216  
217 local info = {}
218 info.isTitle = 1
219 info.text = "Eviscerate Options"
220 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
221  
222 local info = {}
223 info.text = "Use Eviscerate Tracking"
224 if (lazyr.perPlayerConf.useEviscTracking) then
225 info.checked = true
226 end
227 info.keepShownOnClick = 1
228 info.func = lazyr.mm.Menu_ClickSubFunction("Use Eviscerate Tracking")
229 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
230  
231 local info = {}
232 info.text = "... Include Crits (may skew kill shots)"
233 if (lazyr.perPlayerConf.trackEviscCrits) then
234 info.checked = true
235 end
236 info.keepShownOnClick = 1
237 info.func = lazyr.mm.Menu_ClickSubFunction("Track Eviscerate Crits")
238 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
239  
240 local info = {}
241 info.isTitle = 1
242 info.text = "Eviscerate sample window:"
243 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
244  
245 for idx, i in {10, 25, 50, 100} do
246 local info = {}
247 info.text = "... Last "..i.." Eviscerates"
248 if (lazyr.perPlayerConf.eviscerateSample == i) then
249 info.checked = true
250 end
251 info.keepShownOnClick = 1
252 info.func = lazyr.mm.Menu_ClickSubFunction("Eviscerate Sample "..i)
253 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
254 end
255  
256 local info = {}
257 info.isTitle = 1
258 info.text = "Eviscerate Stats"
259 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
260  
261 local info = {}
262 info.isTitle = 1
263 info.text = "Observed/Optimal => % (# seen)"
264 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
265  
266 local info = {}
267 info.isTitle = 1
268  
269 for cp = 1, 5 do
270 local expectedDamage = lazyr.masks.CalculateBaseEviscDamage(cp)
271 if (not expectedDamage) then
272 break
273 end
274 local observedDamage, observedCt = lazyr.et.GetEviscTrackingInfo(cp)
275 local ratio = observedDamage / expectedDamage
276 info.text = cp.."cp: "..
277 string.format("%.1f", observedDamage)..
278 "/"..string.format("%.1f", expectedDamage)..
279 " => "..string.format("%.1f", (ratio * 100)).."%"..
280 " ("..observedCt.." seen)"
281  
282 -- TBD: tooltip
283 --info.tooltipTitle = "Eviscerate Stats ("..i.."cp)"
284 --local text = observedCt.." Eviscerates observed."
285 --text = text.."\nAveraging "..observedDamage.." damage"
286 --text = text.."\nThe documented "..observedDamage.." damage"
287 --info.tooltipText = text
288  
289 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
290 end
291  
292 local info = {}
293 info.text = "< Reset >"
294 info.func = lazyr.mm.Menu_ClickSubFunction("Reset Eviscerate Stats")
295 -- TBD:
296 --info.keepShownOnClick = 1
297 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
298  
299 elseif (UIDROPDOWNMENU_MENU_VALUE == "Interrupts") then
300  
301 local info = {}
302 info.isTitle = 1
303 info.text = "Cast Interrupt Options"
304 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
305  
306 local info = {}
307 info.text = "< Edit Interrupt Exception Criteria >"
308 info.func = lazyr.mm.Menu_ClickSubFunction("Global Interrupt Criteria")
309 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
310  
311 local info = {}
312 info.isTitle = 1
313 local lastInterrupted
314 if (lazyr.interrupt.lastSpellInterrupted) then
315 lastInterrupted = lazyr.interrupt.lastSpellInterrupted
316 else
317 lastInterrupted = "(none)"
318 end
319 info.text = "Last interrupted: "..lastInterrupted
320 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
321  
322 local info = {}
323 info.text = "< ... Don't interrupt it again >"
324 info.func = lazyr.mm.Menu_ClickSubFunction("noLongerInterruptLastInterrupted")
325 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
326  
327 elseif (UIDROPDOWNMENU_MENU_VALUE == "Debugging") then
328  
329 local info = {}
330 info.isTitle = 1
331 info.text = "Debugging Options"
332 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
333  
334 local info = {}
335 info.text = "Log when target casts"
336 if (lazyr.perPlayerConf.showTargetCasts) then
337 info.checked = true
338 end
339 info.keepShownOnClick = 1
340 info.func = lazyr.mm.Menu_ClickSubFunction("showTargetCasts")
341 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
342  
343 local info = {}
344 info.text = "Show why when -ifTargetCCd is true"
345 if (lazyr.perPlayerConf.showReasonForTargetCCd) then
346 info.checked = true
347 end
348 info.keepShownOnClick = 1
349 info.func = lazyr.mm.Menu_ClickSubFunction("showReasonForTargetCCd")
350 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
351  
352 local info = {}
353 info.text = "< Action History >"
354 info.value = "History"
355 info.keepShownOnClick = 1
356 info.hasArrow = 1
357 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
358  
359 local info = {}
360 info.text = "Internal LazyRogue debugging (noisy)"
361 if (lazyr.perPlayerConf.debug) then
362 info.checked = true
363 end
364 info.keepShownOnClick = 1
365 info.func = lazyr.mm.Menu_ClickSubFunction("debug")
366 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
367  
368 else
369 -- a submenu of a form
370 for idx, op in {"Edit", "Copy", "Delete"} do
371 local info = {}
372 info.text = "< "..op.." >"
373 info.func = lazyr.mm.Menu_ClickSubFunction(op, UIDROPDOWNMENU_MENU_VALUE)
374 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
375 end
376 end
377  
378 elseif (UIDROPDOWNMENU_MENU_LEVEL == 3) then
379 if (UIDROPDOWNMENU_MENU_VALUE == "History") then
380 local info = {}
381 info.isTitle = 1
382 info.text = "Action History"
383 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
384 for idx, action in ipairs(lazyr.actionHistory) do
385 info.text = idx..". "..action
386 UIDropDownMenu_AddButton(info, UIDROPDOWNMENU_MENU_LEVEL)
387 end
388 end
389 end
390 end
391  
392 function lazyr.mm.Menu_ClickFunc(form)
393 return function()
394 lazyr.SlashCommand("default "..form)
395 CloseDropDownMenus()
396 LazyRogueMinimapButton:Click()
397 -- This is a hack to deal with the code in UIDropDownMenu.lua.
398 -- This makes it so if a button was already checked, it remains checked,
399 -- which is what I want.
400 if (this.checked) then
401 this.checked = nil
402 end
403 end
404 end
405  
406 function lazyr.mm.Menu_ClickSubFunction(op, form)
407 return function()
408 if (not form) then
409 form = ""
410 end
411 if (op == "New" or op == "Edit") then
412 lazyr.SlashCommand("edit "..form)
413 CloseDropDownMenus()
414 LazyRogueMinimapButton:Click()
415 elseif (op == "Copy") then
416 local newName
417 for i = 1, 10 do
418 newName = form.."-"..i
419 if (not lrConf.forms[newName]) then
420 lazyr.SlashCommand("copy "..form.." "..newName)
421 break
422 end
423 end
424 CloseDropDownMenus()
425 LazyRogueMinimapButton:Click()
426 elseif (op == "Delete") then
427 lazyr.SlashCommand("clear "..form)
428 CloseDropDownMenus()
429 LazyRogueMinimapButton:Click()
430  
431 elseif (op == "About") then
432 lazyr.SlashCommand("about")
433  
434 elseif (op == "AutoTarget") then
435 lazyr.SlashCommand("autoTarget")
436 lazyr.mm.RefreshMenu2("Options")
437  
438 elseif (op == "InitiateAutoAttack") then
439 lazyr.SlashCommand("initiateAutoAttack")
440 elseif (op == "Show Minion") then
441 if (lazyr.perPlayerConf.minionIsVisible) then
442 lazyr.SlashCommand("dismiss")
443 else
444 lazyr.SlashCommand("summon")
445 end
446 elseif (op == "Show Minion in Combat") then
447 lazyr.SlashCommand("hideMinionOutOfCombat")
448 elseif (op == "Show Death Minion") then
449 if (lazyr.perPlayerConf.deathMinionIsVisible) then
450 lazyr.SlashCommand("dismissDeath")
451 else
452 lazyr.SlashCommand("summonDeath")
453 end
454 elseif (op == "Show Death Minion in Combat") then
455 lazyr.SlashCommand("hideDeathMinionOutOfCombat")
456 elseif (op == "Deathstimate 3") then
457 lazyr.perPlayerConf.healthHistorySize = 3
458 lazyr.mm.RefreshMenu("Options")
459 elseif (op == "Deathstimate 5") then
460 lazyr.perPlayerConf.healthHistorySize = 5
461 lazyr.mm.RefreshMenu("Options")
462 elseif (op == "Deathstimate 10") then
463 lazyr.perPlayerConf.healthHistorySize = 10
464 lazyr.mm.RefreshMenu("Options")
465 elseif (op == "Deathstimate 15") then
466 lazyr.perPlayerConf.healthHistorySize = 15
467 lazyr.mm.RefreshMenu("Options")
468 elseif (op == "Deathstimate 30") then
469 lazyr.perPlayerConf.healthHistorySize = 30
470 lazyr.mm.RefreshMenu("Options")
471 elseif (op == "Deathstimate 60") then
472 lazyr.perPlayerConf.healthHistorySize = 60
473 lazyr.mm.RefreshMenu("Options")
474  
475 elseif (op == "Reset Eviscerate Stats") then
476 lazyr.SlashCommand("resetEviscerateStats")
477 elseif (op == "Use Eviscerate Tracking") then
478 lazyr.SlashCommand("useEviscerateTracking")
479 elseif (op == "Track Eviscerate Crits") then
480 lazyr.SlashCommand("trackEviscCrits")
481 elseif (op == "Eviscerate Sample 10") then
482 lazyr.perPlayerConf.eviscerateSample = 10
483 lazyr.mm.RefreshMenu("Eviscerates")
484 elseif (op == "Eviscerate Sample 25") then
485 lazyr.perPlayerConf.eviscerateSample = 25
486 lazyr.mm.RefreshMenu("Eviscerates")
487 elseif (op == "Eviscerate Sample 50") then
488 lazyr.perPlayerConf.eviscerateSample = 50
489 lazyr.mm.RefreshMenu("Eviscerates")
490 elseif (op == "Eviscerate Sample 100") then
491 lazyr.perPlayerConf.eviscerateSample = 100
492 lazyr.mm.RefreshMenu("Eviscerates")
493  
494 elseif (op == "Global Interrupt Criteria") then
495 lazyr.SlashCommand("interruptExceptionCriteria")
496 elseif (op == "noLongerInterruptLastInterrupted") then
497 lazyr.SlashCommand("noLongerInterruptLastInterrupted")
498  
499  
500 elseif (op == "debug") then
501 lazyr.SlashCommand("debug")
502 elseif (op == "showTargetCasts") then
503 lazyr.SlashCommand("showTargetCasts")
504 elseif (op == "showReasonForTargetCCd") then
505 lazyr.SlashCommand("showReasonForTargetCCd")
506 end
507 end
508 end
509  
510 function lazyr.mm.RefreshMenu(which)
511 UIDropDownMenu_Initialize(LazyRogueMinimapMenu, lazyr.mm.Menu_Initialize, which)
512 -- again, a hack to deal with the code in UIDropDownMenu.lua.
513 if (this.checked) then
514 this.checked = nil
515 end
516 end
517  
518 function lazyr.mm.RefreshMenu2(which)
519 UIDropDownMenu_Initialize(LazyRogueMinimapMenu, lazyr.mm.Menu_Initialize, which)
520 -- again, a hack to deal with the code in UIDropDownMenu.lua.
521 if (this.checked) then
522 this.checked = nil
523 else
524 this.checked = true
525 end
526 end
527  
528 -- Thanks to Yatlas for this code
529 function lazyr.mm.Button_BeingDragged()
530 -- Thanks to Gello for this code
531 local xpos,ypos = GetCursorPosition()
532 local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
533  
534 xpos = xmin-xpos/UIParent:GetScale()+70
535 ypos = ypos/UIParent:GetScale()-ymin-70
536  
537 lazyr.mm.Button_SetPosition(math.deg(math.atan2(ypos,xpos)))
538 end
539  
540 function lazyr.mm.Button_SetPosition(v)
541 if(v < 0) then
542 v = v + 360
543 end
544  
545 lazyr.perPlayerConf.minimapButtonPos = v
546 lazyr.mm.MoveButton()
547 end
548  
549 function lazyr.mm.MoveButton()
550 local where = lazyr.perPlayerConf.minimapButtonPos
551 LazyRogueMinimapFrame:ClearAllPoints()
552 LazyRogueMinimapFrame:SetPoint("TOPLEFT", "Minimap", "TOPLEFT",
553 52 - (80 * cos(where)),
554 (80 * sin(where)) - 52)
555 end
556