mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-06 21:50:00 +00:00
energytick: add initial manatick support
* add option to enable mana ticks * move into seperate module
This commit is contained in:
@@ -25,63 +25,4 @@ pfUI:RegisterModule("player", "vanilla:tbc", function ()
|
||||
StaticPopup_Show("CONFIRM_RESET_INSTANCES")
|
||||
end
|
||||
end)
|
||||
|
||||
if C.unitframes.player.energy == "1" then
|
||||
pfUI.uf.player.power.tick = CreateFrame("Frame", nil, pfUI.uf.player.power.bar)
|
||||
pfUI.uf.player.power.tick:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
pfUI.uf.player.power.tick:RegisterEvent("UNIT_DISPLAYPOWER")
|
||||
|
||||
pfUI.uf.player.power.tick:SetScript("OnShow", function()
|
||||
this.spark:Show()
|
||||
end)
|
||||
|
||||
pfUI.uf.player.power.tick:SetScript("OnHide", function()
|
||||
this.spark:Hide()
|
||||
end)
|
||||
|
||||
pfUI.uf.player.power.tick:SetScript("OnEvent", function()
|
||||
if event == "PLAYER_ENTERING_WORLD" then this.lastTick = GetTime() end
|
||||
if event == "PLAYER_ENTERING_WORLD" or ( event == "UNIT_DISPLAYPOWER" and arg1 == "player" ) then
|
||||
if UnitPowerType("player") ~= 3 then
|
||||
this:Hide()
|
||||
else
|
||||
this: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(C.unitframes.player.pheight + 15)
|
||||
pfUI.uf.player.power.tick.spark:SetWidth(C.unitframes.player.pheight + 5)
|
||||
pfUI.uf.player.power.tick.spark:SetBlendMode('ADD')
|
||||
|
||||
-- update spark size on player frame changes
|
||||
local hookUpdateConfig = pfUI.uf.player.UpdateConfig
|
||||
function pfUI.uf.player.UpdateConfig()
|
||||
-- update spark sizes
|
||||
local spark = pfUI.uf.player.power.tick.spark
|
||||
spark:SetHeight(C.unitframes.player.pheight + 15)
|
||||
spark:SetWidth(C.unitframes.player.pheight + 5)
|
||||
|
||||
-- run default unitframe update function
|
||||
hookUpdateConfig(pfUI.uf.player)
|
||||
end
|
||||
|
||||
pfUI.uf.player.power.tick:SetScript("OnUpdate", function()
|
||||
if UnitPowerType("player") ~= 3 then this:Hide() end
|
||||
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 = (C.unitframes.player.pwidth ~= "-1" and C.unitframes.player.pwidth or C.unitframes.player.width) / 200 * value
|
||||
if not C.unitframes.player.pheight then return end
|
||||
this.spark:SetPoint("LEFT", pos-((C.unitframes.player.pheight+5)/2), 0)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user