wobin@1: local AddonName, AfterDark = ... wobin@1: wobin@1: local TOASTERUP = "Interface\\AddOns\\AfterDark\\Images\\WingUp" wobin@1: local TOASTERCOASTER = "Interface\\AddOns\\AfterDark\\Images\\WingNeutral" wobin@1: local TOASTERDOWN = "Interface\\AddOns\\AfterDark\\Images\\WingDown" wobin@1: wobin@1: function AfterDark:ConstructToaster(frame) wobin@1: frame.toasterup = frame:CreateTexture(nil, "BACKGROUND") wobin@1: frame.toasterup:SetAllPoints(frame) wobin@1: frame.toasterup:SetTexture(TOASTERUP) wobin@1: wobin@1: frame.toasterdown = frame:CreateTexture(nil, "BACKGROUND") wobin@1: frame.toasterdown:SetAllPoints(frame) wobin@1: frame.toasterdown:SetTexture(TOASTERDOWN) wobin@1: frame.toasterdown:SetAlpha(0) wobin@1: wobin@1: frame.toasterglide = frame:CreateTexture(nil, "BACKGROUND") wobin@1: frame.toasterglide:SetAllPoints(frame) wobin@1: frame.toasterglide:SetTexture(TOASTERCOASTER) wobin@1: frame.toasterglide:SetAlpha(0) wobin@1: wobin@1: frame.fader = frame.toasterup:CreateAnimationGroup() wobin@1: frame.fader.parent = frame.toasterup wobin@1: frame.fader:SetLooping("BOUNCE") wobin@1: wobin@1: frame.toasterup.fade = frame.fader:CreateAnimation("Alpha") wobin@1: frame.toasterup.fade:SetDuration(1) wobin@1: frame.toasterup.fade:SetChange(-1) wobin@1: frame.toasterup.fade:SetOrder(1) wobin@1: wobin@1: frame.crossfader = frame.toasterdown:CreateAnimationGroup() wobin@1: frame.crossfader.parent = frame.toasterdown wobin@1: frame.crossfader:SetLooping("BOUNCE") wobin@1: wobin@1: frame.toasterdown.fade = frame.crossfader:CreateAnimation("Alpha") wobin@1: frame.toasterdown.fade:SetDuration(1) wobin@1: frame.toasterdown.fade:SetChange(1) wobin@1: frame.toasterdown.fade:SetOrder(1) wobin@1: wobin@1: frame.hashfader = frame.toasterglide:CreateAnimationGroup() wobin@1: frame.hashfader.parent = frame.toasterglide wobin@1: frame.hashfader:SetLooping("BOUNCE") wobin@1: wobin@1: frame.toasterglide.fade = frame.hashfader:CreateAnimation("Alpha") wobin@1: frame.toasterglide.fade:SetDuration(0.5) wobin@1: frame.toasterglide.fade:SetChange(1) wobin@1: frame.toasterglide.fade:SetOrder(1) wobin@1: wobin@1: if math.random(0,5) > 4 then wobin@1: local delay = math.random(30,AfterDark.db.profile.Speed * 10) wobin@1: wobin@1: frame.tumbler = frame:CreateAnimationGroup() wobin@1: frame.tumbler.parent = frame wobin@1: frame.tumbler:SetLooping("NONE") wobin@1: wobin@1: frame.spin = frame.tumbler:CreateAnimation("Rotation") wobin@1: frame.spin:SetDegrees(360) wobin@1: frame.spin:SetOrigin("CENTER", -20,-20) wobin@1: frame.spin:SetStartDelay(delay/10) wobin@1: frame.spin:SetDuration(1) wobin@1: frame.spin:SetOrder(1) wobin@1: end wobin@1: wobin@1: frame.IsToaster = true wobin@1: wobin@1: frame.Respeed = function(self) wobin@1: if frame.spin then wobin@1: frame.spin:SetStartDelay(math.random(30, AfterDark.db.profile.Speed * 10)/10) wobin@1: end wobin@1: end wobin@1: wobin@1: frame.Start = function(self) wobin@1: self.mover:Play() wobin@1: self.fader:Play() wobin@1: self.crossfader:Play() wobin@1: self.hashfader:Play() wobin@1: if self.tumbler then wobin@1: self.tumbler:Play() wobin@1: end wobin@1: self:Show() wobin@1: end wobin@1: wobin@1: frame.Finish = function(self) wobin@1: self:StopAnimating() wobin@1: self:Hide() wobin@1: end wobin@1: wobin@1: end