You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

4 years ago
local E, L, V, P, G = unpack(ElvUI)
5 years ago
local DT = E:GetModule('DataTexts')
local strjoin = strjoin
local format = format
5 years ago
local GetMasteryEffect = GetMasteryEffect
local GetCombatRating = GetCombatRating
local GetCombatRatingBonus = GetCombatRatingBonus
5 years ago
local GetSpecialization = GetSpecialization
local GetSpecializationMasterySpells = GetSpecializationMasterySpells
local BreakUpLargeNumbers = BreakUpLargeNumbers
5 years ago
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
local STAT_MASTERY = STAT_MASTERY
local CreateBaseTooltipInfo = CreateBaseTooltipInfo
local CR_MASTERY = CR_MASTERY
5 years ago
local displayString, db = ''
5 years ago
local function OnEnter()
DT.tooltip:ClearLines()
local primaryTalentTree = GetSpecialization()
if primaryTalentTree then
local masterySpell, masterySpell2 = GetSpecializationMasterySpells(primaryTalentTree)
if masterySpell then
if CreateBaseTooltipInfo then
local tooltipInfo = CreateBaseTooltipInfo('GetSpellByID', masterySpell)
tooltipInfo.append = true
DT.tooltip:ProcessInfo(tooltipInfo)
else
DT.tooltip:AddSpellByID(masterySpell)
end
5 years ago
end
5 years ago
if masterySpell2 then
DT.tooltip:AddLine(' ')
if CreateBaseTooltipInfo then
local tooltipInfo = CreateBaseTooltipInfo('GetSpellByID', masterySpell2)
tooltipInfo.append = true
DT.tooltip:ProcessInfo(tooltipInfo)
else
DT.tooltip:AddSpellByID(masterySpell2)
end
5 years ago
end
local _, bonusCoeff = GetMasteryEffect()
local masteryBonus = (GetCombatRatingBonus(CR_MASTERY) or 0) * (bonusCoeff or 0)
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine(format('%s: %s [+%.2f%%]', STAT_MASTERY, BreakUpLargeNumbers(GetCombatRating(CR_MASTERY) or 0), masteryBonus))
5 years ago
DT.tooltip:Show()
end
end
local function OnEvent(self)
local masteryRating = GetMasteryEffect()
if db.NoLabel then
5 years ago
self.text:SetFormattedText(displayString, masteryRating)
else
self.text:SetFormattedText(displayString, db.Label ~= '' and db.Label or STAT_MASTERY..': ', masteryRating)
5 years ago
end
end
local function ApplySettings(self, hex)
if not db then
db = E.global.datatexts.settings[self.name]
end
5 years ago
displayString = strjoin('', db.NoLabel and '' or '%s', hex, '%.'..db.decimalLength..'f%%|r')
5 years ago
end
DT:RegisterDatatext('Mastery', STAT_CATEGORY_ENHANCEMENTS, {'MASTERY_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, STAT_MASTERY, nil, ApplySettings)