diff --git a/Aptechka.lua b/Aptechka.lua index 381c7e6..c16a678 100644 --- a/Aptechka.lua +++ b/Aptechka.lua @@ -1079,16 +1079,16 @@ function Aptechka:UpdateMindControl(unit) end -local function WidgetStartTrace(widget, slot, frame, opts) +local function WidgetStartTrace(widget, slot, frame, opts, ...) if not widget then widget = Aptechka:CreateDynamicWidget(frame, slot) end if widget then - widget:StartTrace(opts) + widget:StartTrace(opts, ...) end end -local function FrameStartTrace(frame, unit, opts) - Aptechka:ForEachFrameOptsWidget(frame, opts, WidgetStartTrace, frame, opts) +local function FrameStartTrace(frame, unit, opts, ...) + Aptechka:ForEachFrameOptsWidget(frame, opts, WidgetStartTrace, frame, opts, ...) end Aptechka.FrameStartTrace = FrameStartTrace @@ -1118,7 +1118,7 @@ function Aptechka:COMBAT_LOG_EVENT_UNFILTERED(event) local minamount = opts.minamount if not minamount or amount > minamount then local unit = guidMap[dstGUID] - Aptechka:ForEachUnitFrame(unit, FrameStartTrace, opts) + Aptechka:ForEachUnitFrame(unit, FrameStartTrace, opts, spellID) end end end diff --git a/frame.lua b/frame.lua index 01dbe75..b265cc7 100644 --- a/frame.lua +++ b/frame.lua @@ -583,7 +583,7 @@ end local BlinkAnimOnFinished = function(ag) local widget = ag:GetParent() - local frame = widget.parent + local frame = widget:GetParent() widget.traceJob = nil Aptechka:UpdateWidget(frame, widget) end @@ -607,6 +607,36 @@ local function AddBlinkAnimation(f) f.blink = bag end +local function MakeStartTraceForBlinkAnimation(func) + return function(self, job, ...) + if self.traceJob and self.traceJob.priority > job.priority then + return + end + + self.traceJob = job + + self:Show() + + self.blink.a2:SetFromAlpha(1) + self.blink.a2:SetToAlpha(0) + local duration = job.fade or 0.7 + self.blink.a2:SetDuration(duration) + + func(self, job, ...) + -- local r,g,b,a = GetColor(job) + -- self.texture:SetVertexColor(r,g,b,a) + + -- local scale = job.scale or 1 + -- self:SetScale(scale) + + if self.blink:IsPlaying() then + self.blink:Stop() + end + self.blink:Play() + end +end + + local function AddSpinAnimation(f) local rag = f:CreateAnimationGroup() local r1 = rag:CreateAnimation("Rotation") @@ -766,28 +796,11 @@ function PixelScaleMixin.SetUScale(self, scale) self:SetVScale(scale) end -local function Indicator_StartTrace(self, job) - if self.traceJob and self.traceJob.priority > job.priority then - return - end - - self.traceJob = job - - self:Show() - - self.blink.a2:SetFromAlpha(1) - self.blink.a2:SetToAlpha(0) - local duration = job.fade or 0.7 - self.blink.a2:SetDuration(duration) - +local Indicator_StartTrace = MakeStartTraceForBlinkAnimation(function(self, job) local r,g,b,a = GetColor(job) self.color:SetVertexColor(r,g,b,a) +end) - if self.blink:IsPlaying() then - self.blink:Stop() - end - self.blink:Play() -end local SetJob_Indicator = function(self, job, state, contentType, ...) if self.traceJob then return end -- widget is busy with animation @@ -917,31 +930,13 @@ end ------------------------------------------------------------------------------------------- -- Texture ------------------------------------------------------------------------------------------- -local function Texture_StartTrace(self, job) - if self.traceJob and self.traceJob.priority > job.priority then - return - end - - self.traceJob = job - - self:Show() - - self.blink.a2:SetFromAlpha(1) - self.blink.a2:SetToAlpha(0) - local duration = job.fade or 0.7 - self.blink.a2:SetDuration(duration) - +local Texture_StartTrace = MakeStartTraceForBlinkAnimation(function(self, job) local r,g,b,a = GetColor(job) self.texture:SetVertexColor(r,g,b,a) local scale = job.scale or 1 self:SetScale(scale) - - if self.blink:IsPlaying() then - self.blink:Stop() - end - self.blink:Play() -end +end) -- function PrintSetRaidTargetIconTexture (texture, raidTargetIconIndex) @@ -1267,6 +1262,14 @@ local SetJob_Icon = function(self, job, state, contentType, ...) end end +local Icon_StartTrace = MakeStartTraceForBlinkAnimation(function(self, job, spellID) + local tex = spellID and GetSpellTexture(spellID) + self.texture:SetTexture(tex or job.icon or 136190) + + self.stacktext:SetText() + self.cd:Hide() +end) + --[[ local CreateShieldIcon = function(parent,w,h,alpha,point,frame,to,x,y) local icon = CreateFrame("Frame",nil,parent) @@ -1402,6 +1405,9 @@ function Aptechka.Widget.Icon.Create(parent, popts, gopts) icd:SetAllPoints(icon.texture) icon.cd = icd + AddBlinkAnimation(icon) + icon.StartTrace = Icon_StartTrace + Aptechka.Widget.Icon.Reconf(parent, icon, popts, gopts) return WrapFrameAsWidget(icon) @@ -1825,6 +1831,7 @@ function Aptechka.Widget.BarIcon.Create(parent, popts, gopts) Aptechka.Widget.BarIcon.Reconf(parent, bar, popts, gopts) + bar:Hide() return WrapFrameAsWidget(bar) end @@ -2267,35 +2274,37 @@ local SetJob_StaticText = function(self, job, state, contentType, ...) self.text:SetText(text) end -local CreateTextTimer = function(parent, point, frame, to, x, y, hjustify, fontsize, font, flags) - local f = CreateFrame("Frame", nil, parent) -- We need frame to create OnUpdate handler for time updates - local text = f:CreateFontString(nil, "ARTWORK") - f:SetFrameLevel(FRAMELEVEL.TEXT) - f.text = text - text:SetPoint(point,frame,to,x,y)--"TOPLEFT",self,"TOPLEFT",-2,0) - -- text:SetJustifyH("LEFT") - text:SetFont(font, fontsize or 11, flags) - f.SetJob = SetJob_Text - return f -end -AptechkaDefaultConfig.GridSkin_CreateTextTimer = CreateTextTimer +local Text_StartTrace = MakeStartTraceForBlinkAnimation(function(self, job) + local r,g,b,a = GetTextColor(job) + self.text:SetTextColor(r,g,b,a) + + local scale = job.scale or 1 + self:SetScale(scale) + + self.text:SetText(job.text or job.name) +end) Aptechka.Widget.Text = {} Aptechka.Widget.Text.default = { type = "Text", point = "TOPLEFT", x = 0, y = 0, --[[justify = "LEFT",]] font = config.defaultFont, textsize = 13, effect = "NONE" } function Aptechka.Widget.Text.Create(parent, popts, gopts) local opts = InheritGlobalOptions(popts, gopts) - local font = LSM:Fetch("font", opts.font) or LSM:Fetch("font", config.defaultFont) - local flags = opts.effect == "OUTLINE" and "OUTLINE" - local text = CreateTextTimer(parent, opts.point, parent, opts.point, opts.x, opts.y, opts.justify, opts.textsize, font, flags) - if opts.effect == "SHADOW" then - text.text:SetShadowOffset(1,-1) - else - text.text:SetShadowOffset(0,0) - end + + local f = CreateFrame("Frame", nil, parent) -- We need frame to create OnUpdate handler for time updates + local text = f:CreateFontString(nil, "ARTWORK") + f:SetFrameLevel(FRAMELEVEL.TEXT) + f.text = text + + Aptechka.Widget.Text.Reconf(parent, f, popts, gopts) + if opts.type == "StaticText" then - text.SetJob = SetJob_StaticText + f.SetJob = SetJob_StaticText + else + f.SetJob = SetJob_Text end - return text + + AddBlinkAnimation(f) + f.StartTrace = Text_StartTrace + return WrapFrameAsWidget(f) end function Aptechka.Widget.Text.Reconf(parent, f, popts, gopts) @@ -2525,7 +2534,7 @@ local border_backdrop = { edgeFile = "Interface\\Addons\\Aptechka\\border", tileEdge = true, edgeSize = 14, insets = {left = -2, right = -2, top = -2, bottom = -2}, } -local SetJob_Border = function(self, job, state, contentType, ...) +local Border_SetJob = function(self, job, state, contentType, ...) local timerType, cur, max, count, icon, text, r,g,b, texture, texCoords = NormalizeContent(job, state, contentType, ...) self:SetBackdropBorderColor(r,g,b, 0.5) @@ -2536,6 +2545,10 @@ local SetJob_Border = function(self, job, state, contentType, ...) end end end +local Border_StartTrace = MakeStartTraceForBlinkAnimation(function(self, job) + local r,g,b,a = GetColor(job) + self:SetBackdropBorderColor(r,g,b, 0.5) +end) local OnMouseEnterFunc = function(self) @@ -2962,7 +2975,11 @@ AptechkaDefaultConfig.GridSkin = function(self) border:SetBackdrop(border_backdrop) border:SetBackdropBorderColor(1, 1, 1, 0.5) AddPulseAnimation(border) - border.SetJob = SetJob_Border + border.SetJob = Border_SetJob + + AddBlinkAnimation(border) + border.StartTrace = Border_StartTrace + border:Hide() @@ -3001,7 +3018,7 @@ AptechkaDefaultConfig.GridSkin = function(self) self.border = border - self.healthColor = self.health + self.healthColor = WrapFrameAsWidget(self.health) self.bossdebuff = bossdebuff self.raidicon = raidicon self.healabsorb = healAbsorb @@ -3374,9 +3391,6 @@ end Aptechka.CreateCoordStatusBar = CoordStatusBar.Create - - - local function FakeHeader_Arrange(hdr) local db = Aptechka.db.profile local w = pixelperfect(db.width) diff --git a/helpers.lua b/helpers.lua index 135116f..b293a2f 100644 --- a/helpers.lua +++ b/helpers.lua @@ -152,7 +152,10 @@ local function PrepareAuraOpts(data) end if data.id and not data.name then data.name = GetSpellInfo(data.id) end - if data.name == nil then print (string.format("[Aptechka] %d spell id missing", data.id)) return end + if data.name == nil then + -- print(string.format("[Aptechka] %d spell id missing", data.id)) + return + end if data.showDuration then data.infoType = "DURATION" @@ -203,9 +206,10 @@ function helpers.AddTrace(data) if data.id then data.name = GetSpellInfo(data.id) or data.name end if not config.traces then config.traces = {} end - if not data.name then print(string.format("[Aptechka] %d spell id missing", data.id)) return end - data.actualname = data.name - data.name = data.actualname.."Trace" + if not data.name then + -- print(string.format("[Aptechka] %d spell id missing", data.id)) + return + end local id = data.id data.id = nil -- important to do that, because statuses with id field treated as aura