local UIHeroChangeConfirm = UIViewClass() function UIHeroChangeConfirm:OnOpened(context) self.oldHeroId = context.oldHeroId self.newHeroId = context.newHeroId local oldHeroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(self.oldHeroId).NameIDS]) UIUtils.SetLabel(self.txt_Desc, string.FormatByIdsId(Const_IDS.IDS_Formation_ChangeTips, oldHeroName)) self:RefreshHeroHead(self.group_OldHeroHead, self.oldHeroId) self:RefreshHeroHead(self.group_NewHeroHead, self.newHeroId) UIUtils.SetLabelText(self.UICommonPopShowView.TextBtn2, Const_IDS.IDS_BUTTON_CANCEL) self:Init() end function UIHeroChangeConfirm:Init() UIUtils.SetLabelText(self.UICommonPopShowView.TextBtn1, Const_IDS.IDS_BUTTON_CHANGE) UIUtils.SetLabelText(self.UICommonPopShowView.lab_Title, Const_IDS.IDS_Formation_ChangeHero_FucName) end function UIHeroChangeConfirm:RefreshHeroHead(cellTable, heroId) UTL.Color.SetQualityImageByType(cellTable.bg_HeroHead, CTL.HeroAwaken.GetHeroQuality(heroId, MDL.HeroAwaken.GetIsHeroAwaken(heroId)), UTL.Color.QualityType.Square) local isAwaken = MDL.HeroAwaken.GetIsHeroAwaken(heroId) local heroBreak if isAwaken then UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, heroId, true) heroBreak = MDL.HeroAwaken.GetCurStar(heroId) else UTL.Item.SetHeroIconByHeroId(cellTable.img_HeroHead, heroId, false) heroBreak = MDL.HeroStar.GetHeroStarLevel(heroId) end if isAwaken then UIUtils.SetActive(cellTable.bg_Break, true) UIUtils.SetLabel(cellTable.lab_Break, string.FormatByIdsId(Const_IDS.IDS_HeroAwaken_AwakenLevelNum, heroBreak)) else if heroBreak == 0 then UIUtils.SetActive(cellTable.bg_Break, false) else UIUtils.SetActive(cellTable.bg_Break, true) UIUtils.SetLabel(cellTable.lab_Break, "+"..heroBreak) end end end function UIHeroChangeConfirm:OnBackButtonPressed() self:OnButtonClicked(self.UICommonPopShowView.btn_2) end function UIHeroChangeConfirm:OnButtonClicked(comp) if comp == self.UICommonPopShowView.btn_1 then MDL.Formation.SlotHeroSwitchReq(self.oldHeroId, self.newHeroId) self:CloseView() elseif comp == self.UICommonPopShowView.btn_2 then self:CloseView() end end return UIHeroChangeConfirm