vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local _TOOLTIPTAB = 1
2 local _BUTTONTEXTTAB = 2
3 local _ADVANCEDTAB = 3
4 --local _MITIGATIONTAB = 4
5 local _, class = UnitClass("player")
6 TheoryCraft_NotStripped = true
7 TheoryCraft_SetUpButton = function (parentname, type, specialid)
8 oldbutton = getglobal(parentname)
9 if not oldbutton then return end
10 newbutton = getglobal(parentname.."_TCText")
11 if newbutton then return end
12 oldbutton:CreateFontString(parentname.."_TCText", "ARTWORK");
13 oldbutton.oldupdatescript = oldbutton:GetScript("OnUpdate")
14 oldbutton:SetScript("OnUpdate", TheoryCraft_ButtonUpdate)
15 newbutton = getglobal(parentname.."_TCText")
16 newbutton:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE")
17 newbutton:SetPoint("TOPLEFT", oldbutton, "TOPLEFT", 0, 0)
18 newbutton:SetPoint("BOTTOMRIGHT", oldbutton, "BOTTOMRIGHT", 0, 0)
19 newbutton.type = type
20 newbutton.specialid = specialid
21 newbutton:Show()
22 end
23  
24 local function findpattern(text, pattern, start)
25 if (text and pattern and (string.find(text, pattern, start))) then
26 return string.sub(text, string.find(text, pattern, start))
27 else
28 return ""
29 end
30 end
31  
32 local function round(arg1, decplaces)
33 if (decplaces == nil) then decplaces = 0 end
34 if arg1 == nil then arg1 = 0 end
35 return string.format ("%."..decplaces.."f", arg1)
36 end
37  
38 function TheoryCraft_GenBoxEditChange()
39 TheoryCraft_Settings["GenerateList"] = TheoryCraftGenBox_Text:GetText()
40 if string.find(TheoryCraft_Settings["GenerateList"], "ONDEMAND") then
41 TheoryCraft_Settings["GenerateList"] = "ONDEMAND"
42 end
43 end
44  
45 function TheoryCraft_CustomizedEditChange()
46 TheoryCraft_Settings["Customized"] = TheoryCraftCustomized_Text:GetText()
47 end
48  
49 local function UpdateCustomOutfit()
50 if TheoryCraft_Data.outfit == 2 then
51 TheoryCraftCustomOutfit:Show()
52 else
53 TheoryCraftCustomOutfit:Hide()
54 return
55 end
56 local i = 1
57 local i2 = 1
58 TheoryCraftCustomLeft:SetText()
59 TheoryCraftCustomRight:SetText()
60 TheoryCraftCustomLeft:SetHeight(1)
61 TheoryCraftCustomRight:SetHeight(1)
62 local text = 1
63 while (TheoryCraft_SlotNames[i]) do
64 if (TheoryCraftCustomLeft:GetText(text) == nil) or (string.find(TheoryCraftCustomLeft:GetText(text), TheoryCraft_SlotNames[i].slot) == nil) then
65 if string.find(TheoryCraft_SlotNames[i].slot, "%d+") then
66 text = string.sub(TheoryCraft_SlotNames[i].slot, 1, string.find(TheoryCraft_SlotNames[i].slot, "%d+")-1)
67 else
68 text = TheoryCraft_SlotNames[i].slot
69 end
70 if TheoryCraftCustomLeft:GetText() then
71 TheoryCraftCustomLeft:SetText(TheoryCraftCustomLeft:GetText().."\n"..text)
72 else
73 TheoryCraftCustomLeft:SetText(text)
74 end
75 if TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot] then
76 text = TheoryCraft_Settings["CustomOutfit"].slots[TheoryCraft_SlotNames[i].slot]["name"]
77 else
78 text = " "
79 end
80 if TheoryCraftCustomRight:GetText() then
81 TheoryCraftCustomRight:SetText(TheoryCraftCustomRight:GetText().."\n"..text)
82 else
83 TheoryCraftCustomRight:SetText(text)
84 end
85 TheoryCraftCustomLeft:SetHeight(11+TheoryCraftCustomLeft:GetHeight())
86 TheoryCraftCustomRight:SetHeight(TheoryCraftCustomLeft:GetHeight())
87 end
88 i = i + 1
89 end
90 end
91  
92 function TheoryCraft_TabHandler()
93 local name = this:GetName()
94 name = tonumber(string.sub(name, 15))
95 TheoryCraftSettingsTab:Hide()
96 TheoryCraftCustomOutfit:Hide()
97 TheoryCraftOutfitTab:Hide()
98 TheoryCraftButtonTextTab:Hide()
99 TheoryCraftCustomOutfit:Hide()
100 -- TheoryCraftMitigationTab:Hide()
101 if (name == _TOOLTIPTAB) then
102 TheoryCraftSettingsTab:Show()
103 elseif (name == _BUTTONTEXTTAB) then
104 TheoryCraftButtonTextTab:Show()
105 elseif (name == _ADVANCEDTAB) then
106 TheoryCraftOutfitTab:Show()
107 TheoryCraft_UpdateOutfitTab()
108 -- elseif (name == _MITIGATIONTAB) then
109 -- TheoryCraftMitigationTab:Show()
110 end
111 end
112  
113 local function TheoryCraftAddStat(text, text2)
114 if (text == nil) or (text2 == nil) then return end
115 if TheoryCraftStatsLeft:GetText() then
116 TheoryCraftStatsLeft:SetText(TheoryCraftStatsLeft:GetText().."\n"..text)
117 TheoryCraftStatsRight:SetText(TheoryCraftStatsRight:GetText().."\n"..text2)
118 else
119 TheoryCraftStatsLeft:SetText(text)
120 TheoryCraftStatsRight:SetText(text2)
121 end
122 TheoryCraftStatsLeft:SetHeight(10+TheoryCraftStatsLeft:GetHeight())
123 TheoryCraftStatsRight:SetHeight(TheoryCraftStatsLeft:GetHeight())
124 end
125  
126 local function TheoryCraftAddVital(text, text2)
127 if (text == nil) or (text2 == nil) then return end
128 if TheoryCraftVitalsLeft:GetText() then
129 TheoryCraftVitalsLeft:SetText(TheoryCraftVitalsLeft:GetText().."\n"..text)
130 TheoryCraftVitalsRight:SetText(TheoryCraftVitalsRight:GetText().."\n"..text2)
131 else
132 TheoryCraftVitalsLeft:SetText(text)
133 TheoryCraftVitalsRight:SetText(text2)
134 end
135 TheoryCraftVitalsLeft:SetHeight(10+TheoryCraftVitalsLeft:GetHeight())
136 TheoryCraftVitalsRight:SetHeight(TheoryCraftVitalsLeft:GetHeight())
137 end
138  
139 local function TheoryCraftAddMod(text, text2)
140 if (text == nil) or (text2 == nil) then return end
141 if TheoryCraftModsLeft:GetText() then
142 TheoryCraftModsLeft:SetText(TheoryCraftModsLeft:GetText().."\n"..text)
143 else
144 TheoryCraftModsLeft:SetText(text)
145 end
146 if TheoryCraftModsRight:GetText() then
147 TheoryCraftModsRight:SetText(TheoryCraftModsRight:GetText().."\n"..text2)
148 else
149 TheoryCraftModsRight:SetText(text2)
150 end
151 end
152  
153 local function AddMods(mult, mod, all, healing, damage, school, prefix, suffix, pre2)
154 local tmp = TheoryCraft_GetStat("All"..mod)*mult
155 if tmp ~= 0 then
156 if all ~= "DONT" then
157 TheoryCraftAddMod(all, prefix..tmp..suffix)
158 end
159 end
160 tmp = TheoryCraft_GetStat("Healing"..mod)*mult
161 if tmp ~= 0 then
162 TheoryCraftAddMod(healing, prefix..tmp..suffix)
163 end
164 tmp = TheoryCraft_GetStat("Damage"..mod)*mult
165 if tmp ~= 0 then
166 TheoryCraftAddMod(damage, prefix..tmp..suffix)
167 end
168 if pre2 == nil then pre2 = "" end
169 for k,v in pairs(TheoryCraft_PrimarySchools) do
170 tmp = TheoryCraft_GetStat(v.name..mod)*mult
171 if tmp ~= 0 then
172 TheoryCraftAddMod(pre2..v.name..school, prefix..tmp..suffix)
173 end
174 end
175 end
176  
177 function TheoryCraft_UpdateOutfitTab()
178 if not TheoryCraftOutfitTab:IsVisible() then
179 return
180 end
181 local i = 1
182 local i2 = 1
183 while i < 4 do
184 i2 = 1
185 getglobal("TheoryCraftTalentTree"..i):SetText(" ")
186 while getglobal("TheoryCraftTalent"..i..i2) do
187 getglobal("TheoryCraftTalent"..i..i2):Hide()
188 i2 = i2+1
189 end
190 i = i+1
191 end
192 i2 = 1
193 local number
194 local title, rank, i3, _, currank
195 local highestnumber = 0
196 while i2 < 4 do
197 i = 1
198 number = 1
199 while (TheoryCraft_Talents[i]) do
200 if (class == TheoryCraft_Talents[i].class) and (TheoryCraft_Talents[i].dontlist == nil) and (((TheoryCraft_Talents[i].tree == i2) and (TheoryCraft_Talents[i].forcetree == nil)) or (TheoryCraft_Talents[i].forcetree == i2)) then
201 title = getglobal("TheoryCraftTalentTree"..i2)
202 rank = getglobal("TheoryCraftTalent"..i2..number)
203 i3 = 1
204 while (TheoryCraft_Locale.TalentTranslator[i3]) and (TheoryCraft_Locale.TalentTranslator[i3].id ~= TheoryCraft_Talents[i].name) do
205 i3 = i3 + 1
206 end
207 if (TheoryCraft_Locale.TalentTranslator[i3]) and (rank ~= nil) then
208 title:SetText(title:GetText()..TheoryCraft_Locale.TalentTranslator[i3].translated.."\n")
209 _, _, _, _, currank = GetTalentInfo(TheoryCraft_Talents[i].tree, TheoryCraft_Talents[i].number)
210 if ((TheoryCraft_Talents[i].forceto == nil) or (TheoryCraft_Talents[i].forceto == -1)) then
211 rank:SetText(currank)
212 else
213 rank:SetText(TheoryCraft_Talents[i].forceto)
214 end
215 rank:SetNormalTexture(nil)
216 rank:SetPushedTexture(nil)
217 rank:SetHighlightTexture(nil)
218 if (TheoryCraft_Talents[i].forceto) and (TheoryCraft_Talents[i].forceto ~= -1) and (TheoryCraft_Talents[i].forceto ~= currank) then
219 rank:SetTextColor(1,1,0.1)
220 else
221 rank:SetTextColor(0.1,1,0.1)
222 end
223 rank:Show()
224 number = number + 1
225 end
226 end
227 i = i+1
228 end
229 if highestnumber < number then highestnumber = number end
230 i2 = i2 + 1
231 end
232  
233 TheoryCraftTalentTitle:SetPoint("BOTTOMLEFT", TheoryCraftOutfitTab, "BOTTOMLEFT", 20, 42+10*highestnumber)
234  
235 TheoryCraftVitalsLeft:SetText()
236 TheoryCraftVitalsRight:SetText()
237 TheoryCraftVitalsLeft:SetHeight(2)
238 TheoryCraftVitalsRight:SetHeight(2)
239 TheoryCraftStatsLeft:SetText()
240 TheoryCraftStatsRight:SetText()
241 TheoryCraftStatsLeft:SetHeight(2)
242 TheoryCraftStatsRight:SetHeight(2)
243 TheoryCraftModsLeft:SetText()
244 TheoryCraftModsRight:SetText()
245 TheoryCraftModsLeft:SetHeight(2)
246 TheoryCraftModsRight:SetHeight(2)
247  
248 local totalmana = TheoryCraft_GetStat("totalmana")+TheoryCraft_GetStat("manarestore")
249  
250 TheoryCraftAddVital("Health", math.floor(TheoryCraft_GetStat("totalhealth")))
251 if class == "HUNTER" then
252 TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
253 TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
254 TheoryCraftAddVital("Ranged Attack Power", math.floor(TheoryCraft_GetStat("rangedattackpower")))
255 TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
256 TheoryCraftAddVital("Ranged Crit Chance", round(TheoryCraft_GetStat("rangedcritchance"), 2).."%")
257 TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
258 TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
259 TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
260 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
261 TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
262 TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
263 TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
264 TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
265 elseif (class == "ROGUE") or (class == "WARRIOR") then
266 TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
267 TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
268 TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
269 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
270 TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
271 TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
272 elseif (class == "PALADIN") then
273 TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
274 TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
275 TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
276 TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
277 TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
278 TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
279 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
280 TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
281 TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
282 TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
283 TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
284 elseif (class == "DRUID") then
285 if UnitManaMax("player") == 100 then
286 TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
287 TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
288 TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
289 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
290 TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
291 TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
292 else
293 TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
294 TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
295 TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
296 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
297 TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
298 TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
299 end
300 else
301 TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
302 TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
303 TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
304 TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
305 TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
306 TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
307 end
308  
309 TheoryCraftModsLeft:SetHeight(288-TheoryCraftStatsLeft:GetHeight()-TheoryCraftVitalsLeft:GetHeight()-10*highestnumber)
310 TheoryCraftModsRight:SetHeight(TheoryCraftModsLeft:GetHeight())
311  
312 local proceffect
313 if TheoryCraft_GetStat("FrostboltNetherwind") ~= 0 then
314 proceffect = 1
315 end
316 if TheoryCraft_GetStat("Beastmanarestore") ~= 0 then
317 proceffect = 1
318 end
319 if TheoryCraft_Data.EquipEffects["procs"] then
320 if TheoryCraft_IsDifferent(TheoryCraft_Data.EquipEffects["procs"], { }) then
321 proceffect = 1
322 end
323 end
324 if proceffect then
325 TheoryCraftAddMod("Proc Effect", " ")
326 end
327  
328 if TheoryCraft_GetStat("CritReport") ~= 0 then
329 TheoryCraftAddMod("Crit Chance", "+"..(TheoryCraft_GetStat("CritReport")).."%")
330 end
331 if (class ~= "HUNTER") and (class ~= "WARRIOR") and (class ~= "ROGUE") then
332 if TheoryCraft_GetStat("Allcritchance") ~= 0 then
333 TheoryCraftAddMod("Spell Crit Chance", round(TheoryCraft_Data.Stats["critchance"], 2).."% + "..(TheoryCraft_GetStat("Allcritchance")).."%")
334 else
335 TheoryCraftAddMod("Spell Crit Chance", round(TheoryCraft_Data.Stats["critchance"], 2).."%")
336 end
337 end
338 AddMods(1, "critchance", "DONT", "Heal Crit Chance", "Damage Spell Crit Chance", " Crit Chance", "+", "%")
339 AddMods(1, "", "+Damage and Healing", "+Healing", "+Spell Damage", " Damage", "", "", "+")
340 if TheoryCraft_GetStat("Undead") ~= 0 then
341 TheoryCraftAddMod("+Damage to Undead", TheoryCraft_GetStat("Undead"))
342 end
343 if TheoryCraft_GetStat("AttackPowerReport") ~= 0 then
344 TheoryCraftAddMod("Attack Power", "+"..(TheoryCraft_GetStat("AttackPowerReport")))
345 end
346 if TheoryCraft_GetStat("RangedAttackPowerReport") ~= 0 then
347 TheoryCraftAddMod("Ranged Attack Power", "+"..(TheoryCraft_GetStat("RangedAttackPowerReport")))
348 end
349 if TheoryCraft_GetStat("BlockValueReport") ~= 0 then
350 TheoryCraftAddMod("Shield Block Value", TheoryCraft_GetStat("BlockValueReport"))
351 end
352 AddMods(1, "hitchance", "Spell Hit Chance", "", "Damage Spell Hit Chance", " Hit Chance", "+", "%")
353 if TheoryCraft_GetStat("Meleehitchance") ~= 0 then
354 TheoryCraftAddMod("Hit Chance", "+"..(TheoryCraft_GetStat("Meleehitchance")).."%")
355 end
356 AddMods(1, "penetration", "Spell Penetration", "", "Damage Spell Penetration", " Penetration", "", "")
357 if TheoryCraft_GetStat("manaperfive") ~= 0 then
358 TheoryCraftAddMod("Mana Per Five", TheoryCraft_GetStat("manaperfive"))
359 end
360 if TheoryCraft_GetStat("ICPercent") ~= 0 then
361 TheoryCraftAddMod("Spirit In 5 Rule", (TheoryCraft_GetStat("ICPercent")*100).."%")
362 end
363 if TheoryCraft_GetStat("manarestore") ~= 0 then
364 TheoryCraftAddMod("Mana Restore", TheoryCraft_GetStat("manarestore"))
365 end
366 UpdateCustomOutfit()
367 end
368  
369 function TheoryCraft_Combo1Click()
370 local optionID = this:GetID()
371 UIDropDownMenu_SetSelectedID(TheoryCrafttryfirst, optionID)
372 TheoryCraft_Settings["tryfirst"] = this.value
373 TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
374 end
375  
376 function TheoryCraft_Combo2Click()
377 local optionID = this:GetID()
378 UIDropDownMenu_SetSelectedID(TheoryCrafttrysecond, optionID)
379 TheoryCraft_Settings["trysecond"] = this.value
380 TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
381 end
382  
383 function TheoryCraft_Combo3Click()
384 local optionID = this:GetID()
385 UIDropDownMenu_SetSelectedID(TheoryCrafttryfirstsfg, optionID)
386 TheoryCraft_Settings["tryfirstsfg"] = this.value
387 TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
388 end
389  
390 function TheoryCraft_Combo4Click()
391 local optionID = this:GetID()
392 UIDropDownMenu_SetSelectedID(TheoryCrafttrysecondsfg, optionID)
393 TheoryCraft_Settings["trysecondsfg"] = this.value
394 TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
395 end
396  
397 function TheoryCraft_OutfitClick()
398 UIDropDownMenu_SetSelectedID(TheoryCraftoutfit, this:GetID())
399 TheoryCraft_Data["outfit"] = this.value
400 if this.value == 2 then
401 TheoryCraftCustomOutfit:Show()
402 else
403 TheoryCraftCustomOutfit:Hide()
404 end
405 TheoryCraft_UpdateGear("player", true)
406 TheoryCraft_LoadStats()
407 TheoryCraft_GenerateAll()
408 end
409  
410 local info = {}
411  
412 local function AddButton(i, text, value, func, remaining)
413 TheoryCraft_DeleteTable(info)
414 info.remaining = true
415 info.text = text
416 info.value = value
417 info.func = func
418 UIDropDownMenu_AddButton(info)
419 if (func == TheoryCraft_Combo1Click) and (TheoryCraft_Settings["tryfirst"] == value) then
420 UIDropDownMenu_SetSelectedID(TheoryCrafttryfirst, i)
421 end
422 if (func == TheoryCraft_Combo2Click) and (TheoryCraft_Settings["trysecond"] == value) then
423 UIDropDownMenu_SetSelectedID(TheoryCrafttrysecond, i)
424 end
425 if (func == TheoryCraft_Combo3Click) and (TheoryCraft_Settings["tryfirstsfg"] == value) then
426 UIDropDownMenu_SetSelectedID(TheoryCrafttryfirstsfg, i)
427 end
428 if (func == TheoryCraft_Combo4Click) and (TheoryCraft_Settings["trysecondsfg"] == value) then
429 UIDropDownMenu_SetSelectedID(TheoryCrafttrysecondsfg, i)
430 end
431 if (func == TheoryCraft_OutfitClick) and ((TheoryCraft_Data["outfit"] == value) or ((TheoryCraft_Data["outfit"] == nil) and (value == 1))) then
432 UIDropDownMenu_SetSelectedID(TheoryCraftoutfit, i)
433 end
434 return i + 1
435 end
436  
437 function TheoryCraft_InitDropDown()
438 local a
439 local i = 1
440 if string.find(this:GetName(), "TheoryCraftoutfit") then
441 for k, v in pairs(TheoryCraft_Outfits) do
442 if ((v.class == nil) or (class == v.class)) then
443 i = AddButton(i, (v.shortname or v.name), k, TheoryCraft_OutfitClick)
444 end
445 end
446 return
447 end
448 if string.find(this:GetName(), "sfg") then
449 if string.find(this:GetName(), "TheoryCrafttryfirst") then
450 a = TheoryCraft_Combo3Click
451 else
452 a = TheoryCraft_Combo4Click
453 end
454 i = AddButton(i, "0.01", 2, a)
455 i = AddButton(i, "0.1", 1, a)
456 i = AddButton(i, "1", 0, a)
457 i = AddButton(i, "10", -1, a)
458 i = AddButton(i, "100", -2, a)
459 i = AddButton(i, "1000", -3, a)
460 return
461 end
462 if string.find(this:GetName(), "TheoryCrafttryfirst") then
463 a = TheoryCraft_Combo1Click
464 else
465 a = TheoryCraft_Combo2Click
466 end
467 i = AddButton(i, "Do Nothing", "donothing", a)
468 i = AddButton(i, "Min Damage", "mindamage", a)
469 i = AddButton(i, "Max Damage", "maxdamage", a)
470 i = AddButton(i, "Average Damage", "averagedam", a)
471 i = AddButton(i, "Ave Dam (no crits)", "averagedamnocrit", a)
472 i = AddButton(i, "DPS", "dps", a)
473 i = AddButton(i, "With Dot DPS", "withdotdps", a)
474 i = AddButton(i, "DPM", "dpm", a)
475 i = AddButton(i, "Total Damage", "maxoomdamfloored", a)
476 i = AddButton(i, "Total Damage (left)", "maxoomdamremaining", a)
477 i = AddButton(i, "Min Heal", "minheal", a)
478 i = AddButton(i, "Max Heal", "maxheal", a)
479 i = AddButton(i, "Average Heal", "averageheal", a)
480 i = AddButton(i, "Ave Heal (no crits)", "averagehealnocrit", a)
481 i = AddButton(i, "HPS", "hps", a)
482 i = AddButton(i, "With Hot HPS", "withhothps", a)
483 i = AddButton(i, "HPM", "hpm", a)
484 i = AddButton(i, "Total Healing", "maxoomhealfloored", a)
485 i = AddButton(i, "Total Healing (left)", "maxoomhealremaining", a)
486 i = AddButton(i, "Spellcasts remaining", "spellcasts", a)
487 end
488  
489 function TheoryCraft_SetTalent(arg1)
490 local name = this:GetName()
491 local i = 1
492 local i2 = tonumber(string.sub(name, 18, 18))
493 local numberneeded = tonumber(string.sub(name, 19, 19))
494 local number = 1
495 local newrank = 0
496 local _, currank, maxRank
497 number = 1
498 while (TheoryCraft_Talents[i]) do
499 if (class == TheoryCraft_Talents[i].class) and (TheoryCraft_Talents[i].dontlist == nil) and (((TheoryCraft_Talents[i].tree == i2) and (TheoryCraft_Talents[i].forcetree == nil)) or (TheoryCraft_Talents[i].forcetree == i2)) then
500 if (number == numberneeded) then
501 nameneeded = TheoryCraft_Talents[i].name
502 _, _, _, _, currank, maxRank= GetTalentInfo(TheoryCraft_Talents[i].tree, TheoryCraft_Talents[i].number)
503 if (TheoryCraft_Talents[i].forceto == nil) or (TheoryCraft_Talents[i].forceto == -1) then
504 newrank = currank + 1
505 else
506 newrank = TheoryCraft_Talents[i].forceto + 1
507 end
508 if newrank > maxRank then
509 newrank = 0
510 end
511 break
512 end
513 number = number + 1
514 end
515 i = i+1
516 end
517 i = 1
518 while (TheoryCraft_Talents[i]) do
519 if (class == TheoryCraft_Talents[i].class) then
520 if (TheoryCraft_Talents[i].name == nameneeded) then
521 TheoryCraft_Talents[i].forceto = newrank
522 end
523 end
524 i = i+1
525 end
526 TheoryCraft_UpdateTalents()
527 end
528  
529 function TheoryCraft_UpdateButtonTextPos()
530 TheoryCraft_Settings["buttontextx"] = (this:GetParent():GetLeft()-this:GetLeft())/3
531 TheoryCraft_Settings["buttontexty"] = (this:GetParent():GetTop()-this:GetTop())/3
532 TheoryCraftdummytext:GetParent():ClearAllPoints()
533 TheoryCraftdummytext:GetParent():SetPoint("TOPLEFT", TheoryCraftdummytext:GetParent():GetParent(), "TOPLEFT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
534 TheoryCraftdummytext:GetParent():SetPoint("BOTTOMRIGHT", TheoryCraftdummytext:GetParent():GetParent(), "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
535 end
536  
537 function TheoryCraft_UpdateDummyButtonText(dontupdate)
538 if not dontupdate then
539 TheoryCraftFontPath:SetText(TheoryCraft_Settings["FontPath"])
540 TheoryCraftColR:SetText(TheoryCraft_Settings["ColR"]*255)
541 TheoryCraftColG:SetText(TheoryCraft_Settings["ColG"]*255)
542 TheoryCraftColB:SetText(TheoryCraft_Settings["ColB"]*255)
543 TheoryCraftColR2:SetText(TheoryCraft_Settings["ColR2"]*255)
544 TheoryCraftColG2:SetText(TheoryCraft_Settings["ColG2"]*255)
545 TheoryCraftColB2:SetText(TheoryCraft_Settings["ColB2"]*255)
546 TheoryCraftFontSize:SetText(TheoryCraft_Settings["FontSize"])
547 end
548  
549 TheoryCraftdummytext:GetParent():ClearAllPoints()
550 TheoryCraftdummytext:GetParent():SetPoint("TOPLEFT", TheoryCraftdummytext:GetParent():GetParent(), "TOPLEFT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
551 TheoryCraftdummytext:GetParent():SetPoint("BOTTOMRIGHT", TheoryCraftdummytext:GetParent():GetParent(), "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
552  
553 TheoryCraftdummytext:SetFont(TheoryCraft_Settings["FontPath"], TheoryCraft_Settings["FontSize"]*3, "OUTLINE")
554 TheoryCraftdummytext:SetTextColor(TheoryCraft_Settings["ColR"], TheoryCraft_Settings["ColG"], TheoryCraft_Settings["ColB"])
555 TheoryCraftdummytext:SetJustifyV("MIDDLE")
556 if TheoryCraft_Settings["alignleft"] then
557 TheoryCraftdummytext:SetJustifyH("LEFT")
558 elseif TheoryCraft_Settings["alignright"] then
559 TheoryCraftdummytext:SetJustifyH("RIGHT")
560 else
561 TheoryCraftdummytext:SetJustifyH("CENTER")
562 end
563 end
564  
565 local function formattext(a, field, places)
566 if places == nil then
567 places = 0
568 end
569 if (field == "averagedam") or (field == "averageheal") then
570 if TheoryCraft_Settings["dontcrit"] then
571 field = field.."nocrit"
572 end
573 end
574 if a[field] == nil then
575 return nil
576 end
577 if (field == "maxoomdam") or (field == "maxoomdamremaining") or (field == "maxoomdamfloored") or
578 (field == "maxoomheal") or (field == "maxoomhealremaining") or (field == "maxoomhealfloored") then
579 return round(a[field]/1000*10^places)/10^places.."k"
580 end
581 return round(a[field]*10^places)/10^places
582 end
583  
584 function TheoryCraft_GB_Spellbook_UpdatePage(start, finish)
585 TheoryCraft_Data["oldGBMSB"](start, finish)
586 local i2
587 for i = 1,40 do
588 i2 = getglobal("GB_MiniSpellbook_Spell_"..i.."_TCText")
589 if i2 then
590 i2.ID = i+start-1
591 end
592 TheoryCraft_UpdatedButtons["GB_MiniSpellbook_Spell_"..i.."_TCText"] = nil
593 end
594 end
595  
596 function TheoryCraft_ButtonUpdate()
597 if this.oldupdatescript then
598 this.oldupdatescript()
599 end
600 if (TheoryCraft_Settings["framebyframe"] or UnitAffectingCombat("player")) and TheoryCraft_UpdatedThisRound then
601 return
602 end
603 local i = this:GetName().."_TCText"
604 local buttontext = getglobal(i)
605  
606 if (buttontext.fontsize ~= TheoryCraft_Settings["FontSize"]) or
607 (buttontext.fontpath ~= TheoryCraft_Settings["FontPath"]) then
608 buttontext.fontsize = TheoryCraft_Settings["FontSize"]
609 buttontext.fontpath = TheoryCraft_Settings["FontPath"]
610 buttontext:SetFont(TheoryCraft_Settings["FontPath"], buttontext.fontsize, "OUTLINE")
611 end
612 if (buttontext.colr ~= TheoryCraft_Settings["ColR"]) or
613 (buttontext.colg ~= TheoryCraft_Settings["ColG"]) or
614 (buttontext.colb ~= TheoryCraft_Settings["ColB"]) or
615 (buttontext.colr2 ~= TheoryCraft_Settings["ColR2"]) or
616 (buttontext.colg2 ~= TheoryCraft_Settings["ColG2"]) or
617 (buttontext.colb2 ~= TheoryCraft_Settings["ColB2"]) then
618 buttontext.colr = TheoryCraft_Settings["ColR"]
619 buttontext.colg = TheoryCraft_Settings["ColG"]
620 buttontext.colb = TheoryCraft_Settings["ColB"]
621 buttontext.colr2 = TheoryCraft_Settings["ColR2"]
622 buttontext.colg2 = TheoryCraft_Settings["ColG2"]
623 buttontext.colb2 = TheoryCraft_Settings["ColB2"]
624 TheoryCraft_UpdatedButtons[i] = nil
625 end
626 if (buttontext.buttontextx ~= TheoryCraft_Settings["buttontextx"]) or (buttontext.buttontexty ~= TheoryCraft_Settings["buttontexty"]) then
627 buttontext.buttontextx = TheoryCraft_Settings["buttontextx"]
628 buttontext.buttontexty = TheoryCraft_Settings["buttontextx"]
629 buttontext:ClearAllPoints()
630 buttontext:SetPoint("TOPLEFT", this, "TOPLEFT", -TheoryCraft_Settings["buttontextx"], -TheoryCraft_Settings["buttontexty"])
631 buttontext:SetPoint("BOTTOMRIGHT", this, "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"], -TheoryCraft_Settings["buttontexty"])
632 end
633 if (buttontext.align == nil) or
634 ((buttontext.align == 1) and (not TheoryCraft_Settings["alignleft"])) or
635 ((buttontext.align == 2) and (not TheoryCraft_Settings["alignright"])) or
636 ((buttontext.align == 3) and (TheoryCraft_Settings["alignleft"] or TheoryCraft_Settings["alignright"])) then
637 buttontext:SetJustifyV("MIDDLE")
638 if TheoryCraft_Settings["alignleft"] then
639 buttontext.align = 1
640 buttontext:SetJustifyH("LEFT")
641 elseif TheoryCraft_Settings["alignright"] then
642 buttontext.align = 2
643 buttontext:SetJustifyH("RIGHT")
644 else
645 buttontext.align = 3
646 buttontext:SetJustifyH("CENTER")
647 end
648 end
649  
650 if buttontext.type == "Discord" then
651 local actionid = this:GetActionID()
652 if buttontext.actionbutton ~= actionid then
653 TheoryCraft_UpdatedButtons[i] = nil
654 buttontext.actionbutton = actionid
655 end
656 end
657 if TheoryCraft_UpdatedButtons[i] then
658 if TheoryCraft_Data["reporttimes"] then
659 if TheoryCraft_Settings["framebyframe"] then
660 Print("As TC is set to frame by frame mode, only one tooltip needs to be regenerated per frame.")
661 local timetaken = round(TheoryCraft_Data["timetaken"]*1000)
662 Print("This takes approximately: "..timetaken.." milliseconds. One button will be generated per frame at this speed until all have been regenerated. It will not cause noticeable lag.")
663 else
664 Print("TheoryCraft has to generate: "..TheoryCraft_Data["buttonsgenerated"].." tooltips whenever you or your target change in a way that'll modify at least one tooltip.")
665 local timetaken = round(TheoryCraft_Data["timetaken"]*1000)
666 Print("This takes approximately: "..timetaken.." milliseconds. Keep in mind that WoW's timer is only accurate to 1ms, making this not entirely reliable.")
667 if tonumber(timetaken) < 50 then
668 Print("This will *not* result in noticeable frame skip, so it would be best to leave frame by frame disabled.")
669 else
670 Print("This will result in noticeable frame skip, and so you may want to consider setting TC to frame by frame mode. This mode is enabled by default whilst in combat. Alternatively you could reduce the number of buttons showing button text.")
671 end
672 end
673 TheoryCraft_Data["reporttimes"] = nil
674 end
675 return
676 else
677 TheoryCraft_UpdatedThisRound = true
678 -- Counter = (Counter or 0) + 1
679 -- Print(Counter)
680 TheoryCraft_UpdatedButtons[i] = true
681 if not TheoryCraft_Settings["buttontext"] then
682 buttontext:Hide()
683 return
684 end
685  
686 local tryfirst, trysecond, spelldata
687 if buttontext.type == "SpellBook" then
688 local id = getglobal(this:GetName().."SpellName"):GetText()
689 local id2 = getglobal(this:GetName().."SubSpellName"):GetText()
690 if (not (getglobal(this:GetName().."SpellName"):IsShown())) or (id == nil) then
691 buttontext:Hide()
692 id = nil
693 end
694 if id then
695 id2 = tonumber(findpattern(id2, "%d+"))
696 if id2 == nil then id2 = 0 end
697 spelldata = TheoryCraft_GetSpellDataByName(id, id2)
698 end
699 elseif buttontext.type == "GBMiniSpellBook" then
700 local spellname, spellrank = GetSpellName(buttontext.ID, "BOOKTYPE_SPELL");
701 if spellname then
702 spellrank = tonumber(findpattern(spellrank, "%d+"))
703 if spellrank == nil then spellrank = 0 end
704 spelldata = TheoryCraft_GetSpellDataByName(spellname, spellrank)
705 end
706 elseif buttontext.type == "GBButton" then
707 local name = GB_Settings[GB_INDEX][buttontext:GetParent():GetParent().index].Button[buttontext:GetParent():GetID()].name;
708 local rank = GB_Settings[GB_INDEX][buttontext:GetParent():GetParent().index].Button[buttontext:GetParent():GetID()].rank;
709 if name then
710 rank = tonumber(findpattern(rank, "%d+"))
711 if rank == nil then rank = 0 end
712 spelldata = TheoryCraft_GetSpellDataByName(name, rank)
713 end
714 elseif buttontext.type == "Normal" then
715 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
716 TCTooltip:SetAction(buttontext:GetParent():GetID())
717 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
718 elseif buttontext.type == "Flippable" then
719 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
720 TCTooltip:SetAction(buttontext:GetParent():GetID()+(CURRENT_ACTIONBAR_PAGE-1)*NUM_ACTIONBAR_BUTTONS)
721 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
722 elseif buttontext.type == "Special" then
723 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
724 TCTooltip:SetAction(buttontext.specialid)
725 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
726 elseif buttontext.type == "Discord" then
727 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
728 TCTooltip:SetAction(buttontext.actionbutton)
729 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
730 elseif buttontext.type == "Gypsy" then
731 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
732 TCTooltip:SetAction(Gypsy_ActionButton_GetPagedID (this))
733 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
734 elseif buttontext.type == "Bonus" then
735 TCTooltip:SetOwner(UIParent,"ANCHOR_NONE")
736 if ( CURRENT_ACTIONBAR_PAGE==1 ) then
737 TCTooltip:SetAction(this:GetID() + ((NUM_ACTIONBAR_PAGES+GetBonusBarOffset()-1)*NUM_ACTIONBAR_BUTTONS))
738 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
739 else
740 TCTooltip:SetAction(this:GetID() + ((CURRENT_ACTIONBAR_PAGE-1)*NUM_ACTIONBAR_BUTTONS))
741 spelldata = TheoryCraft_GetSpellDataByFrame(TCTooltip)
742 end
743 end
744 if spelldata then
745 tryfirst = formattext(spelldata, TheoryCraft_Settings["tryfirst"], TheoryCraft_Settings["tryfirstsfg"])
746 if tryfirst then
747 buttontext:SetText(tryfirst)
748 buttontext:SetTextColor(buttontext.colr, buttontext.colg, buttontext.colb)
749 buttontext:Show()
750 if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Hide() end
751 if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Hide() end
752 else
753 trysecond = formattext(spelldata, TheoryCraft_Settings["trysecond"], TheoryCraft_Settings["trysecondsfg"])
754 if trysecond then
755 buttontext:SetText(trysecond)
756 buttontext:SetTextColor(buttontext.colr2, buttontext.colg2, buttontext.colb2)
757 if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Hide() end
758 if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Hide() end
759 buttontext:Show()
760 else
761 if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Show() end
762 if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Show() end
763 buttontext:Hide()
764 end
765 end
766 else
767 if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Show() end
768 buttontext:Hide()
769 end
770 end
771 end
772  
773 function TheoryCraft_AddButtonText()
774 local newbutton, oldbutton
775 local setupbutton = TheoryCraft_SetUpButton
776 function TheoryCraft_Nurfed_ActionButton_OnUpdate(elapsed)
777 TheoryCraft_Data["oldNurfed"](elapsed)
778 setupbutton(this:GetName(), "Normal")
779 end
780 if SpellButton1 then
781 for i = 1,12 do setupbutton("SpellButton"..i, "SpellBook") end
782 end
783 if M1BarButton1 then
784 for i = 1,18 do setupbutton("M1BarButton"..i, "Normal") end
785 for i = 1,18 do setupbutton("M2BarButton"..i, "Normal") end
786 for i = 1,18 do setupbutton("M3BarButton"..i, "Normal") end
787 end
788 if DAB_ActionButton_1 then
789 for i = 1,120 do setupbutton("DAB_ActionButton_"..i, "Discord") end
790 end
791 if FlexBarButton1 then
792 for i = 1,120 do setupbutton("FlexBarButton"..i, "Normal") end
793 end
794 if Nurfed_ActionButton1 then
795 for i = 1,120 do setupbutton("Nurfed_ActionButton"..i, "Normal") end
796 end
797 if CT_ActionButton1 then
798 for i = 1,12 do setupbutton("CT_ActionButton"..i, "Special", 12+i) end
799 for i = 1,12 do setupbutton("CT2_ActionButton"..i, "Special", 24+i) end
800 for i = 1,12 do setupbutton("CT3_ActionButton"..i, "Special", 36+i) end
801 for i = 1,12 do setupbutton("CT4_ActionButton"..i, "Special", 48+i) end
802 end
803 if Gypsy_ActionButton1 then
804 for i = 1,12 do setupbutton("Gypsy_ActionButton"..i, "Gypsy") end
805 end
806 if GB_MiniSpellbook_Spell_1 then
807 for i = 1,40 do setupbutton("GB_MiniSpellbook_Spell_"..i, "GBMiniSpellBook") end
808 end
809 if GB_PlayerBar_Button_1 then
810 for i = 1,20 do setupbutton("GB_PlayerBar_Button_"..i, "GBButton") end
811 for i = 1,20 do setupbutton("GB_PartyBar1_Button_"..i, "GBButton") end
812 for i = 1,20 do setupbutton("GB_PartyBar2_Button_"..i, "GBButton") end
813 for i = 1,20 do setupbutton("GB_PartyBar3_Button_"..i, "GBButton") end
814 for i = 1,20 do setupbutton("GB_PartyBar4_Button_"..i, "GBButton") end
815 for i = 1,20 do setupbutton("GB_FriendlyTargetBar_Button_"..i, "GBButton") end
816 for i = 1,20 do setupbutton("GB_HostileTargetBar_Button_"..i, "GBButton") end
817 for i = 1,20 do setupbutton("GB_LowestHealthBar_Button_"..i, "GBButton") end
818 for i = 1,6 do setupbutton("GB_RaidBar_Button_"..i, "GBButton") end
819 end
820 if ActionButton1 then
821 for i = 1,12 do setupbutton("ActionButton"..i, "Flippable") end
822 for i = 1,12 do setupbutton("MultiBarRightButton"..i, "Special", 24+i) end
823 for i = 1,12 do setupbutton("MultiBarLeftButton"..i, "Special", 36+i) end
824 for i = 1,12 do setupbutton("MultiBarBottomRightButton"..i, "Special", 48+i) end
825 for i = 1,12 do setupbutton("MultiBarBottomLeftButton"..i, "Special", 60+i) end
826 for i = 1,12 do setupbutton("BonusActionButton"..i, "Bonus") end
827 end
828 end