local DepotPotentialItemCtrl = class("DepotPotentialItemCtrl", BaseCtrl)
DepotPotentialItemCtrl._mapNodeConfig = {
	btnItem = {
		sComponentName = "UIButton",
		callback = "OnBtnClick_Item"
	},
	canvasGroup = {
		sNodeName = "goNormal",
		sComponentName = "CanvasGroup"
	},
	goNormal = {},
	imgRare = {sComponentName = "Image"},
	goIcon = {
		sCtrlName = "Game.UI.StarTower.Potential.PotentialIconCtrl"
	},
	txtName = {sComponentName = "TMP_Text"},
	txtLevelValue = {sComponentName = "TMP_Text"},
	goSpecial = {},
	imgSpIcon = {sComponentName = "Image"},
	txtSpName = {sComponentName = "TMP_Text"},
	imgChoose = {},
	imgLock = {},
	txtLock = {
		sComponentName = "TMP_Text",
		sLanguageId = "StarTower_Depot_Potential_Lock"
	},
	imgMask = {}
}
DepotPotentialItemCtrl._mapEventConfig = {
	SelectDepotPotential = "OnEvent_SelectDepotPotential"
}
DepotPotentialItemCtrl._mapRedDotConfig = {}
local level_txt_color = {
	[1] = "#264278",
	[2] = "#2c5fd5"
}
function DepotPotentialItemCtrl:InitItem(nPotentialId, nLevel, nPotentialAdd, bShowAdd, bHideChoose)
	self.nPotentialId = nPotentialId
	self.nLevel = nLevel
	self.nPotentialAdd = nPotentialAdd
	self.bHideChoose = bHideChoose
	local itemCfg = ConfigTable.GetData_Item(nPotentialId)
	local potentialCfg = ConfigTable.GetData("Potential", nPotentialId)
	if nil == potentialCfg or nil == itemCfg then
		return
	end
	self._mapNode.imgLock.gameObject:SetActive(nLevel <= 0)
	self._mapNode.imgMask.gameObject:SetActive(nLevel <= 0)
	NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup, 1)
	local bSpecial = itemCfg.Stype == GameEnum.itemStype.SpecificPotential
	self._mapNode.goNormal.gameObject:SetActive(not bSpecial)
	self._mapNode.goSpecial.gameObject:SetActive(bSpecial)
	if not bSpecial then
		self:SetNormalPotential(itemCfg, potentialCfg, bShowAdd)
	else
		self:SetSpecialPotential(itemCfg, potentialCfg)
	end
	self._mapNode.imgChoose.gameObject:SetActive(false)
end
function DepotPotentialItemCtrl:SetNormalPotential(itemCfg, potentialCfg, bShowAdd)
	local sFrame = AllEnum.FrameType_New.PotentialS .. AllEnum.FrameColor_New[itemCfg.Rarity]
	self:SetAtlasSprite(self._mapNode.imgRare, "12_rare", sFrame)
	self._mapNode.goIcon:SetIcon(potentialCfg.Id)
	NovaAPI.SetTMPText(self._mapNode.txtName, itemCfg.Title)
	local nPotentialAdd = self.nPotentialAdd
	if not bShowAdd then
		nPotentialAdd = 0
	end
	local sColor = nPotentialAdd == 0 and level_txt_color[1] or level_txt_color[2]
	local _, color = ColorUtility.TryParseHtmlString(sColor)
	NovaAPI.SetTMPText(self._mapNode.txtLevelValue, self.nLevel + nPotentialAdd)
	NovaAPI.SetTMPColor(self._mapNode.txtLevelValue, color)
end
function DepotPotentialItemCtrl:SetSpecialPotential(itemCfg, potentialCfg)
	NovaAPI.SetTMPText(self._mapNode.txtSpName, itemCfg.Title)
	self:SetPngSprite(self._mapNode.imgSpIcon, itemCfg.Icon .. AllEnum.PotentialIconSurfix.A)
end
function DepotPotentialItemCtrl:OnBtnClick_Item()
	EventManager.Hit("SelectDepotPotential", self.nPotentialId, self.nLevel, self.nPotentialAdd, self._mapNode.btnItem)
end
function DepotPotentialItemCtrl:OnEvent_SelectDepotPotential(nId)
	if self.bHideChoose then
		return
	end
	self._mapNode.imgChoose:SetActive(self.nPotentialId == nId)
end
return DepotPotentialItemCtrl
