diff --git a/modules/config.lua b/modules/config.lua index ca816ceb..01dd060d 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -51,6 +51,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "player", "showPVPMinimap", "0") pfUI:UpdateConfig("unitframes", "player", "showPVP", "0") pfUI:UpdateConfig("unitframes", "player", "buffs", "top") + pfUI:UpdateConfig("unitframes", "player", "energy", "1") pfUI:UpdateConfig("unitframes", "target", "width", "200") pfUI:UpdateConfig("unitframes", "target", "height", "50") diff --git a/modules/gui.lua b/modules/gui.lua index 8045b0c7..9eb59833 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -724,6 +724,7 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Show PvP Icon", pfUI_config.unitframes.player, "showPVP", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Align PvP Icon to Minimap", pfUI_config.unitframes.player, "showPVPMinimap", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Buff position", pfUI_config.unitframes.player, "buffs", "dropdown", { "top", "bottom", "hide"}) + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show energy ticks", pfUI_config.unitframes.player, "energy", "checkbox") pfUI.gui:CreateConfig(pfUI.gui.uf, "Target", nil, nil, "header") pfUI.gui:CreateConfig(pfUI.gui.uf, "Health width", pfUI_config.unitframes.target, "width") diff --git a/modules/player.lua b/modules/player.lua index c601fc4f..3ca2a576 100644 --- a/modules/player.lua +++ b/modules/player.lua @@ -295,6 +295,43 @@ pfUI:RegisterModule("player", function () pfUI.uf.player.power.bar:SetAllPoints(pfUI.uf.player.power) pfUI.uf.player.power.bar:SetMinMaxValues(0, 100) + if pfUI_config.unitframes.player.energy == "1" then + pfUI.uf.player.power.tick = CreateFrame("Frame", nil, UIParent) + pfUI.uf.player.power.tick:RegisterEvent("VARIABLES_LOADED") + pfUI.uf.player.power.tick:RegisterEvent("UNIT_DISPLAYPOWER") + + pfUI.uf.player.power.tick:SetScript("OnEvent", function() + if event == "VARIABLES_LOADED" then this.lastTick = GetTime() end + if event == "VARIABLES_LOADED" or ( event == "UNIT_DISPLAYPOWER" and arg1 == "player" ) then + if UnitPowerType("player") ~= 3 then + this.spark:Hide() + else + this.spark:Show() + end + end + end) + + pfUI.uf.player.power.tick.spark = pfUI.uf.player.power.bar:CreateTexture(nil, 'OVERLAY') + pfUI.uf.player.power.tick.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") + pfUI.uf.player.power.tick.spark:SetHeight(pfUI_config.unitframes.player.pheight + 15) + pfUI.uf.player.power.tick.spark:SetWidth(pfUI_config.unitframes.player.pheight + 5) + pfUI.uf.player.power.tick.spark:SetBlendMode('ADD') + + pfUI.uf.player.power.tick:SetScript("OnUpdate", function() + if not this.energy then this.energy = UnitMana("player") end + + if(UnitMana("player") > this.energy or GetTime() >= this.lastTick + 2) then + this.lastTick = GetTime() + end + + this.energy = UnitMana("player") + + local value = round((GetTime() - this.lastTick) * 100) + local pos = pfUI_config.unitframes.player.width / 200 * value + this.spark:SetPoint("LEFT", pos-((pfUI_config.unitframes.player.pheight+5)/2), 0) + end) + end + pfUI.uf.player.hpText = pfUI.uf.player:CreateFontString("Status", "HIGH", "GameFontNormal") pfUI.uf.player.hpText:SetFont("Interface\\AddOns\\pfUI\\fonts\\" .. pfUI_config.global.font_square .. ".ttf", pfUI_config.global.font_size, "OUTLINE") pfUI.uf.player.hpText:ClearAllPoints()