local this = class("cellHeroHeadItemCircle", G_UIModuleBase)
local _selectScale = 1.1765

function this:ctor(...)
  this.super.ctor(self, ...)
end

function this.bind()
  return {
    goSelect1 = nil,
    goSelect2 = nil,
    scale = nil,
    imgHead = nil,
    txtLevel = nil,
    imgCarrer = nil,
    scaleReddot = nil,
    carrerBg = "",
    qualityColor = C_Color.white,
    activeCarrer = true
  }
end

function this.methods()
  return {
    onClick = function(self)
      self:emit("onClick", self.bind)
    end
  }
end

function this:unBind()
  self.super.unBind(self)
  L_PhotoManager:releaseHead(self)
end

function this:refresh()
  self.bind.goSelect1 = self.bind.selected
  self.bind.goSelect2 = self.bind.selected
  self.bind.scale = self.bind.selected and L_Vector3.new(_selectScale, _selectScale, 1) or L_Vector3.new(1, 1, 1)
  if not self.bind.isPhotoHead then
    self.bind.scaleReddot = self.bind.selected and L_Vector3.new(1 / _selectScale, 1 / _selectScale, 1.0) or L_Vector3.new(1, 1, 1)
    L_ReddotManager:registerReddot(self.bindComponents.redotNew, string.format(L_ReddotManager.DotDef.HeroNew, self.bind.id))
    L_ReddotManager:registerReddot(self.bindComponents.redotNormal, string.format(L_ReddotManager.DotDef.HeroStar, self.bind.id))
    self.bind.activeCarrer = true
  else
    self.bind.activeCarrer = false
  end
  if self.bind.id == L_HeroStore:getDefaultHeroGuid() and self.bindComponents.imgHead then
    L_PhotoManager:fillMainHead(self, self.bindComponents.imgHead.gameObject, nil, L_Const.avatarTextureIndex.head)
  else
    L_PhotoManager:releaseHead(self)
  end
end

return this
