mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-30 19:19:59 +00:00
actionbar: add option to disable reagent counter
This commit is contained in:
@@ -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
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user