mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
- added basic implementation of Druid Eclipse bar for balance druids
This commit is contained in:
@ -625,11 +625,15 @@ function IceBarElement.prototype:CreateFrame()
|
||||
-- in addition, do not register OnUpdate if predictedPower is set and this is the player mana or target mana bar
|
||||
if not string.find(self.elementName, "MirrorBar")
|
||||
and ((IceHUD.WowVer < 30000 or not GetCVarBool("predictedPower")) or (not string.find(self.elementName, "PlayerMana")))
|
||||
and not self.moduleSettings.isCustomBar then
|
||||
and not self.moduleSettings.isCustomBar and self:RegisterOnUpdate() then
|
||||
self.frame:SetScript("OnUpdate", function() self:MyOnUpdate() end)
|
||||
end
|
||||
end
|
||||
|
||||
function IceBarElement.prototype:RegisterOnUpdate()
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
-- Creates background for the bar
|
||||
function IceBarElement.prototype:CreateBackground()
|
||||
|
39
IceHUD.lua
39
IceHUD.lua
@ -923,21 +923,44 @@ function IceHUD:GetAuraCount(auraType, unit, ability, onlyMine, matchByName)
|
||||
return 0
|
||||
end
|
||||
|
||||
for i = 1, 40 do
|
||||
local name, _, texture, applications = UnitAura(unit, i, auraType..(onlyMine and "|PLAYER" or ""))
|
||||
|
||||
if (not matchByName and not texture) or (matchByName and not name) then
|
||||
break
|
||||
end
|
||||
|
||||
if (not matchByName and string.match(texture:upper(), ability:upper())) or (matchByName and string.match(name:upper(), ability:upper())) then
|
||||
local i = 1
|
||||
local name, _, texture, applications = UnitAura(unit, i, auraType..(onlyMine and "|PLAYER" or ""))
|
||||
while name do
|
||||
if (not matchByName and string.match(texture:upper(), ability:upper()))
|
||||
or (matchByName and string.match(name:upper(), ability:upper())) then
|
||||
return applications
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
name, _, texture, applications = UnitAura(unit, i, auraType..(onlyMine and "|PLAYER" or ""))
|
||||
end
|
||||
|
||||
return 0
|
||||
end
|
||||
|
||||
function IceHUD:HasBuffs(unit, spellIDs)
|
||||
local retval = {}
|
||||
for i=1, #spellIDs do
|
||||
retval[i] = false
|
||||
end
|
||||
|
||||
local i = 1
|
||||
local name, _, texture, applications, _, _, _, _, _, _, auraID = UnitAura(unit, i)
|
||||
while name do
|
||||
for i=1, #spellIDs do
|
||||
if spellIDs[i] == auraID then
|
||||
retval[i] = applications == 0 and true or applications
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
name, _, texture, applications, _, _, _, _, _, _, auraID = UnitAura(unit, i)
|
||||
end
|
||||
|
||||
return retval
|
||||
end
|
||||
|
||||
function IceHUD:OnDisable()
|
||||
IceHUD.IceCore:Disable()
|
||||
end
|
||||
|
@ -75,3 +75,4 @@ modules\CustomMana.lua
|
||||
modules\ClassPowerCounter.lua
|
||||
modules\HolyPower.lua
|
||||
modules\Shards.lua
|
||||
modules\EclipseBar.lua
|
||||
|
216
modules/EclipseBar.lua
Normal file
216
modules/EclipseBar.lua
Normal file
@ -0,0 +1,216 @@
|
||||
local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local EclipseBar = AceOO.Class(IceBarElement)
|
||||
EclipseBar.prototype.markerHeight = 6
|
||||
EclipseBar.prototype.barUpdateColor = "EclipseLunar"
|
||||
|
||||
function EclipseBar.prototype:init()
|
||||
EclipseBar.super.prototype.init(self, "EclipseBar")
|
||||
|
||||
self:SetDefaultColor("EclipseLunar", 31, 31, 231)
|
||||
self:SetDefaultColor("EclipseLunarActive", 0, 0, 255)
|
||||
self:SetDefaultColor("EclipseSolar", 190, 210, 31)
|
||||
self:SetDefaultColor("EclipseSolarActive", 238, 251, 31)
|
||||
self:SetDefaultColor("EclipseMarker", 255, 0, 0)
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:GetOptions()
|
||||
local opts = EclipseBar.super.prototype.GetOptions(self)
|
||||
opts.reverse.hidden = true
|
||||
return opts
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:GetDefaultSettings()
|
||||
local defaults = EclipseBar.super.prototype.GetDefaultSettings(self)
|
||||
|
||||
defaults.textVisible.lower = false
|
||||
defaults.offset = -1
|
||||
defaults.enabled = true
|
||||
defaults.usesDogTagStrings = false
|
||||
defaults.textVerticalOffset = 13
|
||||
defaults.textHorizontalOffset = 12
|
||||
defaults.shouldAnimate = false
|
||||
defaults.hideAnimationSettings = true
|
||||
defaults.lockUpperTextAlpha = false
|
||||
|
||||
return defaults
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:Enable(core)
|
||||
EclipseBar.super.prototype.Enable(self, core)
|
||||
|
||||
self:RegisterEvent("UPDATE_SHAPESHIFT_FORM", "UpdateShown")
|
||||
self:RegisterEvent("PLAYER_TALENT_UPDATE", "UpdateShown")
|
||||
self:RegisterEvent("MASTERY_UPDATE", "UpdateShown")
|
||||
self:RegisterEvent("UNIT_AURA", "UpdateEclipseBuffs")
|
||||
|
||||
self.frame:SetScript("OnUpdate", function() self:Update() end)
|
||||
|
||||
self:UpdateShown()
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:Disable(core)
|
||||
EclipseBar.super.prototype.Disable(self, core)
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:CreateFrame()
|
||||
EclipseBar.super.prototype.CreateFrame(self)
|
||||
|
||||
self:CreateSolarBar()
|
||||
self:CreateMarker()
|
||||
self:UpdateShown()
|
||||
self:UpdateAlpha()
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:RegisterOnUpdate()
|
||||
return false
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:CreateSolarBar()
|
||||
if not (self.solarBar) then
|
||||
self.solarBar = CreateFrame("Frame", nil, self.frame)
|
||||
end
|
||||
|
||||
local solarTop = not IceHUD:xor(self.moduleSettings.reverse, self.moduleSettings.inverse)
|
||||
|
||||
self.solarBar:SetFrameStrata("BACKGROUND")
|
||||
self.solarBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
|
||||
self.solarBar:SetHeight(self.settings.barHeight)
|
||||
self.solarBar:ClearAllPoints()
|
||||
if solarTop then
|
||||
self.solarBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
|
||||
else
|
||||
self.solarBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
|
||||
end
|
||||
|
||||
if not (self.solarBar.bar) then
|
||||
self.solarBar.bar = self.solarBar:CreateTexture(nil, "LOW")
|
||||
end
|
||||
|
||||
self.solarBar.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
|
||||
self.solarBar.bar:SetAllPoints(self.solarBar)
|
||||
|
||||
self.solarBar.bar:SetVertexColor(self:GetColor("EclipseSolar", 1))
|
||||
|
||||
local pos = 0.5
|
||||
local min_y = 0
|
||||
local max_y = pos
|
||||
if not solarTop then
|
||||
min_y = 1-pos
|
||||
max_y = 1
|
||||
end
|
||||
|
||||
if self.moduleSettings.side == IceCore.Side.Left then
|
||||
self.solarBar.bar:SetTexCoord(1, 0, min_y, max_y)
|
||||
else
|
||||
self.solarBar.bar:SetTexCoord(0, 1, min_y, max_y)
|
||||
end
|
||||
|
||||
self.solarBar.bar:Show()
|
||||
self.solarBar:SetHeight(self.settings.barHeight * pos)
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:CreateMarker()
|
||||
local bIsNewBar = false
|
||||
if not (self.markerBar) then
|
||||
self.markerBar = CreateFrame("Frame", nil, self.frame)
|
||||
bIsNewBar = true
|
||||
end
|
||||
|
||||
self.markerBar:SetFrameStrata("LOW")
|
||||
self.markerBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
|
||||
self.markerBar:SetHeight(self.markerHeight)
|
||||
self.markerBar:ClearAllPoints()
|
||||
|
||||
if not (self.markerBar.bar) then
|
||||
self.markerBar.bar = self.markerBar:CreateTexture(nil, "LOW")
|
||||
end
|
||||
|
||||
self.markerBar.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
|
||||
self.markerBar.bar:SetAllPoints(self.markerBar)
|
||||
|
||||
self.markerBar.bar:SetVertexColor(self:GetColor("EclipseMarker", 1))
|
||||
|
||||
if bIsNewBar then
|
||||
self:PositionMarker(0)
|
||||
end
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:PositionMarker(pos)
|
||||
if self.moduleSettings.inverse then
|
||||
pos = pos * -1
|
||||
end
|
||||
local coordPos = 0.5 + pos
|
||||
local adjustedBarHeight = self.settings.barHeight - (self.markerHeight)
|
||||
local heightScale = (self.markerHeight / self.settings.barHeight) / 2
|
||||
|
||||
local min_y = 1-coordPos-heightScale
|
||||
local max_y = 1-coordPos+heightScale
|
||||
|
||||
if self.moduleSettings.side == IceCore.Side.Left then
|
||||
self.markerBar.bar:SetTexCoord(1, 0, min_y, max_y)
|
||||
else
|
||||
self.markerBar.bar:SetTexCoord(0, 1, min_y, max_y)
|
||||
end
|
||||
|
||||
self.markerBar.bar:Show()
|
||||
self.markerBar:SetPoint("CENTER", self.frame, "CENTER", 0, (self.settings.barHeight * pos))
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:UpdateShown()
|
||||
local form = GetShapeshiftFormID();
|
||||
|
||||
if form == MOONKIN_FORM or not form then
|
||||
if GetMasteryIndex(GetActiveTalentGroup(false, false)) == 1 then
|
||||
self:Show(true)
|
||||
else
|
||||
self:Show(false)
|
||||
end
|
||||
else
|
||||
self:Show(false)
|
||||
end
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:UseTargetAlpha(scale)
|
||||
return UnitPower("player", SPELL_POWER_ECLIPSE) ~= 0
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:UpdateEclipseBuffs()
|
||||
local buffStatus = IceHUD:HasBuffs("player", {ECLIPSE_BAR_SOLAR_BUFF_ID, ECLIPSE_BAR_LUNAR_BUFF_ID})
|
||||
local hasSolar = buffStatus[1]
|
||||
local hasLunar = buffStatus[2]
|
||||
|
||||
if hasSolar then
|
||||
self.barUpdateColor = "EclipseSolarActive"
|
||||
self.solarBar.bar:SetVertexColor(self:GetColor("EclipseSolarActive", 1))
|
||||
elseif hasLunar then
|
||||
self.barUpdateColor = "EclipseLunarActive"
|
||||
self.solarBar.bar:SetVertexColor(self:GetColor("EclipseLunarActive", 1))
|
||||
else
|
||||
self.barUpdateColor = "EclipseLunar"
|
||||
self.solarBar.bar:SetVertexColor(self:GetColor("EclipseSolar", 1))
|
||||
end
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:UpdateEclipsePower()
|
||||
local power = UnitPower("player", SPELL_POWER_ECLIPSE)
|
||||
local maxPower = UnitPowerMax("player", SPELL_POWER_ECLIPSE)
|
||||
|
||||
self:SetBottomText1(abs((power/maxPower) * 100))
|
||||
|
||||
local pos = (power/maxPower) / 2
|
||||
self:PositionMarker(pos)
|
||||
end
|
||||
|
||||
function EclipseBar.prototype:Update()
|
||||
EclipseBar.super.prototype.Update(self)
|
||||
|
||||
self:UpdateEclipsePower()
|
||||
self:UpdateBar(0.5, self.barUpdateColor)
|
||||
self:UpdateAlpha()
|
||||
end
|
||||
|
||||
local _, unitClass = UnitClass("player")
|
||||
if (unitClass == "DRUID" and IceHUD.WowVer >= 40000) then
|
||||
IceHUD.EclipseBar = EclipseBar:new()
|
||||
end
|
Reference in New Issue
Block a user