mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-03 04:00:02 +00:00
cooldown: new cooldown mechanism
This commit is contained in:
+4
-1
@@ -7,7 +7,6 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("global", nil, "font_default", "arial")
|
||||
pfUI:UpdateConfig("global", nil, "font_square", "homespun")
|
||||
pfUI:UpdateConfig("global", nil, "font_combat", "diediedie")
|
||||
pfUI:UpdateConfig("global", nil, "cooldown_min", "2")
|
||||
pfUI:UpdateConfig("appearance", "border", "background", "0, 0, 0, 1")
|
||||
pfUI:UpdateConfig("appearance", "border", "color", "0.3, 0.3, 0.3, 1")
|
||||
pfUI:UpdateConfig("appearance", "border", "default", "3")
|
||||
@@ -18,6 +17,10 @@ function pfUI:LoadConfig()
|
||||
pfUI:UpdateConfig("appearance", "border", "panels", "-1")
|
||||
pfUI:UpdateConfig("appearance", "border", "chat", "-1")
|
||||
pfUI:UpdateConfig("appearance", "border", "bags", "-1")
|
||||
pfUI:UpdateConfig("appearance", "cd", "mincolor", "55ffff")
|
||||
pfUI:UpdateConfig("appearance", "cd", "hourcolor", "55aaff")
|
||||
pfUI:UpdateConfig("appearance", "cd", "daycolor", "5555ff")
|
||||
pfUI:UpdateConfig("appearance", "cd", "threshold", "2")
|
||||
pfUI:UpdateConfig("unitframes", nil, "disable", "0")
|
||||
pfUI:UpdateConfig("unitframes", nil, "animation_speed", "5")
|
||||
pfUI:UpdateConfig("unitframes", nil, "portrait", "1")
|
||||
|
||||
+45
-49
@@ -1,71 +1,67 @@
|
||||
pfUI:RegisterModule("cooldown", function ()
|
||||
function CooldownFrame_SetTimer(this, start, duration, enable)
|
||||
if not this then return end
|
||||
-- disable animation
|
||||
this:SetPosition(1,1,1)
|
||||
local function pfCreateCoolDown(cooldown, start, duration)
|
||||
cooldown.cd = CreateFrame("Frame", "pfCooldownFrame", cooldown:GetParent())
|
||||
cooldown.cd:SetAllPoints(cooldown:GetParent())
|
||||
cooldown.cd:SetFrameLevel(cooldown.cd:GetFrameLevel() + 1)
|
||||
|
||||
if ( start > 0 and duration > tonumber(pfUI_config.global.cooldown_min) and enable > 0) then
|
||||
this.start = start
|
||||
this.duration = duration
|
||||
this.stopping = 0
|
||||
this:SetSequence(0)
|
||||
cooldown.cd.text = cooldown.cd:CreateFontString("pfCooldownFrameText", "OVERLAY")
|
||||
cooldown.cd.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\" .. pfUI_config.global.font_square .. ".ttf", pfUI_config.global.font_size, "OUTLINE")
|
||||
cooldown.cd.text:SetPoint("CENTER", cooldown.cd, "CENTER", 0, 1)
|
||||
|
||||
if not this.cd then
|
||||
this.cd = CreateFrame("Frame")
|
||||
this.cd:SetAllPoints(this)
|
||||
cooldown.cd:SetScript("OnUpdate", function()
|
||||
if not getglobal(this:GetParent():GetName() .. "Cooldown"):IsShown() then this:Hide() end
|
||||
if not this.next then this.next = GetTime() + .1 end
|
||||
if this.next > GetTime() then return end
|
||||
this.next = GetTime() + .1
|
||||
|
||||
this.cd.back = this.cd:CreateTexture(nil,"BACKGROUND")
|
||||
this.cd.back:SetTexture(0,0,0,1)
|
||||
this.cd.back:SetAlpha(.5)
|
||||
this.cd.back:SetParent(this)
|
||||
this.cd.back:SetAllPoints(this)
|
||||
|
||||
this.cd.text = this.cd:CreateFontString("Status", "HIGH", "GameFontNormal")
|
||||
this.cd.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\" .. pfUI_config.global.font_square .. ".ttf", pfUI_config.global.font_size, "OUTLINE")
|
||||
this.cd.text:ClearAllPoints()
|
||||
this.cd.text:SetParent(this)
|
||||
this.cd.text:SetAllPoints(this)
|
||||
this.cd.text:SetJustifyH("CENTER")
|
||||
this.cd.text:SetFontObject(GameFontWhite)
|
||||
end
|
||||
this:Show()
|
||||
else
|
||||
this:Hide()
|
||||
if this.cd then this.cd:Hide() end
|
||||
end
|
||||
end
|
||||
|
||||
function CooldownFrame_OnUpdateModel()
|
||||
if this.start and this.duration then
|
||||
local remaining = this.duration - (GetTime() - this.start)
|
||||
|
||||
-- disable GCD notify
|
||||
if (remaining >= 0 and this.duration > tonumber(pfUI_config.global.cooldown_min)) then
|
||||
this.cd:Show()
|
||||
if remaining >= 0 then
|
||||
local unit = ""
|
||||
local color = "|cffffffff"
|
||||
if remaining > 99 then
|
||||
remaining = remaining / 60
|
||||
unit = "m"
|
||||
color = "|cff" .. pfUI_config.appearance.cd.mincolor
|
||||
end
|
||||
|
||||
if remaining > 99 then
|
||||
remaining = remaining / 60
|
||||
unit = "h"
|
||||
color = "|cff" .. pfUI_config.appearance.cd.hourcolor
|
||||
end
|
||||
|
||||
this.cd.text:SetText(ceil(remaining)..unit)
|
||||
if remaining > 99 then
|
||||
remaining = remaining / 24
|
||||
unit = "d"
|
||||
color = "|cff" .. pfUI_config.appearance.cd.daycolor
|
||||
end
|
||||
this.text:SetText(color .. round(remaining) .. unit)
|
||||
else
|
||||
this:Hide()
|
||||
this.cd:Hide()
|
||||
this.stopping = 1
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function CooldownFrame_OnAnimFinished()
|
||||
if ( this.stopping == 1 ) then
|
||||
this:Hide()
|
||||
this.cd:Hide()
|
||||
-- hook
|
||||
if not pfCooldownFrame_SetTimer then pfCooldownFrame_SetTimer = CooldownFrame_SetTimer end
|
||||
function CooldownFrame_SetTimer(this, start, duration, enable)
|
||||
-- realign all cooldown frames
|
||||
if this:GetParent():GetWidth() / 36 > 0 then
|
||||
this:SetScale(this:GetParent():GetWidth() / 36)
|
||||
this:SetPoint("TOPLEFT", this:GetParent(), "TOPLEFT", 0, 0)
|
||||
this:SetPoint("BOTTOMRIGHT", this:GetParent(), "BOTTOMRIGHT", 1, -1)
|
||||
end
|
||||
|
||||
-- print time as text on cooldown frames
|
||||
if ( start > 0 and duration > tonumber(pfUI_config.appearance.cd.threshold) and enable > 0) then
|
||||
if( not this.cd ) then
|
||||
pfCreateCoolDown(this, start, duration)
|
||||
end
|
||||
this.cd.start = start
|
||||
this.cd.duration = duration
|
||||
this.cd:Show()
|
||||
elseif(this.cd) then
|
||||
this.cd:Hide();
|
||||
end
|
||||
|
||||
pfCooldownFrame_SetTimer(this, start, duration, enable)
|
||||
end
|
||||
end)
|
||||
|
||||
+4
-1
@@ -602,7 +602,6 @@ pfUI:RegisterModule("gui", function ()
|
||||
pfUI.gui:CreateConfig(pfUI.gui.global, "Default Font", pfUI_config.global, "font_default", "dropdown", values)
|
||||
pfUI.gui:CreateConfig(pfUI.gui.global, "Square Font", pfUI_config.global, "font_square", "dropdown", values)
|
||||
pfUI.gui:CreateConfig(pfUI.gui.global, "Combat Font", pfUI_config.global, "font_combat", "dropdown", values)
|
||||
pfUI.gui:CreateConfig(pfUI.gui.global, "Minimal Cooldown duration (seconds)", pfUI_config.global, "cooldown_min")
|
||||
|
||||
-- appearance
|
||||
pfUI.gui.appearance = pfUI.gui:CreateConfigTab("Appearance")
|
||||
@@ -616,6 +615,10 @@ pfUI:RegisterModule("gui", function ()
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Panel Bordersize", pfUI_config.appearance.border, "panels")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Chat Bordersize", pfUI_config.appearance.border, "chat")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Bags Bordersize", pfUI_config.appearance.border, "bags")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Cooldown color (Minutes)", pfUI_config.appearance.cd, "mincolor")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Cooldown color (Hours)", pfUI_config.appearance.cd, "hourcolor")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Cooldown color (Days)", pfUI_config.appearance.cd, "daycolor")
|
||||
pfUI.gui:CreateConfig(pfUI.gui.appearance, "Cooldown text threshold", pfUI_config.appearance.cd, "threshold")
|
||||
|
||||
-- modules
|
||||
pfUI.gui.modules = pfUI.gui:CreateConfigTab("Modules")
|
||||
|
||||
Reference in New Issue
Block a user