diff --git a/api/config.lua b/api/config.lua index 51ab8a6f..d9d9259e 100644 --- a/api/config.lua +++ b/api/config.lua @@ -407,6 +407,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("bars", nil, "altself", "0") pfUI:UpdateConfig("bars", nil, "animation", "zoomfade") pfUI:UpdateConfig("bars", nil, "animalways", "0") + pfUI:UpdateConfig("bars", nil, "reagents", "1") pfUI:UpdateConfig("bars", nil, "hunterbar", "0") pfUI:UpdateConfig("bars", nil, "pagemaster", "0") pfUI:UpdateConfig("bars", nil, "showcastable", "1") diff --git a/modules/actionbar.lua b/modules/actionbar.lua index c386abac..9a850e3a 100644 --- a/modules/actionbar.lua +++ b/modules/actionbar.lua @@ -1178,68 +1178,70 @@ pfUI:RegisterModule("actionbar", "vanilla:tbc", function () end) -- reagent counter - local reagent_slots = { } - local reagent_counts = { } - local reagent_textureslots = { } - local reagent_capture = SPELL_REAGENTS.."(.+)" - local scanner = libtipscan:GetScanner("actionbar") - local reagentcounter = CreateFrame("Frame", "pfReagentCounter", UIParent) - reagentcounter:RegisterEvent("PLAYER_ENTERING_WORLD") - reagentcounter:RegisterEvent("ACTIONBAR_SLOT_CHANGED") - reagentcounter:RegisterEvent("BAG_UPDATE") - reagentcounter:SetScript("OnEvent", function() - if event == "BAG_UPDATE" then - this.event = true - else - for slot = 1, 120 do - local texture = GetActionTexture(slot) + if C.bars.reagents == "1" then + local reagent_slots = { } + local reagent_counts = { } + local reagent_textureslots = { } + local reagent_capture = SPELL_REAGENTS.."(.+)" + local scanner = libtipscan:GetScanner("actionbar") + local reagentcounter = CreateFrame("Frame", "pfReagentCounter", UIParent) + reagentcounter:RegisterEvent("PLAYER_ENTERING_WORLD") + reagentcounter:RegisterEvent("ACTIONBAR_SLOT_CHANGED") + reagentcounter:RegisterEvent("BAG_UPDATE") + reagentcounter:SetScript("OnEvent", function() + if event == "BAG_UPDATE" then + this.event = true + else + for slot = 1, 120 do + local texture = GetActionTexture(slot) - -- update buttons that previously had an reagent - if reagent_slots[slot] and not texture then - reagent_textureslots[slot] = nil - reagent_slots[slot] = nil - RefreshSlot(slot) - end + -- update buttons that previously had an reagent + if reagent_slots[slot] and not texture then + reagent_textureslots[slot] = nil + reagent_slots[slot] = nil + RefreshSlot(slot) + end - -- search for reagents on buttons with different icon - if reagent_textureslots[slot] ~= texture then - if HasAction(slot) then - reagent_textureslots[slot] = texture - scanner:SetAction(slot) - local _, reagents = scanner:Find(reagent_capture) - if reagents then - reagent_slots[slot] = reagents - reagent_counts[reagents] = reagent_counts[reagents] or 0 - RefreshSlot(slot) + -- search for reagents on buttons with different icon + if reagent_textureslots[slot] ~= texture then + if HasAction(slot) then + reagent_textureslots[slot] = texture + scanner:SetAction(slot) + local _, reagents = scanner:Find(reagent_capture) + if reagents then + reagent_slots[slot] = reagents + reagent_counts[reagents] = reagent_counts[reagents] or 0 + RefreshSlot(slot) + end end end end end - end - end) + end) - -- limit bag events to one per second - reagentcounter:SetScript("OnUpdate", function() - if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end + -- limit bag events to one per second + reagentcounter:SetScript("OnUpdate", function() + if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end - if this.event then - for item in pairs(reagent_counts) do - reagent_counts[item] = GetItemCount(item) - end - for slot in pairs(reagent_slots) do - RefreshSlot(slot) + if this.event then + for item in pairs(reagent_counts) do + reagent_counts[item] = GetItemCount(item) + end + for slot in pairs(reagent_slots) do + RefreshSlot(slot) + end + + this.event = nil end + end) - this.event = nil + function IsReagentAction(slot) + return reagent_slots[slot] and true or nil end - end) - function IsReagentAction(slot) - return reagent_slots[slot] and true or nil - end - - function GetReagentCount(slot) - return reagent_counts[reagent_slots[slot]] + function GetReagentCount(slot) + return reagent_counts[reagent_slots[slot]] + end end -- pagemaster / meta page switch diff --git a/modules/gui.lua b/modules/gui.lua index bf3cf443..0fc8403f 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1724,6 +1724,7 @@ pfUI:RegisterModule("gui", "vanilla:tbc", function () CreateConfig(U["bars"], T["Alt Self Cast For All Hotkeys"], C.bars, "altself", "checkbox") CreateConfig(U["bars"], T["Button Animation"], C.bars, "animation", "dropdown", pfUI.gui.dropdowns.actionbuttonanimations) CreateConfig(U["bars"], T["Show Animation On Hidden Bars"], C.bars, "animalways", "checkbox") + CreateConfig(U["bars"], T["Show Reagent Count"], C.bars, "reagents", "checkbox") CreateConfig(U["bars"], T["Highlight Equipped Items"], C.bars, "showequipped", "checkbox") CreateConfig(U["bars"], T["Equipped Item Color"], C.bars, "eqcolor", "color") CreateConfig(U["bars"], T["Highlight Out Of Range Spells"], C.bars, "glowrange", "checkbox")