mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-22 07:36:56 +00:00
69d778d6d6
* skins: drop includes for two files that were never committed init/skins.xml referenced custom_merchant.lua and arena_score.lua, neither of which is tracked in git. Every install -- release zips included, since the release workflow packages the repo -- throws two 'Error loading' lines at login and ships without those two skins. (cherry picked from commit b338b4a16d0def4ae89fde5c6026e58a796b8c00) * map: don't re-anchor the world map to the frame GetPoint returned Ctrl+scroll rescales the map and repositions it to keep the top-left fixed, but it re-anchored using the relative frame GetPoint handed back. Once anything else is anchored to WorldMapFrame that throws WorldMapFrame:SetPoint(): <unnamed> is dependent on this and the error aborts the rest of the zoom handler, so SetScale never runs. Anchor to the parent instead. That is what the rest of pfUI's movable system already assumes -- LoadMovable uses the 3-arg form and SaveMovable stores only xpos/ypos with no relative frame. (cherry picked from commit bf055d87fc0a04ac912c13fa874a4331f47bdfa8) * firstrun: return after bailing on a disabled chat module All three chat setup steps printed 'Chat module is disabled' and then carried on into the nil pfUI.chat they had just tested for. (cherry picked from commit 1af427e3b38bb7c13f645ae7a48b8ade3e7455a9) * unitxp: stop the free-frame distance poller on logout The PLAYER_LOGOUT handler stops the indicators to avoid the UnitXP crash on exit, but in free-frame distance mode the polling runs on a separate scanner frame that was never exposed, so the handler could not reach it and its OnUpdate kept calling into UnitXP during teardown. Exposes the frame as pfUI.uf.target.distanceScanner and stops it alongside the others. * roll: bail out on an item the client has not cached C_Item.GetItemInfo returns nil for an item that is not cached yet, and the next line assigns pfUI.roll.cache[itemName], which throws "table index is nil" on a nil key. Easy to hit on a fresh login when someone rolls on an item you have never seen. * cooldown: return after hiding on a nil parent Without the return it falls straight through to parent:GetName() on the nil it just tested for.
140 lines
5.0 KiB
Lua
140 lines
5.0 KiB
Lua
pfUI:RegisterModule("cooldown", function ()
|
|
-- cache values
|
|
-- local lowcolor = {strsplit(",", C.appearance.cd.lowcolor)}
|
|
-- local normalcolor = {strsplit(",", C.appearance.cd.normalcolor)}
|
|
-- local minutecolor = {strsplit(",", C.appearance.cd.minutecolor)}
|
|
-- local hourcolor = {strsplit(",", C.appearance.cd.hourcolor)}
|
|
-- local daycolor = {strsplit(",", C.appearance.cd.daycolor)}
|
|
|
|
local parent, parent_name
|
|
local function pfCooldownOnUpdate()
|
|
parent = this:GetParent()
|
|
if not parent then this:Hide() return end
|
|
parent_name = parent:GetName()
|
|
|
|
-- avoid to set cooldowns on invalid frames
|
|
if parent_name and _G[parent_name .. "Cooldown"] then
|
|
if not _G[parent_name .. "Cooldown"]:IsShown() then
|
|
this:Hide()
|
|
end
|
|
end
|
|
|
|
-- only run every 0.1 seconds from here on
|
|
if ( this.tick or .1) > GetTime() then return else this.tick = GetTime() + .1 end
|
|
|
|
-- fix own alpha value (should be inherited, but somehow isn't always)
|
|
if this:GetAlpha() ~= parent:GetAlpha() then
|
|
this:SetAlpha(parent:GetAlpha())
|
|
end
|
|
|
|
if this.start < GetTime() then
|
|
-- calculating remaining time as it should be
|
|
local remaining = this.duration - (GetTime() - this.start)
|
|
if remaining >= 0 then
|
|
this.text:SetText(GetColoredTimeString(remaining))
|
|
else
|
|
this:Hide()
|
|
end
|
|
else
|
|
-- I have absolutely no idea, but it works:
|
|
-- https://github.com/Stanzilla/WoWUIBugs/issues/47
|
|
local time = time()
|
|
local startupTime = time - GetTime()
|
|
-- just a simplification of: ((2^32) - (start * 1000)) / 1000
|
|
local cdTime = (2 ^ 32) / 1000 - this.start
|
|
local cdStartTime = startupTime - cdTime
|
|
local cdEndTime = cdStartTime + this.duration
|
|
local remaining = cdEndTime - time
|
|
|
|
if remaining >= 0 then
|
|
this.text:SetText(GetColoredTimeString(remaining))
|
|
else
|
|
this:Hide()
|
|
end
|
|
end
|
|
end
|
|
|
|
local height, size
|
|
local function pfCreateCoolDown(cooldown, start, duration)
|
|
cooldown.pfCooldownText = CreateFrame("Frame", "pfCooldownFrame", cooldown:GetParent())
|
|
cooldown.pfCooldownText:SetAllPoints(cooldown)
|
|
cooldown.pfCooldownText:SetFrameLevel(cooldown:GetParent():GetFrameLevel() + 2)
|
|
cooldown.pfCooldownText.text = cooldown.pfCooldownText:CreateFontString("pfCooldownFrameText", "OVERLAY")
|
|
|
|
if not cooldown.pfCooldownType then
|
|
size = tonumber(C.appearance.cd.font_size_foreign)
|
|
elseif cooldown.pfCooldownType == "BLIZZARD" then
|
|
size = tonumber(C.appearance.cd.font_size_blizz)
|
|
elseif cooldown.pfCooldownSize then
|
|
size = tonumber(cooldown.pfCooldownSize)
|
|
else
|
|
size = tonumber(C.appearance.cd.font_size)
|
|
end
|
|
|
|
-- enforce dynamic font size
|
|
if C.appearance.cd.dynamicsize == "1" and cooldown.GetParent then
|
|
height = cooldown:GetParent() and cooldown:GetParent():GetHeight() or cooldown:GetHeight() or 0
|
|
size = math.max((height > 0 and height * .64 or 16), size)
|
|
end
|
|
|
|
cooldown.pfCooldownText.text:SetFont(pfUI.media[C.appearance.cd.font], size, "OUTLINE")
|
|
cooldown.pfCooldownText.text:SetPoint("CENTER", cooldown.pfCooldownText, "CENTER", 0, 0)
|
|
cooldown.pfCooldownText:SetScript("OnUpdate", pfCooldownOnUpdate)
|
|
end
|
|
|
|
-- hook
|
|
local function SetCooldown(this, start, duration, enable)
|
|
-- abort on unknown frames
|
|
if C.appearance.cd.foreign == "0" and not this.pfCooldownType then
|
|
return
|
|
end
|
|
|
|
-- add support for omnicc's disable flag
|
|
if this.noCooldownCount then
|
|
return
|
|
end
|
|
|
|
-- realign cooldown frames
|
|
local parent = this.GetParent and this:GetParent()
|
|
if parent and parent:GetWidth() / 36 > 0 then
|
|
this:SetScale(parent:GetWidth() / 36)
|
|
this:SetPoint("TOPLEFT", parent, "TOPLEFT", -1, 1)
|
|
this:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", 1, -1)
|
|
end
|
|
|
|
-- don't draw global cooldowns
|
|
if this.pfCooldownType == "NOGCD" and duration < tonumber(C.appearance.cd.threshold) then
|
|
start, duration = 0, 0
|
|
end
|
|
|
|
-- disable GCDs on non pfUI frames
|
|
if not this.pfCooldownType and duration < tonumber(C.appearance.cd.threshold) then
|
|
start, duration = 0, 0
|
|
end
|
|
|
|
-- hide animation
|
|
if this.pfCooldownStyleAnimation == 0 then
|
|
this:SetAlpha(0)
|
|
elseif not this.pfCooldownStyleAnimation and C.appearance.cd.hideanim == "1" then
|
|
this:SetAlpha(0)
|
|
end
|
|
|
|
-- print time as text on cooldown frames
|
|
if ( not this.pfCooldownStyleText or this.pfCooldownStyleText == 1)
|
|
and start > 0 and duration > 0 and (not enable or enable > 0) then
|
|
if( not this.pfCooldownText ) then
|
|
pfCreateCoolDown(this, start, duration)
|
|
end
|
|
|
|
this.pfCooldownText.start = start
|
|
this.pfCooldownText.duration = duration
|
|
this.pfCooldownText:Show()
|
|
elseif(this.pfCooldownText) then
|
|
this.pfCooldownText:Hide()
|
|
end
|
|
end
|
|
|
|
-- vanilla does not have a cooldown frame type, so we hook the
|
|
-- regular SetTimer function that each one is calling.
|
|
hooksecurefunc("CooldownFrame_SetTimer", SetCooldown)
|
|
end) |