Skip to content

Commit

Permalink
Fix Charges and Cooldown not appearing after on use enchantment lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonomit committed Feb 19, 2023
1 parent 5244a5e commit 4aa14b6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
15 changes: 9 additions & 6 deletions Operations/CalculatePadding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ local Addon = LibStub("AceAddon-3.0"):GetAddon(ADDON_NAME)



local lastUse

local lineOffsets = {
before = -1,
after = 1,
Expand All @@ -17,18 +19,18 @@ local enchantLines = {
}
local padLocations = {
[-1] = {
BaseStat = function(line) return line.type == "BaseStat" or Addon:GetOption"combineStats" and (line.type == "SecondaryStat" or line.type == "Charges" or line.type == "Cooldown" or Addon:GetOption("doReorder", "EnchantOnUse") and line.type == "EnchantOnUse") end,
SecondaryStat = function(line) return(line.type == "SecondaryStat" or line.type == "Charges" or line.type == "Cooldown" or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) and not Addon:GetOption"combineStats" end,
BaseStat = function(line) return line.type == "BaseStat" or Addon:GetOption"combineStats" and (line.type == "SecondaryStat" or Addon:GetOption("doReorder", "EnchantOnUse") and line.type == "EnchantOnUse") end,
SecondaryStat = function(line) return(line.type == "SecondaryStat" or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) and not Addon:GetOption"combineStats" end,
Enchant = function(line) return enchantLines[line.type] or not Addon:GetOption("doReorder", "EnchantOnUse") and line.type == "EnchantOnUse" end,
WeaponEnchant = function(line) return line.type == "WeaponEnchant" end,
Socket = function(line) return line.type == "Socket" end,
SetName = function(line) return line.type == "SetName" end,
SetBonus = function(line) return line.type == "SetBonus" end,
},
[1] = {
BaseStat = function(line) return line.type == "BaseStat" or Addon:GetOption"combineStats" and (line.type == "SecondaryStat" or line.type == "Charges" or line.type == "Cooldown" or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) end,
SecondaryStat = function(line) return(line.type == "SecondaryStat" or line.type == "Charges" or line.type == "Cooldown" or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) and not Addon:GetOption"combineStats" end,
Enchant = function(line) return enchantLines[line.type] or line.type == "RequiredEnchant" or not Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse") end,
BaseStat = function(line) return line.type == "BaseStat" or Addon:GetOption"combineStats" and (line.type == "SecondaryStat" or lastUse == "SecondaryStat" and (line.type == "Charges" or line.type == "Cooldown") or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) end,
SecondaryStat = function(line) return(line.type == "SecondaryStat" or lastUse == "SecondaryStat" and (line.type == "Charges" or line.type == "Cooldown") or Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) and not Addon:GetOption"combineStats" end,
Enchant = function(line) return enchantLines[line.type] or lastUse == "EnchantOnUse" and (line.type == "Charges" or line.type == "Cooldown") or line.type == "RequiredEnchant" or not Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse") end,
WeaponEnchant = function(line) return line.type == "WeaponEnchant" end,
SocketBonus = function(line) return line.type == "SocketBonus" or line.type == "Socket" or Addon:GetOption("doReorder", "SocketHint") and line.type == "SocketHint" end,
SetPiece = function(line) return line.type == "SetPiece" end,
Expand All @@ -37,7 +39,8 @@ local padLocations = {
}

function Addon:CalculatePadding(tooltipData)
local padded = {}
lastUse = tooltipData.lastUse
local padded = {}

for cat, offset in pairs(lineOffsets) do
local padLocation = padLocations[offset]
Expand Down
2 changes: 1 addition & 1 deletion Operations/ModifyTooltipData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Addon:ModifyTooltipData(tooltip, tooltipData)
local allResist = tooltipData.resists == 5 and not self:GetOption("hide", "All Resistance")

for i, line in ipairs(tooltipData) do
self:RecognizeStat(line, allResist)
self:RecognizeStat(line, tooltipData, allResist)

if self:GetOption("debugOutput", "initialTooltipData") then
OutputLineRecognition(line)
Expand Down
6 changes: 5 additions & 1 deletion Operations/RecognizeStat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ local function RecognizeStatHelper(line)
end

do
function Addon:RecognizeStat(line, allResist)
function Addon:RecognizeStat(line, tooltipData, allResist)
RecognizeStatHelper(line)

if line.prefix == ITEM_SPELL_TRIGGER_ONUSE then
tooltipData.lastUse = line.type
end

if allResist then
if line.stat == "Arcane Resistance" then
local n = strMatch(line.normalForm, "(%d+)")
Expand Down
4 changes: 2 additions & 2 deletions Operations/ReorderLines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ local function SortStats(tooltipData)
end

for i = #stats.Charges, 1, -1 do
tinsert(stats.SecondaryStat, tblRemove(stats.Charges, 1))
tinsert(stats[tooltipData.lastUse], tblRemove(stats.Charges, 1))
end
for i = #stats.Cooldown, 1, -1 do
tinsert(stats.SecondaryStat, tblRemove(stats.Cooldown, 1))
tinsert(stats[tooltipData.lastUse], tblRemove(stats.Cooldown, 1))
end

if self:GetOption("doReorder", "EnchantOnUse") then
Expand Down
1 change: 1 addition & 0 deletions Operations/ScanTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function Addon:ReadTooltip(tooltip, name, link, maxLines)
tooltipData.icon = icon

tooltipData.resists = 0
tooltipData.lastUse = "SecondaryStat"

return tooltipData
end
Expand Down

0 comments on commit 4aa14b6

Please sign in to comment.