Skip to content

Commit 7367df9

Browse files
authored
Spell Hit datatext customization settings (#1466)
* Update Global.lua Added settings for 'Spell Hit' datatext customization * Update SpellHit.lua Made use of new datatext customization settings for 'Spell Hit'
1 parent 949c756 commit 7367df9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

ElvUI/Core/Defaults/Global.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ G.datatexts = {
9797
Parry = { decimalLength = 1 },
9898
Block = { decimalLength = 1 },
9999
['Mana Regen'] = { Label = '', NoLabel = false, decimalLength = 1 },
100-
HealPower = { Label = '', NoLabel = false }
100+
HealPower = { Label = '', NoLabel = false },
101+
['Spell Hit'] = { Label = '', NoLabel = false, decimalLength = 0 }
101102
},
102103
newPanelInfo = {
103104
growth = 'HORIZONTAL',

ElvUI/Core/Modules/DataTexts/SpellHit.lua

+14-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ local GetCombatRatingBonus = GetCombatRatingBonus
88
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
99
local CR_HIT_SPELL = CR_HIT_SPELL
1010

11-
local displayString = ''
11+
local displayString, db = ''
1212

1313
local function OnEvent(self)
14-
self.text:SetFormattedText(displayString, E.Classic and GetSpellHitModifier() or GetCombatRatingBonus(CR_HIT_SPELL) or 0)
14+
local spellHit = E.Classic and GetSpellHitModifier() or GetCombatRatingBonus(CR_HIT_SPELL) or 0
15+
16+
if db.NoLabel then
17+
self.text:SetFormattedText(displayString, spellHit)
18+
else
19+
self.text:SetFormattedText(displayString, db.Label ~= '' and db.Label or L["Spell Hit"]..': ', spellHit)
20+
end
1521
end
1622

17-
local function ApplySettings(_, hex)
18-
displayString = strjoin('', L["Spell Hit"], ': ', hex, '%.2f%%|r')
23+
local function ApplySettings(self, hex)
24+
if not db then
25+
db = E.global.datatexts.settings[self.name]
26+
end
27+
28+
displayString = strjoin('', db.NoLabel and '' or '%s', hex, '%.'..db.decimalLength..'f%%|r')
1929
end
2030

2131
DT:RegisterDatatext('Spell Hit', STAT_CATEGORY_ENHANCEMENTS, { 'UNIT_STATS', 'UNIT_AURA' }, OnEvent, nil, nil, nil, nil, L["Spell Hit"], nil, ApplySettings)

0 commit comments

Comments
 (0)