local UIHeroLightEffectResetPopUp = UIViewClass() function UIHeroLightEffectResetPopUp:OnOpened(context) UIUtils.SetLabelText(self.UICommonPopUp.txt_Title, Const_IDS.IDS_LightEffect_ChongZhi) UIUtils.SetActive(self.UICommonPopUp.img_Info, false) self.lightEffectID = context.lightEffectID local lightEffectCfg = DataSheetManager.LightEffect:GetDataByID(context.lightEffectID) self.scroll_Item:AddData({itemID = lightEffectCfg.Activation, itemCount = 1} , 0) -- 激活道具数量 self.itemID = lightEffectCfg.Reset[1] local itemCount = lightEffectCfg.Reset[2] local itemData = DataSheetManager.ItemData:GetDataByID(self.itemID) UTL.Item.ItemIconByName(self.img_Icon, itemData.Icon) local curItemCount = UTL.Item.GetItemStockCount(self.itemID) local count self.isCanBuy = curItemCount >= itemCount if self.isCanBuy then count = UTL.Color.FormatGreenColor(curItemCount).."/"..itemCount else count = UTL.Color.FormatRedColor(curItemCount).."/"..itemCount end UIUtils.SetLabel(self.text_Cost, count) UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self.group_Cost) end function UIHeroLightEffectResetPopUp:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopUp.btn_Close) end function UIHeroLightEffectResetPopUp:OnButtonClicked(comp) if comp == self.UICommonPopUp.btn_Close or comp == self.btn_2 then self:CloseView() elseif comp == self.btn_1 then if self.isCanBuy then MDL.LightEffect.LightEffectOptRequest(MDL.LightEffect.OptType.Reset, MDL.HeroSelect.curSelectHeroID, self.lightEffectID) self:CloseView() else CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS["IDS_DrawCard_Tip_LackItem"], UTL.Item.GetItemDataSpliceByType(self.itemID).Name)) end end end function UIHeroLightEffectResetPopUp:OnCellInit(scrollRect, index, cellTable, data) UTL.Item.SetItemCell(cellTable.item, data.itemID, data.itemCount) end function UIHeroLightEffectResetPopUp:OnCellClicked(scrollRect, index, cellTable, target, data) UTL.ItemTips.ShowCommonTipsById(data.itemID) end return UIHeroLightEffectResetPopUp