panel: add combat timer

This commit is contained in:
shagu
2016-12-27 15:51:47 +01:00
parent bfb9590e69
commit a6accb9053
2 changed files with 32 additions and 2 deletions
+1 -1
View File
@@ -897,7 +897,7 @@ pfUI:RegisterModule("gui", function ()
-- panels
pfUI.gui.panel = pfUI.gui:CreateConfigTab("Panel")
local values = { "time", "fps", "exp", "gold", "friends", "guild", "durability", "zone", "none" }
local values = { "time", "fps", "exp", "gold", "friends", "guild", "durability", "zone", "combat", "none" }
pfUI.gui:CreateConfig(pfUI.gui.panel, "Left Panel: Left", pfUI_config.panel.left, "left", "dropdown", values)
pfUI.gui:CreateConfig(pfUI.gui.panel, "Left Panel: Center", pfUI_config.panel.left, "center", "dropdown", values)
pfUI.gui:CreateConfig(pfUI.gui.panel, "Left Panel: Right", pfUI_config.panel.left, "right", "dropdown", values)
+31 -1
View File
@@ -95,7 +95,6 @@ pfUI:RegisterModule("panel", function ()
elseif arg1 == "RightButton" then
pfUI.panel.clock.timerFrame.Snapshot = GetTime()
end
end
pfUI.panel.clock.tick = GetTime()
@@ -139,6 +138,37 @@ pfUI:RegisterModule("panel", function ()
end
end)
-- Combat Timer
pfUI.panel.clock.combat = CreateFrame("Frame", "pfUICombatTimer", UIParent)
pfUI.panel.clock.combat:RegisterEvent("PLAYER_ENTERING_WORLD")
pfUI.panel.clock.combat:RegisterEvent("PLAYER_REGEN_ENABLED")
pfUI.panel.clock.combat:RegisterEvent("PLAYER_REGEN_DISABLED")
pfUI.panel.clock.combat:SetScript("OnEvent", function()
if event == "PLAYER_REGEN_DISABLED" then
if UnitAffectingCombat("player") and not this.combat then
this.combat = GetTime()
end
elseif event == "PLAYER_REGEN_ENABLED" then
if this.combat then
this.lastcombat = GetTime() - this.combat
this.combat = nil
pfUI.panel:OutputPanel("combat", "|cffffffff" .. SecondsToTime(ceil(this.lastcombat)))
end
elseif event == "PLAYER_ENTERING_WORLD" then
pfUI.panel:OutputPanel("combat", "-- Combat --")
end
end)
pfUI.panel.clock.combat:SetScript("OnUpdate", function()
if not this.tick then this.tick = GetTime() end
if GetTime() <= this.tick + 1 then return else this.tick = GetTime() end
if this.combat then
pfUI.panel:OutputPanel("combat", "|cffffaaaa" .. SecondsToTime(ceil(GetTime() - this.combat)))
end
end)
-- Update "exp"
function pfUI.panel:UpdateExp ()
if UnitLevel("player") ~= 60 then