- Refactored how bars are created and resized.

- Enabled the "expand" bar fill for the PlayerHealth module.
This commit is contained in:
rokiyo
2010-11-02 15:08:42 +00:00
parent 7609b37812
commit 286e413198
6 changed files with 124 additions and 273 deletions

View File

@ -861,15 +861,19 @@ function IceBarElement.prototype:SetBarVisibility(visible)
end end
end end
function IceBarElement.prototype:SetBarFramePoints(frame) function IceBarElement.prototype:SetBarFramePoints(frame, offset_x, offset_y)
local anchor
frame:ClearAllPoints() frame:ClearAllPoints()
if self.moduleSettings.inverse == "INVERSE" then if self.moduleSettings.inverse == "INVERSE" then
frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT") anchor = "TOPLEFT"
elseif self.moduleSettings.inverse == "EXPAND" then elseif self.moduleSettings.inverse == "EXPAND" then
frame:SetPoint("LEFT", self.frame, "LEFT") anchor = "LEFT"
else else
frame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") anchor = "BOTTOMLEFT"
end end
frame:SetPoint(anchor, self.frame, anchor, offset_x, offset_y)
end end
@ -985,27 +989,35 @@ end
-- Creates the actual bar -- Creates the actual bar
function IceBarElement.prototype:CreateBar() function IceBarElement.prototype:CreateBar()
if not (self.barFrame) then self.barFrame = self:BarFactory(self.barFrame, "LOW", "ARTWORK")
self.barFrame = CreateFrame("Frame", nil, self.frame) self:SetBarCoord(self.barFrame)
end
self.barFrame:SetFrameStrata("LOW")
self:SetBarFramePoints(self.barFrame)
self.barFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.barFrame:SetHeight(self.settings.barHeight)
if not (self.barFrame.bar) then
self.barFrame.bar = self.barFrame:CreateTexture(nil, "LOW")
end
self.barFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.barFrame.bar:SetBlendMode(self.settings.barBlendMode) self.barFrame.bar:SetBlendMode(self.settings.barBlendMode)
self.barFrame.bar:SetAllPoints(self.barFrame)
self:SetScale(self.CurrScale, true) self:SetScale(self.CurrScale, true)
self:UpdateBar(1, "undef") self:UpdateBar(1, "undef")
end end
-- Returns a barFrame & barFrame.bar
-- Rokiyo: Currently keeping old behaviour of running through bar creation on every Redraw, but I'm not convinced we need to.
function IceBarElement.prototype:BarFactory(barFrame, frameStrata, textureLayer)
if not (barFrame) then
barFrame = CreateFrame("Frame", nil, self.frame)
end
barFrame:SetFrameStrata(frameStrata and frameStrata or "LOW")
barFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
barFrame:SetHeight(self.settings.barHeight)
self:SetBarFramePoints(barFrame)
if not barFrame.bar then
barFrame.bar = barFrame:CreateTexture(nil, (textureLayer and textureLayer or "ARTWORK"))
end
barFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
barFrame.bar:SetAllPoints(barFrame)
return barFrame
end
function IceBarElement.prototype:GetMyBarTexture() function IceBarElement.prototype:GetMyBarTexture()
if self.moduleSettings.shouldUseOverride and self.moduleSettings.barTextureOverride then if self.moduleSettings.shouldUseOverride and self.moduleSettings.barTextureOverride then
@ -1099,6 +1111,54 @@ function IceBarElement.prototype:Flip(side)
end end
end end
-- Rokiyo: bar is the only required argument, scale & top are optional
function IceBarElement.prototype:SetBarCoord(barFrame, scale, top)
local min_x, max_x, min_y, max_y
if not scale then scale = 0 end
if (self.moduleSettings.side == IceCore.Side.Left) then
min_x = 1
max_x = 0
else
min_x = 0
max_x = 1
end
if IceHUD:xor(self.moduleSettings.reverse, top) then
local offset_y
if self.moduleSettings.inverse == "INVERSE" then
min_y = 1 - scale
max_y = 1
offset_y = 0 - (self.settings.barHeight * (1 - scale))
else
min_y = 0
max_y = scale
offset_y = (self.settings.barHeight * (1 - scale))
end
self:SetBarFramePoints(barFrame, 0, offset_y)
else
if self.moduleSettings.inverse == "INVERSE" then
min_y = 0;
max_y = scale;
elseif self.moduleSettings.inverse == "EXPAND" then
min_y = 0.5 - (scale * 0.5);
max_y = 0.5 + (scale * 0.5);
else
min_y = 1-scale;
max_y = 1;
end
self:SetBarFramePoints(barFrame, 0, 0)
end
barFrame.bar:SetTexCoord(min_x, max_x, min_y, max_y)
barFrame:SetHeight(self.settings.barHeight * scale)
if scale == 0 then
barFrame.bar:Hide()
else
barFrame.bar:Show()
end
end
function IceBarElement.prototype:SetScale(inScale, force) function IceBarElement.prototype:SetScale(inScale, force)
local oldScale = self.CurrScale local oldScale = self.CurrScale
@ -1111,29 +1171,8 @@ function IceBarElement.prototype:SetScale(inScale, force)
if self.moduleSettings.reverse then if self.moduleSettings.reverse then
scale = 1 - scale scale = 1 - scale
end end
if self.moduleSettings.inverse == "INVERSE" then
min_y = 0;
max_y = scale;
elseif self.moduleSettings.inverse == "EXPAND" then
min_y = 0.5 - (scale * 0.5);
max_y = 0.5 + (scale * 0.5);
else
min_y = 1-scale;
max_y = 1;
end
if (self.moduleSettings.side == IceCore.Side.Left) then
self.barFrame.bar:SetTexCoord(1, 0, min_y, max_y)
else
self.barFrame.bar:SetTexCoord(0, 1, min_y, max_y)
end
self.barFrame:SetHeight(self.settings.barHeight * scale) self:SetBarCoord(self.barFrame, scale)
if scale == 0 then
self.barFrame.bar:Hide()
else
self.barFrame.bar:Show()
end
end end
if not self:IsFull(self.CurrScale) or not self:IsFull(inScale) then if not self:IsFull(self.CurrScale) or not self:IsFull(inScale) then

View File

@ -358,19 +358,8 @@ end
function CastBar.prototype:CreateLagBar() function CastBar.prototype:CreateLagBar()
if not (self.lagBar) then self.lagBar = self:BarFactory(self.lagBar, "LOW","BACKGROUND")
self.lagBar = CreateFrame("Frame", nil, self.frame) self:SetBarCoord(self.lagBar, 0 , true)
end
self.lagBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.lagBar:SetHeight(self.settings.barHeight)
if not (self.lagBar.bar) then
self.lagBar.bar = self.lagBar:CreateTexture(nil, "BACKGROUND")
end
self.lagBar.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.lagBar.bar:SetAllPoints(self.lagBar)
local r, g, b = self:GetColor("CastLag") local r, g, b = self:GetColor("CastLag")
if (self.settings.backgroundToggle) then if (self.settings.backgroundToggle) then
@ -378,11 +367,6 @@ function CastBar.prototype:CreateLagBar()
end end
self.lagBar.bar:SetVertexColor(r, g, b, self.moduleSettings.lagAlpha) self.lagBar.bar:SetVertexColor(r, g, b, self.moduleSettings.lagAlpha)
if (self.moduleSettings.side == IceCore.Side.Left) then
self.lagBar.bar:SetTexCoord(1, 0, 0, 0)
else
self.lagBar.bar:SetTexCoord(0, 1, 0, 0)
end
self.lagBar.bar:Hide() self.lagBar.bar:Hide()
end end
@ -404,43 +388,17 @@ function CastBar.prototype:SpellCastStart(event, unit, spell, rank)
return return
end end
self.lagBar:SetFrameStrata("BACKGROUND") local scale
self.lagBar:ClearAllPoints()
if not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) then
self.lagBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.lagBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
local now = GetTime()
local lag = now - (self.spellCastSent or now)
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
if self.unit == "vehicle" then if self.unit == "vehicle" then
pos = 0 scale = 0
end
local y = self.settings.barHeight - (pos * self.settings.barHeight)
local min_y = 0
local max_y = pos
if IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) then
min_y = 1-pos
max_y = 1
end
if (self.moduleSettings.side == IceCore.Side.Left) then
self.lagBar.bar:SetTexCoord(1, 0, min_y, max_y)
else else
self.lagBar.bar:SetTexCoord(0, 1, min_y, max_y) local now = GetTime()
local lag = now - (self.spellCastSent or now)
scale = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
end end
if pos == 0 then self.lagBar:SetFrameStrata("BACKGROUND")
self.lagBar.bar:Hide() self:SetBarCoord(self.lagBar, scale, true)
else
self.lagBar.bar:Show()
end
self.lagBar:SetHeight(self.settings.barHeight * pos)
self.spellCastSent = nil self.spellCastSent = nil
end end
@ -455,48 +413,19 @@ function CastBar.prototype:SpellCastChannelStart(event, unit)
return return
end end
local lagTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) local scale
if self.moduleSettings.reverseChannel then if self.unit == "vehicle" then
lagTop = not lagTop scale = 0
else
local now = GetTime()
local lag = now - (self.spellCastSent or now)
scale = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
end end
local top = not self.moduleSettings.reverseChannel
self.lagBar:SetFrameStrata("MEDIUM") self.lagBar:SetFrameStrata("MEDIUM")
self.lagBar:ClearAllPoints() self:SetBarCoord(self.lagBar, scale, top)
if lagTop then
self.lagBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.lagBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
local now = GetTime()
local lag = now - (self.spellCastSent or now)
local pos = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
if self.unit == "vehicle" then
pos = 0
end
local y = self.settings.barHeight - (pos * self.settings.barHeight)
local min_y = 1-pos
local max_y = 1
if lagTop then
min_y = 0
max_y = pos
end
if (self.moduleSettings.side == IceCore.Side.Left) then
self.lagBar.bar:SetTexCoord(1, 0, min_y, max_y)
else
self.lagBar.bar:SetTexCoord(0, 1, min_y, max_y)
end
if pos == 0 then
self.lagBar.bar:Hide()
else
self.lagBar.bar:Show()
end
self.lagBar:SetHeight(self.settings.barHeight * pos)
self.spellCastSent = nil self.spellCastSent = nil
end end

View File

@ -103,47 +103,16 @@ function EclipseBar.prototype:CreateFrame()
end end
function EclipseBar.prototype:CreateSolarBar() function EclipseBar.prototype:CreateSolarBar()
if not (self.solarBar) then self.solarBar = self:BarFactory(self.solarBar,"BACKGROUND", "ARTWORK")
self.solarBar = CreateFrame("Frame", nil, self.frame)
end
local solarTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) local offsetY
local scale = 0.5
self.solarBar:SetFrameStrata("BACKGROUND") self:SetBarCoord(self.solarBar, scale, true)
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)) 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.bar:Show()
self.solarBar:SetHeight(self.settings.barHeight * pos)
end end
function EclipseBar.prototype:UpdateShown() function EclipseBar.prototype:UpdateShown()

View File

@ -56,8 +56,6 @@ function PlayerHealth.prototype:GetDefaultSettings()
settings["PartyRoleIconOffset"] = {x=90, y=-59} settings["PartyRoleIconOffset"] = {x=90, y=-59}
settings["PartyRoleIconScale"] = 0.9 settings["PartyRoleIconScale"] = 0.9
settings["bAllowExpand"] = false
return settings return settings
end end
@ -865,35 +863,10 @@ function PlayerHealth.prototype:CreateBackground(redraw)
end end
function PlayerHealth.prototype:CreateHealBar() function PlayerHealth.prototype:CreateHealBar()
if not self.healFrame then self.healFrame = self:BarFactory(self.healFrame, "LOW","BACKGROUND")
self.healFrame = CreateFrame("Frame", nil, self.frame)
end
self.healFrame:SetFrameStrata("LOW")
self.healFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.healFrame:SetHeight(self.settings.barHeight)
self.healFrame:ClearAllPoints()
if self.moduleSettings.reverse then
self.healFrame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.healFrame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
if not self.healFrame.bar then
self.healFrame.bar = self.healFrame:CreateTexture(nil, "BACKGROUND")
end
self.healFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.healFrame.bar:SetAllPoints(self.healFrame)
self.healFrame.bar:SetVertexColor(self:GetColor("PlayerHealthHealAmount", self.alpha * self.moduleSettings.healAlpha)) self.healFrame.bar:SetVertexColor(self:GetColor("PlayerHealthHealAmount", self.alpha * self.moduleSettings.healAlpha))
if (self.moduleSettings.side == IceCore.Side.Left) then
self.healFrame.bar:SetTexCoord(1, 0, 0, 1)
else
self.healFrame.bar:SetTexCoord(0, 1, 0, 1)
end
self:UpdateBar(1, "undef") self:UpdateBar(1, "undef")
if not self.moduleSettings.showIncomingHeals or (IceHUD.WowVer < 40000 and not HealComm) then if not self.moduleSettings.showIncomingHeals or (IceHUD.WowVer < 40000 and not HealComm) then
@ -1221,38 +1194,21 @@ function PlayerHealth.prototype:Update(unit)
-- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element -- sadly, animation uses bar-local variables so we can't use the animation for 2 bar textures on the same bar element
if self.moduleSettings.showIncomingHeals and self.healFrame and self.healFrame.bar and incomingHealAmt then if self.moduleSettings.showIncomingHeals and self.healFrame and self.healFrame.bar and incomingHealAmt then
local barValue, percent local percent
if incomingHealAmt > 0 then if incomingHealAmt > 0 then
percent = ((self.health + incomingHealAmt) / self.maxHealth) percent = ((self.health + incomingHealAmt) / self.maxHealth)
barValue = 1-percent if self.moduleSettings.reverse then
percent = 1 - percent
-- Rokiyo: I'm thinking the frama strata should also to be set to medium if we're in reverse.
end
else else
barValue = 1
percent = 0 percent = 0
end end
barValue = IceHUD:Clamp(barValue, 0, 1)
percent = IceHUD:Clamp(percent, 0, 1) percent = IceHUD:Clamp(percent, 0, 1)
local min_y = barValue self:SetBarCoord(self.healFrame, percent)
local max_y = 1
if self.moduleSettings.reverse then
min_y = 0
max_y = 1-barValue
end
if (self.moduleSettings.side == IceCore.Side.Left) then
self.healFrame.bar:SetTexCoord(1, 0, min_y, max_y)
else
self.healFrame.bar:SetTexCoord(0, 1, min_y, max_y)
end
self.healFrame:SetHeight(self.settings.barHeight * percent)
if percent == 0 then
self.healFrame.bar:Hide()
else
self.healFrame.bar:Show()
end
end end
if not IceHUD.IceCore:ShouldUseDogTags() then if not IceHUD.IceCore:ShouldUseDogTags() then

View File

@ -140,22 +140,11 @@ function SliceAndDice.prototype:CreateFrame()
end end
function SliceAndDice.prototype:CreateDurationBar() function SliceAndDice.prototype:CreateDurationBar()
if not self.durationFrame then self.durationFrame = self:BarFactory(self.durationFrame, "BACKGROUND","ARTWORK")
self.durationFrame = CreateFrame("Frame", nil, self.frame)
self.CurrScale = 0
end
self.durationFrame:SetFrameStrata("BACKGROUND") -- Rokiyo: Do we need to call this here?
self:SetBarFramePoints(self.durationFrame) self.CurrScale = 0
self.durationFrame:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.durationFrame:SetHeight(self.settings.barHeight)
if not self.durationFrame.bar then
self.durationFrame.bar = self.durationFrame:CreateTexture(nil, "LOW")
end
self.durationFrame.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.durationFrame.bar:SetAllPoints(self.durationFrame)
self.durationFrame.bar:SetVertexColor(self:GetColor("SliceAndDicePotential", self.alpha * self.moduleSettings.durationAlpha)) self.durationFrame.bar:SetVertexColor(self:GetColor("SliceAndDicePotential", self.alpha * self.moduleSettings.durationAlpha))
self.durationFrame.bar:SetHeight(0) self.durationFrame.bar:SetHeight(0)
@ -306,6 +295,8 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit)
if (self.moduleSettings.reverse) then if (self.moduleSettings.reverse) then
scale = 1 - scale scale = 1 - scale
end end
local min_y, max_y
if (self.moduleSettings.inverse == "INVERSE") then if (self.moduleSettings.inverse == "INVERSE") then
min_y = 0 min_y = 0
max_y = scale max_y = scale

View File

@ -196,67 +196,32 @@ end
-- create the aggro range indicator bar -- create the aggro range indicator bar
function IceThreat.prototype:CreateAggroBar() function IceThreat.prototype:CreateAggroBar()
if not (self.aggroBar) then self.aggroBar = self:BarFactory(self.aggroBar, "BACKGROUND","ARTWORK")
self.aggroBar = CreateFrame("Frame", nil, self.frame)
end
-- Rokiyo: TODO: modify IceBarElement:SetBarFramePoints() to handle this behaviour.
local aggroTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) local aggroTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE"))
self.aggroBar:ClearAllPoints()
self.aggroBar:SetFrameStrata("BACKGROUND")
self.aggroBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.aggroBar:SetHeight(self.settings.barHeight)
self.aggroBar:ClearAllPoints()
if aggroTop then if aggroTop then
self.aggroBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT") self.aggroBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else else
self.aggroBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT") self.aggroBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end end
-- End of IceBarElement:SetBarFramePoints() override.
if not (self.aggroBar.bar) then
self.aggroBar.bar = self.aggroBar:CreateTexture(nil, "LOW")
end
self.aggroBar.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.aggroBar.bar:SetAllPoints(self.aggroBar)
local r, g, b = self:GetColor("ThreatPullAggro") local r, g, b = self:GetColor("ThreatPullAggro")
if (self.settings.backgroundToggle) then if (self.settings.backgroundToggle) then
r, g, b = self:GetColor("CastCasting") r, g, b = self:GetColor("CastCasting")
end end
self.aggroBar.bar:SetVertexColor(r, g, b, self.moduleSettings.aggroAlpha) self.aggroBar.bar:SetVertexColor(r, g, b, self.moduleSettings.aggroAlpha)
self:SetBarCoord(self.aggroBar)
if (self.moduleSettings.side == IceCore.Side.Left) then
self.aggroBar.bar:SetTexCoord(1, 0, 0, 0)
else
self.aggroBar.bar:SetTexCoord(0, 1, 0, 0)
end
end end
function IceThreat.prototype:CreateSecondThreatBar() function IceThreat.prototype:CreateSecondThreatBar()
if not (self.secondThreatBar) then self.secondThreatBar = self:BarFactory(self.secondThreatBar, "MEDIUM", "OVERLAY")
self.secondThreatBar = CreateFrame("Frame", nil, self.frame)
end
self.secondThreatBar:SetFrameStrata("MEDIUM")
self.secondThreatBar:SetWidth(self.settings.barWidth + (self.moduleSettings.widthModifier or 0))
self.secondThreatBar:SetHeight(self.settings.barHeight)
self:SetBarFramePoints(self.secondThreatBar)
if not (self.secondThreatBar.bar) then
self.secondThreatBar.bar = self.secondThreatBar:CreateTexture(nil, "OVERLAY")
end
self.secondThreatBar.bar:SetTexture(IceElement.TexturePath .. self:GetMyBarTexture())
self.secondThreatBar.bar:SetAllPoints(self.secondThreatBar)
local r, g, b = self:GetColor("ThreatSecondPlace") local r, g, b = self:GetColor("ThreatSecondPlace")
self.secondThreatBar.bar:SetVertexColor(r, g, b, self.alpha) self.secondThreatBar.bar:SetVertexColor(r, g, b, self.alpha)
self:SetBarCoord(self.secondThreatBar)
if (self.moduleSettings.side == IceCore.Side.Left) then
self.secondThreatBar.bar:SetTexCoord(1, 0, 0, 0)
else
self.secondThreatBar.bar:SetTexCoord(0, 1, 0, 0)
end
end end
-- bar stuff -- bar stuff
@ -414,6 +379,8 @@ function IceThreat.prototype:UpdateSecondHighestThreatBar(secondHighestThreat, t
if (self.moduleSettings.reverse) then if (self.moduleSettings.reverse) then
pos = 1 - pos pos = 1 - pos
end end
local min_y, max_y
if (self.moduleSettings.inverse == "INVERSE") then if (self.moduleSettings.inverse == "INVERSE") then
min_y = 0 min_y = 0
max_y = pos max_y = pos