Skip to content

Commit

Permalink
Add Cooldown customization
Browse files Browse the repository at this point in the history
Also causes the 'Cooldown' line to stay with 'Use' lines if they move.
  • Loading branch information
Anonomit committed Feb 18, 2023
1 parent c4fbc98 commit 11f0c10
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Config/OptionsTables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,26 @@ function Addon:MakeExtraOptions(categoryName, chatCmd, arg1, ...)

CreateHide(opts, stat)
end

-- Cooldown
do
local stat = "Cooldown"

local sampleCooldown = 10
local defaultText = format(ITEM_COOLDOWN_TIME_MIN, sampleCooldown)

local samples = {}
local defaultText, formattedText = GetFormattedText(stat, self.COLORS.WHITE, defaultText, defaultText)
tinsert(samples, {defaultText, formattedText})

local opts = GUI:CreateGroup(opts, stat, samples[1][2], nil, nil, disabled)

CreateSamples(opts, samples)

CreateColor(opts, stat)

CreateHide(opts, stat)
end
GUI:CreateGroup(opts, GUI:Order(), " ", nil, nil, true)

-- Made By
Expand Down
4 changes: 4 additions & 0 deletions Data/Data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ do
end
end


-- Default color settings

self.statsInfo["Title"] = {color = self.COLORS.WHITE}

self.statsInfo["Heroic"] = {color = self.COLORS.GREEN}
Expand Down Expand Up @@ -724,6 +727,7 @@ do

self.statsInfo["Charges"] = {color = self.COLORS.WHITE}
self.statsInfo["NoCharges"] = {color = self.COLORS.RED}
self.statsInfo["Cooldown"] = {color = self.COLORS.RED}

self.statsInfo["Durability"] = {color = self.COLORS.WHITE}

Expand Down
8 changes: 4 additions & 4 deletions Operations/CalculatePadding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ 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 Addon:GetOption("doReorder", "EnchantOnUse") and line.type == "EnchantOnUse") end,
SecondaryStat = function(line) return(line.type == "SecondaryStat" or line.type == "Charges" 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 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,
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 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 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 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,
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,
Expand Down
6 changes: 6 additions & 0 deletions Operations/RecognizeLineTypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ local contexts = Addon:MakeLookupTable({
"LastSetPiece",
"SetBonus",
"LastSetBonus",
"Cooldown",
"MadeBy",
"SocketHint",
"Refundable",
Expand Down Expand Up @@ -482,6 +483,11 @@ contextActions = Addon:Map({
return SetContext(i-1, tooltipData, line)
end
end,
Cooldown = function(i, tooltipData, line)
if MatchesAny(line.textLeftTextStripped, ITEM_COOLDOWN_TIME) then
return SetContext(i, tooltipData, line)
end
end,
MadeBy = function(i, tooltipData, line)
local madeType = line.colorLeft == Addon.COLORS.GREEN and MatchesAny(line.textLeftTextStripped, ITEM_CREATED_BY, ITEM_WRAPPED_BY, ITEM_WRITTEN_BY)
if madeType then
Expand Down
4 changes: 4 additions & 0 deletions Operations/ReorderLines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local function SortStats(tooltipData)
BaseStat = {},
SecondaryStat = {},
Charges = {},
Cooldown = {},
EnchantOnUse = {},
RequiredEnchantOnUse = {},
}
Expand Down Expand Up @@ -54,6 +55,9 @@ local function SortStats(tooltipData)
for i = #stats.Charges, 1, -1 do
tinsert(stats.SecondaryStat, tblRemove(stats.Charges, 1))
end
for i = #stats.Cooldown, 1, -1 do
tinsert(stats.SecondaryStat, tblRemove(stats.Cooldown, 1))
end

if self:GetOption("doReorder", "EnchantOnUse") then
for i = #stats.EnchantOnUse, 1, -1 do
Expand Down

0 comments on commit 11f0c10

Please sign in to comment.