actionbar: add option to disable reagent counter

This commit is contained in:
shagu
2019-12-10 21:32:16 +01:00
parent 2659f24bdb
commit 549f2b9456
3 changed files with 54 additions and 50 deletions
+1
View File
@@ -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")
+52 -50
View File
@@ -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
+1
View File
@@ -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")