forked from JeffP07/TheorycraftClassic
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTheoryCraftClassicUI.lua
616 lines (567 loc) · 24.7 KB
/
TheoryCraftClassicUI.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
local _TOOLTIPTAB = 1
local _BUTTONTEXTTAB = 2
local _ADVANCEDTAB = 3
--local _MITIGATIONTAB = 4
local _, class = UnitClass("player")
TheoryCraft_NotStripped = true
local function findpattern(text, pattern, start)
if (text and pattern and (string.find(text, pattern, start))) then
return string.sub(text, string.find(text, pattern, start))
else
return ""
end
end
function TheoryCraft_SetUpButton(parentname, type, specialid)
oldbutton = getglobal(parentname)
if not oldbutton then return nil end
newbutton = getglobal(parentname.."_TCText")
if newbutton and newbutton.type then
return newbutton
end
oldbutton:CreateFontString(parentname.."_TCText", "ARTWORK");
newbutton = getglobal(parentname.."_TCText")
newbutton:SetFont("Fonts\\ARIALN.TTF", 12, "OUTLINE")
newbutton:SetPoint("TOPLEFT", oldbutton, "TOPLEFT", 0, 0)
newbutton:SetPoint("BOTTOMRIGHT", oldbutton, "BOTTOMRIGHT", 0, 0)
newbutton.type = type
newbutton.specialid = specialid
newbutton:SetText("0")
newbutton:Show()
return newbutton
end
local function round(arg1, decplaces)
if (decplaces == nil) then decplaces = 0 end
if arg1 == nil then arg1 = 0 end
return string.format ("%."..decplaces.."f", arg1)
end
local function AddMods(mult, mod, all, healing, damage, school, prefix, suffix, pre2)
local tmp = TheoryCraft_GetStat("All"..mod)*mult
if tmp ~= 0 then
if all ~= "DONT" then
TheoryCraftAddMod(all, prefix..tmp..suffix)
end
end
tmp = TheoryCraft_GetStat("Healing"..mod)*mult
if tmp ~= 0 then
TheoryCraftAddMod(healing, prefix..tmp..suffix)
end
tmp = TheoryCraft_GetStat("Damage"..mod)*mult
if tmp ~= 0 then
TheoryCraftAddMod(damage, prefix..tmp..suffix)
end
if pre2 == nil then pre2 = "" end
for k,v in pairs(TheoryCraft_PrimarySchools) do
tmp = TheoryCraft_GetStat(v.name..mod)*mult
if tmp ~= 0 then
TheoryCraftAddMod(pre2..v.name..school, prefix..tmp..suffix)
end
end
end
function TheoryCraft_TabHandler(name)
--local name = self:GetName()
name = tonumber(string.sub(name, 15))
TheoryCraftSettingsTab:Hide()
TheoryCraftCustomOutfit:Hide()
TheoryCraftOutfitTab:Hide()
TheoryCraftButtonTextTab:Hide()
TheoryCraftCustomOutfit:Hide()
-- TheoryCraftMitigationTab:Hide()
if (name == _TOOLTIPTAB) then
TheoryCraftSettingsTab:Show()
elseif (name == _BUTTONTEXTTAB) then
TheoryCraftButtonTextTab:Show()
elseif (name == _ADVANCEDTAB) then
TheoryCraftOutfitTab:Show()
TheoryCraft_UpdateOutfitTab()
-- elseif (name == _MITIGATIONTAB) then
-- TheoryCraftMitigationTab:Show()
end
end
function TheoryCraft_UpdateOutfitTab()
if not TheoryCraftOutfitTab:IsVisible() then
return
end
local i = 1
local i2 = 1
while i < 4 do
i2 = 1
getglobal("TheoryCraftTalentTree"..i):SetText(" ")
while getglobal("TheoryCraftTalent"..i..i2) do
getglobal("TheoryCraftTalent"..i..i2):Hide()
i2 = i2+1
end
i = i+1
end
i2 = 1
local number
local title, rank, i3, _, currank
local highestnumber = 0
while i2 < 4 do
i = 1
number = 1
while (TheoryCraft_Talents[i]) do
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
title = getglobal("TheoryCraftTalentTree"..i2)
rank = getglobal("TheoryCraftTalent"..i2..number)
i3 = 1
while (TheoryCraft_Locale.TalentTranslator[i3]) and (TheoryCraft_Locale.TalentTranslator[i3].id ~= TheoryCraft_Talents[i].name) do
i3 = i3 + 1
end
if (TheoryCraft_Locale.TalentTranslator[i3]) and (rank ~= nil) then
title:SetText(title:GetText()..TheoryCraft_Locale.TalentTranslator[i3].translated.."\n")
_, _, _, _, currank = GetTalentInfo(TheoryCraft_Talents[i].tree, TheoryCraft_Talents[i].number)
if ((TheoryCraft_Talents[i].forceto == nil) or (TheoryCraft_Talents[i].forceto == -1)) then
rank:SetText(currank)
else
rank:SetText(TheoryCraft_Talents[i].forceto)
end
rank:SetNormalTexture(nil)
rank:SetPushedTexture(nil)
rank:SetHighlightTexture(nil)
if (TheoryCraft_Talents[i].forceto) and (TheoryCraft_Talents[i].forceto ~= -1) and (TheoryCraft_Talents[i].forceto ~= currank) then
rank:SetTextColor(1,1,0.1)
else
rank:SetTextColor(0.1,1,0.1)
end
rank:Show()
number = number + 1
end
end
i = i+1
end
if highestnumber < number then highestnumber = number end
i2 = i2 + 1
end
TheoryCraftTalentTitle:SetPoint("BOTTOMLEFT", TheoryCraftOutfitTab, "BOTTOMLEFT", 20, 42+10*highestnumber)
TheoryCraftVitalsLeft:SetText()
TheoryCraftVitalsRight:SetText()
TheoryCraftVitalsLeft:SetHeight(2)
TheoryCraftVitalsRight:SetHeight(2)
TheoryCraftStatsLeft:SetText()
TheoryCraftStatsRight:SetText()
TheoryCraftStatsLeft:SetHeight(2)
TheoryCraftStatsRight:SetHeight(2)
TheoryCraftModsLeft:SetText()
TheoryCraftModsRight:SetText()
TheoryCraftModsLeft:SetHeight(2)
TheoryCraftModsRight:SetHeight(2)
local totalmana = TheoryCraft_GetStat("totalmana")+TheoryCraft_GetStat("manarestore")
TheoryCraftAddVital("Health", math.floor(TheoryCraft_GetStat("totalhealth")))
if class == "HUNTER" then
TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
TheoryCraftAddVital("Ranged Attack Power", math.floor(TheoryCraft_GetStat("rangedattackpower")))
TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
TheoryCraftAddVital("Ranged Crit Chance", round(TheoryCraft_GetStat("rangedcritchance"), 2).."%")
TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
elseif (class == "ROGUE") or (class == "WARRIOR") then
TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
elseif (class == "PALADIN") then
TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
elseif (class == "DRUID") then
if UnitManaMax("player") == 100 then
TheoryCraftAddVital("Attack Power", math.floor(TheoryCraft_GetStat("attackpower")))
TheoryCraftAddVital("Crit Chance", round(TheoryCraft_GetStat("meleecritchancereal"), 2).."%")
TheoryCraftAddVital("Agi per Crit", round(TheoryCraft_agipercrit, 2))
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Strength", math.floor(TheoryCraft_GetStat("strength")))
TheoryCraftAddStat("Agility", math.floor(TheoryCraft_GetStat("agility")))
else
TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
end
else
TheoryCraftAddVital("Mana", math.floor(TheoryCraft_GetStat("totalmana")))
TheoryCraftAddVital("Normal Regen", round(TheoryCraft_Data.Stats["regen"]*2, 2).." / Tick")
TheoryCraftAddVital("Regen Whilst Casting", round(TheoryCraft_Data.Stats["icregen"]*2, 2).." / Tick")
TheoryCraftAddStat("Stamina", math.floor(TheoryCraft_GetStat("stamina")))
TheoryCraftAddStat("Intellect", math.floor(TheoryCraft_GetStat("intellect")))
TheoryCraftAddStat("Spirit", math.floor(TheoryCraft_GetStat("spirit")))
end
TheoryCraftModsLeft:SetHeight(288-TheoryCraftStatsLeft:GetHeight()-TheoryCraftVitalsLeft:GetHeight()-10*highestnumber)
TheoryCraftModsRight:SetHeight(TheoryCraftModsLeft:GetHeight())
local proceffect
if TheoryCraft_GetStat("FrostboltNetherwind") ~= 0 then
proceffect = 1
end
if TheoryCraft_GetStat("Beastmanarestore") ~= 0 then
proceffect = 1
end
if TheoryCraft_Data.EquipEffects["procs"] then
if TheoryCraft_IsDifferent(TheoryCraft_Data.EquipEffects["procs"], { }) then
proceffect = 1
end
end
if proceffect then
TheoryCraftAddMod("Proc Effect", " ")
end
if TheoryCraft_GetStat("CritReport") ~= 0 then
TheoryCraftAddMod("Crit Chance", "+"..(TheoryCraft_GetStat("CritReport")).."%")
end
if (class ~= "HUNTER") and (class ~= "WARRIOR") and (class ~= "ROGUE") then
if TheoryCraft_GetStat("Allcritchance") ~= 0 then
TheoryCraftAddMod("Spell Crit Chance", round(TheoryCraft_Data.Stats["critchance"], 2).."% + "..(TheoryCraft_GetStat("Allcritchance")).."%")
else
TheoryCraftAddMod("Spell Crit Chance", round(TheoryCraft_Data.Stats["critchance"], 2).."%")
end
end
AddMods(1, "critchance", "DONT", "Heal Crit Chance", "Damage Spell Crit Chance", " Crit Chance", "+", "%")
AddMods(1, "", "+Damage and Healing", "+Healing", "+Spell Damage", " Damage", "", "", "+")
if TheoryCraft_GetStat("Undead") ~= 0 then
TheoryCraftAddMod("+Damage to Undead", TheoryCraft_GetStat("Undead"))
end
if TheoryCraft_GetStat("AttackPowerReport") ~= 0 then
TheoryCraftAddMod("Attack Power", "+"..(TheoryCraft_GetStat("AttackPowerReport")))
end
if TheoryCraft_GetStat("RangedAttackPowerReport") ~= 0 then
TheoryCraftAddMod("Ranged Attack Power", "+"..(TheoryCraft_GetStat("RangedAttackPowerReport")))
end
if TheoryCraft_GetStat("BlockValueReport") ~= 0 then
TheoryCraftAddMod("Shield Block Value", TheoryCraft_GetStat("BlockValueReport"))
end
AddMods(1, "hitchance", "Spell Hit Chance", "", "Damage Spell Hit Chance", " Hit Chance", "+", "%")
if TheoryCraft_GetStat("Meleehitchance") ~= 0 then
TheoryCraftAddMod("Hit Chance", "+"..(TheoryCraft_GetStat("Meleehitchance")).."%")
end
AddMods(1, "penetration", "Spell Penetration", "", "Damage Spell Penetration", " Penetration", "", "")
if TheoryCraft_GetStat("manaperfive") ~= 0 then
TheoryCraftAddMod("Mana Per Five", TheoryCraft_GetStat("manaperfive"))
end
if TheoryCraft_GetStat("ICPercent") ~= 0 then
TheoryCraftAddMod("Spirit In 5 Rule", (TheoryCraft_GetStat("ICPercent")*100).."%")
end
if TheoryCraft_GetStat("manarestore") ~= 0 then
TheoryCraftAddMod("Mana Restore", TheoryCraft_GetStat("manarestore"))
end
UpdateCustomOutfit()
end
function TheoryCraft_Combo1Click(self)
local optionID = self:GetID()
UIDropDownMenu_SetSelectedID(TheoryCrafttryfirst, optionID)
TheoryCraft_Settings["tryfirst"] = self.value
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
function TheoryCraft_Combo2Click(self)
local optionID = self:GetID()
UIDropDownMenu_SetSelectedID(TheoryCrafttrysecond, optionID)
TheoryCraft_Settings["trysecond"] = self.value
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
function TheoryCraft_Combo3Click(self)
local optionID = self:GetID()
UIDropDownMenu_SetSelectedID(TheoryCrafttryfirstsfg, optionID)
TheoryCraft_Settings["tryfirstsfg"] = self.value
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
function TheoryCraft_Combo4Click(self)
local optionID = self:GetID()
UIDropDownMenu_SetSelectedID(TheoryCrafttrysecondsfg, optionID)
TheoryCraft_Settings["trysecondsfg"] = self.value
TheoryCraft_DeleteTable(TheoryCraft_UpdatedButtons)
end
local info = {}
local function AddButton(i, text, value, func, remaining)
TheoryCraft_DeleteTable(info)
info.remaining = true
info.text = text
info.value = value
info.func = func
UIDropDownMenu_AddButton(info)
if (func == TheoryCraft_Combo1Click) and (TheoryCraft_Settings["tryfirst"] == value) then
UIDropDownMenu_SetSelectedID(TheoryCrafttryfirst, i)
end
if (func == TheoryCraft_Combo2Click) and (TheoryCraft_Settings["trysecond"] == value) then
UIDropDownMenu_SetSelectedID(TheoryCrafttrysecond, i)
end
if (func == TheoryCraft_Combo3Click) and (TheoryCraft_Settings["tryfirstsfg"] == value) then
UIDropDownMenu_SetSelectedID(TheoryCrafttryfirstsfg, i)
end
if (func == TheoryCraft_Combo4Click) and (TheoryCraft_Settings["trysecondsfg"] == value) then
UIDropDownMenu_SetSelectedID(TheoryCrafttrysecondsfg, i)
end
if (func == TheoryCraft_OutfitClick) and ((TheoryCraft_Data["outfit"] == value) or ((TheoryCraft_Data["outfit"] == nil) and (value == 1))) then
UIDropDownMenu_SetSelectedID(TheoryCraftoutfit, i)
end
return i + 1
end
function TheoryCraft_InitDropDown(this)
local a
local i = 1
if string.find(this:GetName(), "TheoryCraftoutfit") then
for k, v in pairs(TheoryCraft_Outfits) do
if ((v.class == nil) or (class == v.class)) then
i = AddButton(i, (v.shortname or v.name), k, TheoryCraft_OutfitClick)
end
end
return
end
if string.find(this:GetName(), "sfg") then
if string.find(this:GetName(), "TheoryCrafttryfirst") then
a = TheoryCraft_Combo3Click
else
a = TheoryCraft_Combo4Click
end
i = AddButton(i, "0.01", 2, a)
i = AddButton(i, "0.1", 1, a)
i = AddButton(i, "1", 0, a)
i = AddButton(i, "10", -1, a)
i = AddButton(i, "100", -2, a)
i = AddButton(i, "1000", -3, a)
return
end
if string.find(this:GetName(), "TheoryCrafttryfirst") then
a = TheoryCraft_Combo1Click
else
a = TheoryCraft_Combo2Click
end
i = AddButton(i, "Do Nothing", "donothing", a)
i = AddButton(i, "Min Damage", "mindamage", a)
i = AddButton(i, "Max Damage", "maxdamage", a)
i = AddButton(i, "Average Damage", "averagedam", a)
i = AddButton(i, "Ave Dam (no crits)", "averagedamnocrit", a)
i = AddButton(i, "DPS", "dps", a)
i = AddButton(i, "With Dot DPS", "withdotdps", a)
i = AddButton(i, "DPM", "dpm", a)
i = AddButton(i, "Total Damage", "maxoomdamfloored", a)
i = AddButton(i, "Total Damage (left)", "maxoomdamremaining", a)
i = AddButton(i, "Min Heal", "minheal", a)
i = AddButton(i, "Max Heal", "maxheal", a)
i = AddButton(i, "Average Heal", "averageheal", a)
i = AddButton(i, "Ave Heal (no crits)", "averagehealnocrit", a)
i = AddButton(i, "HPS", "hps", a)
i = AddButton(i, "With Hot HPS", "withhothps", a)
i = AddButton(i, "HPM", "hpm", a)
i = AddButton(i, "Total Healing", "maxoomhealfloored", a)
i = AddButton(i, "Total Healing (left)", "maxoomhealremaining", a)
i = AddButton(i, "Spellcasts remaining", "spellcasts", a)
end
function TheoryCraft_UpdateButtonTextPos(this)
TheoryCraft_Settings["buttontextx"] = (this:GetParent():GetLeft()-this:GetLeft())/3
TheoryCraft_Settings["buttontexty"] = (this:GetParent():GetTop()-this:GetTop())/3
TheoryCraftdummytext:GetParent():ClearAllPoints()
TheoryCraftdummytext:GetParent():SetPoint("TOPLEFT", TheoryCraftdummytext:GetParent():GetParent(), "TOPLEFT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
TheoryCraftdummytext:GetParent():SetPoint("BOTTOMRIGHT", TheoryCraftdummytext:GetParent():GetParent(), "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
end
function TheoryCraft_UpdateDummyButtonText(dontupdate)
if not dontupdate then
TheoryCraftFontPath:SetText(TheoryCraft_Settings["FontPath"])
TheoryCraftColR:SetText(TheoryCraft_Settings["ColR"]*255)
TheoryCraftColG:SetText(TheoryCraft_Settings["ColG"]*255)
TheoryCraftColB:SetText(TheoryCraft_Settings["ColB"]*255)
TheoryCraftColR2:SetText(TheoryCraft_Settings["ColR2"]*255)
TheoryCraftColG2:SetText(TheoryCraft_Settings["ColG2"]*255)
TheoryCraftColB2:SetText(TheoryCraft_Settings["ColB2"]*255)
TheoryCraftFontSize:SetText(TheoryCraft_Settings["FontSize"])
end
TheoryCraftdummytext:GetParent():ClearAllPoints()
TheoryCraftdummytext:GetParent():SetPoint("TOPLEFT", TheoryCraftdummytext:GetParent():GetParent(), "TOPLEFT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
TheoryCraftdummytext:GetParent():SetPoint("BOTTOMRIGHT", TheoryCraftdummytext:GetParent():GetParent(), "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"]*3, -TheoryCraft_Settings["buttontexty"]*3)
TheoryCraftdummytext:SetFont(TheoryCraft_Settings["FontPath"], TheoryCraft_Settings["FontSize"]*3, "OUTLINE")
TheoryCraftdummytext:SetTextColor(TheoryCraft_Settings["ColR"], TheoryCraft_Settings["ColG"], TheoryCraft_Settings["ColB"])
TheoryCraftdummytext:SetJustifyV("MIDDLE")
if TheoryCraft_Settings["alignleft"] then
TheoryCraftdummytext:SetJustifyH("LEFT")
elseif TheoryCraft_Settings["alignright"] then
TheoryCraftdummytext:SetJustifyH("RIGHT")
else
TheoryCraftdummytext:SetJustifyH("CENTER")
end
end
local function formattext(a, field, places)
if places == nil then
places = 0
end
if (field == "averagedam") or (field == "averageheal") then
if TheoryCraft_Settings["dontcrit"] then
field = field.."nocrit"
end
end
if a[field] == nil then
return nil
end
if (field == "maxoomdam") or (field == "maxoomdamremaining") or (field == "maxoomdamfloored") or
(field == "maxoomheal") or (field == "maxoomhealremaining") or (field == "maxoomhealfloored") then
return round(a[field]/1000*10^places)/10^places.."k"
end
return round(a[field]*10^places)/10^places
end
function TheoryCraft_AddButtonText(...)
local newbutton, oldbutton
local setupbutton = TheoryCraft_SetUpButton
if SpellButton1 then
for i = 1,12 do setupbutton("SpellButton"..i, "SpellBook") end
end
if ActionButton1 then
for i = 1,12 do setupbutton("ActionButton"..i, "Flippable") end
for i = 1,12 do setupbutton("MultiBarRightButton"..i, "Special", 24+i) end
for i = 1,12 do setupbutton("MultiBarLeftButton"..i, "Special", 36+i) end
for i = 1,12 do setupbutton("MultiBarBottomRightButton"..i, "Special", 48+i) end
for i = 1,12 do setupbutton("MultiBarBottomLeftButton"..i, "Special", 60+i) end
for i = 1,12 do setupbutton("BonusActionButton"..i, "Bonus") end
end
end
function TheoryCraft_UpdateAllButtonText(...)
if not TheoryCraft_Data.TalentsHaveBeenRead then
return
end
local newbutton, oldbutton
local updatebutton = function(name)
local button = getglobal(name)
if button then
TheoryCraft_ButtonUpdate(button)
end
end
if SpellButton1 then
for i = 1,12 do updatebutton("SpellButton"..i, "SpellBook") end
end
if ActionButton1 then
for i = 1,12 do updatebutton("ActionButton"..i, "Flippable") end
for i = 1,12 do updatebutton("MultiBarRightButton"..i, "Special", 24+i) end
for i = 1,12 do updatebutton("MultiBarLeftButton"..i, "Special", 36+i) end
for i = 1,12 do updatebutton("MultiBarBottomRightButton"..i, "Special", 48+i) end
for i = 1,12 do updatebutton("MultiBarBottomLeftButton"..i, "Special", 60+i) end
for i = 1,12 do updatebutton("BonusActionButton"..i, "Bonus") end
end
if _G['Bartender4'] ~= nil then
for i = 1,120 do updatebutton("BT4Button"..i, "Normal") end
end
end
hooksecurefunc("ChangeActionBarPage", function(i)
CURRENT_ACTIONBAR_PAGE = i
TheoryCraft_UpdateAllButtonText()
end)
hooksecurefunc("ActionButton_Update", function(button)
TheoryCraft_ButtonUpdate(button)
end)
hooksecurefunc("SpellBookFrame_UpdateSpells", function(i)
TheoryCraft_UpdateAllButtonText()
end)
function TheoryCraft_ButtonUpdate(this, ...)
if not TheoryCraft_Data.TalentsHaveBeenRead then
return
end
local i = this:GetName().."_TCText"
local buttontext = getglobal(i)
if not buttontext then
return
end
if not buttontext then return end
if (buttontext.fontsize ~= TheoryCraft_Settings["FontSize"]) or
(buttontext.fontpath ~= TheoryCraft_Settings["FontPath"]) then
buttontext.fontsize = TheoryCraft_Settings["FontSize"]
buttontext.fontpath = TheoryCraft_Settings["FontPath"]
buttontext:SetFont(TheoryCraft_Settings["FontPath"], buttontext.fontsize, "OUTLINE")
end
if (buttontext.colr ~= TheoryCraft_Settings["ColR"]) or
(buttontext.colg ~= TheoryCraft_Settings["ColG"]) or
(buttontext.colb ~= TheoryCraft_Settings["ColB"]) or
(buttontext.colr2 ~= TheoryCraft_Settings["ColR2"]) or
(buttontext.colg2 ~= TheoryCraft_Settings["ColG2"]) or
(buttontext.colb2 ~= TheoryCraft_Settings["ColB2"]) then
buttontext.colr = TheoryCraft_Settings["ColR"]
buttontext.colg = TheoryCraft_Settings["ColG"]
buttontext.colb = TheoryCraft_Settings["ColB"]
buttontext.colr2 = TheoryCraft_Settings["ColR2"]
buttontext.colg2 = TheoryCraft_Settings["ColG2"]
buttontext.colb2 = TheoryCraft_Settings["ColB2"]
end
if (buttontext.buttontextx ~= TheoryCraft_Settings["buttontextx"]) or (buttontext.buttontexty ~= TheoryCraft_Settings["buttontexty"]) then
buttontext.buttontextx = TheoryCraft_Settings["buttontextx"]
buttontext.buttontexty = TheoryCraft_Settings["buttontextx"]
buttontext:ClearAllPoints()
buttontext:SetPoint("TOPLEFT", this, "TOPLEFT", -TheoryCraft_Settings["buttontextx"], -TheoryCraft_Settings["buttontexty"])
buttontext:SetPoint("BOTTOMRIGHT", this, "BOTTOMRIGHT", -TheoryCraft_Settings["buttontextx"], -TheoryCraft_Settings["buttontexty"])
end
if (buttontext.align == nil) or
((buttontext.align == 1) and (not TheoryCraft_Settings["alignleft"])) or
((buttontext.align == 2) and (not TheoryCraft_Settings["alignright"])) or
((buttontext.align == 3) and (TheoryCraft_Settings["alignleft"] or TheoryCraft_Settings["alignright"])) then
buttontext:SetJustifyV("MIDDLE")
if TheoryCraft_Settings["alignleft"] then
buttontext.align = 1
buttontext:SetJustifyH("LEFT")
elseif TheoryCraft_Settings["alignright"] then
buttontext.align = 2
buttontext:SetJustifyH("RIGHT")
else
buttontext.align = 3
buttontext:SetJustifyH("CENTER")
end
end
if not TheoryCraft_Settings["buttontext"] then
buttontext:Hide()
return
end
-- Try to find the spell data lookup by the spell we have on the button
local tryfirst, trysecond, spelldata
if buttontext.type == "SpellBook" then
local icon = getglobal(this:GetName().."SpellName")
local id = icon:GetText()
local id2 = getglobal(this:GetName().."SubSpellName"):GetText()
if (not icon:IsShown() or not (getglobal(this:GetName().."SpellName"):IsShown())) or (id == nil) then
buttontext:Hide()
id = nil
end
if id then
id2 = tonumber(findpattern(id2, "%d+"))
if id2 == nil then id2 = 0 end
spelldata = TheoryCraft_GetSpellDataByName(id, id2)
end
else
local action = this:GetAttribute('action') or this.action
spelldata = TheoryCraft_GetSpellDataByAction(action)
end
-- Must contain some properties to be valid
if spelldata then
tryfirst = formattext(spelldata, TheoryCraft_Settings["tryfirst"], TheoryCraft_Settings["tryfirstsfg"])
if tryfirst then
buttontext:SetText(tryfirst)
buttontext:SetTextColor(buttontext.colr, buttontext.colg, buttontext.colb)
buttontext:Show()
if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Hide() end
if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Hide() end
else
trysecond = formattext(spelldata, TheoryCraft_Settings["trysecond"], TheoryCraft_Settings["trysecondsfg"])
if trysecond then
buttontext:SetText(trysecond)
buttontext:SetTextColor(buttontext.colr2, buttontext.colg2, buttontext.colb2)
if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Hide() end
if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Hide() end
buttontext:Show()
else
if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Show() end
if getglobal(buttontext:GetParent():GetName().."_Rank") then getglobal(buttontext:GetParent():GetName().."_Rank"):Show() end
buttontext:Hide()
end
end
else
if getglobal(this:GetName().."Name") then getglobal(this:GetName().."Name"):Show() end
buttontext:Hide()
end
end