local UIHeroAdvancedMaterial = UIViewClass() function UIHeroAdvancedMaterial:OnOpened(context) local materialAttr = context[1] local itemTable = context[2] self.index = context[3] --设置图标和文字 UIUtils.SetLabel(self.txt_EquipName, UTL.Item.GetItemColorName(itemTable.ItemID)) UTL.Item.SetItemCell(self.group_EquipIcon, itemTable.ItemID) --判断是否显示装备按钮 local heroId = MDL.HeroSelect.curSelectHeroID local advancedInfo = MDL.Advanced.GetHeroAdvancedMaterialInfo(heroId)[self.index] if not advancedInfo then --设置数量 local tokenCount = MDL.Currency.GetSoftTokenCountById(itemTable.ItemID) or 0 if tokenCount >= itemTable.ItemNum then UIUtils.SetLabel(self.txt_EquipCost, UTL.Color.FormatGreenColor(tokenCount).."/"..itemTable.ItemNum) UIUtils.SetActive(self.Btn_Equip, true) else UIUtils.SetLabel(self.txt_EquipCost, UTL.Color.FormatRedColor(tokenCount).."/"..itemTable.ItemNum) UIUtils.SetActive(self.Btn_Equip, false) end UIUtils.SetActive(self.group_Cost, true) UIUtils.SetActive(self.img_Equipped, false) else UIUtils.SetActive(self.Btn_Equip, false) UIUtils.SetActive(self.group_Cost, false) UIUtils.SetActive(self.img_Equipped, true) end --设置属性 for i, v in ipairs(self.group_EquipInfo) do if materialAttr[i] then UIUtils.SetActive(v.gameObject, true) local attrInfo = DataSheetManager.AttrData:GetDataByID(materialAttr[i].AttrType) UTL.Attr.SetAttrIconByAttrIcon(v.img_Icon, attrInfo.Icon) UIUtils.SetLabelText(v.txt_Attr, Const_IDS[attrInfo.Name]) UIUtils.SetLabel(v.txt_Num, "+"..materialAttr[i].AttrNum) else UIUtils.SetActive(v.gameObject, false) end end end function UIHeroAdvancedMaterial:OnBackButtonPressed() self:OnButtonClicked(self.Btn_Close) end function UIHeroAdvancedMaterial:OnButtonClicked(comp) if comp == self.Btn_Close or comp == self.btn_Bottom then self:CloseView() elseif comp == self.Btn_Equip then MDL.Advanced.MaterialEquipRequest(MDL.HeroSelect.curSelectHeroID, self.index - 1) self:CloseView() end end return UIHeroAdvancedMaterial