begin utilizing ClassicAPI

This commit is contained in:
Brues
2026-05-16 13:02:38 -05:00
parent a8ee751b42
commit 67146ef3a4
12 changed files with 202 additions and 214 deletions
+2 -2
View File
@@ -1714,9 +1714,9 @@ pfUI:RegisterModule("actionbar", "vanilla", function ()
local reagentcounter = CreateFrame("Frame", "pfReagentCounter", UIParent)
reagentcounter:RegisterEvent("PLAYER_ENTERING_WORLD")
reagentcounter:RegisterEvent("ACTIONBAR_SLOT_CHANGED")
reagentcounter:RegisterEvent("BAG_UPDATE")
reagentcounter:RegisterEvent("BAG_UPDATE_DELAYED")
reagentcounter:SetScript("OnEvent", function()
if event == "BAG_UPDATE" then
if event == "BAG_UPDATE_DELAYED" then
this.event = true
else
this.scan = 1
+4 -22
View File
@@ -94,31 +94,13 @@ pfUI:RegisterModule("afkcam", "vanilla:tbc", function ()
clock.time:SetJustifyH("CENTER")
clock.time:SetPoint("TOP", 0, -10)
clock:SetScript("OnUpdate", function()
local h, m = GetGameTime()
local noon = "AM"
local time = ""
local fmt
if C.global.twentyfour == "0" then
if C.global.servertime == "1" then
if h == 0 then
h = 12
elseif h == 12 then
noon = "PM"
elseif h > 12 then
h = h - 12
noon = "PM"
end
time = string.format("%.2d|cff33ffcc:|r%.2d %s", h, m, noon)
else
time = date("%I|cff33ffcc:|r%M %p")
end
clock.time:SetText(time)
fmt = "%I|cff33ffcc:|r%M %p"
else
if C.global.servertime == "1" then
time = string.format("%.2d|cff33ffcc:|r%.2d", h, m)
else
time = date("%H|cff33ffcc:|r%M")
end
fmt = "%H|cff33ffcc:|r%M"
end
local time = C.global.servertime == "1" and date(fmt, GetServerEpoch()) or date(fmt)
clock.time:SetText(time)
end)
+18 -18
View File
@@ -12,27 +12,24 @@ pfUI:RegisterModule("autovendor", "vanilla:tbc", function ()
end
local function HasGreyItems()
for bag = 0, 4, 1 do
for slot = 1, GetContainerNumSlots(bag), 1 do
local name = GetContainerItemLink(bag,slot)
if name and string.find(name,"ff9d9d9d") then return true end
for bag = 0, 4 do
for slot = 1, GetContainerNumSlots(bag) do
local quality = C_Item.GetItemQuality(ItemLocation:CreateFromBagAndSlot(bag,slot))
if quality and quality == LE_ITEM_QUALITY_POOR then return true end
end
end
return nil
end
local function GetNextGreyItem()
for bag = 0, 4, 1 do
for slot = 1, GetContainerNumSlots(bag), 1 do
local name = GetContainerItemLink(bag,slot)
if name and string.find(name,"ff9d9d9d") and not processed[bag.."x"..slot] then
for bag = 0, 4 do
for slot = 1, GetContainerNumSlots(bag) do
local quality = C_Item.GetItemQuality(ItemLocation:CreateFromBagAndSlot(bag,slot))
if quality and quality == LE_ITEM_QUALITY_POOR and not processed[bag.."x"..slot] then
processed[bag.."x"..slot] = true
return bag, slot
end
end
end
return nil, nil
end
local autovendor = CreateFrame("Frame", "pfMoneyUpdate", nil)
@@ -56,16 +53,15 @@ pfUI:RegisterModule("autovendor", "vanilla:tbc", function ()
end
-- double check to only sell grey
local name = GetContainerItemLink(bag,slot)
if not name or not string.find(name,"ff9d9d9d") then
local quality = C_Item.GetItemQuality(ItemLocation:CreateFromBagAndSlot(bag,slot))
if quality ~= LE_ITEM_QUALITY_POOR then
return
end
-- get value
local _, icount = GetContainerItemInfo(bag, slot)
local _, _, id = string.find(GetContainerItemLink(bag, slot), "item:(%d+):%d+:%d+:%d+")
if pfSellData[tonumber(id)] then
local _, _, sell, buy = strfind(pfSellData[tonumber(id)], "(.*),(.*)")
local id = C_Container.GetContainerItemID(bag, slot)
if pfSellData[id] then
local _, _, sell, buy = strfind(pfSellData[id], "(.*),(.*)")
this.count = this.count + 1
end
@@ -103,7 +99,11 @@ pfUI:RegisterModule("autovendor", "vanilla:tbc", function ()
end
if C["global"]["autosell"] == "1" then
autovendor:Show()
if C_MerchantFrame.GetNumJunkItems() > 0 then
C_MerchantFrame.SellAllJunkItems()
else
autovendor:Show()
end
autovendor.button:Hide()
else
autovendor.button:Show()
+4 -4
View File
@@ -494,10 +494,10 @@ pfUI:RegisterModule("bags", "vanilla:tbc", function ()
-- add shaguscore if we have it
if ShaguScore and pfUI.bags[bag].slots[slot].frame.scoreText then
if quality and quality > 0 then
local link = GetContainerItemLink(bag, slot)
local r,g,b = GetItemQualityColor(quality)
local _, _, itemID = string.find(link, "item:(%d+):%d+:%d+:%d+")
local itemLevel = ShaguScore.Database[tonumber(itemID)] or 0
local item = Item:CreateFromBagAndSlot(bag, slot)
local r,g,b = item:GetItemQualityColorRGB()
local itemID = item:GetItemID()
local itemLevel = ShaguScore.Database[itemID] or 0
local score = ShaguScore:Calculate(vslot, quality, itemLevel)
if score and score > 0 and count and count == 1 then
pfUI.bags[bag].slots[slot].frame.scoreText:SetText(score)
+24 -30
View File
@@ -713,19 +713,15 @@ pfUI:RegisterModule("chat", "vanilla:tbc", function ()
local r,g,b = strsplit(",", C.chat.text.unknowncolor)
local unknowncolorhex = rgbhex(r,g,b)
local nothing = function() return end
local original = FriendsFrame_OnEvent
local who_query = CreateFrame("Frame")
who_query:RegisterEvent("WHO_LIST_UPDATE")
who_query:SetScript("OnEvent", function()
if this.pending then
-- restore everything once a query is received
_G.FriendsFrame_OnEvent = original
this.pending = nil
SetWhoToUI(0)
end
end)
-- Suppress FriendsFrame's WHO_LIST_UPDATE handling for our DLL-issued
-- name lookups so they don't pop the friends panel. User-issued /who
-- still works because IsWhoQueryPending only reports true for queries
-- issued via C_FriendList.SendWhoQueryByName.
local original_FriendsFrame_OnEvent = FriendsFrame_OnEvent
_G.FriendsFrame_OnEvent = function()
if _G.event == "WHO_LIST_UPDATE" and C_FriendList.IsWhoQueryPending() then return end
return original_FriendsFrame_OnEvent()
end
local function GetPlayerLevel(name)
if not pfUI_playerDB then return nil end
@@ -733,23 +729,12 @@ pfUI:RegisterModule("chat", "vanilla:tbc", function ()
return pfUI_playerDB[name].level
end
local function ScanWhoName(name)
-- abort if another query is ongoing
if who_query.pending then return end
who_query.pending = true
-- prepare and send the who query
_G.FriendsFrame_OnEvent = nothing
SetWhoToUI(1)
SendWho("n-"..name)
end
local function AddMessage(frame, text, a1, a2, a3, a4, a5)
local function AddMessage(frame, text, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)
if not text then return end
-- skip chat parsing on combat log
if frame.pfCombatLog then
return frame:HookAddMessage(text, a1, a2, a3, a4, a5)
return frame:HookAddMessage(text, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)
end
-- Remove prat CLINKs
@@ -773,15 +758,24 @@ pfUI:RegisterModule("chat", "vanilla:tbc", function ()
local real, _ = strsplit(":", name)
local color = unknowncolorhex
local match = false
local class = GetUnitData(real)
local class
local guid = GetCurrentChatGUID()
if guid then
_, class = GetPlayerInfoByGUID(guid)
end
if not class then
_, class = C_PlayerCache.GetPlayerInfoByName(real)
end
if not class then
class = GetUnitData(real)
end
if class then
if class ~= UNKNOWN then
color = rgbhex(RAID_CLASS_COLORS[class])
match = true
end
elseif C.chat.text.whosearchunknown == "1" then
ScanWhoName(name)
C_FriendList.SendWhoQueryByName(name) -- cooldown + state managed by DLL
end
if C.chat.text.tintunknown == "1" or match then
@@ -839,7 +833,7 @@ pfUI:RegisterModule("chat", "vanilla:tbc", function ()
end
end
frame:HookAddMessage(text, a1, a2, a3, a4, a5)
frame:HookAddMessage(text, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17)
end
for i=1,NUM_CHAT_WINDOWS do
+6
View File
@@ -29,6 +29,8 @@ local function SetFocusByGUID(guid)
pfUI.uf.focustarget.label = guid .. "target"
pfUI.uf.focustarget.id = ""
end
C_Minimap.SetFocusByGUID(guid)
end
-- Helper: set focus frame by name (fallback, no Nampower)
@@ -42,6 +44,8 @@ local function SetFocusByName(name)
pfUI.uf.focustarget.label = nil
pfUI.uf.focustarget.id = nil
end
C_Minimap.SetFocusByName(name)
end
SLASH_PFFOCUS1, SLASH_PFFOCUS2 = '/focus', '/pffocus'
@@ -122,6 +126,8 @@ function SlashCmdList.PFCLEARFOCUS(msg)
pfUI.uf.focustarget.label = nil
pfUI.uf.focustarget.id = nil
end
C_Minimap.ClearFocus()
end
SLASH_PFCASTFOCUS1, SLASH_PFCASTFOCUS2 = '/castfocus', '/pfcastfocus'
+1 -2
View File
@@ -28,8 +28,7 @@ pfUI:RegisterModule("itemclick", "vanilla", function ()
end
elseif IsAuctionBrowsing() and not IsShiftKeyDown() then
-- search item in auction house
local link = GetContainerItemLink(bag, slot)
local name = link and string.sub(link, string.find(link, "%[")+1, string.find(link, "%]")-1) or ""
local name = C_Item.GetItemName(ItemLocation:CreateFromBagAndSlot(bag, slot))
BrowseName:SetText(name)
AuctionFrameBrowse_Search()
elseif IsAuctionSelling() and not IsShiftKeyDown() then
+87 -124
View File
@@ -12,25 +12,9 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
widget.Tooltip = function()
GameTooltip:ClearLines()
GameTooltip_SetDefaultAnchor(GameTooltip, this)
local h, m = GetGameTime()
local noon = " AM"
local servertime
local time
if C.global.twentyfour == "0" then
if h == 0 then
h = 12
elseif h == 12 then
noon = " PM"
elseif h > 12 then
h = h - 12
noon = " PM"
end
time = date("%I:%M %p")
servertime = string.format("%.2d:%.2d %s", h, m, noon)
else
time = date("%H:%M")
servertime = string.format("%.2d:%.2d", h, m)
end
local fmt = C.global.twentyfour == "0" and "%I:%M %p" or "%H:%M"
local time = date(fmt)
local servertime = date(fmt, GetServerEpoch())
GameTooltip:AddLine("|cff555555" .. T["Time"])
GameTooltip:AddDoubleLine(T["Localtime"], "|cffffffff" .. time)
GameTooltip:AddDoubleLine(T["Servertime"], "|cffffffff".. servertime)
@@ -65,39 +49,14 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
widget:SetScript("OnUpdate",function()
if ( this.tick or 1) > GetTime() then return else this.tick = GetTime() + 1 end
local h, m = GetGameTime()
local noon = "AM"
local time = ""
local secondsenabled = C.panel.seconds == "1"
local fmt
if C.global.twentyfour == "0" then
if C.global.servertime == "1" then
if h == 0 then
h = 12
elseif h == 12 then
noon = "PM"
elseif h > 12 then
h = h - 12
noon = "PM"
end
time = string.format("%.2d:%.2d %s", h, m, noon)
else
if secondsenabled then
time = date("%I:%M:%S %p")
else
time = date("%I:%M %p")
end
end
fmt = secondsenabled and "%I:%M:%S %p" or "%I:%M %p"
else
if C.global.servertime == "1" then
time = string.format("%.2d:%.2d", h, m)
else
if secondsenabled then
time = date("%H:%M:%S")
else
time = date("%H:%M")
end
end
fmt = secondsenabled and "%H:%M:%S" or "%H:%M"
end
local time = C.global.servertime == "1" and date(fmt, GetServerEpoch()) or date(fmt)
pfUI.panel:OutputPanel("time", time, widget.Tooltip, widget.Click)
end)
@@ -249,7 +208,7 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
do -- Bagspace
local widget = CreateFrame("Frame", "pfPanelWidgetBag", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget:SetScript("OnEvent", function()
local maxslots = 0
local usedslots = 0
@@ -259,8 +218,8 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
local bagsize = GetContainerNumSlots(bag)
maxslots = maxslots + bagsize
for j = 1,bagsize do
local link = GetContainerItemLink(bag,j)
if link then
local itemID = C_Container.GetContainerItemID(bag,j)
if itemID then
usedslots = usedslots + 1
end
end
@@ -471,8 +430,7 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
widget.itemLines = {}
widget.durability_slots = { 1, 3, 5, 6, 7, 8, 9, 10, 16, 17, 18 }
widget.totalRep = 0
widget.scantip = libtipscan:GetScanner("panel")
widget.duracapture = string.gsub(DURABILITY_TEMPLATE, "%%[^%s]+", "(.+)")
widget.Click = function() ToggleCharacter("PaperDollFrame") end
widget.Tooltip = function()
if widget.totalRep > 0 then
@@ -489,27 +447,24 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
widget:SetScript("OnEvent", function()
if event == "UNIT_INVENTORY_CHANGED" and arg1 ~= "player" then return end
local repPercent = 100
local lowestPercent = 100
widget.totalRep = 0
wipe(widget.itemLines)
for _, id in pairs(widget.durability_slots) do
local hasItem, _, repCost = widget.scantip:SetInventoryItem("player", id)
if (hasItem) then
widget.totalRep = widget.totalRep + repCost
local line, lval, rval = widget.scantip:Find(widget.duracapture)
if (lval and rval) then
repPercent = math.floor(lval / rval * 100)
if repPercent < 100 then
local link = GetInventoryItemLink("player",id)
local r,g,b,hex = GetColorGradient(repPercent/100)
local cPercent = string.format("%s%s%%|r",hex,repPercent)
widget.itemLines[table.getn(widget.itemLines)+1]={link, cPercent}
end
local cur, max = GetInventoryItemDurability(id)
if cur and max then
widget.totalRep = widget.totalRep + (GetInventoryItemRepairCost(id) or 0)
local repPercent = math.floor(cur / max * 100)
if repPercent < 100 then
local _, _, _, hex = GetColorGradient(repPercent/100)
widget.itemLines[table.getn(widget.itemLines)+1] = {
GetInventoryItemLink("player", id),
string.format("%s%s%%|r", hex, repPercent)
}
end
if repPercent < lowestPercent then
lowestPercent = repPercent
end
end
if repPercent < lowestPercent then
lowestPercent = repPercent
end
end
@@ -553,7 +508,7 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
local widget = CreateFrame("Frame", "pfPanelWidgetAmmo", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("UNIT_INVENTORY_CHANGED")
widget:RegisterEvent("BAG_UPDATE")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget.Tooltip = function()
if GetInventoryItemQuality("player", 0) then
local ammo = GetInventoryItemCount("player", 0)
@@ -573,65 +528,73 @@ pfUI:RegisterModule("panel", "vanilla:tbc", function()
end)
end
do -- Soulshards
local widget = CreateFrame("Frame", "pfPanelWidgetSoulshard", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE")
widget:SetScript("OnEvent", function()
local _, class = UnitClass("player")
if class == "WARLOCK" then
local count = pfUI.api.GetItemCount(T["Soul Shard"])
pfUI.panel:OutputPanel("soulshard", T["Soulshards"] .. ": " .. count)
end
end)
end
do -- Hearthstone bind location
local widget = CreateFrame("Frame", "pfPanelBindLocation", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("CHAT_MSG_SYSTEM")
widget:SetScript("OnEvent", function()
do
-- Hearthstone bind location
local hearth = CreateFrame("Frame", "pfPanelBindLocation", UIParent)
hearth:RegisterEvent("PLAYER_ENTERING_WORLD")
hearth:RegisterEvent("CHAT_MSG_SYSTEM")
hearth:SetScript("OnEvent", function()
pfUI.panel:OutputPanel("bindlocation", T["Hearthstone"] .. ": " .. (GetBindLocation() or T["Not Set"]))
end)
end
do -- Flash Powder
local widget = CreateFrame("Frame", "pfPanelFlashPowder", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE")
widget:SetScript("OnEvent", function()
local _, class = UnitClass("player")
if class == "ROGUE" then
local count = pfUI.api.GetItemCount(T["Flash Powder"])
pfUI.panel:OutputPanel("flashpowder", T["Flash Powder"] .. ": " .. count)
end
end)
end
local itemIDs = {
soulshard = 6265,
flashpowder = 5140,
thistletea = 7676,
blindpowder = 5530
}
do -- Thistle Tea
local widget = CreateFrame("Frame", "pfPanelThistleTea", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE")
widget:SetScript("OnEvent", function()
local _, class = UnitClass("player")
if class == "ROGUE" then
local count = pfUI.api.GetItemCount(T["Thistle Tea"])
pfUI.panel:OutputPanel("thistletea", T["Thistle Tea"] .. ": " .. count)
end
end)
end
local function AddItemToPanel(panelType)
local itemID = itemIDs[panelType]
if C_Item.IsItemDataCachedByID(itemID) then
local itemName, count = C_Item.GetItemNameByID(itemID), C_Item.GetItemCount(itemID)
pfUI.panel:OutputPanel(panelType, itemName .. ": " .. count)
else
local item = Item:CreateFromItemID(itemID)
item:ContinueOnItemLoad(function()
local itemName, count = item:GetItemName(), C_Item.GetItemCount(item:GetItemID())
pfUI.panel:OutputPanel(panelType, itemName .. ": " .. count)
end)
end
end
local class = UnitClassBase('player')
if class == "WARLOCK" then
-- Soulshards
local widget = CreateFrame("Frame", "pfPanelWidgetSoulshard", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget:SetScript("OnEvent", function()
AddItemToPanel("soulshard")
end)
end
do -- Blinding Powder
local widget = CreateFrame("Frame", "pfPanelBlindingPowder", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE")
widget:SetScript("OnEvent", function()
local _, class = UnitClass("player")
if class == "ROGUE" then
local count = pfUI.api.GetItemCount(T["Blinding Powder"])
pfUI.panel:OutputPanel("blindpowder", T["Blinding Powder"] .. ": " .. count)
end
end)
if class == "ROGUE" then
-- Flash Powder
local widget = CreateFrame("Frame", "pfPanelFlashPowder", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget:SetScript("OnEvent", function()
AddItemToPanel("flashpowder")
end)
-- Thistle Tea
local widget = CreateFrame("Frame", "pfPanelThistleTea", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget:SetScript("OnEvent", function()
AddItemToPanel("thistletea")
end)
-- Blinding Powder
local widget = CreateFrame("Frame", "pfPanelBlindingPowder", UIParent)
widget:RegisterEvent("PLAYER_ENTERING_WORLD")
widget:RegisterEvent("BAG_UPDATE_DELAYED")
widget:SetScript("OnEvent", function()
AddItemToPanel("blindpowder")
end)
end
end
end
+9
View File
@@ -6,6 +6,7 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
data:RegisterEvent("CHAT_MSG_COMBAT_FACTION_CHANGE")
data:RegisterEvent("PLAYER_ENTERING_WORLD")
data:RegisterEvent("PLAYER_LEVEL_UP")
data:RegisterEvent("UPDATE_FACTION")
data:SetScript("OnEvent", function()
if event == "PLAYER_ENTERING_WORLD" then
this.starttime = GetTime()
@@ -16,6 +17,14 @@ pfUI:RegisterModule("xpbar", "vanilla:tbc", function ()
elseif event == "CHAT_MSG_COMBAT_FACTION_CHANGE" then
local _,_, faction, amount = string.find(arg1, parse_faction)
this.faction = faction or this.faction
elseif event == "UPDATE_FACTION" then
-- drop the auto-tracked faction when the user changes the watched one
local watched = C_Reputation.GetWatchedFactionData()
local watchedName = watched and watched.name or nil
if watchedName ~= this.watched then
this.watched = watchedName
this.faction = nil
end
end
end)