mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-10 23:50:01 +00:00
Compare 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
|
-- Sets a function to be called automatically once an addon gets loaded
|
||||||
-- 'addon' [string] addon or variable name
|
-- 'addon' [string] addon or variable name
|
||||||
-- 'func' [function] function that should run
|
-- 'func' [function] function that should run
|
||||||
function pfUI.api.HookAddonOrVariable(addon, func)
|
do
|
||||||
local lurker = CreateFrame("Frame", nil)
|
local lurker
|
||||||
lurker.func = func
|
local pending = {}
|
||||||
lurker:RegisterEvent("ADDON_LOADED")
|
|
||||||
lurker:RegisterEvent("VARIABLES_LOADED")
|
local function ProcessPending()
|
||||||
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
if not lurker.foundConfig then return end
|
||||||
lurker:SetScript("OnEvent",function()
|
for i = table.getn(pending), 1, -1 do
|
||||||
-- only run when config is available
|
local hook = pending[i]
|
||||||
if event == "ADDON_LOADED" and not this.foundConfig then
|
if IsAddOnLoaded(hook.addon) or _G[hook.addon] then
|
||||||
return
|
hook.func()
|
||||||
elseif event == "VARIABLES_LOADED" then
|
table.remove(pending, i)
|
||||||
this.foundConfig = true
|
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
|
end
|
||||||
|
|
||||||
if IsAddOnLoaded(addon) or _G[addon] then
|
table.insert(pending, { addon = addon, func = func })
|
||||||
this:func()
|
lurker:RegisterEvent("ADDON_LOADED")
|
||||||
this:UnregisterAllEvents()
|
lurker:RegisterEvent("VARIABLES_LOADED")
|
||||||
end
|
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
end)
|
ProcessPending()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [ QueueFunction ]
|
-- [ QueueFunction ]
|
||||||
|
|||||||
+135
-14
@@ -1,13 +1,11 @@
|
|||||||
pfUI:RegisterModule("sellvalue", function ()
|
pfUI:RegisterModule("sellvalue", function ()
|
||||||
local function AddVendorPrices(frame, id, count)
|
local function AddVendorPrices(frame, id, count)
|
||||||
if not id then return end
|
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 sell = C_Item.GetItemSellPriceByID(id) or 0
|
||||||
local buy = pfSellData[id]
|
local buy = pfSellData[id]
|
||||||
if sell == 0 and not buy then return end
|
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(" ")
|
frame:AddLine(" ")
|
||||||
|
|
||||||
if sell > 0 then
|
if sell > 0 then
|
||||||
@@ -29,17 +27,6 @@ pfUI:RegisterModule("sellvalue", function ()
|
|||||||
frame:Show()
|
frame:Show()
|
||||||
end
|
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()
|
pfUI.hooksecurefunc("SetItemRef", function()
|
||||||
if IsModifierKeyDown() then return end
|
if IsModifierKeyDown() then return end
|
||||||
if ItemRefTooltip:HasItem() then
|
if ItemRefTooltip:HasItem() then
|
||||||
@@ -47,4 +34,138 @@ pfUI:RegisterModule("sellvalue", function ()
|
|||||||
if id then AddVendorPrices(ItemRefTooltip, id, 1) end
|
if id then AddVendorPrices(ItemRefTooltip, id, 1) end
|
||||||
end
|
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)
|
end)
|
||||||
|
|||||||
+34
-3
@@ -28,9 +28,10 @@ pfUI:RegisterModule("swingtimer", function ()
|
|||||||
pendingCastSpellId = nil,
|
pendingCastSpellId = nil,
|
||||||
mhFrozenAt = nil,
|
mhFrozenAt = nil,
|
||||||
hsQueued = false, cleaveQueued = false, maulQueued = false,
|
hsQueued = false, cleaveQueued = false, maulQueued = false,
|
||||||
|
hsSeenCurrent = false, cleaveSeenCurrent = false, maulSeenCurrent = false,
|
||||||
isWarrior = false,
|
isWarrior = false,
|
||||||
isDruid = false,
|
isDruid = false,
|
||||||
cachedHSSlots = {}, cachedCleaveSlots = {},
|
cachedHSSlots = {}, cachedCleaveSlots = {}, cachedMaulSlots = {},
|
||||||
useSpellQueueEvent = false,
|
useSpellQueueEvent = false,
|
||||||
swingThrottle = 0,
|
swingThrottle = 0,
|
||||||
onSwingCache = {},
|
onSwingCache = {},
|
||||||
@@ -416,12 +417,15 @@ pfUI:RegisterModule("swingtimer", function ()
|
|||||||
S.hsQueued = (kind == "hs")
|
S.hsQueued = (kind == "hs")
|
||||||
S.cleaveQueued = (kind == "cleave")
|
S.cleaveQueued = (kind == "cleave")
|
||||||
S.maulQueued = (kind == "maul")
|
S.maulQueued = (kind == "maul")
|
||||||
|
S.hsSeenCurrent, S.cleaveSeenCurrent, S.maulSeenCurrent = false, false, false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function RebuildQueueSlotCache()
|
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.cachedHSSlots = {}
|
||||||
S.cachedCleaveSlots = {}
|
S.cachedCleaveSlots = {}
|
||||||
|
S.cachedMaulSlots = {}
|
||||||
|
if not (S.isWarrior or S.isDruid) then return end
|
||||||
for slot = 1, 120 do
|
for slot = 1, 120 do
|
||||||
local kind, id = GetActionInfo(slot)
|
local kind, id = GetActionInfo(slot)
|
||||||
local name
|
local name
|
||||||
@@ -434,6 +438,8 @@ pfUI:RegisterModule("swingtimer", function ()
|
|||||||
table.insert(S.cachedHSSlots, slot)
|
table.insert(S.cachedHSSlots, slot)
|
||||||
elseif name == CLEAVE_NAME then
|
elseif name == CLEAVE_NAME then
|
||||||
table.insert(S.cachedCleaveSlots, slot)
|
table.insert(S.cachedCleaveSlots, slot)
|
||||||
|
elseif name == MAUL_NAME then
|
||||||
|
table.insert(S.cachedMaulSlots, slot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -445,9 +451,30 @@ pfUI:RegisterModule("swingtimer", function ()
|
|||||||
return false
|
return false
|
||||||
end
|
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()
|
local function IsHSOrCleaveQueued()
|
||||||
if not sw_hsqueue or not S.isWarrior then return false, false end
|
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)
|
return CheckQueuedAction(S.cachedHSSlots), CheckQueuedAction(S.cachedCleaveSlots)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -526,6 +553,10 @@ pfUI:RegisterModule("swingtimer", function ()
|
|||||||
-- HS/Cleave color
|
-- HS/Cleave color
|
||||||
local curR, curG, curB = mhDefaultR, mhDefaultG, mhDefaultB
|
local curR, curG, curB = mhDefaultR, mhDefaultG, mhDefaultB
|
||||||
if sw_hsqueue then
|
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
|
if S.maulQueued and S.isDruid then
|
||||||
curR, curG, curB = 1.0, 0.55, 0.0 -- orange for druid maul queue
|
curR, curG, curB = 1.0, 0.55, 0.0 -- orange for druid maul queue
|
||||||
elseif S.isWarrior then
|
elseif S.isWarrior then
|
||||||
|
|||||||
Reference in New Issue
Block a user