cooldown: only draw cd on known frames

This commit is contained in:
shagu
2018-04-08 19:04:43 +02:00
parent ea17079ad2
commit 41e2400bcb
8 changed files with 41 additions and 8 deletions
+1
View File
@@ -74,6 +74,7 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("appearance", "cd", "threshold", "2")
pfUI:UpdateConfig("appearance", "cd", "font_size", "12")
pfUI:UpdateConfig("appearance", "cd", "debuffs", "1")
pfUI:UpdateConfig("appearance", "cd", "blizzard", "1")
pfUI:UpdateConfig("appearance", "castbar", "castbarcolor", ".7,.7,.9,.8")
pfUI:UpdateConfig("appearance", "castbar", "channelcolor", ".9,.9,.7,.8")
pfUI:UpdateConfig("appearance", "infight", "screen", "0")
+2
View File
@@ -350,6 +350,7 @@ function pfUI.uf:UpdateConfig()
f.buffs[i].stacks:SetShadowOffset(0.8, -0.8)
f.buffs[i].stacks:SetTextColor(1,1,.5)
f.buffs[i].cd = f.buffs[i].cd or CreateFrame("Model", nil, f.buffs[i], "CooldownFrameTemplate")
f.buffs[i].cd.pfCooldownType = "ALL"
f.buffs[i].cd:SetAlpha(0)
f.buffs[i]:RegisterForClicks("RightButtonUp")
@@ -428,6 +429,7 @@ function pfUI.uf:UpdateConfig()
f.debuffs[i].stacks:SetShadowOffset(0.8, -0.8)
f.debuffs[i].stacks:SetTextColor(1,1,.5)
f.debuffs[i].cd = f.debuffs[i].cd or CreateFrame("Model", nil, f.debuffs[i], "CooldownFrameTemplate")
f.debuffs[i].cd.pfCooldownType = "ALL"
f.debuffs[i].cd:SetAlpha(0)
f.debuffs[i]:RegisterForClicks("RightButtonUp")
+6
View File
@@ -557,6 +557,9 @@ pfUI:RegisterModule("actionbar", function ()
button:SetHeight(C.bars.icon_size)
button:Show()
local cooldown = _G["PetActionButton"..i..'Cooldown']
cooldown.pfCooldownType = "NOGCD"
local icon = _G["PetActionButton"..i..'Icon']
icon:SetAllPoints(button)
icon:SetParent(button)
@@ -592,6 +595,9 @@ pfUI:RegisterModule("actionbar", function ()
button:SetNormalTexture("")
button.SetNormalTexture = function() return end
local cooldown = _G[actionbutton..i..'Cooldown']
cooldown.pfCooldownType = "NOGCD"
local icon = _G[actionbutton..i..'Icon']
icon:SetAllPoints(button)
icon:SetTexCoord(.08, .92, .08, .92)
+7 -3
View File
@@ -263,13 +263,17 @@ pfUI:RegisterModule("bags", function ()
if tpl == "BankItemButtonGenericTemplate" then
local bankslot = pfUI.bags[bag].slots[slot].frame
local name = "pfBag" .. bag .. "item" .. slot .. "Cooldown"
bankslot.cooldown = CreateFrame("Model", name, bankslot, "CooldownFrameTemplate")
bankslot.cooldown:SetAllPoints(bankslot)
bankslot.cd = CreateFrame("Model", name, bankslot, "CooldownFrameTemplate")
bankslot.cd:SetAllPoints(bankslot)
bankslot.cd.pfCooldownType = "ALL"
else
local bagslot = pfUI.bags[bag].slots[slot].frame
bagslot.cd = _G[bagslot:GetName().."Cooldown"]
bagslot.cd.pfCooldownType = "ALL"
end
CreateBackdrop(pfUI.bags[bag].slots[slot].frame, default_border)
pfUI.bags[bag].slots[slot].frame:SetNormalTexture("")
pfUI.bags[bag].slots[slot].bag = bag
pfUI.bags[bag].slots[slot].slot = slot
pfUI.bags[bag].slots[slot].frame:SetID(slot)
+11 -5
View File
@@ -46,15 +46,21 @@ pfUI:RegisterModule("cooldown", function ()
-- hook
hooksecurefunc("CooldownFrame_SetTimer", function(this, start, duration, enable)
local parent = this.GetParent and this:GetParent()
if not this.pfCooldownType or ( this.pfCooldownType == "NOGCD" and duration < tonumber(C.appearance.cd.threshold)) then
return
end
-- realign guessed cooldown frames
if this:GetParent() and this:GetParent():GetWidth() / 36 > 0 then
this:SetScale(this:GetParent():GetWidth() / 36)
this:SetPoint("TOPLEFT", this:GetParent(), "TOPLEFT", -1, 1)
this:SetPoint("BOTTOMRIGHT", this:GetParent(), "BOTTOMRIGHT", 1, -1)
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
-- print time as text on cooldown frames
if ( start > 0 and duration > tonumber(C.appearance.cd.threshold) and enable > 0) then
if start > 0 and duration > 0 and enable > 0 then
if( not this.cd ) then
pfCreateCoolDown(this, start, duration)
end
+1
View File
@@ -739,6 +739,7 @@ pfUI:RegisterModule("gui", function ()
CreateConfig(nil, this, T["Cooldown Text Threshold"], C.appearance.cd, "threshold")
CreateConfig(nil, this, T["Cooldown Text Font Size"], C.appearance.cd, "font_size")
CreateConfig(nil, this, T["Display Debuff Durations"], C.appearance.cd, "debuffs", "checkbox")
CreateConfig(nil, this, T["Enable Durations On Blizzard Frames"], C.appearance.cd, "blizzard", "checkbox")
this.setup = true
end
end)
+1
View File
@@ -526,6 +526,7 @@ pfUI:RegisterModule("nameplates", function ()
if pfUI.debuffs and pfUI.debuffs.active and name then
this.debuffs[j].cd = this.debuffs[j].cd or CreateFrame("Model", nil, this.debuffs[j], "CooldownFrameTemplate")
this.debuffs[j].cd.pfCooldownType = "ALL"
local start, duration, timeleft = pfUI.debuffs:GetDebuffInfo("target", name)
this.debuffs[j].cd:SetAlpha(0)
CooldownFrame_SetTimer(this.debuffs[j].cd, start, duration, 1)
+12
View File
@@ -16,6 +16,18 @@ pfUI:RegisterModule("skin", function ()
EnableMovable("ClassTrainerFrame", "Blizzard_TrainerUI")
EnableMovable("InspectFrame", "Blizzard_InspectUI", { "InspectHonorFrame" })
if C.appearance.cd.blizzard == "1" then
hooksecurefunc("PaperDollItemSlotButton_Update", function()
local cooldown = getglobal(this:GetName().."Cooldown")
cooldown.pfCooldownType = "ALL"
end)
hooksecurefunc("SpellButton_UpdateButton", function()
local cooldown = getglobal(this:GetName().."Cooldown")
cooldown.pfCooldownType = "ALL"
end)
end
_, class = UnitClass("player")
local color = RAID_CLASS_COLORS[class]
local cr, cg, cb = color.r , color.g, color.b