mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| acab272ec0 | |||
| 61c2f996fa | |||
| 59ce6d9e74 |
+33
-17
@@ -546,25 +546,41 @@ end
|
||||
-- Sets a function to be called automatically once an addon gets loaded
|
||||
-- 'addon' [string] addon or variable name
|
||||
-- 'func' [function] function that should run
|
||||
function pfUI.api.HookAddonOrVariable(addon, func)
|
||||
local lurker = CreateFrame("Frame", nil)
|
||||
lurker.func = func
|
||||
lurker:RegisterEvent("ADDON_LOADED")
|
||||
lurker:RegisterEvent("VARIABLES_LOADED")
|
||||
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
lurker:SetScript("OnEvent",function()
|
||||
-- only run when config is available
|
||||
if event == "ADDON_LOADED" and not this.foundConfig then
|
||||
return
|
||||
elseif event == "VARIABLES_LOADED" then
|
||||
this.foundConfig = true
|
||||
do
|
||||
local lurker
|
||||
local pending = {}
|
||||
|
||||
local function ProcessPending()
|
||||
if not lurker.foundConfig then return end
|
||||
for i = table.getn(pending), 1, -1 do
|
||||
local hook = pending[i]
|
||||
if IsAddOnLoaded(hook.addon) or _G[hook.addon] then
|
||||
hook.func()
|
||||
table.remove(pending, i)
|
||||
end
|
||||
end
|
||||
if table.getn(pending) == 0 then
|
||||
lurker:UnregisterAllEvents()
|
||||
end
|
||||
end
|
||||
|
||||
function pfUI.api.HookAddonOrVariable(addon, func)
|
||||
if not lurker then
|
||||
lurker = CreateFrame("Frame", nil)
|
||||
lurker:SetScript("OnEvent", function()
|
||||
if event == "VARIABLES_LOADED" or event == "PLAYER_ENTERING_WORLD" then
|
||||
this.foundConfig = true
|
||||
end
|
||||
ProcessPending()
|
||||
end)
|
||||
end
|
||||
|
||||
if IsAddOnLoaded(addon) or _G[addon] then
|
||||
this:func()
|
||||
this:UnregisterAllEvents()
|
||||
end
|
||||
end)
|
||||
table.insert(pending, { addon = addon, func = func })
|
||||
lurker:RegisterEvent("ADDON_LOADED")
|
||||
lurker:RegisterEvent("VARIABLES_LOADED")
|
||||
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
ProcessPending()
|
||||
end
|
||||
end
|
||||
|
||||
-- [ QueueFunction ]
|
||||
|
||||
+135
-14
@@ -1,13 +1,11 @@
|
||||
pfUI:RegisterModule("sellvalue", function ()
|
||||
local function AddVendorPrices(frame, id, count)
|
||||
if not id then return end
|
||||
-- Sell price comes from the engine (item DBC); buy price from pfSellData
|
||||
-- (curated vendor data, since vendor purchase prices aren't a static field).
|
||||
local sell = C_Item.GetItemSellPriceByID(id) or 0
|
||||
local buy = pfSellData[id]
|
||||
if sell == 0 and not buy then return end
|
||||
|
||||
if C.tooltip.vendor.showalways == "1" or IsShiftKeyDown() then
|
||||
if C.tooltip.vendor.showalways == "1" or IsShiftKeyDown() then
|
||||
frame:AddLine(" ")
|
||||
|
||||
if sell > 0 then
|
||||
@@ -29,17 +27,6 @@ pfUI:RegisterModule("sellvalue", function ()
|
||||
frame:Show()
|
||||
end
|
||||
|
||||
pfUI.sellvalue = CreateFrame("Frame", "pfGameTooltip", GameTooltip)
|
||||
pfUI.sellvalue:SetScript("OnShow", function()
|
||||
if GameTooltip:HasItem() then
|
||||
local _, _, id = GameTooltip:GetItem()
|
||||
if id then
|
||||
local count = tonumber(libtooltip:GetItemCount()) or 1
|
||||
AddVendorPrices(GameTooltip, id, math.max(count, 1))
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.hooksecurefunc("SetItemRef", function()
|
||||
if IsModifierKeyDown() then return end
|
||||
if ItemRefTooltip:HasItem() then
|
||||
@@ -47,4 +34,138 @@ pfUI:RegisterModule("sellvalue", function ()
|
||||
if id then AddVendorPrices(ItemRefTooltip, id, 1) end
|
||||
end
|
||||
end)
|
||||
|
||||
local TooltipHooks = {
|
||||
SetLootRollItem = {
|
||||
id = GetLootRollItemID,
|
||||
count = function(slot)
|
||||
local _, _, count = GetLootRollItemInfo(slot)
|
||||
return count
|
||||
end
|
||||
},
|
||||
SetLootItem = {
|
||||
id = GetLootSlotItemID,
|
||||
count = function(slot)
|
||||
local _, _, count = GetLootSlotInfo(slot)
|
||||
return count
|
||||
end
|
||||
},
|
||||
SetQuestLogItem = {
|
||||
id = GetQuestLogItemID,
|
||||
count = function(type, index)
|
||||
local itemCount, _;
|
||||
if type == "choice" then
|
||||
_, _, itemCount = GetQuestLogChoiceInfo(index);
|
||||
else
|
||||
_, _, itemCount = GetQuestLogRewardInfo(index)
|
||||
end
|
||||
return itemCount
|
||||
end,
|
||||
},
|
||||
SetQuestItem = {
|
||||
id = GetQuestItemID,
|
||||
count = function(type, index)
|
||||
local _, _, count = GetQuestItemInfo(type, index);
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetHyperlink = { id = C_Item.GetItemInfoInstant },
|
||||
SetBagItem = {
|
||||
id = C_Container.GetContainerItemID,
|
||||
count = function(container, slot)
|
||||
local _, count = GetContainerItemInfo(container, slot)
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetInboxItem = {
|
||||
id = GetInboxItemID,
|
||||
count = function(index)
|
||||
local _, _, _, count = GetInboxItem(index)
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetSendMailItem = {
|
||||
id = function()
|
||||
local _, id = GetSendMailItemLink()
|
||||
return id
|
||||
end,
|
||||
count = function()
|
||||
local _, _, count = GetSendMailItem()
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetInventoryItem = { id = GetInventoryItemID },
|
||||
SetTradeSkillItem = {
|
||||
id = function(skillIndex, reagentIndex)
|
||||
if reagentIndex then
|
||||
return GetTradeSkillReagentItemID(skillIndex, reagentIndex)
|
||||
else
|
||||
return GetTradeSkillItemID(skillIndex)
|
||||
end
|
||||
end,
|
||||
count = function(skillIndex, reagentIndex)
|
||||
if reagentIndex then
|
||||
local _, _, itemCount = GetTradeSkillReagentInfo(skillIndex, reagentIndex)
|
||||
return itemCount
|
||||
else
|
||||
return GetTradeSkillNumMade(skillIndex)
|
||||
end
|
||||
end,
|
||||
},
|
||||
SetAuctionItem = {
|
||||
id = GetAuctionItemLink,
|
||||
count = function(viewType, index)
|
||||
local _, _, count = GetAuctionItemInfo(viewType, index)
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetAuctionSellItem = { id = GetAuctionSellItemLink },
|
||||
SetTradePlayerItem = {
|
||||
id = GetTradePlayerItemLink,
|
||||
count = function(id)
|
||||
local _, _, count = GetTradePlayerItemInfo(id)
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetTradeTargetItem = {
|
||||
id = GetTradeTargetItemLink,
|
||||
count = function(id)
|
||||
local _, _, count = GetTradeTargetItemInfo(id)
|
||||
return count
|
||||
end,
|
||||
},
|
||||
SetMerchantItem = {
|
||||
id = GetMerchantItemID,
|
||||
count = function(index)
|
||||
local _, _, _, itemCount = GetMerchantItemInfo(index)
|
||||
return itemCount
|
||||
end
|
||||
},
|
||||
SetCraftItem = {
|
||||
id = function(recipeIndex, reagentIndex)
|
||||
return GetCraftReagentItemID(recipeIndex, reagentIndex)
|
||||
end
|
||||
},
|
||||
SetBuybackItem = {
|
||||
id = C_MerchantFrame.GetBuybackItemID,
|
||||
count = function(slotIndex)
|
||||
local _, _, _, itemCount = GetBuybackItemInfo(slotIndex)
|
||||
return itemCount
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
local function makeHook(entry)
|
||||
return function(tooltip, arg1, arg2, arg3)
|
||||
AddVendorPrices(tooltip, entry.id(arg1, arg2, arg3), entry.count and entry.count(arg1, arg2, arg3) or 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function HookTooltip(tooltip)
|
||||
for setter, entry in pairs(TooltipHooks) do
|
||||
pfUI.hooksecurefunc(tooltip, setter, makeHook(entry))
|
||||
end
|
||||
end
|
||||
|
||||
HookTooltip(GameTooltip)
|
||||
end)
|
||||
|
||||
+34
-3
@@ -28,9 +28,10 @@ pfUI:RegisterModule("swingtimer", function ()
|
||||
pendingCastSpellId = nil,
|
||||
mhFrozenAt = nil,
|
||||
hsQueued = false, cleaveQueued = false, maulQueued = false,
|
||||
hsSeenCurrent = false, cleaveSeenCurrent = false, maulSeenCurrent = false,
|
||||
isWarrior = false,
|
||||
isDruid = false,
|
||||
cachedHSSlots = {}, cachedCleaveSlots = {},
|
||||
cachedHSSlots = {}, cachedCleaveSlots = {}, cachedMaulSlots = {},
|
||||
useSpellQueueEvent = false,
|
||||
swingThrottle = 0,
|
||||
onSwingCache = {},
|
||||
@@ -416,12 +417,15 @@ pfUI:RegisterModule("swingtimer", function ()
|
||||
S.hsQueued = (kind == "hs")
|
||||
S.cleaveQueued = (kind == "cleave")
|
||||
S.maulQueued = (kind == "maul")
|
||||
S.hsSeenCurrent, S.cleaveSeenCurrent, S.maulSeenCurrent = false, false, false
|
||||
end
|
||||
|
||||
local function RebuildQueueSlotCache()
|
||||
if not S.isWarrior or not sw_hsqueue or S.useSpellQueueEvent then return end
|
||||
if not sw_hsqueue then return end
|
||||
S.cachedHSSlots = {}
|
||||
S.cachedCleaveSlots = {}
|
||||
S.cachedMaulSlots = {}
|
||||
if not (S.isWarrior or S.isDruid) then return end
|
||||
for slot = 1, 120 do
|
||||
local kind, id = GetActionInfo(slot)
|
||||
local name
|
||||
@@ -434,6 +438,8 @@ pfUI:RegisterModule("swingtimer", function ()
|
||||
table.insert(S.cachedHSSlots, slot)
|
||||
elseif name == CLEAVE_NAME then
|
||||
table.insert(S.cachedCleaveSlots, slot)
|
||||
elseif name == MAUL_NAME then
|
||||
table.insert(S.cachedMaulSlots, slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -445,9 +451,30 @@ pfUI:RegisterModule("swingtimer", function ()
|
||||
return false
|
||||
end
|
||||
|
||||
-- Reconcile a stale event-driven queue flag against the client's current
|
||||
-- action. Not every de-queue emits a SPELL_QUEUE pop — pressing Esc or
|
||||
-- re-pressing to cancel an on-swing spell doesn't — so the flag alone stays
|
||||
-- set. IsCurrentAction, which the client clears on cancel, is the reconciling
|
||||
-- signal, but only after it has confirmed the ability as current at least once
|
||||
-- (`seen`): a nampower-initiated cast may never flip IsCurrentAction, and must
|
||||
-- keep its color until its own pop/resolve rather than be cleared early.
|
||||
-- Returns the updated (queued, seen).
|
||||
local function ReconcileQueued(queued, slots, seen)
|
||||
if not queued then return false, false end
|
||||
if CheckQueuedAction(slots) then return true, true end
|
||||
if seen then return false, false end -- was current, now gone -> cancelled
|
||||
return true, false -- never confirmed current -> keep
|
||||
end
|
||||
|
||||
local function IsHSOrCleaveQueued()
|
||||
if not sw_hsqueue or not S.isWarrior then return false, false end
|
||||
if S.useSpellQueueEvent then return S.hsQueued, S.cleaveQueued end
|
||||
if S.useSpellQueueEvent then
|
||||
S.hsQueued, S.hsSeenCurrent =
|
||||
ReconcileQueued(S.hsQueued, S.cachedHSSlots, S.hsSeenCurrent)
|
||||
S.cleaveQueued, S.cleaveSeenCurrent =
|
||||
ReconcileQueued(S.cleaveQueued, S.cachedCleaveSlots, S.cleaveSeenCurrent)
|
||||
return S.hsQueued, S.cleaveQueued
|
||||
end
|
||||
return CheckQueuedAction(S.cachedHSSlots), CheckQueuedAction(S.cachedCleaveSlots)
|
||||
end
|
||||
|
||||
@@ -526,6 +553,10 @@ pfUI:RegisterModule("swingtimer", function ()
|
||||
-- HS/Cleave color
|
||||
local curR, curG, curB = mhDefaultR, mhDefaultG, mhDefaultB
|
||||
if sw_hsqueue then
|
||||
if S.isDruid and S.useSpellQueueEvent then
|
||||
S.maulQueued, S.maulSeenCurrent =
|
||||
ReconcileQueued(S.maulQueued, S.cachedMaulSlots, S.maulSeenCurrent)
|
||||
end
|
||||
if S.maulQueued and S.isDruid then
|
||||
curR, curG, curB = 1.0, 0.55, 0.0 -- orange for druid maul queue
|
||||
elseif S.isWarrior then
|
||||
|
||||
Reference in New Issue
Block a user