mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-07 22:20:00 +00:00
hunterbar: add range based auto paging
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
pfUI:RegisterModule("hunterbar", function ()
|
||||
local _,class = UnitClass("player")
|
||||
if class ~= "HUNTER" or pfUI_config.bars.hunterbar == "0" then return end
|
||||
|
||||
pfUI.hunterbar = CreateFrame("Frame", "pfHunterBar", UIParent)
|
||||
pfUI.hunterbar.scanner = CreateFrame("GameTooltip", "pfHunterBarScanner", UIParent, "GameTooltipTemplate")
|
||||
pfUI.hunterbar.scanner:SetOwner(pfUI.hunterbar, "ANCHOR_NONE")
|
||||
|
||||
pfUI.hunterbar.melee = nil
|
||||
pfUI.hunterbar.ranged = nil
|
||||
pfUI.hunterbar.current = 1
|
||||
|
||||
pfUI.hunterbar:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
|
||||
pfUI.hunterbar:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
pfUI.hunterbar:SetScript("OnEvent", function()
|
||||
for i=1,120 do
|
||||
if pfUI.hunterbar.melee and pfUI.hunterbar.ranged then return end
|
||||
|
||||
pfUI.hunterbar.scanner:ClearLines()
|
||||
pfUI.hunterbar.scanner:SetAction(i)
|
||||
if pfHunterBarScannerTextLeft1 then
|
||||
if pfHunterBarScannerTextLeft1:GetText() == pfLocaleHunterbars[pfUI.cache["locale"]]["MELEE"] then
|
||||
pfUI.hunterbar.melee = i
|
||||
elseif pfHunterBarScannerTextLeft1:GetText() == pfLocaleHunterbars[pfUI.cache["locale"]]["RANGED"] then
|
||||
pfUI.hunterbar.ranged = i
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.hunterbar:SetScript("OnUpdate", function()
|
||||
if not pfUI.hunterbar.melee or not pfUI.hunterbar.ranged then return end
|
||||
|
||||
if IsActionInRange(pfUI.hunterbar.melee) == 1 and IsActionInRange(pfUI.hunterbar.ranged) == 0 then
|
||||
if pfUI.hunterbar.current ~= 0 then
|
||||
CURRENT_ACTIONBAR_PAGE = 9
|
||||
ChangeActionBarPage()
|
||||
pfUI.hunterbar.current = 0
|
||||
end
|
||||
else
|
||||
if pfUI.hunterbar.current ~= 1 then
|
||||
CURRENT_ACTIONBAR_PAGE = 1
|
||||
ChangeActionBarPage()
|
||||
pfUI.hunterbar.current = 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user