diff --git a/modules/gui.lua b/modules/gui.lua index 7f8faf16..88ba1970 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -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) diff --git a/modules/panel.lua b/modules/panel.lua index df8b142e..ec3cd0ca 100644 --- a/modules/panel.lua +++ b/modules/panel.lua @@ -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