- 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
function IceBarElement.prototype:SetBarFramePoints(frame)
function IceBarElement.prototype:SetBarFramePoints(frame, offset_x, offset_y)
local anchor
frame:ClearAllPoints()
if self.moduleSettings.inverse == "INVERSE" then
frame:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
anchor = "TOPLEFT"
elseif self.moduleSettings.inverse == "EXPAND" then
frame:SetPoint("LEFT", self.frame, "LEFT")
anchor = "LEFT"
else
frame:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
anchor = "BOTTOMLEFT"
end
frame:SetPoint(anchor, self.frame, anchor, offset_x, offset_y)
end
@ -985,27 +989,35 @@ end
-- Creates the actual bar
function IceBarElement.prototype:CreateBar()
if not (self.barFrame) then
self.barFrame = CreateFrame("Frame", nil, self.frame)
end
self.barFrame = self:BarFactory(self.barFrame, "LOW", "ARTWORK")
self:SetBarCoord(self.barFrame)
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:SetAllPoints(self.barFrame)
self:SetScale(self.CurrScale, true)
self:UpdateBar(1, "undef")
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()
if self.moduleSettings.shouldUseOverride and self.moduleSettings.barTextureOverride then
@ -1099,6 +1111,54 @@ function IceBarElement.prototype:Flip(side)
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)
local oldScale = self.CurrScale
@ -1111,29 +1171,8 @@ function IceBarElement.prototype:SetScale(inScale, force)
if self.moduleSettings.reverse then
scale = 1 - scale
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)
if scale == 0 then
self.barFrame.bar:Hide()
else
self.barFrame.bar:Show()
end
self:SetBarCoord(self.barFrame, scale)
end
if not self:IsFull(self.CurrScale) or not self:IsFull(inScale) then

View File

@ -358,19 +358,8 @@ end
function CastBar.prototype:CreateLagBar()
if not (self.lagBar) then
self.lagBar = CreateFrame("Frame", nil, self.frame)
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)
self.lagBar = self:BarFactory(self.lagBar, "LOW","BACKGROUND")
self:SetBarCoord(self.lagBar, 0 , true)
local r, g, b = self:GetColor("CastLag")
if (self.settings.backgroundToggle) then
@ -378,11 +367,6 @@ function CastBar.prototype:CreateLagBar()
end
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()
end
@ -404,43 +388,17 @@ function CastBar.prototype:SpellCastStart(event, unit, spell, rank)
return
end
self.lagBar:SetFrameStrata("BACKGROUND")
self.lagBar:ClearAllPoints()
if not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) then
self.lagBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
local scale
if self.unit == "vehicle" then
scale = 0
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 = 0
local max_y = pos
if IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE")) then
min_y = 1-pos
max_y = 1
scale = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
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.lagBar:SetFrameStrata("BACKGROUND")
self:SetBarCoord(self.lagBar, scale, true)
self.spellCastSent = nil
end
@ -455,48 +413,19 @@ function CastBar.prototype:SpellCastChannelStart(event, unit)
return
end
local lagTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE"))
if self.moduleSettings.reverseChannel then
lagTop = not lagTop
end
self.lagBar:SetFrameStrata("MEDIUM")
self.lagBar:ClearAllPoints()
if lagTop then
self.lagBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
local scale
if self.unit == "vehicle" then
scale = 0
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
scale = IceHUD:Clamp(lag / self.actionDuration, 0, 1)
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
local top = not self.moduleSettings.reverseChannel
if pos == 0 then
self.lagBar.bar:Hide()
else
self.lagBar.bar:Show()
end
self.lagBar:SetHeight(self.settings.barHeight * pos)
self.lagBar:SetFrameStrata("MEDIUM")
self:SetBarCoord(self.lagBar, scale, top)
self.spellCastSent = nil
end

View File

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

View File

@ -56,8 +56,6 @@ function PlayerHealth.prototype:GetDefaultSettings()
settings["PartyRoleIconOffset"] = {x=90, y=-59}
settings["PartyRoleIconScale"] = 0.9
settings["bAllowExpand"] = false
return settings
end
@ -865,35 +863,10 @@ function PlayerHealth.prototype:CreateBackground(redraw)
end
function PlayerHealth.prototype:CreateHealBar()
if not self.healFrame then
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 = self:BarFactory(self.healFrame, "LOW","BACKGROUND")
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")
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
if self.moduleSettings.showIncomingHeals and self.healFrame and self.healFrame.bar and incomingHealAmt then
local barValue, percent
local percent
if incomingHealAmt > 0 then
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
barValue = 1
percent = 0
end
barValue = IceHUD:Clamp(barValue, 0, 1)
percent = IceHUD:Clamp(percent, 0, 1)
local min_y = barValue
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
self:SetBarCoord(self.healFrame, percent)
end
if not IceHUD.IceCore:ShouldUseDogTags() then

View File

@ -140,22 +140,11 @@ function SliceAndDice.prototype:CreateFrame()
end
function SliceAndDice.prototype:CreateDurationBar()
if not self.durationFrame then
self.durationFrame = CreateFrame("Frame", nil, self.frame)
self.durationFrame = self:BarFactory(self.durationFrame, "BACKGROUND","ARTWORK")
-- Rokiyo: Do we need to call this here?
self.CurrScale = 0
end
self.durationFrame:SetFrameStrata("BACKGROUND")
self:SetBarFramePoints(self.durationFrame)
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:SetHeight(0)
@ -306,6 +295,8 @@ function SliceAndDice.prototype:UpdateDurationBar(event, unit)
if (self.moduleSettings.reverse) then
scale = 1 - scale
end
local min_y, max_y
if (self.moduleSettings.inverse == "INVERSE") then
min_y = 0
max_y = scale

View File

@ -196,67 +196,32 @@ end
-- create the aggro range indicator bar
function IceThreat.prototype:CreateAggroBar()
if not (self.aggroBar) then
self.aggroBar = CreateFrame("Frame", nil, self.frame)
end
self.aggroBar = self:BarFactory(self.aggroBar, "BACKGROUND","ARTWORK")
-- Rokiyo: TODO: modify IceBarElement:SetBarFramePoints() to handle this behaviour.
local aggroTop = not IceHUD:xor(self.moduleSettings.reverse, (self.moduleSettings.inverse == "INVERSE"))
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
self.aggroBar:SetPoint("TOPLEFT", self.frame, "TOPLEFT")
else
self.aggroBar:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT")
end
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)
-- End of IceBarElement:SetBarFramePoints() override.
local r, g, b = self:GetColor("ThreatPullAggro")
if (self.settings.backgroundToggle) then
r, g, b = self:GetColor("CastCasting")
end
self.aggroBar.bar:SetVertexColor(r, g, b, self.moduleSettings.aggroAlpha)
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
self:SetBarCoord(self.aggroBar)
end
function IceThreat.prototype:CreateSecondThreatBar()
if not (self.secondThreatBar) then
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)
self.secondThreatBar = self:BarFactory(self.secondThreatBar, "MEDIUM", "OVERLAY")
local r, g, b = self:GetColor("ThreatSecondPlace")
self.secondThreatBar.bar:SetVertexColor(r, g, b, self.alpha)
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
self:SetBarCoord(self.secondThreatBar)
end
-- bar stuff
@ -414,6 +379,8 @@ function IceThreat.prototype:UpdateSecondHighestThreatBar(secondHighestThreat, t
if (self.moduleSettings.reverse) then
pos = 1 - pos
end
local min_y, max_y
if (self.moduleSettings.inverse == "INVERSE") then
min_y = 0
max_y = pos