Skip to content

Commit

Permalink
unitframe range updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kodewdle committed Dec 4, 2024
1 parent 4ef793b commit 42e3904
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 35 deletions.
28 changes: 24 additions & 4 deletions ElvUI/Core/Defaults/Global.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ G.unitframe = {
EVOKER = {
['355913'] = 'Emerald Blossom'
},
HUNTER = {
['136'] = 'Mend Pet'
},
HUNTER = {},
MAGE = {
['1459'] = 'Arcane Intellect'
},
Expand Down Expand Up @@ -195,7 +193,8 @@ G.unitframe = {
['362969'] = 'Azure Strike'
},
HUNTER = {
['75'] = E.Retail and 'Auto Shot' or nil
['2974'] = not E.Retail and 'Wing Clip' or nil,
['75'] = 'Auto Shot'
},
MAGE = {
['2139'] = 'Counterspell'
Expand Down Expand Up @@ -256,6 +255,27 @@ G.unitframe = {
['20707'] = not E.Classic and 'Soulstone' or nil
},
WARRIOR = {}
},
PET = {
DEATHKNIGHT = {
['47541'] = 'Death Coil'
},
DEMONHUNTER = {},
DRUID = {},
EVOKER = {},
HUNTER = {
['136'] = 'Mend Pet'
},
MAGE = {},
MONK = {},
PALADIN = {},
PRIEST = {},
ROGUE = {},
SHAMAN = {},
WARLOCK = {
['755'] = 'Health Funnel'
},
WARRIOR = {}
}
}
}
Expand Down
22 changes: 14 additions & 8 deletions ElvUI/Core/Modules/UnitFrames/Elements/Range.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local UF = E:GetModule('UnitFrames')
local next = next
local tonumber = tonumber

local UnitIsUnit = UnitIsUnit
local UnitInPhase = UnitInPhase
local UnitInRange = UnitInRange
local UnitIsPlayer = UnitIsPlayer
Expand Down Expand Up @@ -42,9 +43,10 @@ end
function UF:UpdateRangeSpells()
local db = E.global.unitframe.rangeCheck
if db then
list[1] = UF:UpdateRangeList(db.RESURRECT[E.myclass])
list[2] = UF:UpdateRangeList(db.ENEMY[E.myclass])
list[3] = UF:UpdateRangeList(db.FRIENDLY[E.myclass])
list[1] = UF:UpdateRangeList(db.ENEMY[E.myclass])
list[2] = UF:UpdateRangeList(db.FRIENDLY[E.myclass])
list[3] = UF:UpdateRangeList(db.RESURRECT[E.myclass])
list[4] = UF:UpdateRangeList(db.PET[E.myclass])
end
end

Expand All @@ -71,7 +73,7 @@ function UF:UnitInSpellsRange(unit, which)
return range
end

return true -- no spells assume range is maxed
return 1 -- no spells checked
end

function UF:FriendlyInRange(realUnit)
Expand All @@ -89,10 +91,10 @@ function UF:FriendlyInRange(realUnit)

local range, checked = UnitInRange(unit)
if checked and not range then
return false -- blizz checked and said the unit is out of range
return false -- blizz checked and unit is out of range
end

return UF:UnitInSpellsRange(unit, 3)
return UF:UnitInSpellsRange(unit, 2)
end

function UF:UpdateRange(unit)
Expand All @@ -109,11 +111,15 @@ function UF:UpdateRange(unit)
element.RangeAlpha = element.MinAlpha
elseif unit then
if UnitIsDeadOrGhost(unit) then
element.RangeAlpha = UF:UnitInSpellsRange(unit, 1) and element.MaxAlpha or element.MinAlpha
element.RangeAlpha = UF:UnitInSpellsRange(unit, 3) == true and element.MaxAlpha or element.MinAlpha
elseif UnitCanAttack('player', unit) then
element.RangeAlpha = UF:UnitInSpellsRange(unit, 2) and element.MaxAlpha or element.MinAlpha
element.RangeAlpha = UF:UnitInSpellsRange(unit, 1) and element.MaxAlpha or element.MinAlpha
elseif UnitIsUnit('pet', unit) then
element.RangeAlpha = UF:UnitInSpellsRange(unit, 4) and element.MaxAlpha or element.MinAlpha
elseif UnitIsConnected(unit) then
element.RangeAlpha = UF:FriendlyInRange(unit) and element.MaxAlpha or element.MinAlpha
else
element.RangeAlpha = element.MinAlpha
end
else
element.RangeAlpha = element.MaxAlpha
Expand Down
56 changes: 33 additions & 23 deletions ElvUI_Options/Core/UnitFrames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,12 @@ local function ResetRangeSpells(list)
E.global.unitframe.rangeCheck.ENEMY[E.myclass] = CopyTable(G.unitframe.rangeCheck.ENEMY[E.myclass])
E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] = CopyTable(G.unitframe.rangeCheck.FRIENDLY[E.myclass])
E.global.unitframe.rangeCheck.RESURRECT[E.myclass] = CopyTable(G.unitframe.rangeCheck.RESURRECT[E.myclass])
E.global.unitframe.rangeCheck.PET[E.myclass] = CopyTable(G.unitframe.rangeCheck.PET[E.myclass])

UpdateRangeSpells(list.args.rangeEnemy, E.global.unitframe.rangeCheck.ENEMY[E.myclass], nil, true)
UpdateRangeSpells(list.args.rangeFriendly, E.global.unitframe.rangeCheck.FRIENDLY[E.myclass], nil, true)
UpdateRangeSpells(list.args.rangeResurrect, E.global.unitframe.rangeCheck.RESURRECT[E.myclass], nil, true)
UpdateRangeSpells(list.args.rangePet, E.global.unitframe.rangeCheck.PET[E.myclass], nil, true)

UF:UpdateRangeSpells()
end
Expand All @@ -671,11 +673,10 @@ local function GetOptionsTable_Fader(updateFunc, groupName, numUnits)
local disabled = function() return not E.db.unitframe.units[groupName].fader.enable end
local ranged = function() return E.db.unitframe.units[groupName].fader.range end

local config = ACH:Group(L["Fader"], nil, nil, nil, function(info) return E.db.unitframe.units[groupName].fader[info[#info]] end, function(info, value) E.db.unitframe.units[groupName].fader[info[#info]] = value updateFunc(UF, groupName, numUnits) end)
local config = ACH:Group(L["Fader"], nil, nil, 'tab', function(info) return E.db.unitframe.units[groupName].fader[info[#info]] end, function(info, value) E.db.unitframe.units[groupName].fader[info[#info]] = value updateFunc(UF, groupName, numUnits) end)
config.args.enable = ACH:Toggle(L["Enable"], nil, 1)
config.args.range = ACH:Toggle(L["Range"], nil, 2, nil, nil, nil, nil, nil, disabled, groupName == 'player')
config.args.unittarget = ACH:Toggle(L["Unit Target"], nil, 3, nil, nil, nil, nil, nil, disabled, ranged or groupName == 'player')
config.args.rangeReset = ACH:Execute(L["Reset Spells"], nil, 4, function() ResetRangeSpells(config) end, nil, nil, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)

config.args.hover = ACH:Toggle(L["Hover"], nil, 11, nil, nil, nil, nil, nil, disabled, ranged)
config.args.combat = ACH:Toggle(L["Combat"], nil, 12, nil, nil, nil, nil, nil, disabled, ranged)
Expand All @@ -687,6 +688,7 @@ local function GetOptionsTable_Fader(updateFunc, groupName, numUnits)
config.args.casting = ACH:Toggle(L["Casting"], nil, 18, nil, nil, nil, nil, nil, disabled, ranged)
config.args.dynamicflight = ACH:Toggle(L["Dynamic Flight"], nil, 19, nil, nil, nil, nil, nil, disabled, ranged)

config.args.spacer1 = ACH:Spacer(30, 'full')
config.args.delay = ACH:Range(L["Fade Out Delay"], nil, 31, { min = 0, max = 3, step = 0.01 }, nil, nil, nil, disabled, ranged)
config.args.smooth = ACH:Range(L["Smooth"], nil, 32, { min = 0, max = 1, step = 0.01 }, nil, nil, nil, disabled)
config.args.minAlpha = ACH:Range(L["Min Alpha"], nil, 33, { min = 0, max = 1, step = 0.01 }, nil, nil, nil, disabled)
Expand All @@ -704,33 +706,41 @@ local function GetOptionsTable_Fader(updateFunc, groupName, numUnits)
config.args.instanceDifficulties.args.timewalking = ACH:Toggle(L["Timewalking"], nil, 9, nil, nil, nil, nil, nil, disabled)
config.args.instanceDifficulties.inline = true

config.args.rangeEnemy = ACH:Group(L["Enemy Spells"], nil, 50, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)
config.args.rangeEnemy.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeEnemy, list, value, true) end)
config.args.rangeEnemy.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.ENEMY[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeEnemy, list, value) end)
config.args.rangeEnemy.inline = true
config.args.rangeGroup = ACH:Group(L["Range"], nil, 50, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)
config.args.rangeGroup.args.rangeReset = ACH:Execute(L["Reset Spells"], nil, 4, function() ResetRangeSpells(config) end, nil, nil, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)

config.args.rangeEnemy.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeEnemy.args.spells.inline = true
config.args.rangeGroup.args.rangeEnemy = ACH:Group(L["Enemy Spells"], nil, 10)
config.args.rangeGroup.args.rangeEnemy.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeGroup.args.rangeEnemy, list, value, true) end)
config.args.rangeGroup.args.rangeEnemy.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.ENEMY[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeGroup.args.rangeEnemy, list, value) end)

config.args.rangeFriendly = ACH:Group(L["Friendly Spells"], nil, 50, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)
config.args.rangeFriendly.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeFriendly, list, value, true) end)
config.args.rangeFriendly.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeFriendly, list, value) end)
config.args.rangeFriendly.inline = true
config.args.rangeGroup.args.rangeEnemy.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.ENEMY[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeGroup.args.rangeEnemy.args.spells.inline = true

config.args.rangeFriendly.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeFriendly.args.spells.inline = true
config.args.rangeGroup.args.rangeFriendly = ACH:Group(L["Friendly Spells"], nil, 20)
config.args.rangeGroup.args.rangeFriendly.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeGroup.args.rangeFriendly, list, value, true) end)
config.args.rangeGroup.args.rangeFriendly.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeGroup.args.rangeFriendly, list, value) end)

config.args.rangeResurrect = ACH:Group(L["Resurrect Spells"], nil, 50, nil, nil, nil, nil, function() return not E.db.unitframe.units[groupName].fader.range end)
config.args.rangeResurrect.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeResurrect, list, value, true) end)
config.args.rangeResurrect.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.RESURRECT[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeResurrect, list, value) end)
config.args.rangeResurrect.inline = true
config.args.rangeGroup.args.rangeFriendly.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.FRIENDLY[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeGroup.args.rangeFriendly.args.spells.inline = true

config.args.rangeResurrect.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeResurrect.args.spells.inline = true
config.args.rangeGroup.args.rangeResurrect = ACH:Group(L["Resurrect Spells"], nil, 30)
config.args.rangeGroup.args.rangeResurrect.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeGroup.args.rangeResurrect, list, value, true) end)
config.args.rangeGroup.args.rangeResurrect.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.RESURRECT[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeGroup.args.rangeResurrect, list, value) end)

UpdateRangeSpells(config.args.rangeEnemy, E.global.unitframe.rangeCheck.ENEMY[E.myclass], nil, true)
UpdateRangeSpells(config.args.rangeFriendly, E.global.unitframe.rangeCheck.FRIENDLY[E.myclass], nil, true)
UpdateRangeSpells(config.args.rangeResurrect, E.global.unitframe.rangeCheck.RESURRECT[E.myclass], nil, true)
config.args.rangeGroup.args.rangeResurrect.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.RESURRECT[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeGroup.args.rangeResurrect.args.spells.inline = true

config.args.rangeGroup.args.rangePet = ACH:Group(L["Pet Spells"], nil, 40)
config.args.rangeGroup.args.rangePet.args.addSpell = ACH:Input(L["Add Spell ID or Name"], nil, 2, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.PET[E.myclass] list[value] = true UpdateRangeSpells(config.args.rangeGroup.args.rangePet, list, value, true) end)
config.args.rangeGroup.args.rangePet.args.removeSpell = ACH:Select(L["Remove Spell ID or Name"], L["If the aura is listed with a number then you need to use that to remove it from the list."], 3, function() local values, list = {}, E.global.unitframe.rangeCheck.PET[E.myclass] for spell in next, list do values[spell] = spell end return values end, nil, nil, nil, function(_, value) local list = E.global.unitframe.rangeCheck.PET[E.myclass] list[value] = nil UpdateRangeSpells(config.args.rangeGroup.args.rangePet, list, value) end)

config.args.rangeGroup.args.rangePet.args.spells = ACH:Group('', nil, 11, nil, function(info) local list = E.global.unitframe.rangeCheck.PET[E.myclass] local value = info[#info] return list[value] end, function(info, value) local list = E.global.unitframe.rangeCheck.PET[E.myclass] list[info[#info]] = value UF:UpdateRangeSpells() end, nil, true)
config.args.rangeGroup.args.rangePet.args.spells.inline = true

UpdateRangeSpells(config.args.rangeGroup.args.rangeEnemy, E.global.unitframe.rangeCheck.ENEMY[E.myclass], nil, true)
UpdateRangeSpells(config.args.rangeGroup.args.rangeFriendly, E.global.unitframe.rangeCheck.FRIENDLY[E.myclass], nil, true)
UpdateRangeSpells(config.args.rangeGroup.args.rangeResurrect, E.global.unitframe.rangeCheck.RESURRECT[E.myclass], nil, true)
UpdateRangeSpells(config.args.rangeGroup.args.rangePet, E.global.unitframe.rangeCheck.PET[E.myclass], nil, true)

return config
end
Expand Down

0 comments on commit 42e3904

Please sign in to comment.