Skip to content

Commit

Permalink
Switched BarIcon to MaskStatusBar, BarIconArray
Browse files Browse the repository at this point in the history
  • Loading branch information
d87 committed Nov 12, 2020
1 parent 3b23294 commit b252b32
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 51 deletions.
6 changes: 3 additions & 3 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ config.DefaultWidgets = {
raidbuff = { type = "IndicatorArray", width = 5, height = 5, point = "TOPLEFT", x = 0, y = 0, growth = "DOWN", max = 5 },
mitigation = { type = "Bar", width=22, height=4, point="BOTTOMLEFT", x=4, y=-5, vertical = false},
-- icon = { type = "Icon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = true, edge = true },
icon = { type = "BarIcon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = true, edge = true },
icon = { type = "BarIcon", width = 24, height = 24, point = "CENTER", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 12, outline = true, edge = true, vertical = true },
spell1 = { type = "Indicator", width = 9, height = 8, point = "BOTTOMRIGHT", x = 0, y = 0, },
-- spell2 = { type = "Indicator", width = 9, height = 8, point = "TOP", x = 0, y = 0, },
spell3 = { type = "Indicator", width = 9, height = 8, point = "TOPRIGHT", x = 0, y = 0, },
bar4 = { type = "Bar", width=21, height=5, point="TOPRIGHT", x=0, y=2, vertical = false},
buffIcons = { type = "IconArray", width = 12, height = 18, point = "TOPRIGHT", x = 5, y = -6, alpha = 1, growth = "LEFT", max = 3, edge = true, outline = true, font = config.defaultFont, textsize = 12 },
buffIcons = { type = "BarIconArray", width = 12, height = 18, point = "TOPRIGHT", x = 5, y = -6, alpha = 1, growth = "LEFT", max = 3, edge = true, outline = true, vertical = true, font = config.defaultFont, textsize = 12 },
bars = { type = "BarArray", width = 21, height = 5, point = "BOTTOMRIGHT", x = 0, y = 0, vertical = false, growth = "UP", max = 7 },
vbar1 = { type = "Bar", width=4, height=20, point="TOPRIGHT", x=-9, y=2, vertical = true},
text1 = { type = "StaticText", point="CENTER", x=0, y=0, font = config.defaultFont, textsize = 12, effect = "SHADOW" },
Expand Down Expand Up @@ -116,7 +116,7 @@ local RangeCheckBySpell = helpers.RangeCheckBySpell


config.templates = {
TankCD = { assignto = set("icon"), infoType = "DURATION", priority = 94, color = { 1, 0.2, 1} },
TankCD = { assignto = set("icon"), infoType = "DURATION", priority = 94, color = { 1, 0.2, 1}, refreshTime = 2 },
SurvivalCD = { assignto = set("buffIcons"), infoType = "DURATION", priority = 90, color = { 0.4, 1, 0.4} },
ActiveMitigation = { assignto = set("mitigation"), infoType = "DURATION", color = {0.7, 0.7, 0.7}, priority = 80 },
HealTrace = { assignto = set("healfeedback"), color = { 1, 0.7, 0.35}, fade = 0.7, priority = 96 },
Expand Down
100 changes: 52 additions & 48 deletions frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ local function AddPulseAnimation(f)
pa1:SetToAlpha(0)
pa1:SetDuration(0.15)
pa1:SetOrder(1)
pag.a1 = pa1
local pa2 = pag:CreateAnimation("Alpha")
pa2:SetFromAlpha(0)
pa2:SetToAlpha(1)
Expand Down Expand Up @@ -1667,31 +1668,35 @@ end
-- Bar Icon
----------------------------------------------------------

local min = math.min
local function BarIcon_OnUpdate(self)
local startTime = self.startTime
local endTime = self.endTime
local duration = endTime - startTime

local timeLeft = endTime - GetTime()
local timeLeft = self.endTime - GetTime()

-- if self.pandemic and timeLeft < self.pandemic then
-- local color = self._color
-- self:SetStatusBarColor(color[1]*0.75, color[2]*0.75, color[3]*0.75)
-- self.pandemic = nil
-- end
local pandemic = self.pandemic
if pandemic and timeLeft < pandemic then
if not self.pulse:IsPlaying() then
self.pulse.maxpulses = 999999
self.pulse:Play()
end
self.pandemic = nil
end
if self.isReversed then
timeLeft = startTime + timeLeft
timeLeft = self.startTime + timeLeft
end

-- self.spark:UpdatePos(timeLeft/duration)
self.spark:Hide()
local a = min(timeLeft, 2)
self.spark:SetAlpha(a/2)
self:SetValue(timeLeft)
end

local function BarIcon_SetJob(self, job, state, contentType, ...)
local timerType, cur, max, count, icon, text, r,g,b, texture, texCoords, isReversed = NormalizeContent(job, state, contentType, ...)


if self.currentJob ~= self.previousJob then
self:SetScript("OnUpdate", nil)
self.pulse:Stop()
end

if count and count > 1 then
self.stacktext:SetText(count)
Expand All @@ -1711,13 +1716,11 @@ local function BarIcon_SetJob(self, job, state, contentType, ...)
local pandemic = job.refreshTime
self.pandemic = pandemic
self:SetMinMaxValues(0, duration)
-- self:SetValue(timeLeft)
BarIcon_OnUpdate(self, 0)
self:SetScript("OnUpdate", BarIcon_OnUpdate)
elseif max and cur then
self:SetMinMaxValues(0, max)
self:SetValue(cur)
self.spark:UpdatePos(cur/max)
self:SetScript("OnUpdate", nil)
self.stacktext:SetText()
else
Expand All @@ -1727,41 +1730,21 @@ local function BarIcon_SetJob(self, job, state, contentType, ...)
end
end

local function BarIcon_SetCooldown(self, startTime, duration)
self:SetMinMaxValues(0, duration)
self.expirationTime = startTime+duration
self.startTime = startTime
self.duration = duration
self:SetValue(GetTime())
self:Show()
end


local function BarIcon_Spark_UpdatePosHorizontal(spark, progress)
local bar = spark:GetParent()
local frameLength = bar:GetWidth()
local p = frameLength * progress
spark:SetPoint("CENTER", bar, "LEFT", p, 0)
end
local function BarIcon_Spark_UpdatePosVertical(spark, progress)
local bar = spark:GetParent()
local frameLength = bar:GetWidth()
local p = frameLength * progress
spark:SetPoint("CENTER", bar, "BOTTOM", 0, p)
end
local function BarIcon_Spark_SetOrientation(spark, orientation)
spark:ClearAllPoints();
if orientation == "VERTICAL" then
local width = spark:GetParent():GetWidth()
spark.UpdatePos = BarIcon_Spark_UpdatePosVertical
local bar = spark:GetParent()
local width = bar:GetWidth()
spark:SetPoint("CENTER", bar._mask, "BOTTOM", 0, 0)
spark:SetWidth(width)
spark:SetHeight(width*2)
spark:SetHeight(width)
spark:SetTexCoord(1,1,0,1,1,0,0,0)
else
local height = spark:GetParent():GetHeight()
spark.UpdatePos = BarIcon_Spark_UpdatePosHorizontal
local bar = spark:GetParent()
local height = bar:GetHeight()
spark:SetPoint("CENTER", bar._mask, "LEFT", 0, 0)
spark:SetTexCoord(0,1,0,1)
spark:SetWidth(height*2)
spark:SetWidth(height)
spark:SetHeight(height)
end
end
Expand All @@ -1779,8 +1762,9 @@ function Aptechka.Widget.BarIcon.Create(parent, popts, gopts)
local w = pixelperfect(opts.width)
local h = pixelperfect(opts.height)

local orientation = opts.vertical and "VERTICAL" or "HORIZONTAL"
-- local bar = CreateFrame("StatusBar", nil, parent)
local bar = Aptechka.CreateCustomStatusBar(nil, parent, "HORIZONTAL")
local bar = Aptechka.CreateMaskStatusBar(nil, parent, orientation)
bar:SetFrameLevel(FRAMELEVEL.ICON)

-- local fg = bar:CreateTexture(nil,"ARTWORK", nil, 2)
Expand All @@ -1795,7 +1779,7 @@ function Aptechka.Widget.BarIcon.Create(parent, popts, gopts)
bg:SetAllPoints(bar)
bar.bg = bg

bar:SetAlpha(opts.alpha)
bar:SetAlpha(opts.alpha or 1)

SetIconTexCoord(bar.bg, w, h)

Expand All @@ -1807,15 +1791,24 @@ function Aptechka.Widget.BarIcon.Create(parent, popts, gopts)

-- bar:SetScript("OnUpdate", BarIcon_OnUpdate)

local spark = bar:CreateTexture(nil, "ARTWORK")
local spark = bar:CreateTexture(nil, "ARTWORK", nil, 5)
-- spark:SetAtlas("honorsystem-bar-spark")
-- spark:SetSize(height/4, height*1.6)
spark:SetTexture("Interface/AddOns/Aptechka/spark")
spark:SetBlendMode("ADD")
spark:SetVertexColor(1,0.7,0)
spark.SetOrientation = BarIcon_Spark_SetOrientation
spark:SetOrientation("HORIZONTAL")
spark:SetOrientation(orientation)
bar.spark = spark

AddPulseAnimation(bar)
bar.pulse.a1:SetDuration(0.3)
bar.pulse.a1:SetToAlpha(0.55)
bar.pulse.a2:SetDuration(0.3)
bar.pulse.a2:SetFromAlpha(0.55)
bar.pulse.maxpulses = 9999


return WrapFrameAsWidget(bar)
end

Expand All @@ -1825,7 +1818,7 @@ function Aptechka.Widget.BarIcon.Reconf(parent, f, popts, gopts)
local h = pixelperfect(opts.height)

UpdateFramePoints(f, parent, opts, w, h)
f:SetAlpha(opts.alpha)
f:SetAlpha(opts.alpha or 1)
SetIconTexCoord(f.bg, w, h)
SetIconTexCoord(f.fg, w, h)
UpdateFontStringSettings(f.stacktext, opts.font, opts.textsize, opts.effect)
Expand All @@ -1835,6 +1828,17 @@ function Aptechka.Widget.BarIcon.Reconf(parent, f, popts, gopts)
f.bar.spark:SetOrientation( opts.vertical and "VERTICAL" or "HORIZONTAL")
end

----------------------------------------------------------

Aptechka.Widget.BarIconArray = {}
Aptechka.Widget.BarIconArray.default = { type = "BarIconArray", width = 15, height = 15, point = "TOPRIGHT", x = 0, y = 0, alpha = 1, font = config.defaultFont, textsize = 10, outline = true, edge = true, vertical = true, growth = "LEFT", max = 3 }
function Aptechka.Widget.BarIconArray.Create(parent, popts, gopts)
local opts = InheritGlobalOptions(popts, gopts)
return CreateArrayHeader("BarIcon", parent, opts.point, opts.x, opts.y, opts, opts.growth, opts.max)
end

Aptechka.Widget.BarIconArray.Reconf = Aptechka.Widget.BarArray.Reconf

----------------------------------------------------------
-- Progress Icon
----------------------------------------------------------
Expand Down
Binary file modified spark.tga
Binary file not shown.
Binary file added tmask.tga
Binary file not shown.

0 comments on commit b252b32

Please sign in to comment.