diff --git a/Config/OptionsTables.lua b/Config/OptionsTables.lua index 8559c52..93ae519 100644 --- a/Config/OptionsTables.lua +++ b/Config/OptionsTables.lua @@ -1452,6 +1452,59 @@ function Addon:MakeExtraOptions(categoryName, chatCmd, arg1, ...) if self:GetOption("doReorder", "EnchantOnUse") then MakeEnchantOnUseOptions() GUI:CreateGroup(opts, GUI:Order(), " ", nil, nil, true) end + + -- Charges + do + local stat = "Charges" + + local sampleCharges = 10 + local someCharges = format(ITEM_SPELL_CHARGES, sampleCharges) + local noCharges = ITEM_SPELL_CHARGES_NONE + + local samples = {} + do + local defaultText = someCharges + local defaultText, formattedText = GetFormattedText(stat, self.COLORS.WHITE, defaultText, defaultText) + tinsert(samples, {defaultText, formattedText}) + end + do + local defaultText = noCharges + local formattedText = defaultText + local originalColor = self.COLORS.WHITE + local color = Addon:GetOption("color", "NoCharges") + + if Addon:GetOption("hide", stat) then + formattedText = Addon.stealthIcon .. Addon:MakeColorCode(Addon.COLORS.GRAY, Addon:StripColorCode(formattedText)) + elseif Addon:GetOption("allow", "recolor") and Addon:GetOption("doRecolor", "NoCharges") and color ~= originalColor then + formattedText = Addon:MakeColorCode(color, formattedText) + else + formattedText = Addon:MakeColorCode(originalColor, formattedText) + end + tinsert(samples, {Addon:MakeColorCode(originalColor, defaultText), formattedText}) + end + + local opts = GUI:CreateGroup(opts, stat, samples[1][2], nil, nil, disabled) + + CreateSamples(opts, samples) + + do + local opts = GUI:CreateGroupBox(opts, L["Recolor"]) + + local disabled = disabled or not Addon:GetOption("allow", "recolor") + GUI:CreateToggle(opts, {"doRecolor", "Charges"}, someCharges, nil, disabled).width = 1 + GUI:CreateColor(opts, {"color", "Charges"}, self.L["Color"], nil, disabled or not Addon:GetOption("doRecolor", "Charges")).width = 0.5 + CreateReset(opts, {"color", "Charges"}) + GUI:CreateNewline(opts) + + GUI:CreateToggle(opts, {"doRecolor", "NoCharges"}, noCharges, nil, disabled).width = 1 + GUI:CreateColor(opts, {"color", "NoCharges"}, self.L["Color"], nil, disabled or not Addon:GetOption("doRecolor", "NoCharges")).width = 0.5 + CreateReset(opts, {"color", "NoCharges"}) + end + + CreateHide(opts, stat) + end + GUI:CreateGroup(opts, GUI:Order(), " ", nil, nil, true) + -- Made By do local stat = "MadeBy" diff --git a/Data/Data.lua b/Data/Data.lua index 80c1b9f..8fd8a07 100644 --- a/Data/Data.lua +++ b/Data/Data.lua @@ -86,6 +86,16 @@ do Addon.ITEM_MOD_INTELLECT = ITEM_MOD_INTELLECT Addon.ITEM_MOD_SPIRIT = ITEM_MOD_SPIRIT + do + local head, single, plural, tail = strMatch(ITEM_SPELL_CHARGES, "(.*)|4([^:]+):([^;]+);(.*)") + if single then + Addon.ITEM_SPELL_CHARGES1 = head .. single .. tail + Addon.ITEM_SPELL_CHARGES2 = head .. plural .. tail + else + Addon.ITEM_SPELL_CHARGES1 = ITEM_SPELL_CHARGES + end + end + local locale = GetLocale() if locale == "esES" then Addon.ITEM_MOD_STAMINA = ITEM_MOD_STAMINA :lower() @@ -712,6 +722,9 @@ do self.statsInfo["Enchant"] = {color = self.COLORS.GREEN} self.statsInfo["WeaponEnchant"] = {color = self.COLORS.GREEN} + self.statsInfo["Charges"] = {color = self.COLORS.WHITE} + self.statsInfo["NoCharges"] = {color = self.COLORS.RED} + self.statsInfo["Durability"] = {color = self.COLORS.WHITE} self.statsInfo["MadeBy"] = {color = self.COLORS.GREEN} diff --git a/Operations/CalculatePadding.lua b/Operations/CalculatePadding.lua index d782bf4..64b222c 100644 --- a/Operations/CalculatePadding.lua +++ b/Operations/CalculatePadding.lua @@ -17,8 +17,8 @@ local enchantLines = { } local padLocations = { [-1] = { - 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, + 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, 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, @@ -26,8 +26,8 @@ local padLocations = { 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 Addon:GetOption("doReorder", "EnchantOnUse") and (line.type == "EnchantOnUse" or line.type == "RequiredEnchantOnUse")) 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, + 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, 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, diff --git a/Operations/RecognizeLineTypes.lua b/Operations/RecognizeLineTypes.lua index 0b7d5bb..92df3e4 100644 --- a/Operations/RecognizeLineTypes.lua +++ b/Operations/RecognizeLineTypes.lua @@ -11,9 +11,18 @@ local strMatch = string.match --- stripped text recoloring -local ITEM_CREATED_BY = Addon.ITEM_CREATED_BY -local ITEM_WRAPPED_BY = Addon.ITEM_WRAPPED_BY + +local ITEM_CREATED_BY = Addon.ITEM_CREATED_BY +local ITEM_WRAPPED_BY = Addon.ITEM_WRAPPED_BY +local ITEM_MOD_STAMINA = Addon.ITEM_MOD_STAMINA +local ITEM_MOD_STRENGTH = Addon.ITEM_MOD_STRENGTH +local ITEM_MOD_AGILITY = Addon.ITEM_MOD_AGILITY +local ITEM_MOD_INTELLECT = Addon.ITEM_MOD_INTELLECT +local ITEM_MOD_SPIRIT = Addon.ITEM_MOD_SPIRIT + + + + local numberPattern = "[%d%"..DECIMAL_SEPERATOR.."]+" @@ -93,6 +102,7 @@ local contexts = Addon:MakeLookupTable({ "RequiredRep", "SecondaryStat", "LastSecondaryStat", + "Charges", "EnchantOnUse", "RequiredEnchantOnUse", "SetName", @@ -320,7 +330,7 @@ contextActions = Addon:Map({ end, LastBaseStat = function(i, tooltipData, line) if not line.texture and line.colorLeft == Addon.COLORS.WHITE then - local stat = MatchesAny(line.textLeftTextStripped, Addon.ITEM_MOD_STAMINA, Addon.ITEM_MOD_STRENGTH, Addon.ITEM_MOD_AGILITY, Addon.ITEM_MOD_INTELLECT, Addon.ITEM_MOD_SPIRIT, ITEM_RESIST_SINGLE, ITEM_RESIST_ALL) + local stat = MatchesAny(line.textLeftTextStripped, ITEM_MOD_STAMINA, ITEM_MOD_STRENGTH, ITEM_MOD_AGILITY, ITEM_MOD_INTELLECT, ITEM_MOD_SPIRIT, ITEM_RESIST_SINGLE, ITEM_RESIST_ALL) if stat then if stat == ITEM_RESIST_SINGLE then local n = strMatch(line.textLeftTextStripped, "(%d+)") @@ -437,6 +447,11 @@ contextActions = Addon:Map({ end end end, + Charges = function(i, tooltipData, line) + if MatchesAny(line.textLeftTextStripped, Addon.ITEM_SPELL_CHARGES1, ITEM_SPELL_CHARGES_NONE) or Addon.ITEM_SPELL_CHARGES2 and MatchesAny(line.textLeftTextStripped, Addon.ITEM_SPELL_CHARGES2) then + return SetContext(i, tooltipData, line) + end + end, EnchantOnUse = function(i, tooltipData, line) if tooltipData.hasEnchant and not tooltipData.foundEnchant and line.colorLeft == Addon.COLORS.GREEN and StartsWithAny(line.textLeftTextStripped, ITEM_SPELL_TRIGGER_ONUSE) then tooltipData.enchant = line.i diff --git a/Operations/RecolorLine.lua b/Operations/RecolorLine.lua index 34a1714..9845e25 100644 --- a/Operations/RecolorLine.lua +++ b/Operations/RecolorLine.lua @@ -5,6 +5,11 @@ local ADDON_NAME, Data = ... local Addon = LibStub("AceAddon-3.0"):GetAddon(ADDON_NAME) + +local strFind = string.find + + +local noChargesPattern = Addon:ReversePattern(ITEM_SPELL_CHARGES_NONE) local sides local function Recolor(side, stat) @@ -45,13 +50,15 @@ function Addon:RecolorLine(tooltip, line, tooltipData) if stat then Recolor("left", stat) end + elseif line.type == "RequiredClasses" then + -- Handled as a reword instead + elseif line.type == "Charges" then + Recolor("left", strFind(line.textLeftTextStripped, noChargesPattern) and "NoCharges" or "Charges") elseif self.statsInfo[line.type].color then Recolor("left", line.type) end elseif line.type == "DamagePerSecond" and line.rewordRight then line.recolorRight = self.COLORS.WHITE -- the speedbar default tooltip color is yellow but let's pretend it's white - elseif line.type == "RequiredClasses" then - -- Handled as a reword instead end if sides.left ~= line.realColor then diff --git a/Operations/ReorderLines.lua b/Operations/ReorderLines.lua index 8eb76d1..8326e25 100644 --- a/Operations/ReorderLines.lua +++ b/Operations/ReorderLines.lua @@ -24,6 +24,7 @@ local function SortStats(tooltipData) local stats = { BaseStat = {}, SecondaryStat = {}, + Charges = {}, EnchantOnUse = {}, RequiredEnchantOnUse = {}, } @@ -50,6 +51,10 @@ local function SortStats(tooltipData) stats.SecondaryStat.location = tooltipData.secondaryStatStart + 1 end + for i = #stats.Charges, 1, -1 do + tinsert(stats.SecondaryStat, tblRemove(stats.Charges, 1)) + end + if self:GetOption("doReorder", "EnchantOnUse") then for i = #stats.EnchantOnUse, 1, -1 do tinsert(stats.SecondaryStat, tblRemove(stats.EnchantOnUse, 1))