mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
75c4657ab9
* nameplates: source totem icons from UnitCreatedBySpell
Read the totem's icon from the totem-drop spell (UnitCreatedBySpell +
GetSpellTexture) instead of the self-aura at index 1 plus a
UNIT_SPELLCAST_SUCCEEDED capture for active totems. The drop spell is a
broadcast descriptor field present for every summoned unit in range, so
it resolves immediately for passive and active totems alike and gives the
totem's own icon rather than the attack-spell proxy. Drops the
UNIT_SPELLCAST_SUCCEEDED registration and handler.
Re-read the spell each render and key the cached texture on the spell id
so an in-place totem swap (same unit, new drop spell -- no plate re-add)
refreshes the icon without needing the plate to leave and re-enter view.
* CAPI min bumped to 1.13.1
* Gracefully disable pfUI when ClassicAPI is missing
Add API_Check.lua as the first TOC entry. When the ClassicAPI DLL is
absent or below the minimum version it sets pfUI_disabled and stands up
an inert stub so the rest of the addon no-ops instead of flooding load
errors: modules and skins register their bodies into no-ops, and the
setfenv'd api/lib files run inside an environment where CreateFrame and
any missing global resolve to a null object -- so no real frames or live
handlers are created and missing API calls just return null. pfUI.lua
bails early on pfUI_disabled.
* auras: scan through GetAuraSlots instead of by-index loops
Every aura scan loop (unit frame buffs/debuffs, dispel indicators, buff and
custom indicators, player buff frame, buffwatch bars, tooltip buff row) now
enumerates a unit's auras once with C_UnitAuras.GetAuraSlots and reads each
aura by slot id via the positional C_UnitAuras.UnitAuraBySlot. The by-index
getters re-walk the aura array from slot 0 on every call, so a per-button
loop over them was quadratic in the aura count; one enumeration plus a
by-slot read per aura is linear.
pfUI.api.ScanAuraSlots(unit, filter, buf, max) wraps GetAuraSlots' fill-a-
table form (table as the 5th argument) so no vararg Lua frame is involved:
Lua 5.0 allocates an `arg` table for every vararg call, which showed up as
nameplate OnUpdate/OnEvent memory growth in the first cut of this change.
Single by-index reads in tooltip and click handlers are unchanged (one call
each, and SetUnitAura takes the same index).
Requires the ClassicAPI build that adds GetAuraSlots' fill form; on an older
DLL the 5th argument is ignored and ScanAuraSlots would read the first slot
id as the count.
* Show Faction/Race icons in chat
* Load pfUI through ClassicAPI's flavor TOCs
ClassicAPI redirects the read of pfUI\pfUI.toc to a flavored file whenever
the DLL is installed, so which TOC the client opens already answers whether
ClassicAPI is there. Split the manifest three ways and let that do the work:
pfUI.toc fallback, reached only when ClassicAPI is missing;
loads API_Check.lua and nothing else
pfUI_ClassicAPI.toc full addon, every non-Turtle client
pfUI_Turtle.toc full addon plus init\turtle.xml, on Turtle
The fallback TOC declares no SavedVariables. It used to, while API_Check.lua
reset pfUI_profiles to an empty table on the disabled path -- which truncated
the player's profiles on logout.
With the missing-DLL case handled by TOC selection, API_Check.lua drops the
null object stub that kept the other ~140 files quiet, along with
pfUI_disabled and the now unreachable early return in pfUI.lua. It keeps the
version gate, which still matters: the flavor redirect landed in ClassicAPI
v1.11.0, below the v1.13.1 pfUI needs, so an old DLL still gets served a
flavor TOC. pfUI.lua also loses a verbatim duplicate of the whole check.
Turtle-only files move to init\turtle.xml: modules\turtle-wow.lua (its
TURTLE_WOW_VERSION guard is now redundant) and the lft, turtle_shop,
barbershop, transmog and ebc skins. turtle-wow registers last instead of
75th of 84; the only ordering it relies on is pfUI.chat, registered 8th.
pfSellData moves to env\selldata.lua, listed only in pfUI_ClassicAPI.toc,
since turtle-wow.lua replaces the table wholesale on Turtle. env\tables.lua
keeps an empty declaration so sellvalue.lua has something to index when the
turtle-wow module is disabled.
The release workflow pinned PFUI_CLASSIC_API_LATEST in pfUI.lua, which has
not held that constant since it moved to API_Check.lua, so the pin was
silently doing nothing. It also switches to brues-code/packager@vCAPI, which
recognizes the _ClassicAPI and _Turtle suffixes and applies the TOC build
type filters to them.
* Split the vendor price tables into their own manifests
Turtle's pfSellData moves out of modules\turtle-wow.lua into
env\selldata_turtle.lua, matching env\selldata.lua for the stock list, and
each is pulled in by the manifest for its client: init\stock.xml from
pfUI_ClassicAPI.toc, init\turtle.xml from pfUI_Turtle.toc. Either way it
loads after init\env.xml and replaces the empty pfSellData declared there.
Turtle's prices used to be assigned inside the turtle-wow module body, which
put them on pfUI.env and skipped them entirely when that module was
disabled. At file scope they land on _G and apply either way.
* Drop the vanilla compat layer
compat\vanilla.lua named the handful of things that differed between clients
back when pfUI targeted several. Only one client remains, so every constant
had exactly one value. Inline each at its use site and delete the file,
init\compat.xml, and both TOC entries.
COOLDOWN_FRAME_TYPE -> "Model"
LOOT_BUTTON_FRAME_TYPE -> "LootButton"
MINIMAP_TRACKING_FRAME -> _G.MiniMapTrackingFrame
FRIENDS_NAME_LOCATION -> "ButtonTextNameLocation"
EVENTS_MINIMAP_ZONE_UPDATE -> the event list, in panel.lua
MICRO_BUTTONS -> a local in panel.lua
NAMEPLATE_OBJECTORDER -> a local in nameplates.lua
ACTIONBAR_SECURE_TEMPLATE_BAR/_BUTTON -> nil, so the argument goes away
NAMEPLATE_FRAMETYPE and PLAYER_BUFF_START_ID had no readers left.
RunMacroText moves to pfUI.lua. compat\vanilla.lua was setfenv'd into the
pfUI environment, so the function only ever existed on pfUI.env; at file
scope it lands on _G as a real export instead. Nothing in pfUI calls it, and
ClassicAPI neither defines nor looks for a RunMacroText global -- it does
the same throwaway edit box natively in src/macro/Execute.cpp and only
defers to a global RunMacro.
* bump CAPI min to 11303
* auras: uncap the self-debuff tooltip lookup
With selfdebuff on, the displayed debuff list is PLAYER-filtered while
GameTooltip:SetUnitAura indexes the unfiltered HARMFUL list, so both
handlers map one to the other by matching name + sourceGUID. That mapping
scanned slots 1..16 only.
The unfiltered harmful list is not capped at 16. Once a unit's 16 debuff
slots are full the server parks further debuffs in buff slots, and
C_UnitAuras classifies by the aura's polarity flag rather than its slot
range, so it reports those as harmful too -- verified live at 18 harmful on
a 20-aura target. Past the sixteenth the lookup found nothing and fell
through to the raw filtered index, opening the wrong tooltip or none.
Both now enumerate however many harmful auras the unit actually has, via
ScanAuraSlots, which also drops the per-index rescan the by-index accessor
was doing. Each handler gets its own slot buffer: OnEnter can fire while a
refresh is showing/hiding frames under the cursor, so sharing the refresh
buffer could clobber a scan mid-walk.
The nameplate module still collects at most 16 debuffs per plate. That one
is a display cap matching its 16 configured icon frames, not an aura-count
assumption, so it is left alone.
* bump CAPI min to 11304
398 lines
15 KiB
Lua
398 lines
15 KiB
Lua
pfUI:RegisterModule("tooltip", function ()
|
|
local rawborder, default_border = GetBorderSize()
|
|
|
|
pfUI.tooltip = CreateFrame('Frame', "pfTooltip", GameTooltip)
|
|
pfUI.tooltip.anchorframe = CreateFrame('Frame', "pfTooltipAnchor", UIParent)
|
|
pfUI.tooltip.anchorframe:SetSize(128, 72)
|
|
pfUI.tooltip.anchorframe:SetPoint("TOP", UIParent, "TOP", 0, -50)
|
|
pfUI.tooltip.anchorframe:Hide()
|
|
UpdateMovable(pfUI.tooltip.anchorframe)
|
|
|
|
function pfUI.tooltip:GetAnchorPoint()
|
|
local prefix = "TOP"
|
|
local suffix = "RIGHT"
|
|
local px, py = UIParent:GetCenter()
|
|
local tx, ty = this.anchorframe:GetCenter()
|
|
if (tx < px) then
|
|
suffix = "LEFT"
|
|
end
|
|
if (ty < py) then
|
|
prefix = "BOTTOM"
|
|
end
|
|
return prefix..suffix
|
|
end
|
|
|
|
if C.tooltip.position == "cursor" then
|
|
-- Cursor mode makes the tooltip follow the mouse. The client has no
|
|
-- mouse-move event, so following means polling GetCursorPosition() via an
|
|
-- invisible follower frame that the tooltip anchors to. The follower is
|
|
-- only shown while a tooltip is visible -- an OnUpdate fires only while its
|
|
-- frame is shown, so the poll stops the moment the tooltip hides instead
|
|
-- of running forever.
|
|
local follower, Reposition
|
|
if C.tooltip.cursoralign ~= "native" then
|
|
local size = tonumber(C.tooltip.cursoroffset) * 2
|
|
follower = CreateFrame("Frame", nil, UIParent)
|
|
follower:SetSize(size, size)
|
|
follower:Hide()
|
|
|
|
Reposition = function()
|
|
local scale = UIParent:GetScale()
|
|
local x, y = GetCursorPosition()
|
|
follower:SetPoint("CENTER", UIParent, "BOTTOMLEFT", x/scale, y/scale)
|
|
if C.tooltip.cursoralign == "top" then
|
|
follower:SetWidth(GameTooltip:GetWidth())
|
|
end
|
|
end
|
|
|
|
follower:SetScript("OnUpdate", function()
|
|
-- throttle - cursor following doesn't need to be every frame
|
|
if (this.tick or 0) > GetTime() then return end
|
|
this.tick = GetTime() + (pfUI.throttle and pfUI.throttle:Get("tooltip_cursor") or 0.1)
|
|
Reposition()
|
|
end)
|
|
|
|
-- stop polling as soon as the tooltip is gone
|
|
pfUI.tooltip:SetScript("OnHide", function() follower:Hide() end)
|
|
end
|
|
|
|
function _G.GameTooltip_SetDefaultAnchor(tooltip, parent)
|
|
tooltip:SetOwner(parent, "ANCHOR_CURSOR")
|
|
if not follower then return end
|
|
|
|
-- position the follower right away so the tooltip doesn't flash at a
|
|
-- stale spot before the first OnUpdate tick
|
|
follower:Show()
|
|
Reposition()
|
|
|
|
if C.tooltip.cursoralign == "top" then
|
|
tooltip:SetPoint("BOTTOMLEFT", follower, "TOPLEFT", 0, 0)
|
|
elseif C.tooltip.cursoralign == "left" then
|
|
tooltip:SetPoint("BOTTOMRIGHT", follower, "LEFT", 0, 0)
|
|
elseif C.tooltip.cursoralign == "right" then
|
|
tooltip:SetPoint("BOTTOMLEFT", follower, "RIGHT", 0, 0)
|
|
end
|
|
end
|
|
end
|
|
|
|
function pfUI.tooltip:GetUnit()
|
|
pfUI.tooltip.unit = "none"
|
|
if GameTooltip:HasUnit() then
|
|
local _, guid = GameTooltip:GetUnitGUID()
|
|
local token = guid and UnitTokenFromGUID(guid)
|
|
if token then pfUI.tooltip.unit = token end
|
|
end
|
|
return pfUI.tooltip.unit
|
|
end
|
|
|
|
pfUI.tooltip.dodge = {
|
|
"pfPanelRight", "pfChatRight"
|
|
}
|
|
|
|
if C.appearance.bags.movable == "0" then
|
|
table.insert(pfUI.tooltip.dodge, "pfBag")
|
|
end
|
|
|
|
pfUI.tooltip:SetAllPoints()
|
|
pfUI.tooltip:SetScript("OnShow", function()
|
|
pfUI.tooltip:Update()
|
|
if GameTooltip:GetAnchorType() == "ANCHOR_NONE" then
|
|
GameTooltip:ClearAllPoints()
|
|
if C.tooltip.position == "bottom" then
|
|
if pfUI.panel and pfUI.panel.right:IsShown() then
|
|
GameTooltip:SetPoint("BOTTOMRIGHT", pfUI.panel.right, "TOPRIGHT", 0, default_border*2)
|
|
else
|
|
GameTooltip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 5)
|
|
end
|
|
elseif C.tooltip.position == "chat" then
|
|
local anchor = nil
|
|
|
|
for _, frame in pairs(pfUI.tooltip.dodge) do
|
|
if _G[frame] and _G[frame]:IsShown() then
|
|
anchor = _G[frame]
|
|
end
|
|
end
|
|
|
|
if anchor then
|
|
GameTooltip:SetPoint("BOTTOMRIGHT", anchor, "TOPRIGHT", 0, default_border*3)
|
|
else
|
|
GameTooltip:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", -5, 5)
|
|
end
|
|
elseif C.tooltip.position == "free" then
|
|
local point = this:GetAnchorPoint()
|
|
if point then
|
|
GameTooltip:SetPoint(point, this.anchorframe, point, 0, 0)
|
|
end
|
|
end
|
|
end
|
|
end)
|
|
|
|
pfUI.tooltipStatusBar = CreateFrame('Frame', nil, GameTooltipStatusBar)
|
|
pfUI.tooltipStatusBar:SetPoint("TOPLEFT", 0, 8)
|
|
pfUI.tooltipStatusBar:SetPoint("TOPRIGHT", 0, 8)
|
|
pfUI.tooltipStatusBar:SetHeight(12)
|
|
pfUI.tooltipStatusBar:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
|
|
pfUI.tooltipStatusBar:SetScript("OnEvent", function()
|
|
this.name = UnitName("mouseover")
|
|
this.level = UnitLevel("mouseover")
|
|
end)
|
|
|
|
pfUI.tooltipStatusBar.text = CreateFrame("Frame", nil, pfUI.tooltipStatusBar)
|
|
pfUI.tooltipStatusBar.text:SetFrameLevel(16)
|
|
pfUI.tooltipStatusBar.text:SetAllPoints()
|
|
|
|
pfUI.tooltipStatusBar.HP = pfUI.tooltipStatusBar.text:CreateFontString("Status", "OVERLAY", "GameFontNormal")
|
|
pfUI.tooltipStatusBar.HP:SetAllPoints()
|
|
pfUI.tooltipStatusBar.HP:SetNonSpaceWrap(false)
|
|
pfUI.tooltipStatusBar.HP:SetFontObject(GameFontWhite)
|
|
pfUI.tooltipStatusBar.HP:SetFont(C.tooltip.font_tooltip, C.tooltip.font_tooltip_size + 2, "OUTLINE")
|
|
|
|
if GameTooltip.SetClampRectInsets then
|
|
GameTooltip:SetClampRectInsets(0, 0, 16, 0)
|
|
else
|
|
GameTooltipStatusBar:SetClampedToScreen(true)
|
|
pfUI.tooltipStatusBar:SetClampedToScreen(true)
|
|
end
|
|
|
|
pfUI.tooltipStatusBar:SetScript("OnUpdate", function()
|
|
local hp = GameTooltipStatusBar:GetValue()
|
|
local _, hpmax = GameTooltipStatusBar:GetMinMaxValues()
|
|
local rhp, rhpmax, estimated
|
|
|
|
if hpmax > 100 or (round(hpmax/100*hp) ~= hp) then
|
|
rhp, rhpmax = hp, hpmax
|
|
elseif pfUI.libhealth and pfUI.libhealth.enabled then
|
|
rhp, rhpmax, estimated = pfUI.libhealth:GetUnitHealthByName(this.name, this.level, tonumber(hp), tonumber(hpmax))
|
|
end
|
|
|
|
if C.tooltip.alwaysperc == "0" and ( estimated or hpmax > 100 or round(hpmax/100*hp) ~= hp ) then
|
|
pfUI.tooltipStatusBar.HP:SetFormattedText("%s / %s", Abbreviate(rhp), Abbreviate(rhpmax))
|
|
elseif hpmax > 0 then
|
|
pfUI.tooltipStatusBar.HP:SetFormattedText("%s%%", ceil(hp/hpmax*100))
|
|
else
|
|
pfUI.tooltipStatusBar.HP:SetText("")
|
|
end
|
|
end)
|
|
|
|
GameTooltipStatusBar:SetHeight(8)
|
|
GameTooltipStatusBar:ClearAllPoints()
|
|
GameTooltipStatusBar:SetPoint("BOTTOMLEFT", GameTooltip, "TOPLEFT", 0, default_border)
|
|
GameTooltipStatusBar:SetPoint("BOTTOMRIGHT", GameTooltip, "TOPRIGHT", 0, default_border)
|
|
GameTooltipStatusBar:SetStatusBarTexture(pfUI.media[C.tooltip.statusbar.texture])
|
|
CreateBackdrop(GameTooltipStatusBar, nil, nil, tonumber(C.tooltip.alpha))
|
|
CreateBackdropShadow(GameTooltipStatusBar)
|
|
|
|
GameTooltipStatusBar.SetStatusBarColor_orig = GameTooltipStatusBar.SetStatusBarColor
|
|
GameTooltipStatusBar.SetStatusBarColor = function() return end
|
|
|
|
-- A row of buff icons anchored above the tooltip for mouseover units.
|
|
-- Icons come from a ClassicAPI object pool: ReleaseAll hides the whole
|
|
-- set each refresh, then we Acquire and re-anchor left-to-right.
|
|
local BUFF_SIZE, BUFF_SPACING, BUFF_MAX = 20, 2, 32
|
|
local auraSlots = {} -- reusable GetAuraSlots buffer for UpdateBuffs
|
|
pfUI.tooltip.buffs = CreateFrame("Frame", "pfTooltipBuffs", GameTooltip)
|
|
pfUI.tooltip.buffs:SetPoint("BOTTOMLEFT", GameTooltipStatusBar, "TOPLEFT", 0, default_border + 2)
|
|
pfUI.tooltip.buffs:SetHeight(BUFF_SIZE)
|
|
|
|
local function CreateBuffIcon()
|
|
local icon = CreateFrame("Frame", nil, pfUI.tooltip.buffs)
|
|
icon:SetSize(BUFF_SIZE, BUFF_SIZE)
|
|
icon.texture = icon:CreateTexture(nil, "BACKGROUND")
|
|
icon.texture:SetTexCoord(.07, .93, .07, .93)
|
|
icon.texture:SetAllPoints(icon)
|
|
CreateBackdrop(icon)
|
|
|
|
icon.stacks = icon:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
|
icon.stacks:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", 1, 0)
|
|
icon.stacks:SetFont(C.tooltip.font_tooltip, C.tooltip.font_tooltip_size, "OUTLINE")
|
|
icon.stacks:SetTextColor(1, 1, 1, 1)
|
|
|
|
icon.timer = icon:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
|
icon.timer:SetPoint("CENTER", icon, "CENTER", 0, 0)
|
|
icon.timer:SetFont(C.tooltip.font_tooltip, C.tooltip.font_tooltip_size, "OUTLINE")
|
|
icon.timer:SetTextColor(1, 1, 1, 1)
|
|
return icon
|
|
end
|
|
|
|
pfUI.tooltip.buffpool = CreateObjectPool(CreateBuffIcon, function(_, icon)
|
|
icon:Hide()
|
|
icon:ClearAllPoints()
|
|
end)
|
|
|
|
-- Tick the remaining-time text on the visible icons. OnUpdate only fires
|
|
-- while the row is shown, so it stops as soon as the tooltip hides.
|
|
pfUI.tooltip.buffs:SetScript("OnUpdate", function()
|
|
local now = GetTime()
|
|
if (this.tick or 0) > now then return end
|
|
this.tick = now + 0.1
|
|
for icon in pfUI.tooltip.buffpool:EnumerateActive() do
|
|
local timeleft = icon.expirationTime and icon.expirationTime > 0 and (icon.expirationTime - now) or 0
|
|
icon.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
|
end
|
|
end)
|
|
|
|
function pfUI.tooltip:UpdateBuffs(unit)
|
|
pfUI.tooltip.buffpool:ReleaseAll()
|
|
|
|
if C.tooltip.showbuffs ~= "1" or not unit or unit == "none" then
|
|
pfUI.tooltip.buffs:Hide()
|
|
return
|
|
end
|
|
|
|
local prev, count = nil, 0
|
|
-- one GetAuraSlots enumeration + positional by-slot reads: no per-aura
|
|
-- table and no per-index re-walk of the aura array
|
|
local n = ScanAuraSlots(unit, "HELPFUL", auraSlots, BUFF_MAX)
|
|
for i = 1, n do
|
|
local name, texture, applications, _, _, expirationTime = C_UnitAuras.UnitAuraBySlot(unit, auraSlots[i])
|
|
if not name then break end
|
|
|
|
count = count + 1
|
|
local icon = pfUI.tooltip.buffpool:Acquire()
|
|
icon.texture:SetTexture(texture)
|
|
icon.stacks:SetText(applications and applications > 1 and applications or "")
|
|
|
|
icon.expirationTime = expirationTime
|
|
local timeleft = expirationTime and expirationTime > 0 and (expirationTime - GetTime()) or 0
|
|
icon.timer:SetText(timeleft > 0 and GetColoredTimeString(timeleft) or "")
|
|
|
|
if prev then
|
|
icon:SetPoint("LEFT", prev, "RIGHT", BUFF_SPACING, 0)
|
|
else
|
|
icon:SetPoint("BOTTOMLEFT", pfUI.tooltip.buffs, "BOTTOMLEFT", 0, 0)
|
|
end
|
|
icon:Show()
|
|
prev = icon
|
|
end
|
|
|
|
if count > 0 then
|
|
pfUI.tooltip.buffs:SetWidth(count * BUFF_SIZE + (count - 1) * BUFF_SPACING)
|
|
pfUI.tooltip.buffs:Show()
|
|
else
|
|
pfUI.tooltip.buffs:Hide()
|
|
end
|
|
end
|
|
|
|
function pfUI.tooltip:Update()
|
|
local unit = pfUI.tooltip:GetUnit()
|
|
pfUI.tooltip:UpdateBuffs(unit)
|
|
if unit == "none" then
|
|
if C.tooltip.itemid == "1" and GameTooltip:HasItem() then
|
|
local _, _, itemID = GameTooltip:GetItem()
|
|
GameTooltip:AddLine(T["ItemID"] .. ": " .. itemID, .25,.5,1)
|
|
GameTooltip:Show()
|
|
elseif C.tooltip.spellid == "1" and GameTooltip:HasSpell() then
|
|
local _, _, spellID = GameTooltip:GetSpell()
|
|
GameTooltip:AddLine(T["SpellID"] .. ": " .. spellID, .25,.5,1)
|
|
GameTooltip:Show()
|
|
end
|
|
|
|
return
|
|
end
|
|
|
|
local pvpname = UnitPVPName(unit)
|
|
local name = UnitName(unit)
|
|
local validTarget, target = pcall(UnitName, unit .. 'target')
|
|
local class = UnitClassBase(unit)
|
|
local guild, rankstr, rankid = GetGuildInfo(unit)
|
|
local reaction = UnitReaction(unit, "player")
|
|
local pvptitle = gsub(gsub(pvpname or name, name, "", 1), "^%s*(.-)%s*$", "%1")
|
|
local hp = UnitHealth(unit)
|
|
local hpm = UnitHealthMax(unit)
|
|
|
|
if name then
|
|
if UnitIsPlayer(unit) and class then
|
|
local color = PFUI_CLASS_COLORS[class]
|
|
GameTooltipStatusBar:SetStatusBarColor_orig(color:GetRGB())
|
|
GameTooltip:SetBackdropBorderColor(color:GetRGB())
|
|
GameTooltipTextLeft1:SetText("|c" .. color.colorStr .. name)
|
|
elseif reaction then
|
|
local color = UnitReactionColor[reaction]
|
|
GameTooltipStatusBar:SetStatusBarColor_orig(color.r, color.g, color.b)
|
|
GameTooltip:SetBackdropBorderColor(color.r, color.g, color.b)
|
|
end
|
|
if pvptitle ~= name and pvptitle ~= "" then
|
|
GameTooltip:AppendText(" |cff666666["..pvptitle.."]|r")
|
|
end
|
|
end
|
|
|
|
if guild then
|
|
local rank = ""
|
|
local lead = ""
|
|
if C.tooltip.extguild == "1" then
|
|
if rankstr then rank = " |cffaaaaaa(" .. rankstr .. ")" end
|
|
if rankid and rankid == 0 then lead = "|cffffcc00*|r" end
|
|
end
|
|
|
|
GameTooltip:AddLine("<" .. guild .. ">" .. lead .. rank, 0.3, 1, 0.5)
|
|
end
|
|
|
|
if validTarget and target then
|
|
local targetClass = UnitClassBase(unit .. "target")
|
|
local targetReaction = UnitReaction("player",unit .. "target")
|
|
if UnitIsPlayer(unit .. "target") and targetClass then
|
|
local color = PFUI_CLASS_COLORS[targetClass]
|
|
GameTooltip:AddLine(target, color.r, color.g, color.b)
|
|
elseif targetReaction then
|
|
local color = UnitReactionColor[targetReaction]
|
|
if color then
|
|
GameTooltip:AddLine(target, color.r, color.g, color.b)
|
|
else
|
|
GameTooltip:AddLine(target, .5, .5, .5)
|
|
end
|
|
end
|
|
end
|
|
|
|
if C.tooltip.movespeed == "1" then
|
|
local currentSpeed = GetUnitSpeed(unit)
|
|
if currentSpeed and currentSpeed > 0 then
|
|
local pct = floor(currentSpeed / 7 * 100 + 0.5)
|
|
GameTooltip:AddLine(T["Speed"] .. ": " .. pct .. "%", 0.7, 0.7, 1)
|
|
end
|
|
end
|
|
|
|
if C.tooltip.unitid == "1" and not UnitIsPlayer(unit) then
|
|
local npcID = C_CreatureInfo.GetCreatureID(UnitGUID(unit))
|
|
if npcID then
|
|
GameTooltip:AddLine(T["UnitID"] .. ": " .. npcID, .25,.5,1)
|
|
end
|
|
end
|
|
|
|
if hp and hpm then
|
|
if hp >= 1000 then hp = round(hp / 1000, 1) .. "k" end
|
|
if hpm >= 1000 then hpm = round(hpm / 1000, 1) .. "k" end
|
|
pfUI.tooltipStatusBar.HP:SetText(hp .. " / " .. hpm)
|
|
end
|
|
GameTooltip:Show()
|
|
end
|
|
|
|
if C.tooltip.aurasource == "1" or C.tooltip.spellid == "1" then
|
|
hooksecurefunc(GameTooltip, "SetUnitAura", function(self, ...)
|
|
local aura = C_UnitAuras.GetAuraDataByIndex(unpack(arg))
|
|
if not aura then return end
|
|
if C.tooltip.aurasource == "1" then
|
|
local caster = aura.sourceUnit and UnitName(aura.sourceUnit)
|
|
if not caster and aura.sourceGUID then
|
|
caster = UnitNameFromGUID(aura.sourceGUID)
|
|
end
|
|
if caster and caster ~= "" then
|
|
local classToken
|
|
if aura.sourceUnit and UnitIsPlayer(aura.sourceUnit) then
|
|
classToken = UnitClassBase(aura.sourceUnit)
|
|
elseif aura.sourceGUID then
|
|
classToken = select(2, GetPlayerInfoByGUID(aura.sourceGUID))
|
|
end
|
|
if classToken then
|
|
caster = PFUI_CLASS_COLORS[classToken]:WrapTextInColorCode(caster)
|
|
end
|
|
self:AddLine(T["Cast by"] .. ": " .. caster, .25,.5,1)
|
|
end
|
|
end
|
|
if C.tooltip.spellid == "1" then
|
|
self:AddLine(T["SpellID"] .. ": " .. aura.spellId, .25,.5,1)
|
|
end
|
|
self:Show()
|
|
end)
|
|
end
|
|
end)
|