mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-01 03:19:59 +00:00
performance update
This commit is contained in:
+350
-29
@@ -1,6 +1,82 @@
|
||||
-- Compatibility layer to use castbars provided by SuperWoW:
|
||||
-- https://github.com/balakethelock/SuperWoW
|
||||
|
||||
-- DLL Status Check Command (always available)
|
||||
SLASH_PFDLLSTATUS1 = "/pfdll"
|
||||
SlashCmdList["PFDLLSTATUS"] = function()
|
||||
local chat = DEFAULT_CHAT_FRAME
|
||||
chat:AddMessage("|cff33ffccpfUI|r: DLL Status Check")
|
||||
|
||||
-- SuperWoW
|
||||
if SUPERWOW_VERSION then
|
||||
chat:AddMessage(" |cff00ff00SuperWoW|r: v" .. tostring(SUPERWOW_VERSION))
|
||||
elseif SpellInfo or SetAutoloot then
|
||||
chat:AddMessage(" |cffffff00SuperWoW|r: Detected (old version)")
|
||||
else
|
||||
chat:AddMessage(" |cffff0000SuperWoW|r: Not detected")
|
||||
end
|
||||
|
||||
-- Nampower
|
||||
if GetNampowerVersion then
|
||||
chat:AddMessage(" |cff00ff00Nampower|r: v" .. tostring(GetNampowerVersion()))
|
||||
else
|
||||
chat:AddMessage(" |cffff0000Nampower|r: Not detected")
|
||||
end
|
||||
|
||||
-- UnitXP
|
||||
local hasUnitXP = pcall(UnitXP, "nop", "nop")
|
||||
if hasUnitXP then
|
||||
chat:AddMessage(" |cff00ff00UnitXP_SP3|r: Detected")
|
||||
else
|
||||
chat:AddMessage(" |cffff0000UnitXP_SP3|r: Not detected")
|
||||
end
|
||||
|
||||
-- Check if castbar exists for indicator positioning
|
||||
if pfUI.castbar and pfUI.castbar.player then
|
||||
chat:AddMessage(" |cff00ff00Castbar|r: Available for indicator anchoring")
|
||||
else
|
||||
chat:AddMessage(" |cffffff00Castbar|r: Not available (indicators use fallback position)")
|
||||
end
|
||||
|
||||
-- Check indicator frames
|
||||
if pfUI.uf and pfUI.uf.target then
|
||||
chat:AddMessage(" |cff00ff00Target frame|r: exists")
|
||||
if pfUI.uf.target.behindIndicator then
|
||||
chat:AddMessage(" |cff00ff00Behind indicator|r: created")
|
||||
else
|
||||
chat:AddMessage(" |cffff0000Behind indicator|r: NOT created")
|
||||
end
|
||||
if pfUI.uf.target.losIndicator then
|
||||
chat:AddMessage(" |cff00ff00LOS indicator|r: created")
|
||||
else
|
||||
chat:AddMessage(" |cffff0000LOS indicator|r: NOT created")
|
||||
end
|
||||
else
|
||||
chat:AddMessage(" |cffff0000Target frame|r: NOT found")
|
||||
end
|
||||
end
|
||||
|
||||
-- UnitXP Behind/LOS test command
|
||||
SLASH_PFBEHIND1 = "/pfbehind"
|
||||
SlashCmdList["PFBEHIND"] = function()
|
||||
local chat = DEFAULT_CHAT_FRAME
|
||||
if not UnitExists("target") then
|
||||
chat:AddMessage("|cff33ffccpfUI|r: No target")
|
||||
return
|
||||
end
|
||||
|
||||
local hasUnitXP = pcall(UnitXP, "nop", "nop")
|
||||
if not hasUnitXP then
|
||||
chat:AddMessage("|cff33ffccpfUI|r: UnitXP not available")
|
||||
return
|
||||
end
|
||||
|
||||
local successB, behind = pcall(UnitXP, "behind", "player", "target")
|
||||
local successL, inSight = pcall(UnitXP, "inSight", "player", "target")
|
||||
|
||||
chat:AddMessage("|cff33ffccpfUI|r: Behind=" .. tostring(behind) .. " LOS=" .. tostring(inSight))
|
||||
end
|
||||
|
||||
pfUI:RegisterModule("superwow", "vanilla", function ()
|
||||
if SetAutoloot and SpellInfo and not SUPERWOW_VERSION then
|
||||
-- Turn every enchanting link that we create in the enchanting frame,
|
||||
@@ -248,12 +324,264 @@ pfUI:RegisterModule("superwow", "vanilla", function ()
|
||||
libdebuff:AddEffect(unit, unitlevel, effect, duration, caster)
|
||||
end)
|
||||
|
||||
-- Enhance libcast with SuperWoW data
|
||||
-- TrackUnit API for adding group members to minimap
|
||||
-- Tracks friendly units on the minimap for easier group coordination
|
||||
if TrackUnit and C.unitframes.track_group == "1" then
|
||||
local trackFrame = CreateFrame("Frame")
|
||||
trackFrame:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
||||
trackFrame:RegisterEvent("RAID_ROSTER_UPDATE")
|
||||
trackFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
|
||||
trackFrame:SetScript("OnEvent", function()
|
||||
-- Track party members
|
||||
for i = 1, 4 do
|
||||
local unit = "party" .. i
|
||||
if UnitExists(unit) and UnitIsConnected(unit) then
|
||||
pcall(TrackUnit, unit)
|
||||
end
|
||||
end
|
||||
|
||||
-- Track raid members
|
||||
for i = 1, 40 do
|
||||
local unit = "raid" .. i
|
||||
if UnitExists(unit) and UnitIsConnected(unit) and not UnitIsUnit(unit, "player") then
|
||||
pcall(TrackUnit, unit)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Raid Marker Targeting API
|
||||
-- Allows targeting units by raid marker ("mark1" to "mark8")
|
||||
if SUPERWOW_VERSION then
|
||||
pfUI.api.GetMarkedUnit = function(markIndex)
|
||||
local markUnit = "mark" .. markIndex
|
||||
if UnitExists(markUnit) then
|
||||
return markUnit
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
pfUI.api.TargetMark = function(markIndex)
|
||||
local markUnit = "mark" .. markIndex
|
||||
if UnitExists(markUnit) then
|
||||
TargetUnit(markUnit)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Get owner of pet/totem using "owner" suffix
|
||||
pfUI.api.GetUnitOwner = function(unit)
|
||||
local ownerUnit = unit .. "owner"
|
||||
if UnitExists(ownerUnit) then
|
||||
return UnitName(ownerUnit), ownerUnit
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Enhanced SpellInfo API wrapper
|
||||
if SpellInfo then
|
||||
pfUI.api.GetSpellInfo = function(spellId)
|
||||
local name, rank, texture, minRange, maxRange = SpellInfo(spellId)
|
||||
return {
|
||||
name = name,
|
||||
rank = rank,
|
||||
texture = texture,
|
||||
minRange = minRange,
|
||||
maxRange = maxRange,
|
||||
spellId = spellId
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Clickthrough Mode API
|
||||
-- Allows clicking through corpses to loot underneath
|
||||
if Clickthrough then
|
||||
pfUI.api.SetClickthrough = function(enabled)
|
||||
Clickthrough(enabled and 1 or 0)
|
||||
end
|
||||
|
||||
pfUI.api.GetClickthrough = function()
|
||||
return Clickthrough() == 1
|
||||
end
|
||||
|
||||
pfUI.api.ToggleClickthrough = function()
|
||||
local current = Clickthrough()
|
||||
Clickthrough(current == 1 and 0 or 1)
|
||||
return Clickthrough() == 1
|
||||
end
|
||||
|
||||
-- Add slash command for clickthrough toggle
|
||||
SLASH_PFCLICKTHROUGH1 = "/clickthrough"
|
||||
SLASH_PFCLICKTHROUGH2 = "/ct"
|
||||
SlashCmdList["PFCLICKTHROUGH"] = function()
|
||||
local enabled = pfUI.api.ToggleClickthrough()
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Clickthrough mode " .. (enabled and "|cff00ff00enabled|r" or "|cffff0000disabled|r"))
|
||||
end
|
||||
end
|
||||
|
||||
-- Autoloot Control API
|
||||
if SetAutoloot then
|
||||
pfUI.api.SetAutoloot = function(enabled)
|
||||
SetAutoloot(enabled and 1 or 0)
|
||||
end
|
||||
|
||||
pfUI.api.GetAutoloot = function()
|
||||
return SetAutoloot() == 1
|
||||
end
|
||||
|
||||
pfUI.api.ToggleAutoloot = function()
|
||||
local current = SetAutoloot()
|
||||
SetAutoloot(current == 1 and 0 or 1)
|
||||
return SetAutoloot() == 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Config Import/Export API using ImportFile/ExportFile
|
||||
if ImportFile and ExportFile then
|
||||
pfUI.api.ExportConfig = function(filename)
|
||||
filename = filename or "pfUI_config_backup.txt"
|
||||
local configStr = ""
|
||||
|
||||
-- Serialize config to string
|
||||
local function serialize(tbl, indent)
|
||||
indent = indent or ""
|
||||
local result = "{\n"
|
||||
for k, v in pairs(tbl) do
|
||||
local keyStr = type(k) == "string" and '["' .. k .. '"]' or "[" .. tostring(k) .. "]"
|
||||
if type(v) == "table" then
|
||||
result = result .. indent .. " " .. keyStr .. " = " .. serialize(v, indent .. " ") .. ",\n"
|
||||
elseif type(v) == "string" then
|
||||
result = result .. indent .. " " .. keyStr .. ' = "' .. v .. '",\n'
|
||||
else
|
||||
result = result .. indent .. " " .. keyStr .. " = " .. tostring(v) .. ",\n"
|
||||
end
|
||||
end
|
||||
return result .. indent .. "}"
|
||||
end
|
||||
|
||||
if pfUI_config then
|
||||
configStr = "pfUI_config = " .. serialize(pfUI_config)
|
||||
ExportFile(filename, configStr)
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Config exported to imports/" .. filename)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
pfUI.api.ImportConfig = function(filename)
|
||||
filename = filename or "pfUI_config_backup.txt"
|
||||
local content = ImportFile(filename)
|
||||
if content and content ~= "" then
|
||||
-- Load the config string
|
||||
local func, err = loadstring(content)
|
||||
if func then
|
||||
func()
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Config imported from imports/" .. filename)
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Please /reload to apply changes")
|
||||
return true
|
||||
else
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Error parsing config: " .. (err or "unknown"))
|
||||
end
|
||||
else
|
||||
DEFAULT_CHAT_FRAME:AddMessage("|cff33ffccpfUI|r: Could not read imports/" .. filename)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Slash commands for config backup
|
||||
SLASH_PFEXPORT1 = "/pfexport"
|
||||
SlashCmdList["PFEXPORT"] = function(msg)
|
||||
pfUI.api.ExportConfig(msg ~= "" and msg or nil)
|
||||
end
|
||||
|
||||
SLASH_PFIMPORT1 = "/pfimport"
|
||||
SlashCmdList["PFIMPORT"] = function(msg)
|
||||
pfUI.api.ImportConfig(msg ~= "" and msg or nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- GetPlayerBuffID wrapper
|
||||
if GetPlayerBuffID then
|
||||
pfUI.api.GetPlayerBuffSpellId = function(buffIndex)
|
||||
return GetPlayerBuffID(buffIndex)
|
||||
end
|
||||
end
|
||||
|
||||
-- CombatLogAdd wrapper for logging
|
||||
if CombatLogAdd then
|
||||
pfUI.api.LogToCombatLog = function(text, raw)
|
||||
CombatLogAdd(text, raw and 1 or nil)
|
||||
end
|
||||
end
|
||||
|
||||
-- Local Raid Markers (marks only visible to self)
|
||||
if SetRaidTarget then
|
||||
local origSetRaidTarget = SetRaidTarget
|
||||
pfUI.api.SetLocalRaidTarget = function(unit, index)
|
||||
origSetRaidTarget(unit, index, "local")
|
||||
end
|
||||
end
|
||||
|
||||
-- Enhanced GetContainerItemInfo for charges
|
||||
-- SuperWoW returns charges as negative numbers
|
||||
pfUI.api.GetItemCharges = function(bag, slot)
|
||||
local texture, count = GetContainerItemInfo(bag, slot)
|
||||
if count and count < 0 then
|
||||
return math.abs(count) -- Return positive charge count
|
||||
end
|
||||
return nil -- Not a charged item
|
||||
end
|
||||
|
||||
-- Weapon Enchant Info on other players
|
||||
if GetWeaponEnchantInfo then
|
||||
local origGetWeaponEnchantInfo = GetWeaponEnchantInfo
|
||||
pfUI.api.GetUnitWeaponEnchants = function(unit)
|
||||
if unit and unit ~= "player" then
|
||||
local mhName, ohName = GetWeaponEnchantInfo(unit)
|
||||
return {
|
||||
mainHand = mhName,
|
||||
offHand = ohName,
|
||||
}
|
||||
else
|
||||
local hasMainHandEnchant, mainHandExpiration, mainHandCharges, hasOffHandEnchant, offHandExpiration, offHandCharges = origGetWeaponEnchantInfo()
|
||||
return {
|
||||
mainHand = hasMainHandEnchant and true or false,
|
||||
mainHandExpiration = mainHandExpiration,
|
||||
mainHandCharges = mainHandCharges,
|
||||
offHand = hasOffHandEnchant and true or false,
|
||||
offHandExpiration = offHandExpiration,
|
||||
offHandCharges = offHandCharges,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Enhance libcast with SuperWoW data for NPCs and other players only
|
||||
-- Player casts use SPELLCAST_* events for proper pushback handling
|
||||
local supercast = CreateFrame("Frame")
|
||||
local playerGuid = nil
|
||||
|
||||
supercast:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
supercast:RegisterEvent("UNIT_CASTEVENT")
|
||||
supercast:SetScript("OnEvent", function()
|
||||
if not supercast.init then
|
||||
-- disable combat parsing events in superwow mode
|
||||
if event == "PLAYER_ENTERING_WORLD" then
|
||||
-- Cache player GUID
|
||||
if UnitExists then
|
||||
local _, guid = UnitExists("player")
|
||||
playerGuid = guid
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local guid = arg1
|
||||
local isPlayer = guid == playerGuid
|
||||
|
||||
-- For non-player units: disable combat parsing events (one-time init)
|
||||
if not isPlayer and not supercast.init then
|
||||
-- disable combat parsing events in superwow mode (for non-player units)
|
||||
libcast:UnregisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE")
|
||||
libcast:UnregisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE")
|
||||
libcast:UnregisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF")
|
||||
@@ -276,13 +604,10 @@ pfUI:RegisterModule("superwow", "vanilla", function ()
|
||||
end
|
||||
|
||||
if arg3 == "START" or arg3 == "CAST" or arg3 == "CHANNEL" then
|
||||
-- human readable argument list
|
||||
local guid = arg1
|
||||
local target = arg2
|
||||
local event_type = arg3
|
||||
local spell_id = arg4
|
||||
local timer = arg5
|
||||
local start = GetTime()
|
||||
|
||||
-- get spell info from spell id
|
||||
local spell, icon, _
|
||||
@@ -297,35 +622,31 @@ pfUI:RegisterModule("superwow", "vanilla", function ()
|
||||
-- skip on buff procs during cast
|
||||
if event_type == "CAST" then
|
||||
if not libcast.db[guid] or libcast.db[guid].cast ~= spell then
|
||||
-- ignore casts without 'START' event, while there is already another cast.
|
||||
-- those events can be for example a frost shield proc while casting frostbolt.
|
||||
-- we want to keep the cast itself, so we simply skip those.
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- For player: store in libcast.db[playerName] so pushback tracking works
|
||||
-- For others: store by GUID
|
||||
local dbKey = isPlayer and UnitName("player") or guid
|
||||
|
||||
-- add cast action to the database
|
||||
if not libcast.db[guid] then libcast.db[guid] = {} end
|
||||
libcast.db[guid].cast = spell
|
||||
libcast.db[guid].rank = nil
|
||||
libcast.db[guid].start = GetTime()
|
||||
libcast.db[guid].casttime = timer
|
||||
libcast.db[guid].icon = icon
|
||||
libcast.db[guid].channel = event_type == "CHANNEL" or false
|
||||
|
||||
-- write state variable
|
||||
superwow_active = true
|
||||
if not libcast.db[dbKey] then libcast.db[dbKey] = {} end
|
||||
libcast.db[dbKey].cast = spell
|
||||
libcast.db[dbKey].rank = nil
|
||||
libcast.db[dbKey].start = GetTime()
|
||||
libcast.db[dbKey].casttime = timer or 0
|
||||
libcast.db[dbKey].icon = icon
|
||||
libcast.db[dbKey].channel = event_type == "CHANNEL" or false
|
||||
elseif arg3 == "FAIL" then
|
||||
local guid = arg1
|
||||
|
||||
-- delete all cast entries of guid
|
||||
if libcast.db[guid] then
|
||||
libcast.db[guid].cast = nil
|
||||
libcast.db[guid].rank = nil
|
||||
libcast.db[guid].start = nil
|
||||
libcast.db[guid].casttime = nil
|
||||
libcast.db[guid].icon = nil
|
||||
libcast.db[guid].channel = nil
|
||||
local dbKey = isPlayer and UnitName("player") or guid
|
||||
if libcast.db[dbKey] then
|
||||
libcast.db[dbKey].cast = nil
|
||||
libcast.db[dbKey].rank = nil
|
||||
libcast.db[dbKey].start = nil
|
||||
libcast.db[dbKey].casttime = nil
|
||||
libcast.db[dbKey].icon = nil
|
||||
libcast.db[dbKey].channel = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user