local addon, ns = ...
local ss = ns.SS

local setmetatable = setmetatable
local CreateFrame = CreateFrame

local mtAnimationCreator = {};

function mtAnimationCreator:New(parent, animation)
  local animationTexture = CreateFrame("PlayerModel",nil, parent)
--  local size = parent:GetWidth() * 1.086
  local size = parent:GetWidth() * 2.172

  animationTexture:SetPoint("CENTER",animation.posX,animation.posY)
  animationTexture:SetHeight(size)
  animationTexture:SetWidth(size)
  animationTexture:SetFrameLevel(animation.frameLevel or 3)
  animationTexture:SetAlpha(animation.alpha)
  animationTexture:SetDisplayInfo(ss.Animations:Get(animation.groupId, animation.id))
  animationTexture:SetCamDistanceScale(animation.camDistance)
  animationTexture:SetPosition(0,animation.posX,animation.posY)

  function animationTexture:UpdateAnimation(anim)
    self:SetPosition(0,anim.posX,anim.posY)
    self:SetAlpha(anim.alpha)
    self:SetDisplayInfo(ss.Animations:Get(anim.groupId, anim.id))
    self:SetCamDistanceScale(anim.camDistance)
    self:Show()
  end

  return animationTexture
end

function mtAnimationCreator:NewGroupItem(parent)
  local animationTexture = CreateFrame("PlayerModel",nil, parent)
  local size = parent:GetWidth() * 2.172

  animationTexture:SetPoint("CENTER",0,0.075)
  animationTexture:SetHeight(size)
  animationTexture:SetWidth(size)
  animationTexture:SetFrameLevel(4)
  animationTexture:SetAlpha(0.3)
  animationTexture:SetDisplayInfo(ss.Animations:Get("orbtacular", "pearl"))
  animationTexture:SetCamDistanceScale(1.85)
  animationTexture:SetPosition(0,0,0.075)

  return animationTexture
end

ss["AnimationCreator"] = setmetatable({}, { __index = mtAnimationCreator });
